- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一堂像这样的课:
public class Foo
{
public readonly int A = 1;
public readonly int B = 2;
}
public class Foo
{
[SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
public readonly int A = 1;
[SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
public readonly int B = 2;
}
[SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
public class Foo
{
public readonly int A = 1;
public readonly int B = 2;
}
最佳答案
无法使用 SuppressMessageAttribute 一次抑制超过 1 条消息。
可以找到讨论 here ,但相关部分是:
You are running into a common misunderstanding about SuppressMessage.
Each time you put a SuppressMessage in a source file, you suppress exactly one problem (one "row" in the grid). Period.
A SuppressMessage may be placed either "near" the violation or at the module-level. Module-level, assembly-level, and global suppression all mean the same thing. By placing at the module-level, you do not suppress multiple instances of the problem at once. You merely get to locate the SuppressMessage in a different place of the code. The main benefit is that you can, for example, collect all the suppressions related to the assembly in a single file (for example, GlobalSuppressions.cs).
When you use a module-level SuppressMessage, you must specify the Target. The Target must match exactly what is reported in the GUI for a violation of the rule.
There is no way to use SuppressMessage to suppress a rule for the entire scope of a class or the entire scope of a namespace.
关于visual-studio - VS2010代码分析。抑制消息 CA1051 :DoNotDeclareVisibleInstanceFields for all class members,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7092778/
我有一堂像这样的课: public class Foo { public readonly int A = 1; public readonly int B = 2; } 当我运行内置
我是一名优秀的程序员,十分优秀!