Support classes for code generated by SharpGen.

c-sharp, cpp, interoperability, sharpdx
Install-Package SharpGen.Runtime -Version 1.0.2



Build status MyGet Pre Release NuGet Docs codecov CodeFactor

Accurate and high performance C++ interop code generator for C#.


  • Accurate, fast code-gen for C++ and COM interfaces from their C++ headers.
  • No dependencies on .NET Runtime COM support
  • Supports passing code-gen information through MSBuild project and package references
  • Pluggable Runtime Library Name and runtime support type names (default library is SharpGen.Runtime)
    • Projects that implement their own SharpGenTools runtime support classes can add mapping rules to ensure that their generated code uses their runtime support library.

Components in this Repo

  • SharpGen
    • The code-gen engine that runs CastXML to parse the C++ and then generates the C# interop code.
  • SharpPatch
    • Patches the calli instructions for efficient C++ interop as well as other constructs not possible in C#
  • SharpGenTools.Sdk
    • MSBuild tooling to integrate SharpGen and SharpPatch directly into projects
  • SharpGen.Runtime
    • Runtime support classes for code generated by SharpGen.
  • SharpGen.Interactive
    • Legacy command line front-end for SharpGen with Avalonia progress-dialog
    • Xplat version of original SharpGen application
  • SharpPatch.Cli
    • Legacy command line front-end for SharpPatch
    • The original SharpCli application


To Use

  • Any projects using the SDK to generate code must use new SDK-style projects with MSBuild 15.3 or higher (.NET Core 2.0 SDK or VS 2017.3)
  • Make any mapping files a SharpGenMapping item in your .csproj.

To Build

  • MSBuild 15.3 or newer.
  • .NET Core 2.0
  • CMake 3.0 or newer.