You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
KTSU0008 never fires for net8.0 (the SDK's lowest default TFM), and on net8.0 advises pinning System.Collections.Immutable to 1.4.0: it reads the stale PackageOverrides.txt #69
_KtsuGenerateFrameworkOverrideInputs in Sdk/Sdk.targets (~L266-310) feeds FrameworkOverridingPackageAnalyzer (KTSU0008) with @(PackageConflictOverrides->'%(OverriddenPackages)'). That is the targeting pack's PackageOverrides.txt, which the analyzer treats as "the packages and versions this framework ships". Before .NET 9 that file is badly incomplete and out of date.
has no entry for System.Text.Json, System.Memory or System.IO.Pipelines, although net8.0 ships all three
lists System.Collections.Immutable|1.4.0 and System.Reflection.Metadata|1.5.0, although net8.0 ships 8.0 versions of both
The 9.0.x pack does list System.Text.Json|9.0.x, which is why the shipped example (examples/analyzers/KTSU0008-FrameworkOverridingPackage, which targets only net10.0;net9.0) passes.
Failure scenarios
These were reproduced by building Sdk.Analyzers at bafee81 and wiring the real target plus the analyzer DLL into a plain SDK project targeting net10.0;net9.0;net8.0. The per-TFM ktsu.framework-*.g.txt inputs and the diagnostics were then inspected.
A. Missed error, which is the case the rule exists for (#44). A library multi-targeting net10.0;net9.0;net8.0 references System.Text.Json privately (PrivateAssets="all").
At 10.0.2, KTSU0008 fires only for net9.0 and says "pin the version to 9.0.x". Following that advice still leaves net8.0 compiled against a 9.0 assembly.
At 9.0.0, nothing fires at all.
In both cases the net8.0 build compiles against a higher System.Text.Json than .NET 8 ships, so net8.0 consumers hit FileNotFoundException at runtime. The analyzer's own remarks (L46) say the lowest-supported framework is the one that fires. Here it is the one that never fires.
B. Wrong advice. A private System.Collections.Immutable 9.0.0 reference on net8.0 reports "overriding the 1.4.0 … pin the version to 1.4.0". The code fix would write 1.4.0 into Directory.Packages.props, which is a real downgrade.
Suggested fix
Take framework-provided versions from the SDK's package-pruning data instead of PackageConflictOverrides. @(PrunePackageReference), which CollectPrunePackageReferences populates, lists System.Text.Json and System.Collections.Immutable at 8.0.32767 for net8.0. Alternatively, compare against the assembly versions of the framework reference assemblies. Either source reflects what the framework actually ships.
Acceptance:
Add a net8.0 leg to the KTSU0008 example/test.
A private System.Text.Json 9.x/10.x reference raises KTSU0008 for net8.0 and suggests an 8.0.x pin.
A private System.Collections.Immutable reference no longer suggests 1.4.0.
Priority: High. This is the exact case KTSU0008 exists to catch (KTSU0006's code fix can silently downgrade a consumer at runtime; add an analyzer for the framework-override case #44): a multi-targeted library privately referencing a newer System.Text.Json than net8.0 ships, which fails at runtime for net8.0 consumers with FileNotFoundException. The rule stays silent for net8.0, which is the lowest default TFM and the one its own remarks say should fire. In the other direction, the code fix would write a real downgrade (System.Collections.Immutable 1.4.0) into Directory.Packages.props.
Area / suggested assignment:Sdk.Analyzers (FrameworkOverridingPackageAnalyzer) plus the _KtsuGenerateFrameworkOverrideInputs target in Sdk/Sdk.targets. The fix is in the MSBuild input source (@(PrunePackageReference) rather than PackageConflictOverrides), so whoever owns the targets should take it.
Activity
matt-edmondson commentedon Sep 30, 2026
Triage
System.Text.Jsonthan net8.0 ships, which fails at runtime for net8.0 consumers withFileNotFoundException. The rule stays silent for net8.0, which is the lowest default TFM and the one its own remarks say should fire. In the other direction, the code fix would write a real downgrade (System.Collections.Immutable1.4.0) intoDirectory.Packages.props.Sdk.Analyzers(FrameworkOverridingPackageAnalyzer) plus the_KtsuGenerateFrameworkOverrideInputstarget inSdk/Sdk.targets. The fix is in the MSBuild input source (@(PrunePackageReference)rather thanPackageConflictOverrides), so whoever owns the targets should take it.analyzerslabel, but in different rules.Generated by Claude Code