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.05k stars 85 forks source link

CsWin32 doesn't use EntryPoints provided by metadata #968

Closed riverar closed 7 months ago

riverar commented 1 year ago

Actual behavior

Added a reference to custom metadata via ProjectionMetadataWinmd (see #356).

Metadata contains:

[DllImport("my.dll", EntryPoint = "#100", ExactSpelling = true, PreserveSig = false)]
public static extern ReturnType function();

CsWin32 generates:

[DllImport("my.dll", ExactSpelling = true)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
internal static extern winmdroot.ReturnType function();

Expected behavior

CsWin32 to read/carry over the entry point as defined by metadata. This can differ from the function name (e.g. FileIconInit).

Repro steps

TBD

Context