CodePorting.Native.Cs2Cpp.PortingControl
22.3.0
See the version list below for details.
dotnet add package CodePorting.Native.Cs2Cpp.PortingControl --version 22.3.0
NuGet\Install-Package CodePorting.Native.Cs2Cpp.PortingControl -Version 22.3.0
<PackageReference Include="CodePorting.Native.Cs2Cpp.PortingControl" Version="22.3.0" />
paket add CodePorting.Native.Cs2Cpp.PortingControl --version 22.3.0
#r "nuget: CodePorting.Native.Cs2Cpp.PortingControl, 22.3.0"
// Install CodePorting.Native.Cs2Cpp.PortingControl as a Cake Addin #addin nuget:?package=CodePorting.Native.Cs2Cpp.PortingControl&version=22.3.0 // Install CodePorting.Native.Cs2Cpp.PortingControl as a Cake Tool #tool nuget:?package=CodePorting.Native.Cs2Cpp.PortingControl&version=22.3.0
Description
CodePorting.Native 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 native (unmanaged) C++ environment.
CodePorting.Native.Cs2Cpp.PortingControl package makes it possible to fine-tune the translated code. There are two ways to do so: attributes and service classes.
Attributes
The attributes defined in the CodePorting.Native.Cs2Cpp.PortingControl package are recognized by the code porter (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 ported 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.Native.Cs2Cpp.PortingControl package that may be used in the original C# code. When this code gets translated to C++, the porter 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 Porter
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.
Usage
Make your project depend on CodePorting.Native.Cs2Cpp.PortingControl:
<PackageReference Include="CodePorting.Native.Cs2Cpp.PortingControl" Version="*" />
Now you can use the attributes and service classes from your code:
using System;
using CsToCppPorter;
using CodePorting.Native.Cs2Cpp;
namespace PortedProject
{
public abstract class MyClass
{
[CppWeakPtr, CppMutable]
private MyClass Parent;
[CppConstMethod]
public void DoSomething()
{
Parent = this;
if (Porter.IsPorted)
PerformCppSpecificOperations();
else
PerformCsSpecificOperations();
}
protected abstract void PerformCppSpecificOperations();
protected abstract void PerformCsSpecificOperations();
}
}
Now, when you use the CodePorting.Native Cs2Cpp to translate your project to C++, the porter will recognize the attributes or service classes and generate the code accordingly.
Resources
- Website: www.codeporting.com
- Product Home: CodePorting.Native Cs2Cpp
- Download: Install CodePorting.Native Cs2Cpp
- Documentation: CodePorting.Native Cs2Cpp Documentation
- Free Support Forum: CodePorting.Native Cs2Cpp Free Support Forum
- Blog: CodePorting.Native Cs2Cpp Blog
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net35 is compatible. net40 was computed. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
-
.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.5.0 | 577 | 5/16/2022 |
22.4.0 | 462 | 4/12/2022 |
22.3.0 | 418 | 3/21/2022 |
22.2.0 | 441 | 2/15/2022 |
22.1.0 | 449 | 1/18/2022 |
21.12.0 | 294 | 12/17/2021 |
21.11.0 | 338 | 11/13/2021 |
21.10.1 | 353 | 10/21/2021 |
21.10.0 | 309 | 10/14/2021 |
21.9.0 | 352 | 9/15/2021 |
21.8.0 | 352 | 8/16/2021 |
21.7.0 | 350 | 7/16/2021 |
21.6.0 | 399 | 6/16/2021 |
21.5.0 | 332 | 5/12/2021 |
21.4.0 | 357 | 4/14/2021 |
21.3.0 | 365 | 3/15/2021 |
21.2.0 | 359 | 2/12/2021 |
21.1.0 | 388 | 1/21/2021 |
20.12.0 | 415 | 12/18/2020 |
20.11.0 | 401 | 11/16/2020 |
20.10.0 | 425 | 10/19/2020 |
20.9.0 | 433 | 9/17/2020 |
20.8.0 | 509 | 8/13/2020 |
20.7.0 | 460 | 7/16/2020 |
20.6.0 | 515 | 6/15/2020 |
20.5.0 | 465 | 5/19/2020 |
20.4.0 | 464 | 4/20/2020 |
20.3.0 | 474 | 3/16/2020 |