Skip to content

[release/11.0.1xx] [registrar] Detect open generic proxy types correctly - #26834

Merged
dalexsoto merged 4 commits into
release/11.0.1xxfrom
dev/rolf/backport-pr-26810-release/11.0.1xx-2026-10-02
Oct 5, 2026
Merged

dalexsoto merged 4 commits into
release/11.0.1xxfrom
dev/rolf/backport-pr-26810-release/11.0.1xx-2026-10-02

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

Cecil's TypeDefinition.ContainsGenericParameter is false for open generic type definitions, so the trimmable registrar still emitted invalid newobj instructions for generic NSObject proxies. NativeAOT then reported that NSLayoutAnchor<T>_Proxy.CreateObject would always throw:

UIKit.NSLayoutAnchor<T>_Proxy.CreateObject(native int) will always throw

Use HasGenericParameters for NSObject, INativeObject, and protocol-wrapper proxy generation, and add focused assembly-preparer coverage that verifies generic CreateObject proxies throw instead of constructing an open generic type.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com
Copilot-Session: ece6a6bd-3e29-4559-b8f3-4465690e25a4

Backport of #26810.

Cecil's TypeDefinition.ContainsGenericParameter is false for open generic type definitions, so the trimmable registrar still emitted invalid newobj instructions for generic NSObject proxies. NativeAOT then reported that NSLayoutAnchor<T>_Proxy.CreateObject would always throw.\n\nUse HasGenericParameters for NSObject, INativeObject, and protocol-wrapper proxy generation, and add focused assembly-preparer coverage that verifies generic CreateObject proxies throw instead of constructing an open generic type.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: ece6a6bd-3e29-4559-b8f3-4465690e25a4
Copilot AI balanced review requested due to automatic review settings October 2, 2026 18:15
@rolfbjarne rolfbjarne added backported ready-to-review This PR is ready to review/merge. labels Oct 2, 2026
@rolfbjarne
rolfbjarne requested a review from dalexsoto as a code owner October 2, 2026 18:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The generic INativeObject and protocol-wrapper paths lack regression coverage.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Backports the trimmable registrar fix for invalid open-generic proxy construction.

Changes:

  • Detects generic proxy types using HasGenericParameters.
  • Adds regression coverage for generic NSObject proxies.
File Description
tools/​dotnet-linker/​Steps/​TrimmableRegistrarStep.cs Corrects generic detection across proxy-generation paths.
tests/​assembly-preparer/​ManagedRegistrarStepTests.cs Tests generated NSObject proxy IL.

@rolfbjarne
rolfbjarne enabled auto-merge (squash) October 2, 2026 18:23
@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.

dalexsoto
dalexsoto previously approved these changes Oct 3, 2026
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

⚠️ AppSizeTest expected files changed ⚠️

The AppSizeTest detected changes in the expected app size files.

To update the expected files, add a comment with the following command:

/apply-gist https://gist.github.com/vs-mobiletools-engineering-service2/4a3da5a7283013b26c4593db4ed6ee47
Updated files
  • MacOSX-CoreCLR-R2R-size.txt

Pipeline on Agent
Hash: 2136dfd4d1f43b307b4e29fc18f98f0a0d764571 [PR build]

@dalexsoto

Copy link
Copy Markdown
Member

CI blocker: repeatable macOS ReadyToRun app-size baseline mismatch

At head 2136dfd4d1f43b307b4e29fc18f98f0a0d764571, build 15552429, T: dotnettests_macos, attempt 2 fails:

Xamarin.Tests.AppSizeTest.CoreCLR_R2R(MacOSX,"osx-arm64;osx-x64",False)
Expected: 333,115,829 bytes
Actual:   333,130,255 bytes
Delta:    +14,426 bytes; allowed tolerance: +/-10,240 bytes

The original attempt and the retry both report the same +14,426-byte mismatch. The NUnit result contains one failed test; this is an app-size assertion, not a build, provisioning, or simulator-launch failure.

The CI size diff accounts for the entire delta:

