Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resharper 9 File Layout: defining sort order when sorting by access modifier not possible?

after installing R# 9.0 my custom file layout from 8.2 did not work anymore. I recreated the same pattern using the layout designer which is new in 9.0.

The part I could not reproduce was the detailed ordering definition for properties using access modifiers:

Pre-9.0 it looked like this:

[...]
<Sort>
    <Access Order="private public internal protected-internal protected"/>
</Sort>
[...]

... resulting in the properties being ordered as defined - especially: private first!

In 9.0 when using the new Designer the produced XAML is the following:

[...]
<Entry.SortBy>
    <Access />
</Entry.SortBy>
[...]

... which still sorts the members by their access modifier but using some default ordering spec. The designer does not allow for specifying any additional attributes and editing the XAML manually as in pre-9.0 produces errors.

Is there any way in R# 9.0 to control the order of public, private etc members like this?

Btw. the same issue exists for other sort specs like Kind: it is not possible anymore to specify that e.g. property should go before method etc.

like image 572
cob Avatar asked Sep 29 '22 01:09

cob


1 Answers

As it turns out the ordering can still be specified as in pre-9.0 - but with slightly different syntax:

[...]
<Entry.SortBy>
    <Access Order="private public internal protectedinternal protected"/>
</Entry.SortBy>
[...]

The difference was that protected-internal now has to be protectedinternal instead...

Also be aware that you have to do this manually in the XAML view since the visual layout designer does not support this setting yet. (But it will detect errors in your edits - so be sure to switch back and forth from XAML to Designer view to check if you broke anything).

For the second part regarding kinds: they can be sorted, too. This was a oversight of mine.

Edit: A whole entry then looks like this:

<Entry DisplayName="non-private Fields">
  <Entry.Match>
    <And>
      <Kind Is="Field" />
      <Not>
        <Access Is="Private" />
      </Not>
    </And>
  </Entry.Match>
  <Entry.SortBy>
    <Access Order="Public Internal ProtectedInternal Protected Private" />
    <Name Is="Enter Pattern Here" />
  </Entry.SortBy>
</Entry>
like image 136
cob Avatar answered Oct 05 '22 06:10

cob