ReSharper Code Cleanup . . .
Cheese Pairing for this Post: Jarlsberg
[my favorite emmentaler; jarlsberg is excellent for snacking or sandwiches]
ReSharper will automatically clean and organize your code for you according to your specifications. The default specs are great; however, I find that I like to put my methods, field, etc in a slightly different order. Here is the config that I use. The only enhancement I still want to add is sorting auto properties before properties that have a backing member rather than intermixed. I haven't figured out how to accomplish that yet, so if anyone knows, please post the answer in the comments, thanks.
Without further ado:
[my favorite emmentaler; jarlsberg is excellent for snacking or sandwiches]
ReSharper will automatically clean and organize your code for you according to your specifications. The default specs are great; however, I find that I like to put my methods, field, etc in a slightly different order. Here is the config that I use. The only enhancement I still want to add is sorting auto properties before properties that have a backing member rather than intermixed. I haven't figured out how to accomplish that yet, so if anyone knows, please post the answer in the comments, thanks.
Without further ado:
<?xml version="1.0" encoding="utf-8" ?>
<Patterns xmlns="urn:shemas-jetbrains-com:member-reordering-patterns">
<!--Do not reorder COM interfaces-->
<Pattern><Match><And Weight="100"><Kind Is="interface"/><HasAttribute CLRName="System.Runtime.InteropServices.InterfaceTypeAttribute"/></And></Match></Pattern>
<!--Special formatting of NUnit test fixture-->
<Pattern RemoveAllRegions="true"><Match><And Weight="100"><Kind Is="class"/><HasAttribute CLRName="NUnit.Framework.TestFixtureAttribute" Inherit="true"/></And></Match>
<!--Setup/Teardow-->
<Entry><Match><And><Kind Is="method"/><Or><HasAttribute CLRName="NUnit.Framework.SetUpAttribute" Inherit="true"/><HasAttribute CLRName="NUnit.Framework.TearDownAttribute" Inherit="true"/><HasAttribute CLRName="NUnit.Framework.FixtureSetUpAttribute" Inherit="true"/><HasAttribute CLRName="NUnit.Framework.FixtureTearDownAttribute" Inherit="true"/></Or></And></Match></Entry>
<!--All other members-->
<Entry/>
<!--Test methods-->
<Entry><Match><And Weight="100"><Kind Is="method"/><HasAttribute CLRName="NUnit.Framework.TestAttribute" Inherit="false"/></And></Match><Sort><Name/></Sort></Entry></Pattern>
<!--Default pattern-->
<Pattern RemoveAllRegions="true">
<!--delegate-->
<Entry><Match><And Weight="100"><Access Is="public"/><Kind Is="delegate"/></And></Match><Sort><Access Order="public protected internal private" /><Name/></Sort></Entry>
<!--enums-->
<Entry><Match><Kind Is="enum"/></Match><Sort><Access Order="public protected internal private" /><Name/></Sort></Entry>
<!--constants-->
<Entry><Match><Kind Is="constant"/></Match><Sort><Access Order="public protected internal private" /><Name/></Sort></Entry>
<!--static and readonly fields-->
<Entry><Match><And><Kind Is="field"/><Or><Static/><Readonly/></Or></And></Match><Sort><Access Order="public protected internal private" /><Name/></Sort></Entry>
<!--fields-->
<Entry><Match><Kind Is="field"/></Match><Sort><Access Order="public protected internal private" /><Name/></Sort></Entry>
<!--Constructors. Place static one first-->
<Entry><Match><Kind Is="constructor"/></Match><Sort><Static/><Access Order="public protected internal private" /></Sort></Entry>
<!--Destructors. Place static one first-->
<Entry><Match><Kind Is="destructor"/></Match><Sort><Static/><Access Order="public protected internal private" /></Sort></Entry>
<!--Instance indexers-->
<Entry><Match><And><Kind Is="indexer"/><Not><Static/></Not></And></Match><Sort><Access Order="public protected internal private" /><Abstract/><Virtual/><Override/><Name/></Sort></Entry>
<!--instance properties-->
<Entry><Match><And><Kind Is="property"/><Not><Static/></Not><Not><Kind Is="indexer"/></Not></And></Match><Sort><Access Order="public protected internal private" /><Abstract/><Virtual/><Override/><Name/></Sort></Entry>
<!--Methods-->
<Entry><Match><And><Kind Is="method"/><Not><Static/></Not><Not><HandlesEvent /></Not><Not><Kind Is="destructor"/></Not></And></Match><Sort><Access Order="public protected internal private" /><Abstract/><Virtual/><Override/><Name/></Sort></Entry>
<!--Event Handling-->
<Entry><Match><HandlesEvent /></Match><Sort><Access Order="public protected internal private" /><Abstract/><Virtual/><Override/><Name/></Sort></Entry>
<!-- event -->
<Entry><Match><Kind Is="event"/></Match><Sort><Access Order="public protected internal private" /><Name/></Sort></Entry>
<!-- operator -->
<Entry><Match><Kind Is="operator"/></Match><Sort><Access Order="public protected internal private" /><Name/></Sort></Entry>
<!--Class indexers-->
<Entry><Match><And><Kind Is="indexer"/><Static/></And></Match><Sort><Access Order="public protected internal private" /><Abstract/><Virtual/><Override/><Name/></Sort></Entry>
<!--Class properties-->
<Entry><Match><And><Kind Is="property"/><Static/></And></Match><Sort><Access Order="public protected internal private" /><Abstract/><Virtual/><Override/><Name/></Sort></Entry>
<!--Class Methods-->
<Entry><Match><And><Kind Is="method"/><Static/></And></Match><Sort><Access Order="public protected internal private" /><Abstract/><Virtual/><Override/><Name/></Sort></Entry>
<!--all other members-->
<Entry><Sort><Access Order="public protected internal private" /><Abstract/><Virtual/><Override/><Name/></Sort></Entry>
<!--nested types-->
<Entry><Match><Kind Is="type"/></Match><Sort><Name/></Sort></Entry></Pattern>
</Patterns>
Comments
Post a Comment