Component Change
arm64 _Microsoft.macOS.TypeMap.dll +4,096 bytes
x64 _Microsoft.macOS.TypeMap.dll +4,096 bytes
arm64 Microsoft.macOS.dll +3,584 bytes
x64 Microsoft.macOS.dll +3,072 bytes
SizeTestApp native executable -416 bytes
Info.plist -6 bytes

For context, both macOS CoreCLR interpreter variants pass with a +9,089-byte difference, and both NativeAOT variants pass with a -12-byte difference. This establishes a repeatable output/baseline mismatch; it does not establish that all of the growth was introduced by this PR.

Required fix: reconcile tests/dotnet/UnitTests/expected/MacOSX-CoreCLR-R2R-size.txt with the intended output. If the growth is expected, update the checked-in baseline using the CI-generated MacOSX-CoreCLR-R2R-size.txt.diff in the updated-expected-sizes-simulator_testsdotnettests_macos-2 artifact. Otherwise, investigate and fix the unintended ReadyToRun/typemap growth before updating that baseline.

No source or expected files have been changed by this monitor. I have not queued another retry for this repeatable size assertion.

Note

This CI analysis was generated by GitHub Copilot.

@dalexsoto

Copy link
Copy Markdown
Member

/apply-gist https://gist.github.com/vs-mobiletools-engineering-service2/4a3da5a7283013b26c4593db4ed6ee47

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

✅ Applied expected app size files from gist.

Copilot AI balanced review requested due to automatic review settings October 3, 2026 16:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

GitHub currently reports unresolved merge conflicts with the release branch.

Review effort: Balanced
Findings: None

Resolved since last review (2)

@dalexsoto

Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request be very thorough and rubber duck your patch with other models

dalexsoto
dalexsoto previously approved these changes Oct 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The size baseline includes unrelated drift, and two modified proxy-generation paths lack regression coverage.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)

@@ -1,13 +1,13 @@
AppBundleSize: 333,078,531 bytes (325,272.0 KB = 317.6 MB)
AppBundleSize: 333,092,957 bytes (325,286.1 KB = 317.7 MB)
@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

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

simonrozsival
simonrozsival previously approved these changes Oct 5, 2026
@dalexsoto

Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

…backport-pr-26810-release/11.0.1xx-2026-10-02

# Conflicts:
#	tests/assembly-preparer/ManagedRegistrarStepTests.cs

Co-authored-by: dalexsoto <204671+dalexsoto@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 5, 2026 14:11
auto-merge was automatically disabled October 5, 2026 14:11

Head branch was pushed to by a user without write access

Copilot AI dismissed stale reviews from simonrozsival and dalexsoto via 922f824 October 5, 2026 14:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The size baseline includes unrelated build-environment drift that should be removed.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)

Copilot AI commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved and published in merge commit 922f8248bb. Both registrar regression tests are retained; the PR head now includes release/11.0.1xx. Focused tests could not run locally because the required .NET 11 RC2 SDK is unavailable.

Note

AI-generated by GitHub Copilot.

Copilot AI requested a review from dalexsoto October 5, 2026 14:26
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

❗ API diff vs stable (Breaking changes)

NET (empty diffs)

ℹ️ Generator diff

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

Pipeline on Agent
Hash: 1cf2ab24c9e681a3a8a25b6c3027da9b572f77ee [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #922f824] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 269 tests passed 🎉

Tests counts

✅ 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 (macOS): 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. [attempt 2] 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
✅ monotouch (iOS): All 25 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 25 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 25 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
✅ Tests on macOS Golden Gate (27): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

✅ Linux build succeeded

Pipeline on Agent
Hash: 922f8248bbd90e3214b665691698458868348bec [PR build]

@dalexsoto
dalexsoto merged commit 54f9838 into release/11.0.1xx Oct 5, 2026
56 checks passed
@dalexsoto
dalexsoto deleted the dev/rolf/backport-pr-26810-release/11.0.1xx-2026-10-02 branch October 5, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported ready-to-review This PR is ready to review/merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants