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
[browser][trimmed] DI generic constraint tests conflict with trimmability validation #134266
Aggressively trimmed browser library tests enable Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability. Seven existing CallSiteFactoryTest cases then fail during container construction because their deliberately varied open-generic constraint shapes do not satisfy that validation contract.
Affected methods:
CreateCallSite_Throws_IfClosedTypeDoesNotSatisfyStructGenericConstraint
CreateCallSite_ReturnsService_IfClosedTypeSatisfiesStructGenericConstraint
CreateCallSite_Throws_IfClosedTypeDoesNotSatisfyNewGenericConstraint
CreateCallSite_ReturnsService_IfClosedTypeSatisfiesNewGenericConstraint
CreateCallSite_ReturnsMatchingTypesThatMatchCorrectConstraints (three data rows)
Reproduction Steps
Build and run Microsoft.Extensions.DependencyInjection.Tests for browser-Wasm with:
The failures reproduce on CoreCLR and Mono browser trimming.
Expected behavior
Tests not specifically validating trimming annotations should continue exercising their intended generic-constraint behavior, or be adapted to a service registration shape valid under the trimming feature switch.
Actual behavior
Representative exception:
System.ArgumentException: Generic implementation type 'ClassWithStructConstraint`1' has a DefaultConstructorConstraint ('new()' constraint), but the generic service type 'IFakeOpenGenericService`1' doesn't.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.ValidateTrimmingAnnotations(...)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.Populate()
Regression?
Unknown. Broad aggressive-trimming browser coverage is newly enabled.
Known Workarounds
Temporarily exclude only the affected methods/data rows under aggressively trimmed browser builds. All non-trimmed coverage remains enabled, and dedicated open-generic trimmability validation tests remain active.
Configuration
Browser-Wasm Release with aggressive trimming, CoreCLR and Mono.
Other information
A linker descriptor is not the appropriate fix because the exception is intentional validation behavior, not missing generic metadata.
Note
This issue was generated with GitHub Copilot assistance and reviewed as part of the #133193 bring-up.
Description
Aggressively trimmed browser library tests enable
Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability. Seven existingCallSiteFactoryTestcases then fail during container construction because their deliberately varied open-generic constraint shapes do not satisfy that validation contract.Affected methods:
Reproduction Steps
Build and run
Microsoft.Extensions.DependencyInjection.Testsfor browser-Wasm with:The failures reproduce on CoreCLR and Mono browser trimming.
Expected behavior
Tests not specifically validating trimming annotations should continue exercising their intended generic-constraint behavior, or be adapted to a service registration shape valid under the trimming feature switch.
Actual behavior
Representative exception:
Regression?
Unknown. Broad aggressive-trimming browser coverage is newly enabled.
Known Workarounds
Temporarily exclude only the affected methods/data rows under aggressively trimmed browser builds. All non-trimmed coverage remains enabled, and dedicated open-generic trimmability validation tests remain active.
Configuration
Browser-Wasm Release with aggressive trimming, CoreCLR and Mono.
Other information
A linker descriptor is not the appropriate fix because the exception is intentional validation behavior, not missing generic metadata.
Note
This issue was generated with GitHub Copilot assistance and reviewed as part of the #133193 bring-up.