Skip to content

Replace MethodDescCallSite with UnmanagedCallersOnly for ObjC interop#124446

Merged
AaronRobinsonMSFT merged 2 commits intodotnet:mainfrom
AaronRobinsonMSFT:uco-objc-interop
Feb 16, 2026
Merged

Replace MethodDescCallSite with UnmanagedCallersOnly for ObjC interop#124446
AaronRobinsonMSFT merged 2 commits intodotnet:mainfrom
AaronRobinsonMSFT:uco-objc-interop

Conversation

@AaronRobinsonMSFT
Copy link
Member

Convert AvailableUnhandledExceptionPropagation and InvokeUnhandledExceptionPropagation to use UnmanagedCallersOnly reverse P/Invoke pattern instead of MethodDescCallSite/CallDescrWorker.

Part of #123864 (Priority 4 - ObjC interop).

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR converts ObjC interop methods from the legacy MethodDescCallSite pattern to the more efficient UnmanagedCallersOnly reverse P/Invoke pattern, as part of the broader effort tracked in issue #123864 (Priority 4 - ObjC interop).

Changes:

  • Replaced MethodDescCallSite with UnmanagedCallersOnlyCaller for calling into managed ObjC marshaling methods
  • Updated method signatures to use pointer parameters compatible with UnmanagedCallersOnly
  • Added proper exception handling in the managed methods using try-catch blocks

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/coreclr/vm/metasig.h Updated method signatures for UnmanagedCallersOnly pattern; replaced old signatures with pointer-based ones and removed unused SM_RetBool signature
src/coreclr/vm/interoplibinterface_objc.cpp Replaced MethodDescCallSite dispatch with UnmanagedCallersOnlyCaller for both availability check and invocation methods
src/coreclr/vm/corelib.h Updated method signature references to match new pointer-based signatures
src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/ObjectiveCMarshal.CoreCLR.cs Added UnmanagedCallersOnly attributes, converted methods to use pointer parameters, added exception handling, removed unused Debug import

Convert InvokeUnhandledExceptionPropagation to use UnmanagedCallersOnly
reverse P/Invoke pattern instead of MethodDescCallSite/CallDescrWorker.
Pass MethodDesc* directly as IntPtr and use RuntimeMethodHandle.FromIntPtr
in managed code. Remove AvailableUnhandledExceptionPropagation as the
fast path check is unnecessary.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 16, 2026 13:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@AaronRobinsonMSFT
Copy link
Member Author

/ba-g Known issues - #110173 and #121518

@AaronRobinsonMSFT AaronRobinsonMSFT merged commit a4e2e2c into dotnet:main Feb 16, 2026
104 of 108 checks passed
@AaronRobinsonMSFT AaronRobinsonMSFT deleted the uco-objc-interop branch February 16, 2026 16:29
@github-project-automation github-project-automation bot moved this to Done in AppModel Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants