Uh oh!
There was an error while loading. Please reload this page.
Convert more COM interop MethodDescCallSite to UnmanagedCallersOnly (UCO) - #125849
Conversation
Converts COM interop code from MethodDescCallSite to UnmanagedCallersOnly (UCO) pattern for three sites: 1. DispatchEx_GetMemberProperties (Property case): replaces two MethodDescCallSite invocations (for CanRead/CanWrite) with a single UCO helper GetDispatchExPropertyFlags in StubHelpers. 2. ICustomQueryInterface.GetInterface: replaces the callback struct pattern with a UCO helper CallICustomQueryInterface. Also removes the cached MethodDesc field m_pICustomQueryInterfaceGetInterfaceMD from ComCallWrapperTemplate. 3. ConnectionPoint.InvokeProviderMethod: replaces MethodDescCallSite calls for delegate construction and provider invocation with a single UCO helper InvokeConnectionPointProviderMethod. Removes the UIntPtr ctor fallback path (addressing pending feedback). Also removes the m_ohDelegate field and related methods (GetOHDelegate/SetOHDelegate/GetObjCreateDelegate/SetObjCreateDelegate) from EEClass/MethodTable since the delegate-based COM object creation callback feature in CreateAggregatedInstance is removed. Adds [RequiresUnsafe] to GetIEnumeratorToEnumVariantMarshaler UCO overload to be consistent with the new UCO methods. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Tagging subscribers to this area: @agocke |
There was a problem hiding this comment.
Pull request overview
This PR continues the CoreCLR COM interop migration away from MethodDescCallSite toward the UnmanagedCallersOnly (UCO) reverse-P/Invoke calling pattern, and removes now-dead COM interop callback/delegate infrastructure in the VM.
Changes:
- Added new UCO helpers in
StubHelpers.csand updated native call sites to useUnmanagedCallersOnlyCaller. - Converted COM interop call paths in
stdinterfaces.cpp,comconnectionpoints.cpp, andcomcallablewrapper.cppfromMethodDescCallSiteto UCO-based helpers. - Removed dead COM interop delegate/callback code paths and related cached fields/helpers in VM types.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/stdinterfaces.cpp | Uses UCO helper to query PropertyInfo.CanRead/CanWrite flags instead of two MethodDescCallSite calls. |
| src/coreclr/vm/runtimecallablewrapper.cpp | Removes unused delegate-based aggregated COM instance creation path and related logic. |
| src/coreclr/vm/methodtable.h | Removes delegate-handle-related APIs from MethodTable. |
| src/coreclr/vm/methodtable.cpp | Removes implementations for COM object-creation delegate storage/retrieval. |
| src/coreclr/vm/metasig.h | Adds COM-interp UCO metasig definitions for new StubHelpers methods. |
| src/coreclr/vm/corelib.h | Registers new StubHelpers methods (including a NoSig entry). |
| src/coreclr/vm/comconnectionpoints.cpp | Uses a single UCO helper to construct delegate + invoke provider method. |
| src/coreclr/vm/comcallablewrapper.h | Removes cached ICustomQueryInterface.GetInterface MethodDesc field/API. |
| src/coreclr/vm/comcallablewrapper.cpp | Replaces callback/cached-MD pattern with UCO helper that calls ICustomQueryInterface.GetInterface. |
| src/coreclr/vm/class.h | Removes now-dead delegate handle storage from EEClass COM interop union. |
| src/coreclr/System.Private.CoreLib/src/System/StubHelpers.cs | Adds UCO helpers for DispatchEx property flags, ICustomQueryInterface, and connection point invocation. |
Uh oh!
There was an error while loading. Please reload this page.
AaronRobinsonMSFT
left a comment
There was a problem hiding this comment.
Some minor nits. Otherwise, looks good when green.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…InvokeThrowing_Ret Co-authored-by: AaronRobinsonMSFT <30635565+AaronRobinsonMSFT@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/dde670ee-197d-4271-8596-d75d3cca3116
jkotas
commented
Mar 24, 2026
/ba-g timeouts |
Uh oh!
There was an error while loading. Please reload this page.
am11
commented
Mar 24, 2026
@jkotas, it would be good to ask copilot to keep the author of original commit and add stuff on top. am11@ae7563a has dispatchinfo conversions. I tested it last week but haven't retested after the cherry-pick (should be fine). Copilot can pick it and continue the next batch. |
jkotas
commented
Mar 25, 2026
Triggered copilot on it with explicit instruction to preserve the author name and some initial feedback, let's see how it does. |
Continues the COM interop UCO migration (group 5), converting three
MethodDescCallSitecall sites to the UCO pattern and removing associated dead code. Addresses all pending feedback from #125508.Description
New UCO helpers in
StubHelpers.csGetDispatchExPropertyFlags– replaces twoMethodDescCallSitecalls forPropertyInfo.CanRead/CanWriteinDispatchEx_GetMemberProperties; returnsintdirectly viaInvokeThrowing_Retat the callsite (no out-param)CallICustomQueryInterface– replaces theInvokeICustomQueryInterfaceGetInterface_CallBackstruct/callback pattern; returnsintdirectly (usesInvokeThrowing_Ret)InvokeConnectionPointProviderMethod– replaces twoMethodDescCallSitecalls inConnectionPoint::InvokeProviderMethod; usesnint/UIntPtrctor fallback for correctness; usesGetMultiCallableAddrOfCode()for the event target since it is stored for future invokes[RequiresUnsafe]to the existingGetIEnumeratorToEnumVariantMarshalerUCO overload for consistencyFeedback addressed
INVOKE_CONNECTION_POINT_PROVIDER_METHODregistered asNoSigincorelib.h(has unmanaged fn-ptr params — encoding in metasig not worth the pain)CallICustomQueryInterfaceusesInvokeThrowing_Ret<INT32>and passesppUnkOutdirectly — no local copy neededGetDispatchExPropertyFlagssignature changed to returnintdirectly; metasig (SM_PtrPropertyInfo_PtrException_RetInt) andcorelib.hregistration updated accordingly; callsite instdinterfaces.cppupdated to useInvokeThrowing_Ret<INT32>ConnectionPoint::InvokeProviderMethodfor correctnesscomconnectionpoints.cppto clarify whyGetMultiCallableAddrOfCode()is used for the event targetDead code removed
InvokeICustomQueryInterfaceGetInterface_CallBack+ arg struct incomcallablewrapper.cppGetICustomQueryInterfaceGetInterfaceMD/m_pICustomQueryInterfaceGetInterfaceMDfromComCallWrapperTemplatem_ohDelegateunion field andGetOHDelegate/SetOHDelegate/GetObjCreateDelegate/SetObjCreateDelegatefromEEClass/MethodTable—SetObjCreateDelegatehad no callers; the delegate-basedCreateAggregatedInstancepath was effectively dead⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.