Thursday, June 7, 2012

SA1202 All private fields must be placed after all public fields

Resharper’s default type members layout for C# doesn’t enforce the accessibility ordering on fields. So if you turn it on by checking the “Reorder type members” option and you’ve got private constants before public constants then you’ll run into SA1202.

The fix? Add the Access elements to the entry that matches fields and constants. The entire match should look like the following:

<!--fields and constants-->
<
Entry>
<
Match>
<
Or>
<
Kind Is="constant"/>
<
Kind Is="field"/>
</
Or>
</
Match>
<
Sort>
<
Access Order="public internal protected-internal protected private" />
<
Kind Order="constant field"/>
<
Readonly/>
<
Static/>
<
Name/>
</
Sort>
</
Entry>



And that’s it!

No comments :

Post a Comment