Reputation: 3353
I have inherited a C# project with countless XML doc comments like this:
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
There's no value to these; they're just a bunch of noise.
Short of writing a custom program, is there a way to eliminate such empty XML comments from my entire solution? I would like to keep ones that are not empty. I marked this ReSharper because it seems like it would be the tool to use, but if there's a way that doesn't involve R# that's fine too.
Upvotes: 1
Views: 640
Reputation: 28097
The following Regex matches the following:
/// <summary></summary>
/// <param name="id"></param>
/// <returns></returns>
/// <summary>
///
/// </summary>
/// <summary>
/// </summary>
/// <param name="id"></param>
But not
/// <summary>
/// A summary
/// </summary>
/// <returns>Some things</returns>
As desired.
///\s*<summary>\s*(\r\n///\s*)*(\r\n///)?\s*</summary>\s*\r\n(///.*></.*(\r\n)?)*
Unfortunately, it doesn't seem to work in Visual Studio's Find and Replace dialog!
It does work in Notepad++ though so you could use that.
Working regex from comment by emodendroket:
*///\s*<summary>\r\n\s*///\s*\r\n\s*///\s*</summary>(\s*(\r\n)*\s*///\s*<[^>]+></[^>]+>)*
Upvotes: 2