Skip to content

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

@rolfbjarne

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIf an issue is a bug or a pull request a bug fix

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions