Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to strip out robo-comments and #region from C#?

I've got some code I'm maintaining that has a good deal of machine generated comments and machine generated regions. (or created by a particularly misled developer)

These are comments exclusively repeating the method metadata and space expansions of pascal cased names:

#region methods
/// <summary>
/// Implementation of a public method foo bar, returning a void
/// </summary>
/// <param name="value">A string parameter named value input</param>
public void fooBar(string valueInput)
{

}
#endregion

Is there a plug in or feature of Resharper for stripping out the comments and #region tags in bulk?

like image 955
MatthewMartin Avatar asked Jun 05 '09 18:06

MatthewMartin


4 Answers

Why not use the regex find & replace in Visual Studio?

For triple slash comments:

    ///.*

For region tags:

    [#]region.*
    [#]endregion
like image 161
Gavin Miller Avatar answered Oct 02 '22 18:10

Gavin Miller


These parts were likely hand-typed:

Implementation of a public method foo bar, returning a void

and

A string parameter named value input

If this is in a class library project, I wouldn't get rid of the xml comments - they are what will show up in the intellisense prompts for those items. Removing them could make other developers very mad at you; for all the text here isn't very good, the default prompts are cryptic and even worse.

like image 42
Joel Coehoorn Avatar answered Oct 02 '22 18:10

Joel Coehoorn


I'd say replacing them with something more sensible is much better than stripping them out. As mundane as they may be, having no comments is always worse (unless the comments are incorrect of course? Then no comments is certainly better) :-)

That said, I believe this does what you're looking for.

For region tags, you could try adapting that app or using VS' regex find/replace.

like image 43
Matt Brindley Avatar answered Oct 02 '22 17:10

Matt Brindley


I vote that you go in and fix them as you come across them. I've had to do the same thing here... every time that I go into a class that has bad comments (in my case: none). I comment the methods/properties as I work with them. After 3 weeks, I've properly commented about 1/2 the codebase and have developed a stronger understanding of the entire project.

like image 29
Steven Evers Avatar answered Oct 02 '22 17:10

Steven Evers