Convert CustomMarshalerInfo GetInstance to UnmanagedCallersOnly#124440
Open
AaronRobinsonMSFT wants to merge 2 commits intodotnet:mainfrom
Open
Convert CustomMarshalerInfo GetInstance to UnmanagedCallersOnly#124440AaronRobinsonMSFT wants to merge 2 commits intodotnet:mainfrom
AaronRobinsonMSFT wants to merge 2 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR converts the CustomMarshalerInfo GetInstance call from the legacy MethodDescCallSite/CallDescrWorker infrastructure to the more efficient UnmanagedCallersOnly reverse P/Invoke pattern, completing the last Priority 1 item from issue #123864.
Changes:
- Added
GetCustomMarshalerInstanceUnmanagedCallersOnly wrapper in MngdRefCustomMarshaler that converts MethodDesc pointer to MethodBase, invokes GetInstance via reflection, and validates non-null return - Moved null-return validation from native to managed code using the existing managed resource string
SR.CustomMarshaler_NullReturnForGetInstance - Removed unused native resource strings
IDS_EE_NOCUSTOMMARSHALERfrom resource.h and mscorrc.rc
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/metasig.h | Added signature definition for new UCO method: IntPtr, byte*, int, object*, Exception* parameters |
| src/coreclr/vm/corelib.h | Added DEFINE_METHOD entry for GetCustomMarshalerInstance |
| src/coreclr/vm/custommarshalerinfo.cpp | Replaced MethodDescCallSite with UnmanagedCallersOnlyCaller, removed string creation, updated comment to reflect managed Invoke usage |
| src/coreclr/dlls/mscorrc/resource.h | Removed unused IDS_EE_NOCUSTOMMARSHALER resource ID |
| src/coreclr/dlls/mscorrc/mscorrc.rc | Removed unused native error message string |
| src/coreclr/System.Private.CoreLib/src/System/StubHelpers.cs | Implemented GetCustomMarshalerInstance UCO method with MethodDesc-to-MethodBase conversion, UTF-8 string decoding, reflection invoke, and null validation |
9c8b724 to
171c3c7
Compare
e615ba7 to
0618885
Compare
jkotas
reviewed
Feb 15, 2026
jkotas
reviewed
Feb 15, 2026
Replace MethodDescCallSite/CallDescrWorker with UnmanagedCallersOnly reverse P/Invoke for the GetInstance call in CustomMarshalerInfo. - Add MngdRefCustomMarshaler.GetCustomMarshalerInstance UCO wrapper that takes a MethodTable pointer and raw UTF-8 cookie bytes, finds GetInstance via managed reflection, invokes it, and validates the result is non-null - Move FindGetInstanceMethod logic entirely into managed code, eliminating the native method lookup, generic instantiation stub handling, and MetaSig::EnsureSigValueTypesLoaded - Move null-return and missing-method validation from native to managed using existing SR resource strings - Remove unused IDS_EE_NOCUSTOMMARSHALER and IDS_EE_GETINSTANCENOTIMPL from resource.h and mscorrc.rc - Remove unused gsig_SM_Str_RetICustomMarshaler metasig entry Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0618885 to
e358b8a
Compare
jkotas
approved these changes
Feb 15, 2026
This was referenced Feb 15, 2026
68 tasks
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.
Converts the last Priority 1 item from #123864 — replacing
MethodDescCallSite/CallDescrWorkerwithUnmanagedCallersOnlyreverse P/Invoke for theGetInstancecall inCustomMarshalerInfo::CustomMarshalerInfo.Changes
MngdRefCustomMarshaler.GetCustomMarshalerInstanceUCO wrappercorelib.hentries for the new UCO method