WORK IN PROGRESS
Download the nuget package.
dotnet add package Bindgen.NET --version *-*A runtime id is needed to resolve the ClangSharp native dependencies. Your project file should look like this.
<ProjectSdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<!-- This line is required -->
<RuntimeIdentifierCondition="'$(RuntimeIdentifier)' == ''">$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReferenceInclude="Bindgen.NET"Version="*-*" />
</ItemGroup>
</Project>Configure your binding options and generate!
Example:
usingBindgen.NET;BindingOptionsexampleConfig=new(){Namespace="ExampleNamespace",Class="ExampleClass",DllImportPath="libexample",// Pass raw source code instead// TreatInputFileAsRawSourceCode = true,InputFile="path/header.h",OutputFile="path/Header.cs",IncludeDirectories={"path/include"},SystemIncludeDirectories={"path/include"},};stringoutput=BindingGenerator.Generate(exampleConfig);A runnable example can be found here.
A basic example of generated bindings can be found in here.
A real world example of generated bindings can be seen in the Flecs.NET repo here.