-
Notifications
You must be signed in to change notification settings - Fork 114
Open
Labels
Description
Is your feature request related to a problem? Please describe.
APIs take native function pointers, which are defined in the metadata, but we have no wrapping projection for them.
For example, in the Win32Metadata:
[StructLayout(LayoutKind.Auto, CharSet = CharSet.Auto)]
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate LRESULT WNDPROC([In] HWND param0, [In] uint param1, [In] WPARAM param2, [In] LPARAM param3);Describe the solution you'd like
Create a "handle" struct like we do for HANDLE objects. Here is how I've wrapped this manually:
public unsafe readonly struct WNDPROC
{
public readonly delegate* unmanaged<HWND, uint, WPARAM, LPARAM, LRESULT> Value;
public WNDPROC(delegate* unmanaged<HWND, uint, WPARAM, LPARAM, LRESULT> value) => Value = value;
public bool IsNull => Value is null;
public static implicit operator WNDPROC(delegate* unmanaged<HWND, uint, WPARAM, LPARAM, LRESULT> value)
=> new(value);
public static implicit operator delegate* unmanaged<HWND, uint, WPARAM, LPARAM, LRESULT>(WNDPROC value)
=> value.Value;
}With that you should be able to use the struct in the APIs.
JackHarckness, FireController1847 and jevansaks