How to reorder type members with Resharper?

Viewed 39594

Typical scenario: a class that a lot of people have worked on. I'd like to sort methods, properties, etc... in alphabetical order.

I'd like to be able to do this within the region or globally in the class.

I see the feature in Resharper to do it, but it does not seem to do anything.

8 Answers

jgauffin's answer is close, but I found that (with R# 2017) to reorder Properties I needed to click the 'XAML' option in the header of the File Layout dialog and change

<Entry DisplayName="Properties, Indexers">
  <Entry.Match>
    <Or>
      <Kind Is="Property" />
      <Kind Is="Indexer" />
    </Or>
  </Entry.Match>
</Entry>

to

<Entry DisplayName="Properties, Indexers">
  <Entry.Match>
    <Or>
      <Kind Is="Property" />
      <Kind Is="Indexer" />
    </Or>
  </Entry.Match>
  <Entry.SortBy>
    <Name />
  </Entry.SortBy>
</Entry>

The 'Sort By' property was empty and read-only, which makes sense because it's only used for items with the same name (and all properties should be uniquely named)

Related