I was commisioned to make other people’s code compliant with some StyleCop ruleset, as far as possible.. now I was wondering about the following case:
I have an abstract class that contains a field
protected double[] coefficients;
Stylecop says: SA1401: Fields must be declared with private access. Use properties to expose fields.
So I changed it to:
protected double[] coefficients { get; set; }
Stylecop says: SA1300: property names begin with an upper-case letter: coefficients.
Since it’s an abstract class, the child classes are beyond my control. And they use their parent’s class field base.coefficients.. well.
So.. there is no way other way to get rid of this warning than to suppress (or disable) it, right? :T
Well, actually you don’t.
If you want to get it clean in future releases of the code, you could set the
coefficientsproperty deprecated and provide a message that states that this property will be removed in any further version of the code.In the current release:
In a later release: