Example of generated code:
Here is a simple C# method:
public Class RecursiveTest
public static int Fib(int n)
if (n < 2)
return Fib(n - 2) + Fib(n - 1);
Here is the generated C++ code:
::System::Int32 CrossNetUnitTest::_Benchmark::RecursiveTest::Fib(::System::Int32 n)
if ((n < 2))
return ((::CrossNetUnitTest::_Benchmark::RecursiveTest::Fib((((n - 2)))) + ::CrossNetUnitTest::_Benchmark::RecursiveTest::Fib((((n - 1))))));
Note that all the types are fully qualified, System::Int32 is a typedef to int.
An example with delegates and strings:
const int SCALE = 1;
DoTest("Binary Tree", BinaryTreesTest.Test, SCALE * 1000);
With BinaryTreesTest.Test a static method, TestDelegate and DoTest being defined as:
public delegate bool TestDelegate(int N);
public static void DoTest(string text, TestDelegate del, int n)
Will generate this code:
The fully qualified types makes it a bit cryptic, but you can see few things here:
- C strings are replaced by .NET strings. Static strings are actually pooled and constructed one time when initializing the assembly. Each string has actually an unique identifier (the 10 first characters of the string prefixed with the assembly name, a counter is appended if two strings have differences after the 10th character). In that case, C String "Binary Tree" is replaced by global System.String pointer scsharpbenchmarkBinary_Tre.
- Delegates are manipulated with C++ functors, macros exist to create the delegate type. Crossnet Functors can manipulate member methods, static methods and interface methods.
- SCALE * 1000 has been directly converted to 1000.