ReSharper's 'Sort Modifiers' Cleanup Setting, Explained
What ReSharper's Sort Modifiers cleanup setting does, the default Microsoft-guideline modifier order it applies, and where to configure it.
readonly public static int MyField; compiles just as well as public static readonly int MyField; — C# doesn’t care about modifier order. People do, though, and a codebase where modifier order varies field by field is a small but constant source of friction during review. ReSharper’s Sort Modifiers setting exists to make that order consistent without anyone having to think about it.
What counts as a modifier
Modifiers are the keywords that describe a member or type’s characteristics or behavior:
- Access modifiers:
public,protected,private,internal. - Other modifiers:
static,readonly,const,abstract,sealed,virtual,override, and similar.
What the setting does
When enabled, it reorders modifiers on members to follow a consistent, logical sequence. For example:
// Before
readonly public static int MyField;
// After
public static readonly int MyField;
The default order
ReSharper follows the Microsoft C# coding guidelines by default:
- Access modifiers —
public,protected,private,internal - Static modifier —
static - Other modifiers —
abstract,sealed,virtual,override,readonly,unsafe, and so on partial(for types, where applicable)
A slightly messier before-and-after, with multiple members at once:
// Before
static private readonly string Example;
protected virtual public void Method() {}
// After
private static readonly string Example;
public virtual protected void Method() {}
Why bother
Consistency. Every member across the codebase follows the same modifier order, which makes the code easier to read and maintain simply by removing one more axis of unnecessary variation.
Reduced cognitive load. Because the order matches conventions most C# developers already know, there’s nothing new to learn — it just removes friction.
Standards compliance. It’s an easy way to enforce a specific coding standard across a team without relying on everyone remembering to do it manually.
Where to enable it
Via Code Cleanup: ReSharper → Options → Code Cleanup → Profiles, then enable Sort Modifiers in whichever profile you use.
Via Type Members Layout: ReSharper → Options → Code Editing → C# → Type Members Layout, where you can include modifier-sorting rules as part of broader member ordering rules if you’re customizing that layout.
The takeaway
Modifier order is exactly the kind of detail that doesn’t matter to the compiler and matters just enough to humans that leaving it inconsistent creates low-grade friction in every code review. Sort Modifiers removes that friction automatically, applying the same order everywhere as part of routine cleanup.