Stylecop SA 1201 and initialization order

  • Thread starter Thread starter MarkusSchaber
  • Start date Start date
M

MarkusSchaber

Hi,

We currently have the problem that stylecop complains "All private
fields must be placed after all public fields. [StyleCop Rule
SA1202]". But the specific private static readonly field is used as an
input in the initialization expressions for several public static
readonly fields, so reversing the field order breaks initialization
order of those static members.

How should we deal with that?

Thanks,
Markus
 
MarkusSchaber said:
We currently have the problem that stylecop complains "All private
fields must be placed after all public fields. [StyleCop Rule
SA1202]". But the specific private static readonly field is used as an
input in the initialization expressions for several public static
readonly fields, so reversing the field order breaks initialization
order of those static members.

How should we deal with that?

Adjust the StyleCop rule? After all, it's mostly guidelines which are
subject to change every now and again anyway.

Andrew
 
Hi,

We currently have the problem that stylecop complains "All private
fields must be placed after all public fields. [StyleCop Rule
SA1202]". But the specific private static readonly field is used as an
input in the initialization expressions for several public static
readonly fields, so reversing the field order breaks initialization
order of those static members.

How should we deal with that?

Thanks,
Markus

Can't you initialize the constants in the static constructor?
 
Back
Top