Replace MethodDescCallSite with UnmanagedCallersOnly for ObjC interop#124446
Merged
AaronRobinsonMSFT merged 2 commits intodotnet:mainfrom Feb 16, 2026
Merged
Replace MethodDescCallSite with UnmanagedCallersOnly for ObjC interop#124446AaronRobinsonMSFT merged 2 commits intodotnet:mainfrom
AaronRobinsonMSFT merged 2 commits intodotnet:mainfrom
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/interop-contrib |
68 tasks
Contributor
There was a problem hiding this comment.
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
MethodDescCallSitewithUnmanagedCallersOnlyCallerfor 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 |
jkotas
reviewed
Feb 16, 2026
...reclr/System.Private.CoreLib/src/System/Runtime/InteropServices/ObjectiveCMarshal.CoreCLR.cs
Outdated
Show resolved
Hide resolved
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>
36f19af to
bbd44ab
Compare
This was referenced Feb 16, 2026
jkotas
approved these changes
Feb 16, 2026
huoyaoyuan
reviewed
Feb 16, 2026
...reclr/System.Private.CoreLib/src/System/Runtime/InteropServices/ObjectiveCMarshal.CoreCLR.cs
Outdated
Show resolved
Hide resolved
jkotas
reviewed
Feb 16, 2026
...reclr/System.Private.CoreLib/src/System/Runtime/InteropServices/ObjectiveCMarshal.CoreCLR.cs
Outdated
Show resolved
Hide resolved
…ervices/ObjectiveCMarshal.CoreCLR.cs
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Convert
AvailableUnhandledExceptionPropagationandInvokeUnhandledExceptionPropagationto useUnmanagedCallersOnlyreverse P/Invoke pattern instead ofMethodDescCallSite/CallDescrWorker.Part of #123864 (Priority 4 - ObjC interop).