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
ILLink: root assembly preserves referenced forwarders in other assemblies #126518
This issue was filed with AI (Copilot) assistance.
When an assembly is rooted with -a (AllMembers) and has link action, ILLink preserves type forwarder assemblies that are referenced through type references. This is unnecessary because the linker rewrites the type references to point directly to the implementation assembly, so the forwarder is not needed at runtime to load the assembly. Without -a, these forwarder assemblies are correctly removed.
Root Cause
MarkStep.MarkEntireAssembly unconditionally calls TypeReferenceMarker.MarkTypeReferences, which walks all type references in the assembly and calls MarkForwardedScope for each one. This marks the ExportedType entries in forwarder assemblies, which causes those assemblies to be preserved.
This is correct for copy/save action assemblies — they can't be rewritten, so forwarders they reference must be kept. But for root assemblies with link action, the type references will be rewritten by AssemblyReferencesCorrector in the sweep step to point directly to the implementation assemblies, making the forwarders unnecessary.
Activity
dotnet-policy-service commentedon Apr 3, 2026
Tagging subscribers to this area: @agocke, @dotnet/illink
See info in area-owners.md if you want to be subscribed.
Don't preserve forwarder assemblies referenced by link-action root as…
Add TODO to simplify TrimmerRootDescriptor once dotnet/runtime#126518 …
[illink] Move `FixLegacyResourceDesignerStep` to post-trim pipeline (#…
ILLink: Don't preserve forwarder assemblies referenced by link-action…
sbomer commentedon Jul 1, 2026
Fixed by #126519.
ILLink: Don't preserve forwarder assemblies referenced by link-action…