-
Notifications
You must be signed in to change notification settings - Fork 710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Simplify the C# development experience when using classic COM interfaces needed for WinRT objects #2595
Comments
Definitely as a baseline, we should hand-roll these projections. In addition, it's possible that a cswinrt project could use a source generator to 'reflect' on a developer's [ComImport] interfaces and attempt to project these. At a minimum, the cswinrt generated As<>() helper and the new ICastableObject support could both assert that the target interface has a projection, and if not issue a helpful diagnostic. |
See cswinrt proposal for projecting ComImport interfaces: |
Not mentioned in OP so I'd like to request ensuring compatibility between WinUI SwapChain technology and custom projections of DXGI/D3D (I assume you won't be producing an official projection of those APIs). Interleaving UI with swapchain rendering was one of the more unique features of the UWP UI framework and I'd like to keep it working when transitioning to WinUI, so please keep it in mind when building the new interop. |
Direct ComImport interop support has been added to C#/WinRT (microsoft/CsWinRT#333). This will support all existing ComImport scenarios without requiring custom projections, except for a very few cases that intentionally cross the COM/WinRT streams (e.g., IGraphicsEffectD2D1Interop). DXGI/D3D interop should work as before. @marb2000 - you should be able to remove your custom projections from https://github.com/microsoft/WinUI-3-Demos/blob/master/DemoBuildCs/ /cc @ryalanms, to consider removing similar hand-rolled IWindowNative/IInitializeWithWindow projections from WinUI. |
For the Microsoft.WinUI.dll projection assembly, consider:
|
Support for this has been implemented in C#/WinRT: https://github.com/microsoft/CsWinRT/pull/830/files Closing this as there is an internal issue (28988767) tracking enabling this support in the Windows SDK projection |
Some interfaces, like IWindowNative, IInitializeWithWindow, IBufferByteAccess, or IDesktopWindowXamlSource, are classic-COM interfaces requested to consume a few WinRT APIs from Win32. For instance, the WinRT API FileOpenPicker looks for a CoreWindow on the current thread to serve as the owner of the dialog. But when running in Win32 (WinUI 3 in Desktop), the APIs crash because there is not CoreWindow. The solution is to use the IInitializeWithWindow interface to allow a Win32 app to specify an explicit window handle.
These interfaces aren't defined in WinMD files (they are classic-COM), so C#/WinRT can't generate C# projections. As a consequence, C# developers require to implement a pattern to use them in their apps.
You can find an example here.
This proposal is to simplify the development experience when using COM interfaces needed for frequently used WinRT APIs in Win32. Below is the current top list of these interfaces:
The text was updated successfully, but these errors were encountered: