CodePorting.Translator.Cs2Cpp.Control 22.8.0

.NET Framework 3.5
Install-Package CodePorting.Translator.Cs2Cpp.Control -Version 22.8.0
dotnet add package CodePorting.Translator.Cs2Cpp.Control --version 22.8.0
<PackageReference Include="CodePorting.Translator.Cs2Cpp.Control" Version="22.8.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CodePorting.Translator.Cs2Cpp.Control --version 22.8.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CodePorting.Translator.Cs2Cpp.Control, 22.8.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install CodePorting.Translator.Cs2Cpp.Control as a Cake Addin
#addin nuget:?package=CodePorting.Translator.Cs2Cpp.Control&version=22.8.0

// Install CodePorting.Translator.Cs2Cpp.Control as a Cake Tool
#tool nuget:?package=CodePorting.Translator.Cs2Cpp.Control&version=22.8.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.


CodePorting.Translator Cs2Cpp is a framework capable of translating C# code to C++. The resulting code provides the same API original .Net code had and can run in the translator (unmanaged) C++ environment.

CodePorting.Translator.Cs2Cpp.Control package makes it possible to fine-tune the translated code. There are two ways to do so: attributes and service classes.


The attributes defined in the CodePorting.Translator.Cs2Cpp.Control package are recognized by the code translator and affect how the output code looks. It is possible to remove, stub or rename members, use weak pointers instead of shared pointers, move arrays from heap to stack, alter inheritance scheme, change includes list, add C++-specific declarations (such as friend class, constexpr field or const method) and so on. To use these attributes, add reference to this package into the project being translated and use the attributes in the code. See the Attributes guide for more details.

Service classes

There are several service classes provided in the CodePorting.Translator.Cs2Cpp.Control package that may be used in the original C# code. When this code gets translated to C++, the translator replaces calls into these classes with calls into C++-specific versions of them, thus providing the means of inserting the C++-specific operations into the C# code. For example, the MemoryManagement class provides the ways to control the lifetime of objects in C++ (this should only be used occasionally, where the default translation doesn't work well) without doing any changes to C# code behavior. The Translator class provides the means to check if the code is being executed in C# or C++. Based on the result, one can choose an appropriate logic at runtime. See The Memory management model for more details.


Make your project depend on CodePorting.Translator.Cs2Cpp.Control:

<PackageReference Include="CodePorting.Translator.Cs2Cpp.Control" Version="*" />

Now you can use the attributes and service classes from your code:

using System;
using CodePorting.Translator.Cs2Cpp;

namespace MyProject
    public abstract class MyClass
        [CppWeakPtr, CppMutable]
        private MyClass Parent;

        public void DoSomething()
            Parent = this;
            if (Translator.IsTranslated)

        protected abstract void PerformCppSpecificOperations();
        protected abstract void PerformCsSpecificOperations();

Now, when you use the CodePorting.Translator Cs2Cpp to translate your project to C++, the translator will recognize the attributes or service classes and generate the code accordingly.


Product Versions
.NET Framework net35 net40 net403 net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 3.5

    • No dependencies.
  • .NETFramework 4.7.2

    • No dependencies.

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
22.8.0 44 8/16/2022
22.7.0 69 7/19/2022
22.6.0 62 6/16/2022