I have a class like this:
public class Foo
{
public readonly int A = 1;
public readonly int B = 2;
}
When I launch VS2010, which is built into the code analysis tool, I get the same warning 2 : that the "field" ... "is visible outside of its type of announcement, changes its accessibility to the closed one and adds a property with the same availability as the field is currently time to provide access to it. "
I want to suppress this warning for all fields of my Foo class , but I do not want to mark each field with the SuppressMessage attribute as follows:
public class Foo
{
[SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
public readonly int A = 1;
[SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
public readonly int B = 2;
}
I want to mark all members of the class using the following code:
[SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
public class Foo
{
public readonly int A = 1;
public readonly int B = 2;
}
, .
?