抑制所有方法的警告

发布于 2025-02-03 10:41:25 字数 306 浏览 2 评论 0原文

抑制视觉工作室(以及可能是罗斯林分析仪)的所有警告的最简单方法是什么?就像我从stackoverflow答案复制到我的类的新方法一样,该代码不符合我的编码准则,但我也不想更改它,我不想插入很多PRAGMA警告禁用指令或大量undressMessage属性。

关于重音警告,我可以简单地将以下属性添加到该方法中:

 [SuppressMessage("ReSharper", "All")]

但是,这仅适用于载荷警告,而不适合来自Visual Studio的人员。

What is the easiest way to suppress all warnings from Visual Studio (and possibly Roslyn Analyzers) for a certain method? Like I copy-paste code from a stackoverflow answer into a new method of my class and the code doesn't comply with my coding guidelines but also I don't want to change it and I don't want to insert lots of pragma warning disable directives or lots of SuppressMessage attributes.

Regarding ReSharper warnings I can simply add the following attribute to the method:

 [SuppressMessage("ReSharper", "All")]

but this works only for the ReSharper warnings, not for those from Visual Studio.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

小镇女孩 2025-02-10 10:41:25

禁用所有方法的所有警告:

#pragma warning disable
void MethodWithWarnings()
{
   ...
}
#pragma warning restore

To disable all warnings for a single method:

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