TedToolkit.CppBindings.Occt.Generator
2026.9.15
dotnet add package TedToolkit.CppBindings.Occt.Generator --version 2026.9.15
NuGet\Install-Package TedToolkit.CppBindings.Occt.Generator -Version 2026.9.15
<PackageReference Include="TedToolkit.CppBindings.Occt.Generator" Version="2026.9.15" />
<PackageVersion Include="TedToolkit.CppBindings.Occt.Generator" Version="2026.9.15" />
<PackageReference Include="TedToolkit.CppBindings.Occt.Generator" />
paket add TedToolkit.CppBindings.Occt.Generator --version 2026.9.15
#r "nuget: TedToolkit.CppBindings.Occt.Generator, 2026.9.15"
#:package TedToolkit.CppBindings.Occt.Generator@2026.9.15
#addin nuget:?package=TedToolkit.CppBindings.Occt.Generator&version=2026.9.15
#tool nuget:?package=TedToolkit.CppBindings.Occt.Generator&version=2026.9.15
TedToolkit.CppBindings.Occt.Generator
Generate matching C# and C++ OCCT bindings from installed headers and compiler-proved facts. This .NET 10 tool package supplies the OCCT provider for the reusable generation platform, not the ready-to-use Windows bindings.
The package is unreleased. Use a locally packed package or a repository project reference.
Generate sources
Install OCCT 8.0.1 in vcpkg's x64-windows triplet and set VCPKG_ROOT. The supported profile
is Windows x64, MSVC ABI, a compatible Clang parser/probe, and CMake 3.28 or later.
using ModularPipelines;
using TedToolkit.CppBindings.Occt.Generator;
var output = new DirectoryInfo("output/generated");
var pipeline = await Pipeline.CreateBuilder()
.AddOcctGenerators(new OcctGenerationOptions
{
DeclOptions = [new OcctDeclarationOptions("Geom2d_BSplineCurve")],
CSharpFolder = output.CreateSubdirectory("csharp"),
CppFolder = output.CreateSubdirectory("cpp"),
NativeLibraryVersion = new Version(8, 0, 1),
})
.BuildAsync();
await pipeline.RunAsync();
Output roots must be dedicated and non-overlapping: validated preparation clears their old
contents. Generation performs native compiler probes but does not build the final binding DLL.
Compile cpp/CMakeLists.txt separately against the matching OCCT libraries. Managed sources and
the resulting DLL are one inseparable artifact set.
Capabilities and configuration
| Task | Entry or option | Contract |
|---|---|---|
| Select root records | Required DeclOptions |
Each OcctDeclarationOptions accepts a header stem or generated enum value. The exact <stem>.hxx must exist; dependencies are discovered recursively. |
| Select public headers | GenerateAllPublicHeaders = true, DeclOptions = [] |
Complete-header discovery reports excluded headers in unsupported-headers.txt beside the language roots. |
| Configure native discovery | Triplet, CommandLineArgs |
An omitted triplet selects a compatible installed one; extra arguments go to Clang. Only the proved win-x64 runtime profile is supported. |
| Configure output | Inherited CSharpFolder, CppFolder, CSharpNamespace, NativeLibraryBaseName, IsInternal |
Default namespace is TedToolkit.CppBindings.Occt; basename is ted_toolkit_occt. Namespace applies to layouts, extensions, enums and loader without changing native identities. |
| Configure language | Inherited CppVersion |
Defaults to 17; passed to parsing, probes and emitted CMake. Another language version does not establish another supported ABI. |
| Select native version | Inherited NativeLibraryVersion |
Optional exact Open CASCADE version. It must match the installed opencascade package for the selected triplet; generated CMake includes the version and EXACT. Omission retains unversioned resolution. |
| Select projected fields | FieldTypeToGenerate |
Filters modeled fields; native layout still determines storage. |
| Retained layout option | GetFieldOffsetByRunning |
Compatibility property, currently unused. Layout comes from Clang and compiler proof. |
| Discover header selectors | Bundled OcctHeaderTypeGenerator |
Generates TedToolkit.CppBindings.Occt.Generator.OcctHeaderType when installed headers exist. The non-packable SourceGenerators component ships here as analyzer assets, not as consumer lifetime diagnostics. |
Preparation and output boundary
OcctParseModule → OcctCompilerProbeModule → OCCT provider model
→ Shared root/dependency closure + normalization → one validated GenerationPlan
→ CleanGenerationOutputModule → GenerateCSharpModule + GenerateCppModule
Parsing, compiler probes, OCCT classification, and finite OCCT emission policy are provider-owned. The provider converts Clang declarations into Shared's normalized records, members, types, transport, lifetime, layout, and template facts. Shared then owns dependency closure, semantic admission, managed and native declaration emission, source inventory, slot ordering, and final plan construction. Both emitted languages therefore consume the same normalized model and exact export order. Preparation failures, missing dependencies, rejected semantics, invalid paths, collisions, duplicate exports and cancellation fail the pipeline instead of yielding a successful empty set.
The provider owns OCCT error projection, headers, native dependency choices, compiler options, and unity grouping facts as finite profile or supplemental metadata. Shared owns declaration emission, deterministic CMake construction, publication, loader, and function table. Record/template-family and enum emission limits remain unchanged; this migration does not adopt a benchmark strategy.
Native source filenames use a readable stem capped at 80 characters, with a stable hash for long template names. This leaves room for CMake's object-directory suffix in nested worktrees without changing managed names or native exports. The Windows build rejects unsafe CMake object-path warnings before compilation; use a shorter output root if the checkout still exceeds that budget.
Each supported object has one unmanaged physical representation. Reference returns remain
ref readonly T or ref T, subject to native owner lifetime and invalidation rules.
Transient operations expose separate direct Handle<T> and in handle<T> receivers invoking
the same slot; only the owning overload checks owner liveness. Lowercase handle<T> is non-owning
storage, not an owner interface. Handles returned by value use owning Handle<T>; non-transient
RAII uses generic Owned<T>.
Overlapping ordinary fields, including union members, use same-named ref T properties over shared
sequential storage (ref readonly T for const storage). References alias native bytes without
copying, retaining or allocating. Non-overlapping fields remain fields; bitfields remain value
properties. Reference accessors also preserve aliasing through in or ref readonly containing
receivers, without defensive copies. Reflection and field-specific syntax must account for the property distinction.
Callers must obey native union active-member, construction/destruction, owner-lifetime and
invalidation rules; accessing a generated property does not activate a union member.
Representable template type arguments stay generic; non-type values and unrepresentable arguments
such as void are fixed into the family name. A shared managed family requires a valid physical
graph. Each selected closed native specialization retains direct invocation slots without runtime
generic native dispatch.
Explicit full specializations retain their own closed declarations. Template families with distinct native base identities also remain closed; fixed-base families can share a managed type while retaining the exact base interface. Generic base dependence is not inferred from coincident type spellings. Family compatibility is finalized only after native ownership classification.
Fail-closed limitations
The installed headers and DLLs are authoritative. Incomplete/inaccessible declarations, unrepresentable layout/transport, unsafe ownership, unavailable copying/destruction and uncallable members are rejected at the narrowest safe boundary. Templates, streams and smart pointers are not excluded merely by category; each concrete specialization needs proof.
All-header discovery excludes missing/broken include dependencies and their dependants, the
installed broken MathLin_Jacobi.hxx, and incompatible desktop/GLES declarations from
OpenGl_GLESExtensions.hxx. It reports exclusions without patching installed headers.
Exact members proved absent from the Windows libraries are recorded in
UnsupportedNativeExports.txt. Recreate linker evidence
when the native installation changes; do not replace a member failure with broad type exclusion.
The repository has no vcpkg manifest; maintainers supply the documented installation. No Linux, ARM, alternate compiler ABI, replaceable native DLL, or published package is implied.
Verify
From the repository root, run all-header source generation:
$env:VCPKG_ROOT = 'C:\vcpkg'
dotnet run --project src/tools/TedToolkit.CppBindings.Windows.Generation.Tool/TedToolkit.CppBindings.Windows.Generation.Tool.csproj -c Release -- --provider occt --repository-root . --output-root output/generated --vcpkg-root $env:VCPKG_ROOT --configuration Release
dotnet build TedToolkit.CppBindings.slnx -c Release additionally builds the Windows project's
matched native artifact using Visual Studio's MSVC and Ninja tools. The separate
TedToolkit.CppBindings.Occt.GeneratedSmoke executable exercises native Value, Owned, Handle,
inheritance and error behavior. TUnit regressions live in
TedToolkit.CppBindings.Occt.Generator.Tests.
The independent generic package consumer proves the public provider boundary, not OCCT correctness.
pwsh -NoProfile -File Build/VerifyOcctGeneratorPackage.ps1 packs and consumes this provider in an
isolated project, checks header source-generator assets and public identities, and compares two
real-header generation runs. After a successful Release solution build,
pwsh -NoProfile -File Build/VerifyWindowsPackage.ps1 consumes the matching Windows package and
its direct analyzer package through the native smoke test without generating code in the consumer.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- ClangSharp (>= 21.1.8.3)
- libclang.runtime.win-x64 (>= 21.1.8)
- libClangSharp.runtime.win-x64 (>= 21.1.8.2)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 5.0.0)
- ModularPipelines (>= 3.2.8)
- TedToolkit.CppBindings.Generator (>= 2026.9.15)
- TedToolkit.RoslynHelper (>= 2026.6.19)
- ZString (>= 2.6.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.