How to create ///summary

前端 未结 9 685
面向向阳花
面向向阳花 2021-02-01 00:13

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

/// 
///  Returns a number
/// 
/// 

        
相关标签:
9条回答
  • 2021-02-01 00:45

    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.

    0 讨论(0)
  • 2021-02-01 00:52

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

    0 讨论(0)
  • 2021-02-01 00:56

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

    0 讨论(0)
  • 2021-02-01 00:56

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

    0 讨论(0)
  • 2021-02-01 00:57

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

    0 讨论(0)
  • 2021-02-01 01:00

    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>
    
    0 讨论(0)
提交回复
热议问题