Repository navigation
[ObjCRuntime] Add opt-in Runtime.InvokedSelector tracking. Fixes #23905 - #27220
rolfbjarne wants to merge 3 commits into
Conversation
Expose the actual selector of the innermost active Objective-C-to-managed invocation on the current thread. Save and restore the context across nested calls and Objective-C exception exits, without flowing it through the managed execution context. Detect getter references in build inputs and persist the decision through assembly preparation, linking, and post-processing. EnableInvokedSelectorTracking provides an explicit override for reflection or dynamically loaded code, and explicitly disabling tracking rejects detected references instead of returning misleading results. Keep unused invocation paths unchanged by selecting separate tracked dynamic trampolines at startup and conditionally instrumenting generated registrar methods. Partial-static registration falls back to dynamic registration when enabled, since its prebuilt platform registrar cannot be instrumented per application. Add detection, registrar-generation, incremental-build, and runtime coverage, and document the property and its limitations. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e2ccbe90-e08b-4e00-b391-a795b08a3b6c
Keep dynamic registrar analysis owned by assembly preparation when the linker reruns selector detection. Avoid scanning unrelated modules or scanning again after tracking is already enabled, while preserving conservative detection and explicit-disable errors. Handle missing preparation output without failing isolated or non-Mac target execution, and preserve explicit EnableInvokedSelectorTracking overrides. Cover automatic detection, explicit-disable failures, incremental reuse, and missing output across the supported preparation/post-processing combinations; document diagnostic MT2388. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e2ccbe90-e08b-4e00-b391-a795b08a3b6c
Forward AdditionalDefineConstants to MySimpleApp so selector tracking integration tests compile the getter reference when requested. Without this test-fixture hook, the automatic-detection cases exercised an app with no reference and could not verify the intended build-time behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e2ccbe90-e08b-4e00-b391-a795b08a3b6c
✅ 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 |
🔥 [CI Build #7ea6892] Test results 🔥Test results❌ Tests failed on VSTS: test results 0 tests crashed, 5 tests failed, 212 tests passed. Failures❌ dotnettests tests (iOS)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ dotnettests tests (MacCatalyst)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ dotnettests tests (tvOS)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ Tests on macOS Sonoma (14) tests1 tests failed, 4 tests passed.Failed tests
Html Report (VSDrops) Download ❌ Tests on macOS Sequoia (15) tests1 tests failed, 4 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
|
Expose the actual selector of the innermost active Objective-C-to-managed invocation on the current thread. Save and restore the context across nested calls and Objective-C exception exits, without flowing it through the managed execution context.
Detect getter references in build inputs and persist the decision through assembly preparation, linking, and post-processing.
EnableInvokedSelectorTrackingprovides an explicit override for reflection or dynamically loaded code, and explicitly disabling tracking rejects detected references instead of returning misleading results.Keep unused invocation paths unchanged by selecting separate tracked dynamic trampolines at startup and conditionally instrumenting generated registrar methods. Partial-static registration falls back to dynamic registration when enabled, since its prebuilt platform registrar cannot be instrumented per application.
Add detection, registrar-generation, incremental-build, and runtime coverage, and document the property and its limitations.
This enables multiple selectors registered with
Runtime.ConnectMethodto share a managed method and distinguish which selector invoked it. It does not add general support for overridingmethodSignatureForSelector:or fix its existing dynamic-registrar recursion.Fixes #23905
🤖 Pull request created by Copilot