Skip to content

[browser][trimmed] Fix DI generic constraint tests conflicting with trimmability validation - #134760

Merged
lewing merged 1 commit into
mainfrom
lewing-supreme-enigma
Sep 28, 2026
Merged

lewing merged 1 commit into
mainfrom
lewing-supreme-enigma

Conversation

@lewing

@lewing lewing commented Sep 27, 2026

Copy link
Copy Markdown
Member

Cause: When PublishTrimmed is set, src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets defaults VerifyDependencyInjectionOpenGenericServiceTrimmability to true, which enables the Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability feature switch. CallSiteFactory.ValidateTrimmingAnnotations then rejects the open-generic registrations that these CallSiteFactoryTest cases deliberately use (implementation constraints the service type lacks), so container construction throws ArgumentException. This is intended validation, not missing metadata.

Fix: The DI test project opts out of the default, and the five ActiveIssue attributes are removed. The only test that needs the switch on, VerifyOpenGenericTrimmabilityChecks, sets it explicitly through RemoteExecutor RuntimeConfigurationOptions, so its coverage is unchanged. It's also skipped wherever RemoteExecutor is unsupported, including browser.

Validation: browser-wasm CoreCLR Release, Microsoft.Extensions.DependencyInjection.Tests with EnableAggressiveTrimming=true TestTrimming=true on Chrome: 884 tests, 847 passed, 37 skipped, 0 failed. All 7 re-enabled cases (4 facts + 3 theory rows) passed, and the published runtimeconfig.json shows the switch as false. The issue reports the same failure on Mono browser trimming; only CoreCLR was run locally.

Resolves #134266

Note

This PR was generated with GitHub Copilot assistance.

When PublishTrimmed is set, ILLink defaults
VerifyDependencyInjectionOpenGenericServiceTrimmability to true, causing
CallSiteFactory to reject the open-generic registrations that
CallSiteFactoryTest deliberately uses. Opt the test project out and
re-enable the affected tests. VerifyOpenGenericTrimmabilityChecks still
enables the switch explicitly via RemoteExecutor.

Fixes #134266

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-extensions-dependencyinjection
See info in area-owners.md if you want to be subscribed.

@lewing
lewing enabled auto-merge (squash) September 27, 2026 23:12
@lewing
lewing merged commit caf6b2a into main Sep 28, 2026
86 checks passed
@lewing
lewing deleted the lewing-supreme-enigma branch September 28, 2026 01:40
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[browser][trimmed] DI generic constraint tests conflict with trimmability validation

2 participants