With the code below i get a CA2104 (DoNotDeclareReadOnlyMutableReferenceTypes) warning
public readonly ReadOnlyCollection<char> IllegalChars;
with part of the error message
change the field to one that is an
immutable reference type. If the
reference type
‘ReadOnlyCollection’ is, in
fact, immutable, exclude this message.
I am sure ReadOnlyCollection is immutable but my question is is there a type can i use to not have this message appear?
You can rewrite the public field to a property:
or exclude the Code Analysis warning, because the collection can’t be changed. The problem is that FxCop is unable to detect that the
ReadOnlyCollection<T>is actually immutable.