Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Visual Studio

Visual Studio: Fix Code Cleanup on Save Skipping a Format Rule

- 28.11.26 - ErcanOPAK

🛠️ 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.

— Developer Tip

Related posts:

Visual Studio: Use Diagnostic Tools to Profile Performance

Visual Studio: Use Diagnostic Tools to Profile Performance

Hidden Feature That Fixes “Works on My Machine” Bugs

Hidden Feature That Fixes “Works on My Machine” Bugs

Visual Studio: Fix the Object Browser Showing a Type as Missing Members Because It's Reading a Refer...

Visual Studio: Fix the Object Browser Showing a Type as Missing Members Because It's Reading a Refer...

Views: 13
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

WordPress: Fix a Redirect Loop After Forcing HTTPS in Settings
Ajax: Fix a Polling Loop Doubling After a Tab Regains Focus

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,079 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 868 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 671 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 584 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 562 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com