ReSharper's 'Apply File Layout' Cleanup Setting, Explained
What ReSharper's Apply File Layout cleanup setting does, how to customize it, and why it matters for team consistency.
Two files written by two different developers, both technically correct, can still look meaningfully different just from the order things appear in — where the using directives sit, whether the file header is present, how types are arranged. ReSharper’s Apply File Layout Code Cleanup setting exists specifically to remove that variance by applying a predefined structure to every file it touches.
What it actually does
Reordering file components. It organizes elements like file headers (comments, license information), using directives, namespace declarations, and class or type definitions — for example, placing using System; at the top and stripping unused or duplicate using statements.
Grouping and sorting. using directives get grouped and sorted in a consistent order — System namespaces first, then project-specific ones, or whatever ordering your rules specify — for predictable, readable import blocks.
File header insertion. It can add or update standard file headers, such as copyright notices or documentation comments, automatically.
Namespace ordering. Namespaces are arranged in a specific, consistent order rather than whatever order they happened to be typed in.
Before and after
// Before
using MyApp.Models;
using System.Linq;
using System;
namespace MyApp
{
public class MyClass
{
// Methods, properties, etc.
}
}
// After
// File Header
// This file is part of MyApp.
using System;
using System.Linq;
using MyApp.Models;
namespace MyApp
{
public class MyClass
{
// Methods, properties, etc.
}
}
The functional behavior of the code hasn’t changed at all — only its structure has, and that structure is now something every file in the codebase shares.
Why it’s worth turning on
- Team consistency. Every developer’s files end up following the same organizational conventions, without anyone having to remember to do it by hand.
- Readability. A predictable structure means less time spent hunting for where something “should” be.
- Integration with broader cleanup. It’s a natural fit as one step inside a larger Code Cleanup profile rather than something run in isolation — see the comparison of ReSharper’s built-in cleanup profiles for where it fits (only Full Cleanup includes it).
Customizing it
File layout rules are configured under ReSharper → Options → Code Editing → C# → File Layout, using an XML-based rule set. From there you can specify how using directives should be grouped and sorted and define exactly how headers get applied — the defaults are a starting point, not a fixed contract.
The takeaway
“Apply File Layout” is a small setting with an outsized effect on how a codebase feels to navigate. Once it’s part of your Code Cleanup profile, file structure stops being a matter of individual habit and becomes something the tooling enforces consistently — one less thing for code review to catch, and one less source of pointless diff noise.