Reputation: 659
Before this gets marked as duplicate, I know this question has been asked in the past [1] [2], but the answers are extremely outdated and only contain workarounds and 3rd party tools.
The exact question here would be: Is it possible to change the xml comment template generated by typing "///" in Visual Studio 2019+ without using 3rd party tools? For example, add custom tags to the template?
For example, replace:
/// <summary>
///
/// </summary>
/// <param name="myParam"></param>
/// <returns></returns>
public int MyMethod(string myParam) { }
with:
/// <summary>
///
/// </summary>
/// <param name="myParam"></param>
/// <myTag></myTag>
/// <returns></returns>
public int MyMethod(string myParam) { }
Upvotes: 1
Views: 790
Reputation: 31656
Yes/No, one can create a code snippet which can give you the basic format, but getting the parameters dynamically will be problematic.
I would suggest using a hybrid method where after running the standard xml comment that the code snippet deletes (if needed) and adds more tag(s) and other items which you may need.
One line Summary
This snippet just creates <Summary> X </Summary>
and deposits a user on the X to fill it out. It is one I created and actually use.
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Single line summary</Title>
<Shortcut>summary</Shortcut>
</Header>
<Snippet>
<Code Language="csharp">
<![CDATA[/// <summary>$end$</summary>]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Here it is in action, by just typing in summary
then Tab to initiate it.
Upvotes: 1