Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I automate the removal of XML Documentation Comments?

Does someone have a script or snippet for Visual Studio that automatically removes comment headers for functions or classes?

I want to remove comments like.

/// <summary>
/// 
/// </summary>

Actually anything that removes comments starting with /// would really help. We have projects with massive amount of GhostDoc comment that really just hides the code and we are not using the document output. It is a tedious work for us to remove theese comments.

like image 529
Poxet Avatar asked Nov 14 '13 15:11

Poxet


People also ask

Which is the proper commenting method for XML?

To insert XML comments for a code element Type /// in C#, or ''' in Visual Basic.

What is the advantage of using XML comments?

XML comments help speed development by providing IntelliSense on custom methods and other code constructs. XML comments encourage code reuse by providing a path to generate API style reference documentation from your source code.

What sequence of characters indicates the start of an XML style documentation comment in C# code?

The only part of the following comment that's processed is the line that begins with <summary> . The three tag formats produce the same comments. The compiler identifies a common pattern of " * " at the beginning of the second and third lines. The pattern isn't included in the output.

What is triple slash in C#?

XML documentation comment is a special feature in C#. It starts with a triple slash /// and is used to categorically describe a piece of code.. This is done using XML tags within a comment. These comments are then, used to create a separate XML documentation file.


2 Answers

Open Quick Replace (CTRL + H) in Visual Studio and replace :b+///.*\n with an empty string (ensure you set Use to Regular expressions). This should allow you to get rid of the comments in the specified scope.

like image 120
Gene Avatar answered Oct 31 '22 14:10

Gene


You can use this Regex \/\/\/.*<summary>.*<\/summary>, with these options gms, to match the string. You can replace that with nothing. This can be done in Notepad++ or Visual Studio.

Here is a Regex 101 to prove it.

like image 30
Mike Perrenoud Avatar answered Oct 31 '22 14:10

Mike Perrenoud