I have the following pattern:
public class Test
{
public ICollection<string> Stuff { get; private set; }
public Test()
{
Stuff = new List<string>();
Stuff.Add("Initial Item");
}
}
FxCop is complaining with CA2227:CollectionPropertiesShouldBeReadOnly. Why? The setter is private so it's no different to having a private field, except it's a shorter and neater syntax.
This is a very common pattern for me, and I really don't want to have to Suppress each warning individually or replace it with a field + property pattern.
Is there a way around this?
Issue seems to have resolved itself.