Skip to content

test: guard PrivateAssets=all per shipping project - #26

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
test/build-only-references-per-project
Aug 16, 2026
Merged

test: guard PrivateAssets=all per shipping project#26
CaffeinatedCoder merged 1 commit into
mainfrom
test/build-only-references-per-project

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Why

Triaging the 32 open Dependabot alerts (all one package — System.Security.Cryptography.Xml 9.0.0, 8 advisories × 4 projects) confirmed none reach a consumer: it arrives only through Microsoft.EntityFrameworkCore.Design, which every src/ project marks PrivateAssets=all. That is the premise NU1903 staying a warning rests on (Directory.Build.props) and the reason dependabot.yml ignores the package under src/.

Nothing checked that premise per project. Sbom_filter_covers_every_private_reference builds its set with SelectMany(...).ToHashSet(...), flattening all three projects into one collection of ids, so it only ever asks whether a name is somewhere private. Drop PrivateAssets=all from a single csproj and the other two keep the id in that set — the SBOM test stays green while that one package's nuspec starts declaring the dependency.

What

Build_only_references_are_private_in_every_project: every package id marked PrivateAssets=all in any src/ project must not be referenced publicly by another. General rather than hardcoded to EF Core Design, so it catches the class of drift; the failure message names the project, the id, and the escape hatch if a consumer genuinely needs the package at runtime.

CLAUDE.md gains the rationale next to the existing SBOM-filter paragraph.

Verified (verify-the-guard)

The subject is delivery, so the counterfactual breaks the mechanism rather than reverting a source fix. Removed PrivateAssets=all from Microsoft.EntityFrameworkCore.Design in EFCore.ComplexIndexes.SqlServer.csproj only:

broken tree
new guard failsEFCore.ComplexIndexes.SqlServer -> Microsoft.EntityFrameworkCore.Design — marked PrivateAssets=all elsewhere under src/ but not here…
Sbom_filter_covers_every_private_reference passes

That contrast is the reason the test exists.

The stated consequence was checked rather than assumed. Packing the broken project yields a nuspec declaring <dependency id="Microsoft.EntityFrameworkCore.Design" …>, and a throwaway consumer restoring it — outside the repo, source-mapped, with a fresh NUGET_PACKAGES so the good 5.0.3 built minutes earlier could not shadow it — reports all eight advisories on System.Security.Cryptography.Xml. The good build of the same package reports none.

Tree restored; full unit suite green at 195.

🤖 Generated with Claude Code

The SBOM filter test flattens all three src/ projects into one set of package
ids, so it only asks whether a name is somewhere private. Drop PrivateAssets=all
from a single csproj and the other two keep the id in that set: every check stays
green while that one nuspec starts declaring the dependency and its consumers
restore the whole subtree behind it.

For Microsoft.EntityFrameworkCore.Design that subtree is ~45 MSBuild/Roslyn
components carrying System.Security.Cryptography.Xml 9.0.0 and its eight high
advisories. "Consumers never receive it" is the premise NU1903 staying a warning
rests on (Directory.Build.props) and the reason dependabot.yml ignores that
package under src/ — and nothing checked it per project.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@CaffeinatedCoder
CaffeinatedCoder merged commit ce72a9d into main Aug 16, 2026
9 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the test/build-only-references-per-project branch August 16, 2026 13:54
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.

1 participant