Skip to content

Interop source generators do not respect [NativeMarshalling(typeof(TMarshaller))] for COM interfaces #121642

@jtschuster

Description

@jtschuster

In the COM interface generator and LibraryImport generator, we should be able to specify [NativeMarshalling(typeof(UniqueComInterfaceMarshaller<IFoo>))] to instruct the generators to use that marshaller. However, it doesn't override the default marshaller for COM interfaces.

In the example below, the marshalling of foo parameters should use UniqueComInterfaceMarshaller, but currently use ComInterfaceMarshaller.

[GeneratedComInterface]
[GUID(...)]
[NativeMarshalling(typeof(UniqueComInterfaceMarshaller<IFoo>))]
internal partial interface IFoo
{
    string GetMessage();
    void DoWorkTogether(IFoo foo);
}

public static class PInvokes
{
    [LibraryImport("lib")]
    bool TryGetFoo(out IFoo foo);
}

This shouldn't require changing code outside of src/libraries/System.Runtime.InteropServices.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions