How to stop Code Cleanup from Sorting Fields

Answered

Whenever I execute Code Cleanup, it seems to alphabetize all fields.  How can I stop this behavior?  I've tried disabling C#->Code Styles->Sort Modifiers under Code Cleanup, however that didn't work.  I really couldn't find any other setting which might work.  Here's an example of how it's reordering my fields:

BEFORE:

public CanvasGameoverController gameOverController;
public GameTimer gameTimer;
public CanvasHUDController hUDController;
public CanvasPauseController pauseController;

private ObscuredBool mIsAdvertShowing;
private ObscuredBool mIsPaused;
private ObscuredFloat mTimeLastAdPlayed;

[SerializeField] private CanvasNotificationController _notificationDialog;

AFTER:

[SerializeField] private CanvasNotificationController _notificationDialog;
public CanvasGameoverController gameOverController;
public GameTimer gameTimer;
public CanvasHUDController hUDController;

private ObscuredBool mIsAdvertShowing;

private ObscuredBool mIsPaused;
private ObscuredFloat mTimeLastAdPlayed;
public CanvasPauseController pauseController;

 

2
4 comments

Hi Jordan,

We are working on code layout settings page, this is planned for v2017.3. Currently, you could completely exclude file layout from code cleanup:

1. Go to File | Settings | Editor | Code Cleanup

2. Clone Built-in: Full Cleanup configuration

3. Uncheck Apply file layout option

4. Set your custom Cleanup as default for silent cleanup

0
Avatar
Permanently deleted user

Not work in JetBrains Rider 2018.3
Build #RD-183.5047.86, built on December 17, 2018

0

I am using Rider 2024.3.4 and am also trying to achieve the same thing.

I am happy for other file layout features such as ordering methods based on access modifier, but I very much do not want all my methods to be alphabetically ordered. 

Is there a way to do this without disabling file layout altogether?

0

Liam The Code Cleanup feature is inherited from ReSharper. To specify the file layout preferences, you can edit the file layout definition in File | Settings | Editor | Code Style | C#. Please refer to the sample provided in this documentation.

 

0

Please sign in to leave a comment.