🛠️ Fix Code Cleanup on Save Skipping a Format Rule
Visual Studio’s “Run Code Cleanup on Save” setting runs whichever fixer profile is currently selected in the Code Cleanup configuration dialog, and that profile is a customizable, ordered list of individual fixers (Remove unnecessary usings, Sort usings, Apply file header preferences, Fix formatting, Naming rules, and more) rather than an implicit “run everything” action. Saving a file only ever applies the fixers actually checked in that specific profile, so if “Fix formatting” was unchecked, or never added, when the profile was first created, every save-triggered cleanup will silently leave indentation and brace placement exactly as typed, even while usings still get sorted and removed correctly – making it look like Code Cleanup is working when one particular rule simply never fires.
🔎 The Problem
Code Cleanup profile: "Profile 1" (active on Ctrl+K, Ctrl+E and Run on Save) [x] Remove unnecessary usings [x] Sort usings [x] Apply file header preferences [ ] Fix formatting <- unchecked, so indentation/brace style is never touched [x] Naming rules Save triggers these fixers in order top-to-bottom; an unchecked fixer is simply skipped, with no warning that formatting itself never ran.
✅ Fix: Make Fix Formatting Part of the Active Profile
- Open Tools > Options > Text Editor > Code Cleanup (or the broom icon in the editor’s bottom status bar), select the active profile, and explicitly check “Fix formatting” so a save actually reformats the file, not just reorganizes its usings.
- Create a dedicated “Run on Save” profile that always includes Fix formatting plus whichever analyzer-driven fixers the team wants, instead of reusing a manual Ctrl+K, Ctrl+E profile someone may have trimmed down for an unrelated purpose.
- Check which profile is actually active from the editor’s broom-icon dropdown before assuming a save-time cleanup is doing a full pass – a trimmed profile applies silently, with no error, every single time.
🚨 Why This Is Dangerous
A team that assumes “Code Cleanup on Save” means every file is reformatted to the project’s style can end up with inconsistent indentation and brace placement quietly building up across commits, since nothing in the build or in Visual Studio’s UI distinguishes a full cleanup pass from a partial one using a trimmed profile.
Code Cleanup on Save only ever runs the fixers your active profile actually lists – an unticked box is a silent no-op, not an error.




