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
Remove the crossgen2 TypeRef workaround for trimmable-static type maps #26343
The trimmable-static registrar generates its type map assemblies (_<platform>.TypeMap.dll) with Mono.Cecil, so the types named by the type-map entries only appear as assembly-qualified name strings in the custom attribute blobs — the assembly has no TypeRef row for them.
That's valid metadata (ECMA-335 II.23.3 only requires the type to be stored as a SerString holding its canonical name, and neither the CustomAttribute (II.22.10) nor the TypeRef (II.22.38) validity rules require a matching TypeRef row), but crossgen2 assumes the row is there and crashes with a NotImplementedException in ModuleTokenResolver.GetModuleTokenForType when ReadyToRun-compiling the type map assembly.
Until that's fixed, TrimmableRegistrarStep.EmitTypeReferencesForTypeMaps works around it by emitting an unused <TypeReferences>.KeepTypeReferences () method that does ldtoken + pop for every externally defined type the maps name, which forces Cecil to emit the TypeRef rows. It's gated on CoreCLR + PublishReadyToRun, because that's the only configuration that needs it, and the extra metadata isn't free (it adds ~64 KB per runtime identifier to _Microsoft.macOS.TypeMap.dll).
Once dotnet/runtime#131527 is fixed and we've moved to a runtime that contains the fix, remove:
EmitTypeReferencesForTypeMaps and its call site in tools/dotnet-linker/Steps/TrimmableRegistrarStep.cs
and update the expected app sizes if any of them change.
Activity
[dotnet-linker] Work around a crossgen2 crash compiling the trimmable…
rolfbjarne commentedon Aug 31, 2026
The runtime fix won't be in .NET 11 (the fix was reverted/modified, see dotnet/runtime#132811), but it should be in .NET 12.