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:
- Delete the
skippedActualTypes HashSet and its comment block.
- 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
We have a workaround in
tools/dotnet-linker/Steps/TrimmableRegistrarStep.csfor a bug in ILLink's TypeMapHandler (dotnet/runtime#127504).What the workaround does
Types that are the "actual" (non-generic) target of
SkippedObjectiveCTypeUniverseassociations (e.g.,NSOrderedSet,NSArray,NSDictionary) use the 2-arg (unconditional)TypeMapAttributeconstructor 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:skippedActualTypesHashSet and its comment block.if (skippedActualTypes.Contains (td))branch, keeping only theelsebranch (the 3-arg constructor path).Validation
The
MakeNSOrderedSet_WithNulltest is a good canary — it failed withInvalidCastException: Unable to cast object of type 'Foundation.NSObject' to type 'Foundation.NSOrderedSet'before the workaround.Upstream issue: dotnet/runtime#127504