Enable Analyzers when building source-only

Open
#115,397 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp

Research direction

Start by reading eng/Analyzers.targets at line 11, then review the linked pull request and historical corefx commit to understand why analyzers were disabled for source-only builds. Check the source-only jobs and SB stage2 validation; done means source-only builds run applicable analyzers while online-only analyzers remain excluded, with CA2025 behavior consistent across build flows.

Written by the indexing model from the issue text.

Description

area-Infrastructure

https://github.com/dotnet/runtime/pull/115395 showed new CA2025 errors but only in the non-source-only jobs. That's because analyzers are disabled globally when building source-only: https://github.com/dotnet/runtime/blob/08cb954444914798a1a7e41737447c26b134169e/eng/Analyzers.targets#L11

This setting dates back to https://github.com/dotnet/corefx/commit/7732d6b2569f5ffa44ecca1755d0135d300e8569 which disabled analyzers for source-only builds.

This is problematic for various reasons:

  • Creates an artificial difference between source-only and non-source-only builds
  • Diverging behavior form other repositories which don't disable analyzers when building source-only
  • Doesn't get caught in SB's stage2 validation that runs as part of VMR PRs. For the above PR that meant it only get caught in the VMR -> runtime backflow PR and not in the roslyn-analyzers -> VMR forward flow PR.

I propose that we change this setting to only apply to "online" analyzers that don't exist in the source-build graph.

cc @dotnet/source-build @ericstj (as you made the original commit) for opinions

Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.