Move IDispatch helpers into IDispatchHelpers.cs#126074
Move IDispatch helpers into IDispatchHelpers.cs#126074AaronRobinsonMSFT merged 6 commits intomainfrom
Conversation
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/e2be20c8-cc8c-49fc-97ea-b347cc7d3563
|
Tagging subscribers to this area: @agocke |
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/21948eb6-cd2b-4a4e-a3b6-a841957b63b1
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/be85d1df-1094-477e-bf82-5e75bd66c221
There was a problem hiding this comment.
Pull request overview
This PR refactors CoreCLR COM interop dispatch support by moving IDispatch-related managed helpers out of StubHelpers into a dedicated System.Runtime.InteropServices.IDispatchHelpers type, and updates the VM to call these helpers via UnmanagedCallersOnlyCaller.
Changes:
- Introduces
IDispatchHelpers.csand migrates all IDispatch helper entrypoints fromStubHelpersto the new type. - Updates CoreCLR VM call sites (e.g.,
dispatchinfo.cpp,stdinterfaces.cpp) to useMETHOD__IDISPATCHHELPERS__*instead ofMETHOD__STUBHELPERS__*. - Extends
corelib.handmetasig.hto register the new class and required metasigs; updates CoreLib project file inclusion underFeatureCominterop.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/stdinterfaces.cpp | Switches DispatchEx helper call to IDISPATCHHELPERS entrypoint. |
| src/coreclr/vm/metasig.h | Adds metasigs needed for new UCO helper signatures. |
| src/coreclr/vm/dispatchinfo.cpp | Replaces MethodDescCallSite usage with UnmanagedCallersOnlyCaller calls into IDispatchHelpers. |
| src/coreclr/vm/corelib.h | Registers new IDISPATCHHELPERS class and maps VM method IDs to the new managed helpers. |
| src/coreclr/System.Private.CoreLib/src/System/StubHelpers.cs | Removes IDispatch helper(s) and adds RequiresUnsafe annotations to some UCO methods. |
| src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/IDispatchHelpers.cs | Adds new managed helper type with [UnmanagedCallersOnly] entrypoints for IDispatch interop. |
| src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj | Includes IDispatchHelpers.cs under FeatureCominterop. |
…ed GCPROTECTs Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/fe919c7d-b4ae-44c9-be31-bc6220c3dfd2
…rectly, merge property callbacks, use InvokeThrowing_Ret, remove SupportedOSPlatform annotations Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/b1a9ba44-d8f2-4fb0-984b-b4e0fda837a2
am11
left a comment
There was a problem hiding this comment.
Looks good, I think it would need to resolve conflicts after @AaronRobinsonMSFT's PR is merged.
|
/ba-g known issue dotnet/dnceng#6473 (no space left on device), not getting matched for some reason |
|
I was postponing |
|
The goal here is to get rid of |
Cherry-picks am11@ae7563a (author: Adeel Mujahid / am11) which converts
MethodDescCallSiteto UCO inDispatchInfo, then moves all IDispatch helper methods into their own file.Changes
ae7563afrom am11/runtime with author preserved (Adeel Mujahid)src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/IDispatchHelpers.csas a standaloneinternal static class IDispatchHelpersin theSystem.Runtime.InteropServicesnamespace, containing all IDispatch-related helpers:StubHelpers.cs:DispatchExPropertyCanRead/DispatchExPropertyCanWriteconstants andGetDispatchExPropertyFlagsGetDispatchParameterInfoName,GetDispatchMemberInfoName,GetDispatchMemberInfoType,HasDispatchCustomAttribute,GetDispatchMemberParameters,GetDispatchPropertyTokenAndModule,GetDispatchPropertyAccessor,GetDispatchFieldValue,SetDispatchFieldValue,GetDispatchPropertyValue,SetDispatchPropertyValue,InvokeDispatchMethodInfo,InvokeDispatchReflectMember,GetDispatchProperties,GetDispatchFields,GetDispatchMethods,GetDispatchInnerExceptionStubHelpers.csIDispatchHelpers.cstoSystem.Private.CoreLib.csprojunder theFeatureCominteropcondition group (no#if FEATURE_COMINTEROPinside the file itself, as conditional compilation is handled by the project file)corelib.hto define a newIDISPATCHHELPERSclass entry (mapped toSystem.Runtime.InteropServices.IDispatchHelpers) and moved all dispatch-relatedDEFINE_METHODregistrations fromSTUBHELPERStoIDISPATCHHELPERSdispatchinfo.cppandstdinterfaces.cppto useMETHOD__IDISPATCHHELPERS__*method references instead ofMETHOD__STUBHELPERS__*for all IDispatch methodsGCPROTECT_BEGIN/GCPROTECT_ENDpairs indispatchinfo.cppinto single struct-basedGCPROTECT_BEGINblocks using the standard anonymous-structgcpatternGetMemberProps()andSetUpParamMarshalerInfo(), replaced theGetDispatchMethodDescandGetDispatchFieldDescmanaged callbacks with direct native casts toREFLECTMETHODREF/REFLECTFIELDREFand calls toGetMethod()/GetField()— eliminating those two callbacks entirelyGetDispatchPropertyTokenandGetDispatchPropertyModulemanaged callbacks into a singleGetDispatchPropertyTokenAndModulecallback that returns both values in one callGetDispatchMemberInfoTypeto returnintdirectly (likeGetDispatchExPropertyFlags) and updated its call site to useInvokeThrowing_Ret<INT32>[SupportedOSPlatform("windows")]annotations fromIDispatchHelpers.csand the now-unusedusing System.Runtime.Versioning;metasig.h(SM_PtrMethodBase_PtrIntPtr_PtrException_RetVoid,SM_PtrFieldInfo_PtrIntPtr_PtrException_RetVoid,SM_PtrPropertyInfo_PtrModule_PtrException_RetVoid,SM_PtrMember_PtrInt_PtrException_RetVoid,SM_PtrPropertyInfo_PtrInt_PtrException_RetVoid) and added replacements (SM_PtrMember_PtrException_RetInt,SM_PtrPropertyInfo_PtrInt_PtrModule_PtrException_RetVoid)Note
This PR was created with AI assistance (GitHub Copilot).
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.