How to remove all C# methods/properties/fields “su

2020-05-19 02:15发布

How to remove all C# methods/properties/fields "summary" comments

(starting with ///)

in current document in Visual Studio with one shot?

In other words convert this:

/// <summary>
/// Very stupid comment generated with very stupid tool
/// </summary>
protected void MyMethod
{

}

Into this:

protected void MyMethod
{

}

2条回答
Evening l夕情丶
2楼-- · 2020-05-19 02:29

Regex pattern ^.*\/\/\/ ?<summary>.*\n(?:^.*\/\/\/.*$\n)* will be more suitable in this case because it will match whole summary comment at once.

  • ^.*\/\/\/ ?<summary>.*\n - matches line with /// <summary> text (with optional space after slashes)
  • (?:)+ - non-capturing group, repeated zero or more times
  • ^ - beginning of the line
  • .* - any characters
  • \/\/\/ - three slashes
  • .* - any characters
  • $ - end of line
  • \n - line break symbol
查看更多
在下西门庆
3楼-- · 2020-05-19 02:31

How about

  • Ctrl+H for quick replace
  • Mark Use : Regular expressions
  • Enter in Find what field following expression ^.*\/\/\/.*$\n (shortly - line with /// pattern)
  • Leave Replace with field empty
  • Make sure that you Look in in Current Document
  • Click Replace All
查看更多
登录 后发表回答