I have a class where FileHelpers is dependent on the field order in this class file. If the class file ever gets a code clean up run against it that will cause the fields to be sorted alphabetically and invisibly ruin my class.
Since I would like to avoid this from ever accidentally occuring, is there a resharper comment directive to disable code cleanup for a class?
You can customize the default member layout XML file and specify a pattern you want to ignore during the “reorder members” step of a code cleanup.
Have a look at the Type Member Layout section under the Resharper settings. You can see that there already are two exceptions defined for COM interfaces and Structs with the
StructLayoutAttribute:You could easily create your own
IgnoreTypeMemberReorderingAttributeand add a small section in the XML file that check against it.