我可以スpreSS FX警察code分析全球范围内的侵犯?范围内、警察、全球、preSS

2023-09-04 07:54:39 作者:杀你男神做你男人

当您使用Visual Studio的code analysic(FxCop的),并希望苏preSS的消息出现3个选项。

When you use Visual Studio's code analysic (FxCop), and want to supress a message there are 3 options.

苏preSS在code违规。 苏preSS在GlobalSu pression.cs文件中的违规行为。 禁用项目文件中的违规检查(通过项目 - >属性 - > code Analysic)。

后来是很难源控制检查的时候,审查,这是很难让所有残疾人vioaltions的概述。所以,我们想使用选项2。

The later is very hard to review when checking in to Source Control, and it is hard to get an overview of all disabled vioaltions. So we would like to use option 2.

与选项1和2的问题是,你得到一个SU pression线为每次违规。例如这样的:

The problem with option 1 and 2 is that you get one supression line for each violation. E.g like:

[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Company.Project.Namespace2")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Company.Project.Namespace1")]

我们很乐意做这样的事情荷兰国际集团GlobalSup pressions.cs:

We would love to do something like this ing GlobalSuppressions.cs:

[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes")]

但是,这可能吗?

But is this possible?

你是如何解决的?

推荐答案

燮pressing多次违反与单个的燮pressMessage 官方不支持的属性。显然,这是通过设计

Suppressing multiple violations with a single SuppressMessage attribute is officially not supported. Apparently, this is by design.

我同意,这可能是讨厌的时候,但我不能说我不同意的决定,因为该属性是他们的方式,迫使你不得不说:是的,我知道我在做什么,这应该在案件逐案进行评估。

I agree, it might be annoying at times, but I can't say I disagree with the decision, since the attribute is their way to force you to say, "Yes, I know what I am doing", which should be evaluated in a case-by-case basis.