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 repo ที่นี่