Bindgen.NET
1.0.0
Работа в процессе
Загрузите пакет Nuget.
dotnet add package Bindgen.NET --version *-*Идентификатор времени выполнения необходим для разрешения нативных зависимостей ClangSharp. Ваш файл проекта должен выглядеть так.
< Project Sdk = " Microsoft.NET.Sdk " >
< PropertyGroup >
< OutputType >Exe</ OutputType >
< TargetFramework >net7.0</ TargetFramework >
<!-- This line is required -->
< RuntimeIdentifier Condition = " '$(RuntimeIdentifier)' == '' " >$(NETCoreSdkRuntimeIdentifier)</ RuntimeIdentifier >
</ PropertyGroup >
< ItemGroup >
< PackageReference Include = " Bindgen.NET " Version = " *-* " />
</ ItemGroup >
</ Project >Настройте варианты привязки и генерируйте!
Пример:
using Bindgen . NET ;
BindingOptions exampleConfig = 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" } ,
GenerateFunctionPointers = true ,
GenerateMacros = true ,
GenerateStructEqualityFunctions = true
} ;
string output = BindingGenerator . Generate ( exampleConfig ) ;Заполненный пример можно найти здесь.
Основной пример сгенерированных привязков можно найти здесь.
Пример реального мира сгенерированных привязков можно увидеть в репо flecs.net здесь.