You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dotnet format not applying rules specified in globalconfig #53750
Summary
I'm confused regarding the intended behavior of dotnet format and dotnet build when applying analyzer rules specified in analysislevel_X_recommended.globalconfig files. I have specifically tested with .Net8 and .Net10 with analysismode = recommended and the rules CA2251 and CA5374. I noticed that these rules doesn't apply when using dotnet format but flag when apply dotnet build. In the globalconfig the severity is set to warning while the documentation either states hidden or not enabled by default depending on if you read documentation on dotnet/sdk repo or the microsoft page, respectively.
Specify Analysismode and level in csproj <PropertyGroup> <AnalysisMode>Recommended</AnalysisMode> <AnalysisLevel>10</AnalysisLevel> <TreatWarningsAsErrors>true</TreatWarningsAsErrors> </PropertyGroup>
Run dotnet format --verbosity detailed
Run dotnet build --verbosity detailed
Questions
Should dotnet format apply analyzer settings specified in the .globalconfig folder or does it primarly rely on the .editorconfig file for configuration?
If it should adhere to globalconfig settings, why are rules like CA2251 and CA5374 not being applied by dotnet format when their severity is warning in the .globalconfig?
If not, how come dotnet build applies these rules if they are supposed to be disabled by default?
Reacted by ossendorf-at-hoelscher and Michael Martin
If it should adhere to globalconfig settings, why are rules like CA2251 and CA5374 not being applied by dotnet format when their severity is warning in the .globalconfig?
It's seeing them at the rules' default analysis level, rather than at the level the globalconfig configures them.
For many that will be info rather than warning. Which means you need to specifically run dotnet format --severity info.
This smells like a nasty bug.
In particular it makes dotnet format --verify-no-changes a quality gate that cannot be trusted.
Activity
rjgotten commentedon Oct 1, 2026
It's seeing them at the rules' default analysis level, rather than at the level the globalconfig configures them.
For many that will be
inforather thanwarning. Which means you need to specifically rundotnet format --severity info.This smells like a nasty bug.
In particular it makes
dotnet format --verify-no-changesa quality gate that cannot be trusted.