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
:
<!--Do not reorder COM interfaces-->
<Pattern>
<Match>
<And Weight="100">
<Kind Is="interface"/>
<HasAttribute
CLRName="System.Runtime.InteropServices.InterfaceTypeAttribute"/>
</And>
</Match>
</Pattern>
<!--Do not reorder when StructLayoutAttribute is set -->
<Pattern>
<Match>
<And Weight="100">
<Or>
<Kind Is="struct"/>
<Kind Is="class"/>
</Or>
<HasAttribute
CLRName="System.Runtime.InteropServices.StructLayoutAttribute"/>
</And>
</Match>
</Pattern>
You could easily create your own IgnoreTypeMemberReorderingAttribute
and add a small section in the XML file that check against it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…