microsoft / xlang

MIT License
877 stars 103 forks source link

Ability to declare classic COM interfaces from MIDL 3.0 and use it as a projected type #775

Closed JaiganeshKumaran closed 1 year ago

JaiganeshKumaran commented 2 years ago

Today it's only possible to declare Windows Runtime (IInspectable derived) interfaces in a Windows Metadata file. While Win32Metadata exists, it's just not the same. Certain interop interfaces are declared in SDK headers since they use raw pointers but that means they won't be projected by language projections in a natural way. This means projected languages that support raw pointers can directly expose them if the interface has methods that return or take in pointers.

Essentially I want to do something like this from MIDL 3.0.

interface IComInterface : IUnknown
{
    Int32 MyProperty { get; };
    Int32* MyPropertyPointer { get; };
}

And access it from C++/WinRT just like any other projected interface just by referencing the WinMD file (no com_ptr needed). The same should work with other projections. If a language doesn't support raw pointers, either it could be made available in some other way or hidden from user code.

IComInterface comInterface = ....;
int myProperty = comInterface.MyProperty();
int* myPropertyPointer = comInterface.MyPropertyPointer();
github-actions[bot] commented 1 year ago

This issue is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 5 days.