Skip to content

[browser][CoreCLR] Root UnloadableAssembly so trimmed builds keep it for AssemblyGetForwardedTypesLoadFailure - #134759

Merged
lewing merged 3 commits into
mainfrom
lewing-fix-forwarded-types-134263
Sep 28, 2026
Merged

lewing merged 3 commits into
mainfrom
lewing-fix-forwarded-types-134263

Conversation

@lewing

@lewing lewing commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

This fixes the forwarded-types half of #134263 and re-enables AssemblyGetForwardedTypesLoadFailure on browser aggressive-trimming builds.

Cause: ForwardedTypesAssembly contains [assembly: TypeForwardedTo(typeof(TypeInUnloadableAssembly))]. UnloadableAssembly has [assembly: ReferenceAssembly], and that attribute is why loading it throws the BadImageFormatException the test expects. The type forwarder is the only reference to UnloadableAssembly, so ILLink removed UnloadableAssembly.dll from the trimmed output and shipped only its .pdb. GetForwardedTypes then fails because the file is missing, not with BadImageFormatException, so foundBifException is false.

Fix: Root UnloadableAssembly in the test's ILLink.Descriptors.xml. The assembly is then kept along with its ReferenceAssemblyAttribute. This PR also removes the ActiveIssue for #134263 on the test.

Apple CoreCLR: This PR also removes the Apple mobile CoreCLR ActiveIssue for #124344, which #129226 added because GetForwardedTypes() failed on trimmed Apple CoreCLR app bundles. The cause is likely the same: Apple CoreCLR lanes build with EnableAggressiveTrimming=true, and the descriptor applies on all platforms. This still needs validation in runtime-extra-platforms (ioslikesimulator).

Android: The Android ActiveIssue for #77821 stays. Android lanes aren't trimmed today, and #77821 predates CoreCLR on Android.

Validation: browser-wasm, CoreCLR, Release.

  • Before the fix, the failure reproduced with EnableAggressiveTrimming=true TestTrimming=true (no R2R).
  • After the fix, the full System.Reflection.Tests suite ran in the CI lane configuration (EnableAggressiveTrimming=true TestWasmReadyToRun=true, Chrome): 1773 tests, 1749 passed, 24 skipped, 0 failed. AssemblyGetForwardedTypesLoadFailure was among the passing tests.

Scope: This PR does not resolve #134263. The MetadataLoadContext MarshalAs half is a Cecil bug. When ILLink rewrites assemblies, it drops the IidParameterIndex for IDispatch/IUnknown/Interface and the SafeArray user-defined subtype from FieldMarshal blobs (confirmed byte-for-byte). That needs a fix in dotnet/cecil, so the existing TrimMode=copy workaround in System.Reflection.MetadataLoadContext.Tests.csproj stays.

Contributes to #134263

Note

This PR was generated with GitHub Copilot assistance.

AssemblyGetForwardedTypesLoadFailure relies on UnloadableAssembly.dll existing
so loading it throws BadImageFormatException. ILLink dropped it under aggressive
trimming because its only reference is a type forwarder.

Contributes to #134263

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Sep 27, 2026
@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: @steveisok, @dotnet/area-system-reflection
See info in area-owners.md if you want to be subscribed.

The Apple CoreCLR failure came from trimming dropping UnloadableAssembly,
which the ILLink descriptor now roots on all platforms.

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

lewing commented Sep 27, 2026

Copy link
Copy Markdown
Member Author

/azp run runtime-ioslikesimulator

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@lewing

lewing commented Sep 27, 2026

Copy link
Copy Markdown
Member Author

/azp run runtime-ioslikesimulator

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@lewing lewing added the arch-wasm WebAssembly architecture label Sep 28, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

Comment thread src/libraries/System.Runtime/tests/System.Reflection.Tests/AssemblyTests.cs Outdated
Comment thread src/libraries/System.Runtime/tests/System.Reflection.Tests/AssemblyTests.cs Outdated
@lewing
lewing enabled auto-merge (squash) September 28, 2026 04:08
@lewing
lewing merged commit 29be631 into main Sep 28, 2026
82 of 84 checks passed
@lewing
lewing deleted the lewing-fix-forwarded-types-134263 branch September 28, 2026 06:48
@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

Labels

arch-wasm WebAssembly architecture area-System.Reflection linkable-framework Issues associated with delivering a linker friendly framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[browser][CoreCLR][trimmed R2R] Reflection metadata tests lose pseudo-attribute and forwarder data

2 participants