[ACCEPTED]-Resharper Clean-up Code - how to affect sorting of methods?-resharper

Accepted answer
Score: 92

Customizing the layout can indeed be accomplished 19 with Resharper. Go to:

Resharper->Options->Languages->C#->Formatting 18 Style->Type Members Layout

ReSharper 2017

Resharper -> Options-> Code 17 Editing -> C# -> File Layout -> Interface 16 Implementations/All Other Members

and uncheck 15 the "Use Default Patterns" option.

Now 14 you'll want to edit the xml in the "Custom 13 Patterns" box. I'd recommend copying 12 it out to an editor that can properly hi-light 11 the xml (notepad++ or visual studio should 10 work fine).

Now, find the section near the 9 bottom:

    <!--all other members-->
    <Entry/>

and change it to:

    <!--all other members-->
    <Entry>
      <Match>
        <Kind Is="method"/>
      </Match>
      <Sort>
        <Name/>
      </Sort>
    </Entry>

Now, make sure that 8 your cleanup profile has "Reorder type 7 members", and then right click on the 6 filename in solution explorer and do "Cleanup 5 code...". I've just tried this myself 4 and it does order the methods alphabetically.

If 3 you want to also sort by access type, you 2 can add this under the <Sort> element:

<Access Order="public protected internal private" />

Here's an article to 1 learn more.

Score: 25

Resharper->Options->Languages->C#->File 3 Layout

Select "All other members" and 2 select "Sort by name" (highlighted 1 in bottom right of pic)

Options screen

Score: 0

In the XML file layout you have to add the 5 element Entry.SortBy For example in All 4 other members:

 <Entry DisplayName="All other members">
  <Entry.SortBy>
    <Name />
  </Entry.SortBy>
</Entry>

The problem with the 9.2 3 is that when the Entry.SortBy is missing 2 from XML the selected value from the designer 1 is not saved.

More Related questions