The CA2104 warning: Is there any way to mark a class as `Immutable` to suppress it?
问题 Consider the following code, which provokes CA2104: Do not declare read only mutable reference types. public class Test { // This provokes CA2104: "Do not declare read only mutable reference types". protected readonly ImmutableClass ImmutableMember; } public class ImmutableClass { } Does anyone know of a way to mark a class as immutable in a way that would suppress warning CA2104? I tried decorating MutableClass with [ImmutableObject(true)] with no hope of success (since that attribute is