Closed HppZ closed 1 week ago
Win32Metadata uses the --config exclude-empty-records
by default. Not sure why we do, but it's dropping your "empty" structure.
Do you need Win32Metadata tooling? Perhaps you just need:
console:
dotnet tool install --global ClangSharpPInvokeGenerator
ClangSharpPInvokeGenerator -f .\main.h -n Namespace -o .\main.cs "@options.rsp"
options.rsp:
--config
log-exclusions
--with-librarypath
mpv_create=libmpv-2
main.cs
using System.Runtime.InteropServices;
namespace Namespace
{
public partial struct mpv_handle
{
}
public static unsafe partial class Methods
{
[DllImport("libmpv-2", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern mpv_handle* mpv_create();
}
}
Actually I need Microsoft.Windows.WinmdGenerator
to generate winmd file and cswin32
to generate c#
code.
You can set the UseWinSDKAssets
property to false to omit inclusion of some of the Windows-specific response files.
Example:
<PropertyGroup Label="Globals">
<OutputWinmd>Generated.winmd</OutputWinmd>
<WinmdVersion>0.0.0.0</WinmdVersion>
+ <UseWinSDKAssets>false</UseWinSDKAssets>
</PropertyGroup>
...
mpv.h (for testing)
mpvnet.modified.cs
\obj\crossarch\common\mpvnet.modified.cs(271,30): error CS0246: The type or namespace name 'mpv_handle' could not be found (are you missing a using directive or an assembly reference?)