Skip to content

Suppress the intentional UseRealFor constraint change against the 1.1.0 package baseline#340

Merged
Vulthil merged 1 commit into
mainfrom
fix/userealfor-constraint
Jul 20, 2026
Merged

Suppress the intentional UseRealFor constraint change against the 1.1.0 package baseline#340
Vulthil merged 1 commit into
mainfrom
fix/userealfor-constraint

Conversation

@Vulthil

@Vulthil Vulthil commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

Main's Pack preview step fails with CP0021 against the 1.1.0 package baseline: the recently merged testing-stack PR tightened UseRealFor<TService, TImplementation>'s TService constraint from notnull to class. The PublicAPI analyzers don't track generic constraints, so the PR build was green - APICompat at pack time caught it.

The constraint change is kept and declared as an intentional divergence via CompatibilitySuppressions.xml (same mechanism as the MySql per-TFM suppression), because:

  • No valid caller can break: TImplementation : class, TService already made a non-reference TService uninstantiable (a class cannot derive from a struct; interfaces satisfy the class constraint).
  • Reverting to notnull is not implementable with the lazy-factory design: AutoMocker's Use<TService>(Func<AutoMocker, TService>) cannot be bound when TService is merely notnull - explicit type arguments fail with CS0452 against the class-constrained Mock<TService> overload, and inference silently binds the wrong overload (registering the delegate itself as a service; test-verified). The alternative would regress UseRealFor to eager creation, losing the lazy + auto-disposal semantics.

The full analysis is preserved as a comment in the suppression file.

Verification

  • dotnet pack src/Vulthil.xUnit -c Release against the 1.1.0 baseline: green (previously CP0021 x4).
  • tests/Vulthil.SharedKernel.Tests (incl. the UseRealFor auto-disposal and dependency-visibility tests): 36/36 passing, both TFMs.
  • Both alternative fixes were implemented and tested before choosing the suppression: the explicit-delegate + notnull variant compiles but binds the wrong overload (2 test failures); explicit type arguments fail with CS0452.

Backport to v1.0: no - repairs the main-line package baseline only.

@claude

claude Bot commented Jul 20, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@Vulthil
Vulthil merged commit 3894dd8 into main Jul 20, 2026
6 checks passed
@Vulthil
Vulthil deleted the fix/userealfor-constraint branch July 20, 2026 19:34
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