Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML Auto Commenting C# in Visual Studio Code

In MonoDevelop, when I type "///", it auto-generates an xml-style comment like this:

/// <summary> /// Describes the variable x /// </summary> int x = 0; 

Is there a way to get this behavior in Visual Studio Code?

like image 862
s2Jakob Avatar asked Dec 14 '15 19:12

s2Jakob


People also ask

How do you put comments in XML?

An XML comment encountered outside the document type declaration is represented by the Comment value syntax element. It contains the comment text from the XML message. If the value of the element contains the character sequence --> , the sequence is replaced with the text --&gt; .

What is XML comment in C#?

C# documentation comments use XML elements to define the structure of the output documentation. One consequence of this feature is that you can add any valid XML in your documentation comments. The C# compiler copies these elements into the output XML file.

What is the comment syntax for C #s XML based documentation?

XML documentation comments - document APIs using /// comments | Microsoft Docs.


2 Answers

This feature is not available out-of-the-box with VS Code, but like most features is available via third-party extensions. As of the time of this answer, here is a popular extension that provides some XML comments support to VS Code:

C# XML Documentation Comments Support for Visual Studio Code

If that extension doesn't work for you, you may be able to find alternatives by searching the VS Code Marketplace

like image 198
Keisuke KATO Avatar answered Oct 02 '22 20:10

Keisuke KATO


Starting with C# for Visual Studio Code Extension 1.23.8 this is suppored when Editor: Format On Type. setting is enabled.

This can be found in the menu under File/Preferences/Settings/Text Editor/Formatting.

like image 36
Pascal Berger Avatar answered Oct 02 '22 21:10

Pascal Berger