How to create ///summary

C#Visual Studio

C# Problem Overview


How do I generate these kind of summaries in Visual Studio?

/// <summary>
///  Returns a number
/// </summary>
/// <param name="num"></param>
/// <returns></returns>

C# Solutions


Solution 1 - C#

Type in /// before your method, property, etc. VS will generate the comment blocks automatically.

Solution 2 - C#

As others have said, Visual Studio will, by default, add the documentation template automatically when you type three slashes in a row above the member declaration. If the member has any Attributes applied to it, then type the slashes on the line above the attributes.

Note, however, that one of the most useful things to document for a method (or constructer, property, etc.) is the exceptions that the method may generate. Those can be added by typing ///<exception after the rest of the documentation. When you accept the Intellisense suggestion, you will be provided with a place for the Exception type as an XML attribute, and you can fill in the circumstances in the exception element content.

If any parameters are added to a method after the documentation is already produced, then the Intellisense will also be very helpful in filling in the new paramter name when you go to add it to the documentation. It is a pretty slick feature.

Solution 3 - C#

Use tools like GhostDoc. It will generate using right clicking a method name.

Solution 4 - C#

type three times / and Visual Studio will fill rest of the code.

Solution 5 - C#

Put the cursor on the line just before the method or class that you want to document and type ///. Visual Studio will generate the XML doc tags, like <summary> and <param>, then you can fill in the details.

Solution 6 - C#

I can recommend GhostDoc to make this even easier.

Solution 7 - C#

Like George says, /// on the line just above will autogenerate it.

Beyond the boilerplate comment template it gives you, I'd recommend taking a look at the other tags you may use: http://msdn.microsoft.com/en-us/library/5ast78ax.aspx

This may be used in combination with other tools such as Sandcastle to automatically build CHM guides, etc.

Solution 8 - C#

On the line before your property/method/etc, simply type /// and then Visual Studio will automatically add the XML tags.

Solution 9 - C#

For Controllers: Use 3 forward slash before Methods i.e. /// which will generate summary tag like this,

     /// <summary>
     /// 
     /// </summary>
     /// <param name="searchKey"></param>
     /// <returns></returns>

For Models: Use 3 forward slash before an auto-property i.e. /// which will generate summary tag like this,

     /// <summary>
     /// 
     /// </summary>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser710502View Question on Stackoverflow
Solution 1 - C#George JohnstonView Answer on Stackoverflow
Solution 2 - C#Jeffrey L WhitledgeView Answer on Stackoverflow
Solution 3 - C#AnurajView Answer on Stackoverflow
Solution 4 - C#Vlad BezdenView Answer on Stackoverflow
Solution 5 - C#FishBasketGordoView Answer on Stackoverflow
Solution 6 - C#MagnusView Answer on Stackoverflow
Solution 7 - C#jglouieView Answer on Stackoverflow
Solution 8 - C#KeithView Answer on Stackoverflow
Solution 9 - C#Bijaya PandeyView Answer on Stackoverflow