Skip to content

[Workaround] Remove unconditional TypeMap entries for skipped actual types when dotnet/runtime#127504 is fixed #25275

Closed

Description

@rolfbjarne

We have a workaround in tools/dotnet-linker/Steps/TrimmableRegistrarStep.cs for a bug in ILLink's TypeMapHandler (dotnet/runtime#127504).

What the workaround does

Types that are the "actual" (non-generic) target of SkippedObjectiveCTypeUniverse associations (e.g., NSOrderedSet, NSArray, NSDictionary) use the 2-arg (unconditional) TypeMapAttribute constructor instead of the 3-arg (conditional) one. This prevents the linker from incorrectly trimming their TypeMap entries.

Code to remove

In tools/dotnet-linker/Steps/TrimmableRegistrarStep.cs:

  1. Delete the skippedActualTypes HashSet and its comment block.
  2. Remove the if (skippedActualTypes.Contains (td)) branch, keeping only the else branch (the 3-arg constructor path).

Validation

cd tests/monotouch-test/dotnet/MacCatalyst
make build run-bare TEST_VARIATION='release|trimmable-static-registrar-all-optimizations-linkall' RUN_ARGUMENTS="--test MonoTouchFixtures.Foundation.NSOrderedSetTest"

The MakeNSOrderedSet_WithNull test is a good canary — it failed with InvalidCastException: Unable to cast object of type 'Foundation.NSObject' to type 'Foundation.NSOrderedSet' before the workaround.

Upstream issue: dotnet/runtime#127504

Activity

  1. added
    bug
    on Apr 28, 2026
  2. added this to the .NET 11 milestone on Apr 28, 2026
  3. added a commit that references this issue on Jul 11, 2026
    b7ba67c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions