Skip to content

[Workaround] Remove proxy type attribute on source type when dotnet/runtime#127004 is fixed #25276

@rolfbjarne

Description

@rolfbjarne

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

What the workaround does

When creating TypeMapAssociation entries, we add the proxy type's NSObjectProxyAttribute (or protocol equivalent) as a custom attribute on the source type as well (not just on the proxy type itself). This ensures the linker keeps the TypeMapAssociation when the external TypeMap preserves the source type.

Code to remove

In tools/dotnet-linker/Steps/TrimmableRegistrarStep.cs, remove the two addPostAction blocks with the comment referencing dotnet/runtime/issues/127004:

  1. Around line 469-473 (NSObject proxy case)
  2. Around line 560-564 (Protocol proxy case)

Validation

Run the TypeMap-related tests with full trimming to ensure proxy associations are still kept without the workaround:

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

Upstream issue: dotnet/runtime#127004
Upstream fix: dotnet/runtime#127005

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIf an issue is a bug or a pull request a bug fixdotnet-external-dependency.NET: this issue/pull request is blocked on external work

    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