Search code examples
c#visual-studio-2012keyboard-shortcuts

Is there a VS shortcut to automatically update the triple-slash comments when adding new parameter to the method signature?


Visual Studio's nifty auto-documenting feature lets you type three slashes ('///') before a method in order to auto-generate xml-style documentation stubs, like this:

    /// <summary>
    /// 
    /// </summary>
    /// <param name="bar"></param>
    /// <param name="baz"></param>
    /// <returns></returns>
    public int foo(bool bar, string baz)
    {
        return 0;
    }

If I edit the signature and add a new parameter, is there a keyboard shortcut to update the comments, adding a new line with a <param ...> tag?

UPDATE: This feature is officially called "Smart Comment Editing", and the full documentation for it is found in the MSDN Programmers Guide under "XML Documentation Comments" (Delimiters). No mention of any "update" feature, so the answer to this question is apparently, "No".


Solution

  • I haven't seen this functionality in Visual Studio, but certainly in R# ReSharper (I'm currently running 8.2 C# Edition).

    Depending on your R# settings, you'll get a red squiggle under the variable name with an explanation of:

     Parameter 'foo' has no matching param tag in the XML comment for Class1.Bar (but other parameters do)
    

    You then have R# options like:

     Add xml-doc comments
    

    Hope this helps. If you don't currently use R#, you'll find loads of other great features/uses and is worth its weight in gold :-)