code-analysis

Configures built-in .NET SDK analyzers and gradually promotes Roslyn warnings to build errors.

Updated May 2, 2026
One-click install
npx skills add https://github.com/hdeshev/pi-config --skill code-analysis-hdeshev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: code-analysis
Source: https://github.com/hdeshev/pi-config/tree/main/agent/skills/code-analysis
Command: npx skills add https://github.com/hdeshev/pi-config --skill code-analysis-hdeshev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Legacy .NET codebases often have hundreds of analyzer warnings, making it impossible to enable TreatWarningsAsErrors in one step. This Skill sets up first-party .NET SDK analyzers and applies a phased warning promotion strategy so CI can fail on analyzer violations without flooding the build. ## Core Features & Use Cases - Analyzer Bootstrap: Detects existing analyzer policy and configures EnableNETAnalyzers, AnalysisLevel, and AnalysisMode in Directory.Build.props. - Gradual Warning Promotion: Promotes warnings in batches (trivial hygiene, code quality, security, full coverage) using WarningsAsErrors and .editorconfig severity rules. - Policy Protection: Enforces hard rules that prevent agents from disabling TreatWarningsAsErrors, adding NoWarn suppressions, or downgrading severities to make builds pass. - Use Case: A team inherits a legacy .NET solution with 500 warnings. The Skill counts warnings by ID, asks which batch to fix first, promotes those IDs to errors, and repeats until the build is clean. ## Quick Start Ask the agent to enable built-in .NET analyzers and gradually promote Roslyn warnings to errors in this repository.

Frequently Asked Questions about code-analysis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enable built-in .NET analyzers in my project?▼

Set EnableNETAnalyzers to true and AnalysisLevel to latest-recommended in Directory.Build.props or your project file. For .NET 5 and later, analyzers are included with the SDK and enabled by default, but explicit settings prevent accidental disabling.

How to treat specific Roslyn warnings as errors in legacy code?▼

Use the WarningsAsErrors MSBuild property with specific diagnostic IDs like CS8019;CS0219;CA2000 instead of blanket TreatWarningsAsErrors. Fix each batch of warnings, verify the build, then add more IDs incrementally.

What is the difference between AnalysisLevel and AnalysisMode?▼

AnalysisLevel selects which SDK rule set version applies, such as latest or latest-recommended. AnalysisMode controls how many rules are active: None, Default, Minimum, Recommended, or All, and can be set per category like AnalysisModeSecurity.

Should I use .editorconfig or NoWarn to suppress analyzer warnings?▼

Prefer .editorconfig severity settings because they are visible, scoped, and reviewable in the repo root. NoWarn disables warnings entirely and should be used sparingly; never add suppressions just to make a build pass without user approval.

When should I not use built-in .NET SDK analyzers?▼

Avoid relying on them alone when you only need code formatting, or when the project requires third-party or framework-specific analyzer rules beyond the built-in SDK set. This Skill covers first-party analyzer policy, not third-party analyzer selection.