TedToolkit.CppInteropGen 2025.12.23.1

dotnet add package TedToolkit.CppInteropGen --version 2025.12.23.1
                    
NuGet\Install-Package TedToolkit.CppInteropGen -Version 2025.12.23.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TedToolkit.CppInteropGen" Version="2025.12.23.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TedToolkit.CppInteropGen" Version="2025.12.23.1" />
                    
Directory.Packages.props
<PackageReference Include="TedToolkit.CppInteropGen" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TedToolkit.CppInteropGen --version 2025.12.23.1
                    
#r "nuget: TedToolkit.CppInteropGen, 2025.12.23.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TedToolkit.CppInteropGen@2025.12.23.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TedToolkit.CppInteropGen&version=2025.12.23.1
                    
Install as a Cake Addin
#tool nuget:?package=TedToolkit.CppInteropGen&version=2025.12.23.1
                    
Install as a Cake Tool

CppInteropGen

This tool is still work in progress.

Brief

This is an easy tool to wrap the cpp file to c#.

CPP

You should include the file csharp_interop.h to your cpp project. And Define the Macro WRAP_CALL_CUSTOM_CATCH before include the csharp_interop.h. Use the Macro CSHARP_WRAPPER To define the method you like.

use //DLL_NAME: to define the dll name. ust //STRUCT: to define the struct layout.

Namings

  • The method name must be %CLASSNAME%_%METHODNAME%_%EXTRA%.
  • And the file name must be %CLASSNAME%_C with the extension h, cpp, hxx, or cxx.
  • Every file must have the definitions of Create and Delete for the ctor and the dtor.

Example

Define your own WRAP_CALL_CUSTOM_CATCH.

#ifndef EXPORT_MACRO_H
#define EXPORT_MACRO_H
#include <Standard_Failure.hxx>
#include <string>
#ifndef WRAP_CALL_CUSTOM_CATCH
#define WRAP_CALL_CUSTOM_CATCH \
catch (const Standard_Failure &ex) { \
const std::string typeName = ex.DynamicType()->Name(); \
const std::string message = ex.GetMessageString(); \
return copy_to_heap("OCCT [" + typeName + "]: " + message); \
}
#endif
#include <csharp_interop.h>
#endif //EXPORT_MACRO_H

Add your own methods

#include <gp_Pnt.hxx>
#include "export_macro.h"

//DLL_NAME: EXAMPLE.dll
//STRUCT: gp_XYZ.Data coord

CSHARP_WRAPPER(gp_Pnt_Create_0(gp_Pnt*& handle), {
                    handle= new gp_Pnt();
                    })

CSHARP_WRAPPER(gp_Pnt_Create_coord(const gp_XYZ& xyz, gp_Pnt*& handle), {
                    handle= new gp_Pnt(xyz);
                    })

CSHARP_WRAPPER(gp_Pnt_Create_xyz(const double x, const double y, const double z, gp_Pnt*& handle), {
                    handle= new gp_Pnt(x, y, z);
                    })

CSHARP_WRAPPER(gp_Pnt_Delete(const gp_Pnt *self), {
                    delete self;
                    })

CSHARP_WRAPPER(gp_Pnt_ChangeCoord(gp_Pnt *self, gp_XYZ*& xyz), {
                    xyz = &self->ChangeCoord();
                    })

CSHARP_WRAPPER(gp_Pnt_Distance(const gp_Pnt *self, const gp_Pnt& other, double& distance), {
                    distance = self->Distance(other);
                    })

CSHARP_WRAPPER(gp_Pnt_SquareDistance(const gp_Pnt *self, const gp_Pnt& other, double& squareDistance), {
                    squareDistance = self->SquareDistance(other);
                    })

C#

In C#, it'll generate the Wrappers for you. You can use partial keyword to add more things.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2025.12.23.1 179 12/23/2025
2025.12.23 170 12/23/2025
2025.12.17 279 12/17/2025
2025.12.12.2 122 12/12/2025
2025.12.12.1 125 12/12/2025
2025.12.12 115 12/12/2025
2025.12.9 450 12/9/2025
2025.11.25 196 11/25/2025
2025.11.24.3 190 11/24/2025
2025.11.24.2 185 11/24/2025
2025.11.24.1 181 11/24/2025
2025.11.24 194 11/24/2025
2025.11.21 391 11/21/2025
2025.11.20.4 395 11/20/2025
2025.11.20.3 397 11/20/2025
2025.11.20.2 402 11/20/2025
2025.11.20.1 405 11/20/2025
2025.11.20 402 11/20/2025
2025.11.19.6 402 11/19/2025
2025.11.19.5 403 11/19/2025
2025.11.19.4 392 11/19/2025
2025.11.19.3 397 11/19/2025
2025.11.19.2 400 11/19/2025
2025.11.19.1 394 11/19/2025
2025.11.19 407 11/19/2025
2025.11.18.6 407 11/18/2025
2025.11.18.5 405 11/18/2025
2025.11.18.4 395 11/18/2025
2025.11.18.2 407 11/18/2025
2025.11.18.1 400 11/18/2025
2025.11.12 295 11/12/2025