Skip to content

build(analyzers): load PublicApiAnalyzers only in projects that track their API - #361

Merged
Chris-Wolfgang merged 1 commit into
mainfrom
build/publicapi-analyzer-conditional
Sep 20, 2026
Merged

Chris-Wolfgang merged 1 commit into
mainfrom
build/publicapi-analyzer-conditional

Conversation

@Chris-Wolfgang

Copy link
Copy Markdown
Owner

Fleet sync of the template's Directory.Build.props (Chris-Wolfgang/repo-template#611 follow-up, alerts like #n/a).

The Microsoft.CodeAnalysis.PublicApiAnalyzers reference here had lost the template's Condition="Exists('PublicAPI.Shipped.txt') or Exists('PublicAPI.Unshipped.txt')", so the analyzer loaded in every project — including test projects, which track no public API — and InspectCode reported RS0016 / RS0037 for every public test type. The Release build never showed them (blanket suggestion severity), InspectCode does. Restoring the condition scopes the analyzer to projects that actually have the API files; no change for those.

Configuration-only PR (Directory.Build.props) — passes the protected-file guard with the banner, merges on review. The open RS0016/RS0037 code-scanning alerts and their auto-issues close on the next InspectCode run on main.

🤖 Generated with Claude Code

… their API

The template references Microsoft.CodeAnalysis.PublicApiAnalyzers with
Condition="Exists('PublicAPI.Shipped.txt') or Exists('PublicAPI.Unshipped.txt')"
so the analyzer only runs where the API files are. This repository's copy had
lost the condition, so the analyzer loaded in every project - including tests,
which track no API - and InspectCode reported RS0016/RS0037 for every public
test type (the build hides them behind the blanket suggestion severity).
Restores the condition; the AdditionalFiles items were already conditional.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 20, 2026 20:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Chris-Wolfgang
Chris-Wolfgang merged commit fbacd71 into main Sep 20, 2026
22 checks passed
@Chris-Wolfgang
Chris-Wolfgang deleted the build/publicapi-analyzer-conditional branch September 20, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants