Skip to content

[UIKit] Preserve trait registration token identity during disposal. - #27447

Merged
rolfbjarne merged 1 commit into
mainfrom
dev/rolf/trait-disposal-token-identity
Nov 25, 2026
Merged

rolfbjarne merged 1 commit into
mainfrom
dev/rolf/trait-disposal-token-identity

Conversation

@rolfbjarne

@rolfbjarne rolfbjarne commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Pass the returned managed token to UnregisterForTraitChanges so overrides that track tokens by object identity can unregister it. Add a regression test that checks callback removal and repeated disposal.

This is a follow-up PR to #26699.


Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: b14a8c7248501bbdecf35896bbe55c7af5bcf129

Dimension Assessment Rationale
Change confidence 9/10 ↑ All 25 Mac Catalyst trait tests passed with the fix.
↑ Two independent model reviews found no errors or warnings.
↓ iOS and tvOS were not run.
Diagnosis confidence 9.5/10 ↑ Reverting only the argument makes the identity regression fail: the override does not recognize the token.
Evidence fit 9.5/10 ↑ The regression reproduces the reported identity-sensitive override and passes with the fix.

🤖 Pull request created by Copilot

Pass the returned managed token to UnregisterForTraitChanges so overrides that track tokens by object identity can unregister it. Add a regression test that checks callback removal and repeated disposal.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 17:33
@rolfbjarne rolfbjarne added backport-to-net11.0 Add this to issues or pull requests that should be backported to .NET 11 copilot labels Nov 24, 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.

🟢 Approval recommended

No active review issues remain for the change preserving trait-registration token identity during disposal.

No open issues 🎉

What changed in this PR

Preserves managed trait-registration token identity during disposal, allowing identity-sensitive UIKit overrides to recognize and unregister the original token.

Changes:

  • Passes the returned managed token to UnregisterForTraitChanges during disposal.
  • Adds a regression test covering token identity, callback removal, and repeated disposal.
File Description
tests/​monotouch-test/​UIKit/​UITraitOverrides.cs Adds identity-sensitive disposal regression coverage.
src/​UIKit/​UITraitChangeObservable.cs Passes the original managed token when unregistering during disposal.

Review effort: Balanced

@MauiBot

MauiBot commented Nov 24, 2026

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: b14a8c7248501bbdecf35896bbe55c7af5bcf129 [PR build]

@MauiBot

MauiBot commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

🔥 [CI Build #b14a8c7] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

1 tests crashed, 1 tests failed, 195 tests passed.

Failures

❌ assembly-processing tests

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

Html Report (VSDrops) Download

❌ msbuild tests

1 tests failed, 1 tests passed.

Failed tests

  • MSBuild tasks tests: Failed (Execution failed with exit code 1)
    • Xamarin.MacDev.Tasks.CodesignTaskTests.ExtendedAttributesDiagnos...: #RunTask-ErrorCount
      : error: /Users/cloudtest/vss/_work/1/s/macios/tests/msbuild/Xamarin.MacDev.Tasks.Tests/bin/Debug/net12.0...

Html Report (VSDrops) Download

Successes

✅ 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 1 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 17 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 17 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 17 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 17 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 19 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: b14a8c7248501bbdecf35896bbe55c7af5bcf129 [PR build]

@MauiBot

MauiBot commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

🔥 [CI Build #b14a8c7] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

0 tests crashed, 1 tests failed, 196 tests passed.

Failures

❌ msbuild tests [attempt 2]

1 tests failed, 1 tests passed.

Failed tests

  • MSBuild tasks tests: Failed (Execution failed with exit code 1)
    • Xamarin.MacDev.Tasks.CodesignTaskTests.ExtendedAttributesDiagnos...: #RunTask-ErrorCount
      : error: /Users/cloudtest/vss/_work/1/s/macios/tests/msbuild/Xamarin.MacDev.Tasks.Tests/bin/Debug/net12.0...

Html Report (VSDrops) Download

Successes

✅ assembly-processing: All 1 tests passed. [attempt 2] 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 1 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 17 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 17 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 17 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 17 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 19 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: b14a8c7248501bbdecf35896bbe55c7af5bcf129 [PR build]

@MauiBot

MauiBot commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #b14a8c7] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 197 tests passed 🎉

Tests counts

✅ assembly-processing: All 1 tests passed. [attempt 2] 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 1 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 17 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 17 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 17 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 17 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 19 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. [attempt 3] 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: b14a8c7248501bbdecf35896bbe55c7af5bcf129 [PR build]

@rolfbjarne
rolfbjarne enabled auto-merge (squash) November 25, 2026 12:27
@rolfbjarne rolfbjarne added the ready-to-review This PR is ready to review/merge. label Nov 25, 2026
@rolfbjarne
rolfbjarne merged commit d04d737 into main Nov 25, 2026
56 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/trait-disposal-token-identity branch November 25, 2026 12:48
rolfbjarne added a commit that referenced this pull request Nov 25, 2026
…lines. (#27454)

Add `[UserDelegateType]` to the trait change callbacks and all 99 other unannotated production block trampolines found by the new Cecil check.

The check follows `BlockLiteral` constructor calls and verifies the annotation on the method used to calculate the block signature. Checking only delegate types passed to `GetDelegateForBlock<T>` would miss these unmanaged function-pointer callbacks.

For callbacks that transform their arguments, use a delegate matching the native block signature rather than the public callback's signature. This changes metadata only, not callback implementations or public APIs.

Follow-up to #26699. The separate token-identity fix is in #27447.

🤖 Pull request created by Copilot

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
rolfbjarne added a commit that referenced this pull request Nov 26, 2026
… during disposal. (#27468)

Pass the returned managed token to UnregisterForTraitChanges so overrides that track tokens by object identity can unregister it. Add a regression test that checks callback removal and repeated disposal.

This is a follow-up PR to #26699.

----

🤖 Pull request created by Copilot

---------

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

Backport of #27447.

---------

Co-authored-by: Rolf Bjarne Kvinge <rokvin@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-net11.0 Add this to issues or pull requests that should be backported to .NET 11 copilot ready-to-review This PR is ready to review/merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants