I have a type which contains a collection of constant data. The constants are defined by a standard which is defined outside of my program. The type looks like this:
public class IAmImmutable
{
public IAmImmutable(string member1, string member2)
{
this.Member1 = member1;
this.Member2 = member2;
}
public string Member1 { get; private set; }
public string Member2 { get; private set; }
public static readonly Instance1 = new IAmImmutable("abc", "def");
public static readonly Instance2 = new IAmImmutable("example", "data");
public static readonly Instance3 = new IAmImmutable("for", "stackoverflow");
public static readonly Instance4 = new IAmImmutable("these are", "constant fields");
public static readonly Instance5 = new IAmImmutable("42", "1729");
/* ... */
public static readonly Instance1000 = new IAmImmutable("HUNGRY EVIL", "ZOMBIES");
}
This results in thousands of CA2104:DoNotDeclareReadOnlyMutableReferenceTypes
detections from FxCop. The notes in this detection indicate that one should suppress the detection if the indicated type is immutable, which it is in this case. However, I don't want to have thousands and thousands of suppressions if I can avoid doing that.
Is it possible to mark this type as immutable and therefore prevent this detection from occuring?