Question

In C#, XML comments begin with three forward slashes (///). For example:

/// <summary>
/// 
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

Is there any way to change the generated comment, for example to add additional tags? I thought there might be a snippet file that defines the XML, but I can't find one. Can anyone help?

UPDATE: As far as I can tell, the first answer to the existing question simply provides a snippet that inserts code on demand. Specifically, summ+tab+tab to insert a summary line. It doesn't seem to involve changing the XML inserted by ///, which is what I'm looking for.

Additional answers to that question say it can be done with macro InsertDocComments (but I don't think that's what's invoked by ///, or I don't know how to cause it to be), and another answer says it can't be done. So, if it really can't be done, oh well, but I'm still hoping.

No correct solution

OTHER TIPS

I use GhostDoc which is a free Visual Studio Extension which automatically generates xml documentation when you press [Ctrl] + [Shift] + D on a symbol.

As far as I am aware, you cannot override the default /// behavior

Without the aid of external software, you could create your own custom snippet, this one has a shortcut of ccc

<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Slashes</Title>
      <Author>Benjamin Thomas Blodgett</Author>
      <Shortcut>ccc</Shortcut>
      <Description>Creates xml documentation</Description>
    </Header>
    <Snippet>
      <Code Language="csharp">
        <![CDATA[/// <summary></summary>
/// <AnotherTag></AnotherTag>
/// <param name="sender"></param>
/// <param name="e"></param>$end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

when going this route you can always also add the tab-stops, as I've put in below

<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Slashes</Title>
      <Author>Benjamin Thomas Blodgett</Author>
      <Shortcut>ccc</Shortcut>
      <Description>Creates xml documentation</Description>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>summary</ID>
          <Default>Summary...</Default>
        </Literal>
        <Literal>
          <ID>anothertag</ID>
          <Default>Another Tag's Value...</Default>
        </Literal>
        <Literal>
          <ID>sender</ID>
          <Default>Sender Description...</Default>
        </Literal>
        <Literal>
          <ID>event</ID>
          <Default>Event Args...</Default>
        </Literal>
      </Declarations>
      <Code Language="csharp">
        <![CDATA[/// <summary> $summary$ </summary>
/// <AnotherTag> $anothertag$ </AnotherTag>
/// <param name="sender"> $sender$ </param>
/// <param name="e"> $event$ </param>$end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top