Skip to content

[VALIDATION ONLY - DO NOT MERGE] Validate removing the TypeMap proxy-attribute workaround on .NET 11#26019

Draft
rolfbjarne wants to merge 2 commits into
net11.0from
dev/rolf/validate-25276-net11
Draft

[VALIDATION ONLY - DO NOT MERGE] Validate removing the TypeMap proxy-attribute workaround on .NET 11#26019
rolfbjarne wants to merge 2 commits into
net11.0from
dev/rolf/validate-25276-net11

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

This PR is for validation only and must not be merged.

It cherry-picks the change from #26018 onto net11.0. On net11.0, the gating
(TargetFramework.Version.Major <= 10 in the linker and !NET11_0_OR_GREATER
in the runtime) disables the workaround for dotnet/runtime#127004,
so this PR exercises the code path where the workaround is removed and the
ILLink fix (present in .NET 11) is relied upon instead.

The purpose is to confirm via CI that the TypeMap proxy associations are still
kept without the workaround on .NET 11.

Related issue: #25276
Real PR (targets main): #26018

🤖 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

Copy link
Copy Markdown
Collaborator

❌ [CI Build #83cff3f] Prepare .NET Release failed ❌

The following jobs reported a non-successful result:

Job Result
Sign NuGets ❌ Failed
Convert NuGet to MSI ⏭️ Skipped
Push NuGets ⏭️ Skipped

Pipeline on Agent
Hash: 83cff3f838f184cdbb0d23695f9145ba66a7efad [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [CI Build #d255353] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

1 tests crashed, 8 tests failed, 225 tests passed.

Failures

❌ dotnettests tests (iOS) [attempt 2]

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.AppSizeTest.NativeAOT_TrimmableStatic(iOS,"ios-arm...: App size changed significantly (-16,413 bytes (-16.0 KB = -0.0 MB) different > tolerance of +-10,240 bytes (10.0 KB = 0.0 MB)). ...

Html Report (VSDrops) Download

❌ dotnettests tests (MacCatalyst) [attempt 2]

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.AppSizeTest.NativeAOT_TrimmableStatic(MacCatalyst,...: App size changed significantly (-16,541 bytes (-16.2 KB = -0.0 MB) different > tolerance of +-10,240 bytes (10.0 KB = 0.0 MB)). ...

Html Report (VSDrops) Download

❌ dotnettests tests (macOS) [attempt 2]

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.AppSizeTest.CoreCLR_Interpreter_TrimmableStatic(Ma...: App size changed significantly (-642,941 bytes (-627.9 KB = -0.6 MB) different > tolerance of +-10,240 bytes (10.0 KB = 0.0 MB))...

Html Report (VSDrops) Download

❌ monotouch tests (iOS) [attempt 2]

2 tests failed, 21 tests passed.

Failed tests

  • monotouch-test/iOS - simulator/Release (trimmable static registrar, NativeAOT): Crashed
  • monotouch-test/iOS - simulator/Release (trimmable static registrar, all optimizations): Crashed

Html Report (VSDrops) Download

❌ monotouch tests (MacCatalyst) [attempt 2]

2 tests failed, 21 tests passed.

Failed tests

  • monotouch-test/Mac Catalyst/Release (trimmable static registrar, all optimizations): Failed (Test run crashed (exit code: 134).
    Test run crashed)
  • monotouch-test/Mac Catalyst/Release (trimmable static registrar, NativeAOT): Failed (Test run crashed (exit code: 134).
    Test run crashed)

Html Report (VSDrops) Download

❌ monotouch tests (macOS) [attempt 2]

1 tests failed, 17 tests passed.

Failed tests

  • monotouch-test/macOS/Release (trimmable static registrar, NativeAOT): Failed (Test run failed.
    Tests run: 3733 Passed: 3576 Inconclusive: 13 Failed: 16 Ignored: 141)

Html Report (VSDrops) Download

❌ monotouch tests (tvOS)

🔥 Failed catastrophically on VSTS: test results - monotouch_tvos (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 (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 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 7 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 31 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 31 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 31 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 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: d255353549f859386151372743ca9545f3307303 [PR build]

…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: cf751e40ae2fbeca0099b74734a25c067c5312fd [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.

2 participants