如何从 C# 中删除机器人评论和#region?

发布于 2024-07-23 11:13:02 字数 432 浏览 4 评论 0原文

我正在维护一些代码,其中包含大量机器生成的注释和机器生成的区域。 (或由特别受误导的开发人员创建)

这些注释专门重复了方法元数据和 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

黑凤梨 2024-07-30 11:13:02

为什么不使用正则表达式 find & 在 Visual Studio 中替换?

对于三斜杠注释:

    ///.*

对于区域标签:

    [#]region.*
    [#]endregion

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

For triple slash comments:

    ///.*

For region tags:

    [#]region.*
    [#]endregion
似狗非友 2024-07-30 11:13:02

这些部分可能是手写的:

实现公共方法 foo bar,返回 void

名为 value 输入的字符串参数

如果这是在类库项目中,我不会删除 xml 注释 - 它们将显示在这些项目的智能提示中。 删除它们可能会让其他开发人员对你非常生气; 因为这里的所有文字都不是很好,默认提示很神秘,甚至更糟。

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.

黎夕旧梦 2024-07-30 11:13:02

我想说用更明智的东西替换它们比剥离它们要好得多。 尽管很平凡,但没有评论总是更糟糕(当然,除非评论不正确?那么没有评论肯定更好):-)

也就是说,我相信 这正是您正在寻找的

对于区域标签,您可以尝试调整该应用程序或使用 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.

诗笺 2024-07-30 11:13:02

我投票赞成你在遇到这些问题时进去修复它们。 我必须在这里做同样的事情......每次我进入一个有不好评论的班级(在我的例子中:没有)。 我在使用方法/属性时对其进行评论。 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文