Skip to content

Feature Request: Allow Filtering Analyzer Execution by Severity During Build #81026

@ericstj

Description

@ericstj

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:

<PropertyGroup>
  <RunAnalyzersWithSeverity>WarningOrAbove</RunAnalyzersWithSeverity>
</PropertyGroup>

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions