Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

51 Commits

Repository files navigation

Bindgen.NET

MITNuget

WORK IN PROGRESS

Usage

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.

About

Generate C# bindings from C headers

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages