Proj4052: Use global configuration for Roslyn diagnostics
Configuration entries intended to configure Roslyn diagnostics globally should
be placed in a global analyzer configuration file (typically a .globalconfig
file) instead of a standard .editorconfig file.
Traditional .editorconfig files use folder-based path matching (like [*.cs])
which forces the Roslyn compiler engine to evaluate file-system hierarchies for
every single source file.
Moving Roslyn diagnostics to a .globalconfig file:
- Improves Build Performance: Roslyn processes the configuration once per project instead of once per file.
- Ensures Codebase Uniformity: Rules apply globally across all sub-folders and projects without risk of accidental path exclusions.
- Separates Concerns: Keeps .editorconfig focused strictly on IDE editor
styles while the
.globalconfigmanages static analysis severity rules.
Non-compliant
When defined in an .editorconfig.
[*.cs]
dotnet_diagnostic.IDE0001.severity = warning # Simplify name
Compliant
When defined in a .globalconfig.
is_global = true
dotnet_diagnostic.IDE0001.severity = warning # Simplify name