Resharper 9 File Layout: determining the sort order when sorting by access modifier is not possible?

after installing R # 9.0, my custom file layout from 8.2 no longer worked. I recreated the same template using the layout constructor, which is new in 9.0.

The part that I could not reproduce is a detailed definition of the order of properties using access modifiers:

Pre-9.0 looked like this:

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

..., whereby the properties are ordered as defined - especially: private first!

In 9.0, when using the new constructor, the created XAML looks like this:

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

... which still sorts items by their access modifier, but uses some standard order specification. The designer does not allow you to specify any additional attributes and edit XAML manually, as errors occur in pre-9.0.

Is there a way in R # 9.0 to control the order of public , private , etc. such elements?

Btw. the same problem exists for other sort specifications, such as Kind : it is no longer possible to specify, for example, property must go before method , etc.

+5
source share
1 answer

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

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

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

Also keep in mind that you need to do this manually in the XAML view, as the visual layout designer does not yet support this setting. (But it will detect errors in your changes - so be sure to switch between XAML and Designer to verify that you have broken something).

For the second part related to views: they can also be sorted. That was my control.

Edit: The whole entry is as follows:

 <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> 
+4
source

Source: https://habr.com/ru/post/1210488/


All Articles