IDataTransferManagerInterop with void** parameter
Open
@sotteson1 is already working on this.
Since Sep 29, 2021.
- Dominant language
- C#
- Stars
- 2.5k
- Forks
- 124
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 9
Description
Actual behavior
When I try to use IDataTransferManagerInterop the generated code uses a void** to return the requested DataTransferManager. I believe more comfortable code can and should be generated e.g. using an out DataTansferManager parameter.
Generated code:
[Guid("3A3DCD6C-3EAB-43DC-BCDE-45671CE800C8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport]
public interface IDataTransferManagerInterop
{
unsafe void GetForWindow(HWND appWindow, global::System.Guid*riid, [Optional] void **dataTransferManager);
void ShowShareUIForWindow(HWND appWindow);
}
as well as
public static partial class FriendlyOverloadExtensions
{
public static unsafe void GetForWindow(this IDataTransferManagerInterop @this, HWND appWindow, in global::System.Guid riid, void **dataTransferManager)
{
// ...
}
}
Expected behavior
The generated code works. The unsafe nature of a void** pointer and the complexity to arrive at a working implementation lead me to file this issue.
Repro steps
NativeMethods.txtcontent:
IDataTransferManagerInterop
NativeMethods.jsoncontent (if present):
{
"$schema": "https://aka.ms/CsWin32.schema.json",
"public": true
}
- Any of your own code that should be shared?
using WinRT;
// riid of DataTransferManager, not IDataTransferManagerInterop
var guid = Guid.Parse("a5caee9b-8708-49d1-8d36-67d25a8da00c");
var iop = DataTransferManager.As<IDataTransferManagerInterop>();
var transferManager = IntPtr.Zero;
iop.GetForWindow(PInvoke.GetActiveWindow(), guid, (void**)&transferManager);
var realManager = DataTransferManager.FromAbi(transferManager);
Context
- CsWin32 version: 0.1.445-beta
- Target Framework: .net 5.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.