Feature Request: Allow Filtering Analyzer Execution by Severity During Build
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
### Summary
Add a compiler/MSBuild switch to control which analyzers are executed during build based on their configured severity (e.g., only run analyzers with severity `warning` or higher).
### Motivation
Currently, analyzers configured as `suggestion` (or `silent`) still run during `dotnet build`, even though their diagnostics are not emitted. This adds unnecessary overhead to builds, especially in large solutions with many analyzers. Developers often want these diagnostics visible in the IDE, but not evaluated during command-line builds.
### Proposal
Introduce a new MSBuild property or compiler switch, such as:
```xml
WarningOrAbove
```
### Related
This request stems from a discussion in dotnet/extensions#7012, where I was investigating why build was so slow in the extensions repo.
### Workarounds
- Disabling analyzers entirely during build - will remove the checks we want during development.
- Using custom build configurations to exclude analyzers.
- Swapping .editorconfig files based on context. (complicated and error prone, duplicates content).
cc @stephentoub @jaredpar @baronfel
Contributor guide
Research direction
Start by reading the proposal and the related discussion in dotnet/extensions#7012, focusing on how analyzer severity currently affects command-line builds. Done means defining and implementing an MSBuild property or compiler switch that skips analyzers below the selected severity while preserving IDE diagnostics and existing build checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system, compilers, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100