Stylecop SA 1201 and initialization order

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
 
A

Andrew Morton

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
 
F

Family Tree Mike

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top