如何从 C# 中删除机器人评论和#region?
我正在维护一些代码,其中包含大量机器生成的注释和机器生成的区域。 (或由特别受误导的开发人员创建)
这些注释专门重复了方法元数据和 pascal 大小写名称的空间扩展:
#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
Resharper 是否有插件或功能用于批量删除注释和 #region 标签?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
为什么不使用正则表达式 find & 在 Visual Studio 中替换?
对于三斜杠注释:
对于区域标签:
Why not use the regex find & replace in Visual Studio?
For triple slash comments:
For region tags:
这些部分可能是手写的:
和
如果这是在类库项目中,我不会删除 xml 注释 - 它们将显示在这些项目的智能提示中。 删除它们可能会让其他开发人员对你非常生气; 因为这里的所有文字都不是很好,默认提示很神秘,甚至更糟。
These parts were likely hand-typed:
and
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.
我想说用更明智的东西替换它们比剥离它们要好得多。 尽管很平凡,但没有评论总是更糟糕(当然,除非评论不正确?那么没有评论肯定更好):-)
也就是说,我相信 这正是您正在寻找的。
对于区域标签,您可以尝试调整该应用程序或使用 VS 的正则表达式查找/替换。
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.
我投票赞成你在遇到这些问题时进去修复它们。 我必须在这里做同样的事情......每次我进入一个有不好评论的班级(在我的例子中:没有)。 我在使用方法/属性时对其进行评论。 3 周后,我已经正确评论了 1/2 的代码库,并对整个项目有了更深入的理解。
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.