microsoft / CsWin32

A source generator to add a user-defined set of Win32 P/Invoke methods and supporting types to a C# project.
MIT License
2.06k stars 87 forks source link

HINSTANCE is missing #924

Closed harborsiem closed 1 year ago

harborsiem commented 1 year ago

Actual behavior

IUIFramework.LoadUI() first parameter "instance" now has the type "HMODULE". CsWin32 version 0.2.223-beta had for the first parameter the type "HINSTANCE".

Expected behavior

The documentation and also the header file UiRibbon.h say that the first parameter type is a HINSTANCE

Repro steps

IUIFramework Framework;
private void Method(HINSTANCE hInstance, string resourceIdent)
{
    Framework = new UIRibbonFramework() as IUIFramework;
    Framework.LoadUI(hInstance, resourceIdent);
}
  1. NativeMethods.txt content:
    
    UIRibbonFramework
    IUIFramework

2. `NativeMethods.json` content (if present):
```json
  1. Any of your own code that should be shared?

Context

mikebattista commented 1 year ago

Once https://github.com/microsoft/win32metadata/issues/1517 is fixed this will be resolved, but that fix is dependent on CsWin32 supporting implicit conversions between HMODULE and HINSTANCE. That's tracked by https://github.com/microsoft/CsWin32/issues/199.

harborsiem commented 1 year ago

It does not work in CsWin32 version 0.2.240-beta.

AArnott commented 1 year ago

@harborsiem, the fix requires a combination of CsWin32 changes (which you have) and the fix in the metadata (which has merged but has not yet shipped). Once those two things are available, CsWin32 will have to update to consume that metadata (or you could try referencing the latest metadata directly and you might get lucky).