FxCop 警告源代码中的模块级抑制
将其放入我们的 AssemblyInfo.cs 中:
[module: SuppressMessage("Microsoft.Performance",
"CA1822:MarkMembersAsStatic", Scope="member",
Target="Foo.CoreTest.StringUtilTest.CapitalizeNull():System.Void")]
导致 CA1822 被排除在方法 Foo.CoreTest.StringUtilTest.CapitalizeNull 之外。然而,我们希望 CA1822 从整个程序集中排除。
从源头可以吗?如果是的话,我们应该如何改变上面的抑制线呢?
Placing this in our AssemblyInfo.cs:
[module: SuppressMessage("Microsoft.Performance",
"CA1822:MarkMembersAsStatic", Scope="member",
Target="Foo.CoreTest.StringUtilTest.CapitalizeNull():System.Void")]
Results in CA1822 being excluded for the method Foo.CoreTest.StringUtilTest.CapitalizeNull. However we would like CA1822 to be excluded from the assembly as a whole.
Is it possible from source? And if so, how should we change our suppression line above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,不可能应用对整个组件起作用的模块级抑制。您需要为每个规则违规目标添加一个抑制,无论抑制属性是直接应用于目标还是在模块级别应用。
如果您不想针对程序集运行规则,请将其从程序集的分析规则中删除,而不是尝试排除每个违规。
No, it is not possible to apply a module-level suppression that will act against the entire assembly. You need to add a single suppression per rule violation target, regardless of whether the suppression attribute is applied directly against the target or at the module level.
If you don't want to run the rule against the assembly, remove it from the analysis rules for the assembly instead of trying to exclude each violation.