Loading...
Loading...
Use the free built-in .NET SDK analyzers and analysis levels with gradual Roslyn warning promotion. USE FOR: the repo wants first-party .NET analyzers; CI should fail on analyzer warnings; the team needs AnalysisLevel or AnalysisMode guidance. DO NOT USE FOR: third-party analyzer selection by itself; formatting-only work. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
npx skill4agent add managedcode/dotnet-skills code-analysisAnalysisLevelAnalysisModeAGENTS.mdDirectory.Build.propsTreatWarningsAsErrorsWarningsAsErrorsfalse<TreatWarningsAsErrors>false</TreatWarningsAsErrors><NoWarn>#pragma warning disable.editorconfigerrorwarningnoneflowchart 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]EnableNETAnalyzersAnalysisLevelAnalysisModeDirectory.Build.props.editorconfigdotnet buildDirectory.Build.propsTreatWarningsAsErrorsAnalysisLevel.editorconfigTreatWarningsAsErrorsWarningsAsErrorsCS8019;CS0219;CS0168WarningsAsErrors.editorconfig[*.cs]
dotnet_analyzer_diagnostic.category-Security.severity = error<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsNotAsErrors>CA1707</WarningsNotAsErrors> <!-- explicit exceptions only -->dotnet buildWarningsAsErrorsdotnet --inforg -n "EnableNETAnalyzers|AnalysisLevel|AnalysisMode|TreatWarningsAsErrors|WarningsAsErrors" -g '*.csproj' -g 'Directory.Build.*' .dotnet build SOLUTION_OR_PROJECT 2>&1EnableNETAnalyzersAnalysisLevelAnalysisMode.editorconfigdotnet buildstatus: configuredstatus: improvedstatus: not_applicableTreatWarningsAsErrorsWarningsAsErrorsstatus: not_applicablestatuscompletecleanimprovedconfigurednot_applicableblockedplanactions_takenvalidation_skillsverificationremainingnone