Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop fields being ordered alphabetically in ReSharper?

I'm trying to stop my fields being ordered alphabetically when running a clean code up across my solution, I have sort of got an answer for this question but this answer doesn't exactly work.

When going to the file layout section of ReSharper, many suggestions are to change the "sort by" box to something else when selection 'Fields' in the menu.

The issue with this is I don't have a drop down at all, I don't have anything I can select other than an empty white box that I can't really do anything with. I've tried researching this on google but it seems nobody knows why this happens or how to resolve the issue.

Here is an image of my current state.

https://i.imgur.com/qpds2PY.png

like image 626
vebat Avatar asked Apr 09 '26 10:04

vebat


1 Answers

I don't know why the dropdown is not showing in the UI, but you should be able to do it by directly editing the XAML.

In order to do it:

  1. Open ReSharper/Options....
  2. Select Code Editing/C#/File Layout in the tree on the left hand side.
  3. Click on the XAML link on the top right corner of the file layout editor.
  4. Look for the <Entry DisplayName="Fields"> tag.
  5. Remove the <Entry.SortBy> child element from the entry:

    <Entry.SortBy>
        <Readonly />
        <Name />
    </Entry.SortBy>
    
  6. Click Save.

After this the Cleanup Code command won't affect the order of the fields.

Update (2018-02-01)

It seems the feature you're looking for is now available again in ReSharper 2017.3.2 which was released on 2018-01-31.

Quote from the changelog.

Sort by drop-down list and Switch to Constraint View icon come back to the File Layout page.

I tried it and it works now.

Sort by dropdown is back

like image 90
Szabolcs Dézsi Avatar answered Apr 12 '26 00:04

Szabolcs Dézsi