roslyn-analyzers
Develops and tests tools that analyze and fix C# and VB.NET code. It helps ensure code quality and compliance.
What it does
This tool helps developers create and improve automatic code checks (Roslyn analyzers) and code generators. It ensures code follows specific rules and helps find errors.
When to use it
- ✓When creating new checks to find common code errors.
- ✓When fixing issues that analyzers have already found.
- ✓When optimizing how code is automatically generated.
Example of what to ask your AI
“How can I create an analyzer that checks if all variables have descriptive names?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
It works by inspecting code as it's written or compiled. It uses rules to understand the code's structure and symbols, identifying patterns that need attention or correction.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add github/awesome-copilot --skill roslyn-analyzersOr download just the file:
curl -L https://raw.githubusercontent.com/github/awesome-copilot/main/skills/roslyn-analyzers/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
Roslyn Analyzers and Source Generators
Use this workflow when adding or changing a Roslyn analyzer, code fix, source generator, tests, dependencies, or package layout. First inspect the repository's target frameworks, central package management, test framework, analyzer and generator conventions, diagnostic ID allocation, localization, and packaging. Preserve established conventions unless they conflict with the compatibility rules below.
Non-negotiable design rules
- Prefer
IOperation-based analysis wherever possible. Register the narrowest applicableOperationKindand inspect typed operations such asIInvocationOperation,IAwaitOperation, orIObjectCreationOperation. This usually supports C# and VB with one analyzer and gives direct access to symbols and conversions. - Use syntax analysis only for inherently syntactic rules or syntax not represented adequately by
IOperation. A syntax-node callback already has aSemanticModel; do not callCompilation.GetSemanticModelor fetch another semantic model from it. Repeated semantic-model creation is expensive and often indicates that an operation or symbol action is the better abstraction. - Every analyzer must support C#. VB.NET support is optional until requested or established repository precedent requires it. A language-neutral operation analyzer may declare both languages. If VB support is promised, include equivalent C# and VB snippets in tests; do not infer VB correctness from shared implementation alone.
- Keep analyzer and code-fix providers in distinct assemblies. The analyzer project must never reference Roslyn Workspaces packages. Workspaces dependencies belong only in the code-fix and test projects.
- Analyzer callbacks must be stateless or concurrency-safe. Call
EnableConcurrentExecution(). Make an explicit generated-code choice withConfigureGeneratedCodeAnalysis(...); follow repository policy rather than silently accepting the default. - Respect cancellation where APIs expose a token. Do not retain compilations, operations, syntax trees, symbols, or semantic models in static state.
- Avoid
InternalsVisibleTo. Test analyzers through their publicDiagnosticAnalyzerandCodeFixProviderAPIs and the Roslyn test harness. A small analyzer helper may be public when direct testing is genuinely useful, but most behavior should be tested end to end. - Centralize metadata names and member names instead of propagating magic strings. Use one shared static catalog for fully qualified type names, namespaces, and API member names.
- Never identify a symbol, including an attribute class, by calling
ToDisplayString()and comparing the result with a string literal. Resolve an expected named type from theCompilationonce by metadata name. To resolve a method, property, field, or event, first resolve its containing type, then select the expected member by name and signature. Compare encountered symbols withSymbolEqualityComparer.Default.Equals(actual, expected). When generic substitutions are irrelevant, compare named types, properties, fields, and events byOriginalDefinition; compare methods after replacing a reduced extension method withReducedFrom ?? methodand then takingOriginalDefinition. Normalize both expected and encountered symbols, and inspect type arguments separately when they are part of the match. Display strings are for presentation, not identity, and can vary with formatting, aliases, qualification, nullability, and other context. - Document every diagnostic ID. When the repository uses Docfx, put analyzer documentation under its Docfx tree, typically
docfx/analyzers, and include each page in the relevant table of contents. - Set every analyzer assembly's version precisely enough that each commit produces a unique assembly version. When using Nerdbank.GitVersioning, give each analyzer project its own
version.jsonwithassemblyVersion.precisionset torevisionand ensure that repository-wide MSBuild properties do not prevent that file from being discovered. - Source generators must implement
IIncrementalGenerator, notISourceGenerator. Design the provider graph so unchanged inputs remain cached and do not regenerate output. - Source generators must use a small
SourceWriterabstraction for deterministic newlines, indentation, encoding, and balanced output. Start from SourceWriter.cs and tailor its namespace and target-framework details to the receiving repository.
…
FAQ
What are 'Roslyn analyzers'?
These are tools that analyze your C# or VB.NET code to find potential issues, suggest improvements, or even fix them automatically.
What are 'code generators'?
These are programs that automatically create code based on other parts of your project, saving time and reducing manual errors.
Do I need to know a lot about programming to use this?
This tool is for developers who are already writing code. It helps make their code better and more efficient.
Details
Original description by the author
Build, review, debug, package, and test Roslyn diagnostic analyzers, code fix providers, and incremental source generators. Use for DiagnosticAnalyzer, CodeFixProvider, IIncrementalGenerator, IOperation analysis, Microsoft.CodeAnalysis dependency pinning, Roslyn test harnesses, C#/VB tests, and analyzer NuGet packaging.
repo: github/awesome-copilot
Popularity
- GitHub stars
- 40k
- Ranking position
- #5349
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
acquire-codebase-knowledge
Helps your agent understand and document an existing code project. It's useful for onboarding new people or getting an overview of the architecture.
github/awesome-copilot
acreadiness-assess
Enables your agent to assess a project's readiness for AI and generate a report. It's useful for understanding how well a project is prepared to use AI tools.
github/awesome-copilot
acreadiness-generate-instructions
Helps your agent create instructions for AI tools based on an assessment. It's useful for improving how AI interacts with code and closing identified gaps.
github/awesome-copilot
acreadiness-policy
Enables your agent to help define or apply policies for AI project assessment. It's useful for standardizing how projects are evaluated and ensuring compliance.
github/awesome-copilot
Similar skills
benchmark-optimization-loop
Has your agent improve something's speed in a measured way. It tests multiple versions and chooses the fastest one that still works correctly.
affaan-m/ECC
change-impact
Helps your agent analyze the impact of code changes before making them. It compares the planned vs. actual results afterward, covering paths, data, tests, and documentation. Useful for risky or system-wide changes.
affaan-m/ECC
click-path-audit
Lets your agent trace all user buttons and interactions to find bugs. It finds issues where functions seem to work alone but fail together. Useful when bugs persist even after debugging.
affaan-m/ECC