Skip to content

[dotnet-linker] Gate the TypeMap proxy-attribute workaround to .NET 10 only. Fixes #25276#26018

Draft
rolfbjarne wants to merge 2 commits into
mainfrom
dev/rolf/ubiquitous-waffle
Draft

[dotnet-linker] Gate the TypeMap proxy-attribute workaround to .NET 10 only. Fixes #25276#26018
rolfbjarne wants to merge 2 commits into
mainfrom
dev/rolf/ubiquitous-waffle

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

The workaround for dotnet/runtime#127004 (adding the
proxy type's attribute to the source type so ILLink's TypeMapHandler keeps the
TypeMapAssociation) is no longer needed once the ILLink fix is available.

The fix is only present in .NET 11+, so keep the workaround for .NET 10 and only
stop applying it for .NET 11+:

  • In TrimmableRegistrarStep, only add the proxy attribute to the source type
    when targeting .NET 10 or earlier.
  • In TypeMaps (runtime), only read the workaround attribute from the source
    type for .NET 10 or earlier (gated with !NET11_0_OR_GREATER).

A separate validation-only PR targeting net11.0 (not to be merged) confirms
the TypeMap tests still pass on .NET 11 with the workaround disabled.

Fixes #25276

🤖 Pull request created by Copilot

…0 only

The workaround for dotnet/runtime#127004 (adding
the proxy type's attribute to the source type so ILLink's TypeMapHandler keeps
the TypeMapAssociation) is no longer needed once the ILLink fix is available.

The fix is only present in .NET 11+, so keep the workaround for .NET 10 and
only stop applying it for .NET 11+:

* In TrimmableRegistrarStep, only add the proxy attribute to the source type
  when targeting .NET 10 or earlier.
* In TypeMaps (runtime), only read the workaround attribute from the source
  type for .NET 10 or earlier (gated with !NET11_0_OR_GREATER).

Fixes #25276.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

…indClass

When looking up the Objective-C class for a managed type, the trimmable
static registrar's FindClass looked up the *closed* generic type (e.g.
UIGestureRecognizer.Callback<UITapGestureRecognizer>) in the type maps.
However, generic types are registered using their generic type definition
(the maps are keyed by the *open* generic type, e.g. Callback`1), so the
lookup failed and the runtime tried to fall back to the dynamic registrar
(which has been linked away), throwing MT8026:

    Can't register the class UIKit.UIGestureRecognizer+Callback`1[[UIKit.UITapGestureRecognizer, ...]] when the dynamic registrar has been linked away.

This was previously masked by the workaround for
dotnet/runtime#127004: reading the proxy attribute
directly off the closed generic type (Type.GetCustomAttribute) returns the
attribute stamped on the open generic definition, so the lookup happened to
succeed. Once that workaround was gated off for .NET 11+ (commit
d255353), the missing generic-type-definition reduction was exposed,
causing MT8026 (and, depending on timing, a NullReferenceException in
UIGestureRecognizer.OnDispose during finalization of an uninitialized
UITapGestureRecognizer).

Mirror the reduction already done in the non-trimmable FindClass path
(which does `if (type.IsGenericType) type = type.GetGenericTypeDefinition ()`).

Verified with:

    make build run-bare -C tests/monotouch-test/dotnet/MacCatalyst \
        TEST_VARIATION='trimmable-static-registrar-all-optimizations-linkall|release' CONFIG=Release \
        RUN_ARGUMENTS="--test=MonoTouchFixtures.UIKit.GestureRecognizerTest.GenericCallbackTest"

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 22caaaa0-7267-4c5e-8c22-58e5b04e9f42
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 70fb83f6fc812034575b05b92b1de7c2f152ac42 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [CI Build #70fb83f] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

3 tests crashed, 1 tests failed, 174 tests passed.

Failures

❌ dotnettests tests (macOS)

🔥 Failed catastrophically on VSTS: test results - dotnettests_macos (no summary found).

Html Report (VSDrops) Download

❌ framework tests

🔥 Failed catastrophically on VSTS: test results - framework (no summary found).

Html Report (VSDrops) Download

❌ linker tests (MacCatalyst)

1 tests failed, 14 tests passed.

Failed tests

  • link sdk/Mac Catalyst/Release: Failed (Test run failed.
    Tests run: 134 Passed: 125 Inconclusive: 0 Failed: 1 Ignored: 8)

Html Report (VSDrops) Download

❌ linker tests (macOS)

🔥 Failed catastrophically on VSTS: test results - linker_macos (no summary found).

Html Report (VSDrops) Download

Successes

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 17 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 18 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 70fb83f6fc812034575b05b92b1de7c2f152ac42 [PR build]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants