dotnet / dotnet/runtime

Migrate core part of IDispatch support for built-in COM to managed

Open
#124,423 3 comments 0 reactions 0 assignees View on GitHub
area-Interop-coreclr
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

Opening for discussion per https://github.com/dotnet/runtime/pull/124303#discussion_r2807101831. @AaronRobinsonMSFT

Currently, the IDispatch support relies heavily on managed reflection stack:

https://github.com/dotnet/runtime/blob/1969a31f6755d0baf5553eca5ec4c2576a539a2a/src/coreclr/vm/dispatchinfo.cpp#L1592-L1794

https://github.com/dotnet/runtime/blob/1969a31f6755d0baf5553eca5ec4c2576a539a2a/src/coreclr/vm/dispatchinfo.cpp#L510-L568

The majority of code is manipulating managed objects in native code. The proposal is to convert the managed-manipulating code to managed.

The scope will include:
- `DispatchInfo::InvokeMemberWorker`: this is the core member that manipulates managed reflection types intensively.
- `DispatchMemberInfo`: it uses managed `MemberInfo` and `ParameterInfo` to represent parameter information. The native signature parsing part is shared with `MarshalInfo` and should be kept native.
- Most of `DispatchInfo`: it uses managed reflection stack to retrieve member list, with manual synchronization etc.
- Overrides of `DispParamMarshaler`: most are invoking managed functions or custom marshalers. SafeArray and VT_RECORD will be kept native.

The parameter marshal and coerce logic will be kept as-is, with some code written in plain transcribed managed code.

After the conversion, the central logic of `IDispatch` support would be managed reflection code, with native calls for pieces unsuitable for managed code.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.