C# Rearrange code in preferred order

Answered

I am new to RIder and am trying to use the rearrange feature.  It does rearrange, but not in the code style we are using.  Our desired order is:

private members
public members (properties)
constructor
public methods
private methods

What we are seeing is the public methods and public members (properties) are mixing:

private member

public method

public member (property)

Another public methods

 

We can't seem to follow this: https://www.jetbrains.com/help/rider/File_and_Type_Layout.html to get the desired result.  Does anybody have a solution out there for this?

8 comments
Comment actions Permalink

Hi,

Could you please share the content of the "Preferences | Editor | Code Style | C#"  settings page (XML text with the layout settings)? 

 

Kind regards,

Sofia

0
Comment actions Permalink

Do you mean this file?

0
Comment actions Permalink

Yes,

I mean the content of this page (XML).

One can upload it via https://uploads.services.jetbrains.com/ or attach it to a new support request or youtrack ticket (https://youtrack.jetbrains.com/issues/RIDER).

0
Comment actions Permalink

I uploaded it:

Upload complete!
Uploading...
File uploaded: CSharpFile.xml
Upload complete!

 

2
Comment actions Permalink

Thank you, file received! I'll be back as soon as I investigate it.

0
Comment actions Permalink

Hello,

As far as I can see, CSharpFile.xml has the default settings. But to sort the members in the way you specified, you need to make additional changes for File Layout.

Something like this:

<TypePattern DisplayName="Default Pattern">
<Entry DisplayName="Private members">
<Entry.Match>
<And>
<Kind Is="Member" />
<Access Is="Private" />
</And>
</Entry.Match>
</Entry>
<Entry DisplayName="Public properties">
<Entry.Match>
<And>
<Kind Is="Property" />
<Access Is="Public" />
</And>
</Entry.Match>
</Entry>
<Entry DisplayName="Constructors">
<Entry.Match>
<Kind Is="Constructor" />
</Entry.Match>
<Entry.SortBy>
<Static />
</Entry.SortBy>
</Entry>
<Entry DisplayName="Public methods">
<Entry.Match>
<And>
<Kind Is="Method" />
<Access Is="Public" />
</And>
</Entry.Match>
</Entry>
<Entry DisplayName="Private methods" Priority="100">
<Entry.Match>
<And>
<Kind Is="Method" />
<Access Is="Private" />
</And>
</Entry.Match>
</Entry>

 

I attached the full file in another ticket that you created.

0
Comment actions Permalink

Thank you.  The file works for our company's standards.

0

Please sign in to leave a comment.