何时抑制对源代码和项目抑制文件的警告

发布于 2024-09-10 23:44:05 字数 133 浏览 2 评论 0原文

我正在努力解决大约 300 个警告,其中一些警告是不必要的,可以被抑制。但是,我的问题是我是否在源中抑制它们 - 在方法上方添加一个属性 - 或者我是否在 GlobalSuppressioins.cs 中抑制它们?有没有这方面的指导,如果有的话在哪里?

I'm working on resolving about 300 warnings and some of the warnings are unnecessary and can be suppressed. However, my question is do I suppress them in the Source - an attribute is added above the method - Or do I suppress them in the GlobalSuppressioins.cs? Is there any guidance for this, if so where?

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

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

发布评论

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

评论(2

脸赞 2024-09-17 23:44:05

GlobalSuppression.cs 文件用于无法放置在源文件中的 SuppressMessage 属性。如果可以将抑制放置在源文件中,则应该这样做。

无法放在源文件中的问题是“命名空间应该至少有五个类”之类的问题。您无法将属性放置在命名空间上,因此它会出现在全局抑制文件中。

The GlobalSuppression.cs file is for SuppressMessage attributes that cannot be placed in the source files. If a suppression can be placed in a source file it should.

Issues that cannot be placed in the source file are things like "namespaces should have at least five classes". You can't place an attribute on a namespace so it goes in the global suppressions file.

月野兔 2024-09-17 23:44:05

来自 MSDN 的一些附加信息:

MSDN - 源代码抑制

“全局抑制文件维护全局级别的抑制或未指定目标的抑制,例如,程序集级别违规的抑制存储在此文件中。

Some additional information from MSDN:

MSDN - In Source Suppression

"The global suppression file maintains suppressions that are either global-level suppressions or suppressions that do not specify a target. For example, suppressions for assembly level violations are stored in this file. "

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