When setting a custom classname (instead of PInvoke), the generated file Windows.Win32.ICCloseSafeHandle.g.cs contains the line
protected override bool ReleaseHandle() => SomeClass.ICClose((winmdroot.Media.Multimedia.HIC)this.handle) == (global::Windows.Win32.Foundation.LRESULT)PInvoke.ICERR_OK;
This uses PInvoke instead of the classname set in NativeMethods.json, which results in the compilation error The name 'PInvoke' does not exist in the current context. It also uses a hardcoded global::Windows.Win32 which I assume should be winmdroot, although this does not error as those are defined to be the same.
Repro steps
NativeMethods.txt content:
Windows.Win32.Media.Multimedia
NativeMethods.json content:
{
"$schema": "https://aka.ms/CsWin32.schema.json",
"className": "SomeClass",
}
Context
- CsWin32 version: 0.3.275
- Win32Metadata version: not explicitly set by project
- Target Framework: net8.0
LangVersion: preview
When setting a custom classname (instead of
PInvoke), the generated fileWindows.Win32.ICCloseSafeHandle.g.cscontains the lineThis uses
PInvokeinstead of the classname set inNativeMethods.json, which results in the compilation errorThe name 'PInvoke' does not exist in the current context. It also uses a hardcodedglobal::Windows.Win32which I assume should bewinmdroot, although this does not error as those are defined to be the same.Repro steps
NativeMethods.txtcontent:NativeMethods.jsoncontent:{ "$schema": "https://aka.ms/CsWin32.schema.json", "className": "SomeClass", }Context
LangVersion:preview