Use a repo-root `.editorconfig` to configure free .NET analyzer and style rules.
.NET Code Analysis
Use the free built-in .NET SDK analyzers and analysis levels with gradual Roslyn warning promotion. Use when a .NET repo needs first-party code analysis, `EnableNETAnalyzers`, `AnalysisLevel`, or warning-as-error policy wired into build and CI.
Trigger On
- the repo wants first-party .NET analyzers
- CI should fail on analyzer warnings
- the team needs
AnalysisLevelorAnalysisModeguidance - the repo needs a gradual Roslyn warning promotion strategy
Workflow
flowchart TD
A[Start] --> B{New or legacy project?}
B -->|New| C[TreatWarningsAsErrors=true immediately]
B -->|Legacy| D[dotnet build, count warnings by ID]
D --> E{"< 30 warnings?"}
E -->|Yes| F[Fix all, then enable TreatWarningsAsErrors]
E -->|No| G[Report counts to user, ask which batch first]
G --> H[Add selected IDs to WarningsAsErrors]
H --> I[Fix that batch, verify build]
I --> J{More batches?}
J -->|Yes| G
J -->|No| F
C --> K[Set AnalysisLevel latest-recommended]
F --> K
K --> L[Promote security CA3xxx/CA5xxx to error in .editorconfig]
L --> M[Validate: build + CI green]
- Start with SDK analyzers before third-party packages.
- Detect project maturity: new or existing/legacy.
- Enable
EnableNETAnalyzers,AnalysisLevel,AnalysisModeinDirectory.Build.props. - Apply the right warning promotion strategy (see below).
- Per-rule severity goes in repo-root
.editorconfig. dotnet buildis the analyzer gate in CI.
Deliver
- explicit, reviewable first-party analyzer policy
- build-time analyzer execution for CI
- warning promotion plan matching project maturity
Validate
- analyzer behavior driven by repo config, not IDE defaults
- CI reproduces same warnings/errors locally
- no
TreatWarningsAsErrors,WarningsAsErrors, or severity settings removed/weakened without user approval - promoted warnings produce build errors, not just IDE hints
Load References
references/rules.mdreferences/config.mdreferences/code-analysis.md
Related skills
Use the open-source free `CSharpier` formatter for C# and XML.
Use Chous in .NET repositories that ship sizeable frontend codebases and want file-structure linting, naming convention enforcement, and folder-layout policy as a CLI gate.
Related agents
.NET Review
Review orchestration agent for .NET changes across bugs, regressions, analyzers, architecture, tests, and maintainability.
Also works: dotnet agents install review
.NET Build
Build-focused orchestration agent for .NET restore, build, test, packaging, CI failures, diagnostics, and environment drift.
Also works: dotnet agents install build