[release/9.0.1xx] [src] Fix calling ConformsToProtocol on native instances that don't have a managed peer yet. Fixes #24111.#24191
Conversation
…ave a managed peer yet. Fixes #24111. Say we have: 1. A native type with an init method. 2. A managed binding for that native type, but the init method isn't bound. 3. A managed subclass of the managed binding (also without an implementation for the init method). In this case, native code can create a native instance of the subclass, but no managed code is executed, which means there won't be a corresponding managed peer either. This became a problem in our ConformsToProtocol override/implementation, because recently it changed to just return 'false' if we couldn't find a managed peer for a native instance. The fix is to create the managed instance in that case (by doing what we did before: call "Runtime.GetNSObject" on the native handle). Fixes #24111.
✅ [CI Build #45cd533] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #45cd533] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ [CI Build #45cd533] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #45cd533] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #45cd533] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #45cd533] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #45cd533] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
💻 [CI Build #45cd533] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #45cd533] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 123 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Say we have:
bound.
implementation for the init method).
In this case, native code can create a native instance of the subclass,
but no
managed code is executed, which means there won't be a corresponding
managed
peer either.
This became a problem in our ConformsToProtocol override/implementation,
because recently it changed to just return 'false' if we couldn't find a
managed peer for a native instance.
The fix is to create the managed instance in that case (by doing what we
did
before: call "Runtime.GetNSObject" on the native handle).
Fixes #24111.
Co-authored-by: GitHub Actions Autoformatter github-actions-autoformatter@xamarin.com
Backport of #24189.