Introduce `GenerateFreeStandingFunctionsClassName` option (#1782)

* Introduce `GenerateFreeStandingFunctionsClassName` option

* Support CLI and fixes
This commit is contained in:
Stefan 2023-10-20 18:54:58 +02:00 коммит произвёл GitHub
Родитель 03874e743f
Коммит b16e809b9e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
11 изменённых файлов: 73 добавлений и 63 удалений

Просмотреть файл

@ -219,7 +219,7 @@ namespace CppSharp.Generators.CLI
{ {
PushBlock(BlockKind.FunctionsClass, decl); PushBlock(BlockKind.FunctionsClass, decl);
WriteLine("public ref class {0}", TranslationUnit.FileNameWithoutExtension); WriteLine("public ref class {0}", Options.GenerateFreeStandingFunctionsClassName(TranslationUnit));
WriteLine("{"); WriteLine("{");
WriteLine("public:"); WriteLine("public:");
Indent(); Indent();

Просмотреть файл

@ -909,7 +909,7 @@ namespace CppSharp.Generators.CLI
GenerateDeclarationCommon(function); GenerateDeclarationCommon(function);
var classSig = string.Format("{0}::{1}", QualifiedIdentifier(@namespace), var classSig = string.Format("{0}::{1}", QualifiedIdentifier(@namespace),
TranslationUnit.FileNameWithoutExtension); Options.GenerateFreeStandingFunctionsClassName(TranslationUnit));
Write("{0} {1}::{2}(", function.ReturnType, classSig, Write("{0} {1}::{2}(", function.ReturnType, classSig,
function.Name); function.Name);

Просмотреть файл

@ -329,7 +329,7 @@ namespace CppSharp.Generators.CLI
var result = string.Join("::", names); var result = string.Join("::", names);
var translationUnit = decl.Namespace as TranslationUnit; var translationUnit = decl.Namespace as TranslationUnit;
if (translationUnit != null && translationUnit.HasFunctions && if (translationUnit != null && translationUnit.HasFunctions &&
rootNamespace == translationUnit.FileNameWithoutExtension) rootNamespace == Options.GenerateFreeStandingFunctionsClassName(translationUnit))
return "::" + result; return "::" + result;
return result; return result;
} }

Просмотреть файл

@ -250,7 +250,7 @@ namespace CppSharp.Generators.CSharp
if (!context.Functions.Any(f => f.IsGenerated) && !hasGlobalVariables) if (!context.Functions.Any(f => f.IsGenerated) && !hasGlobalVariables)
return; return;
var parentName = SafeIdentifier(context.TranslationUnit.FileNameWithoutExtension); var parentName = SafeIdentifier(Context.Options.GenerateFreeStandingFunctionsClassName(context.TranslationUnit));
var isStruct = EnumerateClasses() var isStruct = EnumerateClasses()
.ToList() .ToList()
.FindAll(cls => cls.IsValueType && cls.Name == parentName && context.QualifiedLogicalName == cls.Namespace.QualifiedLogicalName) .FindAll(cls => cls.IsValueType && cls.Name == parentName && context.QualifiedLogicalName == cls.Namespace.QualifiedLogicalName)

Просмотреть файл

@ -575,7 +575,7 @@ $"[{Context.TargetInfo.LongDoubleWidth}]");
} }
if (decl is Variable && !(decl.Namespace is Class)) if (decl is Variable && !(decl.Namespace is Class))
names.Push(decl.TranslationUnit.FileNameWithoutExtension); names.Push(Options.GenerateFreeStandingFunctionsClassName(decl.TranslationUnit));
while (!(ctx is TranslationUnit)) while (!(ctx is TranslationUnit))
{ {

Просмотреть файл

@ -172,6 +172,12 @@ namespace CppSharp
public string IncludePrefix; public string IncludePrefix;
public Func<TranslationUnit, string> GenerateName; public Func<TranslationUnit, string> GenerateName;
/// <summary>
/// By default the classes in which free standing functions are contained are named like the header they are in
/// this options allows you to customize this behavior.
/// </summary>
public Func<TranslationUnit, string> GenerateFreeStandingFunctionsClassName = tu => tu.FileNameWithoutExtension;
/// <summary> /// <summary>
/// Set this option to the kind of comments that you want generated /// Set this option to the kind of comments that you want generated
/// in the source code. This overrides the default kind set by the /// in the source code. This overrides the default kind set by the

Просмотреть файл

@ -57,7 +57,8 @@ namespace CppSharp.Passes
} }
else else
{ {
string name = (function.Namespace as TranslationUnit)?.FileNameWithoutExtension ?? var tu = function.Namespace as TranslationUnit;
string name = tu != null ? Options.GenerateFreeStandingFunctionsClassName(tu) :
function.Namespace.Name; function.Namespace.Name;
@class = ASTContext.FindClass( @class = ASTContext.FindClass(
name, ignoreCase: true).FirstOrDefault( name, ignoreCase: true).FirstOrDefault(

Просмотреть файл

@ -68,6 +68,7 @@ namespace CppSharp.Tests
{ {
driver.Options.GenerateFinalizers = true; driver.Options.GenerateFinalizers = true;
driver.Options.GenerateObjectOverrides = true; driver.Options.GenerateObjectOverrides = true;
driver.Options.GenerateFreeStandingFunctionsClassName = tu => tu.FileNameWithoutExtension + "Cool";
base.Setup(driver); base.Setup(driver);
} }

Просмотреть файл

@ -78,7 +78,7 @@ public class CLITests
byte[] bytes2 = Encoding.ASCII.GetBytes("TestMulti2"); byte[] bytes2 = Encoding.ASCII.GetBytes("TestMulti2");
sbyte[] sbytes2 = Array.ConvertAll(bytes2, q => Convert.ToSByte(q)); sbyte[] sbytes2 = Array.ConvertAll(bytes2, q => Convert.ToSByte(q));
string s = CLI.CLI.MultipleConstantArraysParamsTestMethod(sbytes, sbytes2); string s = CLI.CLICool.MultipleConstantArraysParamsTestMethod(sbytes, sbytes2);
Assert.AreEqual("TestMultiTestMulti2", s); Assert.AreEqual("TestMultiTestMulti2", s);
} }
@ -88,7 +88,7 @@ public class CLITests
byte[] bytes = Encoding.ASCII.GetBytes("TestMultipleConstantArraysParamsTestMethodLongerSourceArray"); byte[] bytes = Encoding.ASCII.GetBytes("TestMultipleConstantArraysParamsTestMethodLongerSourceArray");
sbyte[] sbytes = Array.ConvertAll(bytes, q => Convert.ToSByte(q)); sbyte[] sbytes = Array.ConvertAll(bytes, q => Convert.ToSByte(q));
Assert.Throws<InvalidOperationException>(() => CLI.CLI.MultipleConstantArraysParamsTestMethod(sbytes, new sbyte[] { })); Assert.Throws<InvalidOperationException>(() => CLI.CLICool.MultipleConstantArraysParamsTestMethod(sbytes, new sbyte[] { }));
} }
[Test] [Test]
@ -110,7 +110,7 @@ public class CLITests
Assert.AreEqual(10, val.NestedUnion.SzText.Length); Assert.AreEqual(10, val.NestedUnion.SzText.Length);
Assert.AreEqual("TestUnions", val.NestedUnion.SzText); Assert.AreEqual("TestUnions", val.NestedUnion.SzText);
string ret = CLI.CLI.StructWithNestedUnionTestMethod(val); string ret = CLI.CLICool.StructWithNestedUnionTestMethod(val);
Assert.AreEqual("TestUnions", ret); Assert.AreEqual("TestUnions", ret);
} }
@ -146,7 +146,7 @@ public class CLITests
Assert.AreEqual(10, unionWithNestedStruct.NestedStruct.SzText.Length); Assert.AreEqual(10, unionWithNestedStruct.NestedStruct.SzText.Length);
Assert.AreEqual("TestUnions", unionWithNestedStruct.NestedStruct.SzText); Assert.AreEqual("TestUnions", unionWithNestedStruct.NestedStruct.SzText);
string ret = CLI.CLI.UnionWithNestedStructTestMethod(unionWithNestedStruct); string ret = CLI.CLICool.UnionWithNestedStructTestMethod(unionWithNestedStruct);
Assert.AreEqual("TestUnions", ret); Assert.AreEqual("TestUnions", ret);
} }
@ -172,7 +172,7 @@ public class CLITests
Assert.AreEqual(2, unionWithNestedStructArray.NestedStructs.Length); Assert.AreEqual(2, unionWithNestedStructArray.NestedStructs.Length);
string ret = CLI.CLI.UnionWithNestedStructArrayTestMethod(unionWithNestedStructArray); string ret = CLI.CLICool.UnionWithNestedStructArrayTestMethod(unionWithNestedStructArray);
Assert.AreEqual("TestUnion1TestUnion2", ret); Assert.AreEqual("TestUnion1TestUnion2", ret);
} }

Просмотреть файл

@ -26,6 +26,8 @@ namespace CppSharp.Tests
driver.ParserOptions.UnityBuild = true; driver.ParserOptions.UnityBuild = true;
driver.ParserOptions.AddSupportedFunctionTemplates("FunctionTemplate"); driver.ParserOptions.AddSupportedFunctionTemplates("FunctionTemplate");
driver.Options.GenerateFreeStandingFunctionsClassName = t => t.FileNameWithoutExtension + "Cool";
} }
public override void SetupPasses(Driver driver) public override void SetupPasses(Driver driver)

Просмотреть файл

@ -85,9 +85,9 @@ public unsafe class CSharpTests
{ {
} }
CSharp.CSharp.FunctionInsideInlineNamespace(); CSharp.CSharpCool.FunctionInsideInlineNamespace();
CSharp.CSharp.TakeMappedEnum(TestFlag.Flag1); CSharp.CSharpCool.TakeMappedEnum(TestFlag.Flag1);
using (CSharpTemplates.SpecialiseReturnOnly()) using (CSharpTemplatesCool.SpecialiseReturnOnly())
{ {
} }
@ -127,16 +127,16 @@ public unsafe class CSharpTests
[Ignore("https://github.com/mono/CppSharp/issues/1518")] [Ignore("https://github.com/mono/CppSharp/issues/1518")]
public void TestReturnCharPointer() public void TestReturnCharPointer()
{ {
Assert.That(new IntPtr(CSharp.CSharp.ReturnCharPointer()), Is.EqualTo(IntPtr.Zero)); Assert.That(new IntPtr(CSharp.CSharpCool.ReturnCharPointer()), Is.EqualTo(IntPtr.Zero));
const char z = 'z'; const char z = 'z';
Assert.That(*CSharp.CSharp.TakeConstCharRef(z), Is.EqualTo(z)); Assert.That(*CSharp.CSharpCool.TakeConstCharRef(z), Is.EqualTo(z));
} }
[Test] [Test]
public void TestTakeCharPointer() public void TestTakeCharPointer()
{ {
char c = 'c'; char c = 'c';
Assert.That(*CSharp.CSharp.TakeCharPointer(&c), Is.EqualTo(c)); Assert.That(*CSharp.CSharpCool.TakeCharPointer(&c), Is.EqualTo(c));
} }
[Test] [Test]
@ -346,16 +346,16 @@ public unsafe class CSharpTests
methodsWithDefaultValues.DefaultOverloadedImplicitCtor(); methodsWithDefaultValues.DefaultOverloadedImplicitCtor();
methodsWithDefaultValues.DefaultWithParamNamedSameAsMethod(5); methodsWithDefaultValues.DefaultWithParamNamedSameAsMethod(5);
Assert.That(methodsWithDefaultValues.DefaultIntAssignedAnEnumWithBinaryOperatorAndFlags(), Is.EqualTo((int)(Bar.Items.Item1 | Bar.Items.Item2))); Assert.That(methodsWithDefaultValues.DefaultIntAssignedAnEnumWithBinaryOperatorAndFlags(), Is.EqualTo((int)(Bar.Items.Item1 | Bar.Items.Item2)));
Assert.That(methodsWithDefaultValues.DefaultWithConstantFlags(), Is.EqualTo(CSharp.CSharp.ConstFlag1 | CSharp.CSharp.ConstFlag2 | CSharp.CSharp.ConstFlag3)); Assert.That(methodsWithDefaultValues.DefaultWithConstantFlags(), Is.EqualTo(CSharp.CSharpCool.ConstFlag1 | CSharp.CSharpCool.ConstFlag2 | CSharp.CSharpCool.ConstFlag3));
Assert.IsTrue(methodsWithDefaultValues.DefaultWithPointerToEnum()); Assert.IsTrue(methodsWithDefaultValues.DefaultWithPointerToEnum());
Assert.AreEqual(CSharp.CSharp.DefaultSmallPODInstance.__Instance, methodsWithDefaultValues.DefaultWithNonPrimitiveType().__Instance); Assert.AreEqual(CSharp.CSharpCool.DefaultSmallPODInstance.__Instance, methodsWithDefaultValues.DefaultWithNonPrimitiveType().__Instance);
} }
} }
[Test] [Test]
public void TestGenerationOfAnotherUnitInSameFile() public void TestGenerationOfAnotherUnitInSameFile()
{ {
AnotherUnit.FunctionInAnotherUnit(); AnotherUnitCool.FunctionInAnotherUnit();
} }
[Test] [Test]
@ -710,9 +710,9 @@ public unsafe class CSharpTests
public void TestReferenceToArrayWithConstSize() public void TestReferenceToArrayWithConstSize()
{ {
int[] incorrectlySizedArray = { 1 }; int[] incorrectlySizedArray = { 1 };
Assert.Catch<ArgumentOutOfRangeException>(() => CSharp.CSharp.PassConstantArrayRef(incorrectlySizedArray)); Assert.Catch<ArgumentOutOfRangeException>(() => CSharp.CSharpCool.PassConstantArrayRef(incorrectlySizedArray));
int[] array = { 1, 2 }; int[] array = { 1, 2 };
var result = CSharp.CSharp.PassConstantArrayRef(array); var result = CSharp.CSharpCool.PassConstantArrayRef(array);
Assert.That(result, Is.EqualTo(array[0])); Assert.That(result, Is.EqualTo(array[0]));
} }
@ -782,9 +782,9 @@ public unsafe class CSharpTests
[Test] [Test]
public void TestStdStringConstant() public void TestStdStringConstant()
{ {
Assert.That(CSharp.HasFreeConstant.AnotherUnit.STD_STRING_CONSTANT, Is.EqualTo("test")); Assert.That(CSharp.HasFreeConstant.AnotherUnitCool.STD_STRING_CONSTANT, Is.EqualTo("test"));
// check a second time to ensure it hasn't been improperly freed // check a second time to ensure it hasn't been improperly freed
Assert.That(CSharp.HasFreeConstant.AnotherUnit.STD_STRING_CONSTANT, Is.EqualTo("test")); Assert.That(CSharp.HasFreeConstant.AnotherUnitCool.STD_STRING_CONSTANT, Is.EqualTo("test"));
} }
[Test] [Test]
@ -842,10 +842,10 @@ public unsafe class CSharpTests
} }
foreach (var (type, offsets) in new (Type, uint[])[] { foreach (var (type, offsets) in new (Type, uint[])[] {
(typeof(ClassCustomTypeAlignment), CSharp.CSharp.ClassCustomTypeAlignmentOffsets), (typeof(ClassCustomTypeAlignment), CSharp.CSharpCool.ClassCustomTypeAlignmentOffsets),
(typeof(ClassCustomObjectAlignment), CSharp.CSharp.ClassCustomObjectAlignmentOffsets), (typeof(ClassCustomObjectAlignment), CSharp.CSharpCool.ClassCustomObjectAlignmentOffsets),
(typeof(ClassMicrosoftObjectAlignment), CSharp.CSharp.ClassMicrosoftObjectAlignmentOffsets), (typeof(ClassMicrosoftObjectAlignment), CSharp.CSharpCool.ClassMicrosoftObjectAlignmentOffsets),
(typeof(StructWithEmbeddedArrayOfStructObjectAlignment), CSharp.CSharp.StructWithEmbeddedArrayOfStructObjectAlignmentOffsets), (typeof(StructWithEmbeddedArrayOfStructObjectAlignment), CSharp.CSharpCool.StructWithEmbeddedArrayOfStructObjectAlignmentOffsets),
}) })
{ {
var internalType = type.GetNestedType("__Internal"); var internalType = type.GetNestedType("__Internal");
@ -884,10 +884,10 @@ public unsafe class CSharpTests
[Test] [Test]
public void TestConstantArray() public void TestConstantArray()
{ {
Assert.That(CSharp.CSharp.VariableWithFixedPrimitiveArray[0], Is.EqualTo(5)); Assert.That(CSharp.CSharpCool.VariableWithFixedPrimitiveArray[0], Is.EqualTo(5));
Assert.That(CSharp.CSharp.VariableWithFixedPrimitiveArray[1], Is.EqualTo(10)); Assert.That(CSharp.CSharpCool.VariableWithFixedPrimitiveArray[1], Is.EqualTo(10));
Assert.That(CSharp.CSharp.VariableWithVariablePrimitiveArray[0], Is.EqualTo(15)); Assert.That(CSharp.CSharpCool.VariableWithVariablePrimitiveArray[0], Is.EqualTo(15));
Assert.That(CSharp.CSharp.VariableWithVariablePrimitiveArray[1], Is.EqualTo(20)); Assert.That(CSharp.CSharpCool.VariableWithVariablePrimitiveArray[1], Is.EqualTo(20));
} }
[Test] [Test]
@ -1489,17 +1489,17 @@ public unsafe class CSharpTests
[Test] [Test]
public void TestGenerationOfIncompleteClasses() public void TestGenerationOfIncompleteClasses()
{ {
var incompleteStruct = CSharp.CSharp.CreateIncompleteStruct(); var incompleteStruct = CSharp.CSharpCool.CreateIncompleteStruct();
Assert.IsNotNull(incompleteStruct); Assert.IsNotNull(incompleteStruct);
Assert.DoesNotThrow(() => CSharp.CSharp.UseIncompleteStruct(incompleteStruct)); Assert.DoesNotThrow(() => CSharp.CSharpCool.UseIncompleteStruct(incompleteStruct));
} }
[Test] [Test]
public void TestForwardDeclaredStruct() public void TestForwardDeclaredStruct()
{ {
using (var forwardDeclaredStruct = CSharp.CSharp.CreateForwardDeclaredStruct(10)) using (var forwardDeclaredStruct = CSharp.CSharpCool.CreateForwardDeclaredStruct(10))
{ {
var i = CSharp.CSharp.UseForwardDeclaredStruct(forwardDeclaredStruct); var i = CSharp.CSharpCool.UseForwardDeclaredStruct(forwardDeclaredStruct);
Assert.AreEqual(forwardDeclaredStruct.I, i); Assert.AreEqual(forwardDeclaredStruct.I, i);
} }
} }
@ -1507,8 +1507,8 @@ public unsafe class CSharpTests
[Test, Ignore("The Linux CI (alone) failes to generate these functions.")] [Test, Ignore("The Linux CI (alone) failes to generate these functions.")]
public void TestDuplicateDeclaredIncompleteStruct() public void TestDuplicateDeclaredIncompleteStruct()
{ {
//var duplicateDeclaredIncompleteStruct = CSharp.CSharp.CreateDuplicateDeclaredStruct(10); //var duplicateDeclaredIncompleteStruct = CSharp.CSharpCool.CreateDuplicateDeclaredStruct(10);
//var i = CSharp.CSharp.UseDuplicateDeclaredStruct(duplicateDeclaredIncompleteStruct); //var i = CSharp.CSharpCool.UseDuplicateDeclaredStruct(duplicateDeclaredIncompleteStruct);
//Assert.AreEqual(10, i); //Assert.AreEqual(10, i);
} }
@ -1684,7 +1684,7 @@ public unsafe class CSharpTests
public void TestFuncWithTypedefedFuncPtrAsParam() public void TestFuncWithTypedefedFuncPtrAsParam()
{ {
TypedefedFuncPtr function = (a, b) => 5; TypedefedFuncPtr function = (a, b) => 5;
Assert.That(CSharp.CSharp.FuncWithTypedefedFuncPtrAsParam(function), Is.EqualTo(5)); Assert.That(CSharp.CSharpCool.FuncWithTypedefedFuncPtrAsParam(function), Is.EqualTo(5));
} }
[Test] [Test]
@ -1769,14 +1769,14 @@ public unsafe class CSharpTests
[Test] [Test]
public void TestConstCharStarRef() public void TestConstCharStarRef()
{ {
Assert.That(CSharp.CSharp.TakeConstCharStarRef("Test"), Is.EqualTo("Test")); Assert.That(CSharp.CSharpCool.TakeConstCharStarRef("Test"), Is.EqualTo("Test"));
} }
[Test] [Test]
public void TestRValueReferenceToPointer() public void TestRValueReferenceToPointer()
{ {
int value = 5; int value = 5;
IntPtr intPtr = CSharp.CSharp.RValueReferenceToPointer((IntPtr*)&value); IntPtr intPtr = CSharp.CSharpCool.RValueReferenceToPointer((IntPtr*)&value);
Assert.That((int)intPtr, Is.EqualTo(value)); Assert.That((int)intPtr, Is.EqualTo(value));
} }
@ -1785,7 +1785,7 @@ public unsafe class CSharpTests
{ {
using (Foo foo = new Foo { A = 25 }) using (Foo foo = new Foo { A = 25 })
{ {
Foo returnedFoo = CSharp.CSharp.TakeReturnReferenceToPointer(foo); Foo returnedFoo = CSharp.CSharpCool.TakeReturnReferenceToPointer(foo);
Assert.That(returnedFoo.A, Is.EqualTo(foo.A)); Assert.That(returnedFoo.A, Is.EqualTo(foo.A));
using (Qux qux = new Qux()) using (Qux qux = new Qux())
{ {
@ -1832,7 +1832,7 @@ public unsafe class CSharpTests
[Test] [Test]
public void TestTypemapTypedefParam() public void TestTypemapTypedefParam()
{ {
Assert.That(CSharp.CSharp.TakeTypemapTypedefParam(false), Is.False); Assert.That(CSharp.CSharpCool.TakeTypemapTypedefParam(false), Is.False);
} }
[Test] [Test]
@ -1866,13 +1866,13 @@ public unsafe class CSharpTests
foreach (var @string in strings) foreach (var @string in strings)
{ {
var cs = @string; var cs = @string;
Assert.That(CSharp.CSharp.TestCSharpString(cs, out var @out), Is.EqualTo(cs)); Assert.That(CSharp.CSharpCool.TestCSharpString(cs, out var @out), Is.EqualTo(cs));
Assert.That(@out, Is.EqualTo(cs)); Assert.That(@out, Is.EqualTo(cs));
Assert.That(CSharp.CSharp.TestCSharpStringWide(cs, out var outWide), Is.EqualTo(cs)); Assert.That(CSharp.CSharpCool.TestCSharpStringWide(cs, out var outWide), Is.EqualTo(cs));
Assert.That(outWide, Is.EqualTo(cs)); Assert.That(outWide, Is.EqualTo(cs));
Assert.That(CSharp.CSharp.TestCSharpString16(cs, out var out16), Is.EqualTo(cs)); Assert.That(CSharp.CSharpCool.TestCSharpString16(cs, out var out16), Is.EqualTo(cs));
Assert.That(out16, Is.EqualTo(cs)); Assert.That(out16, Is.EqualTo(cs));
Assert.That(CSharp.CSharp.TestCSharpString32(cs, out var out32), Is.EqualTo(cs)); Assert.That(CSharp.CSharpCool.TestCSharpString32(cs, out var out32), Is.EqualTo(cs));
Assert.That(out32, Is.EqualTo(cs)); Assert.That(out32, Is.EqualTo(cs));
} }
} }
@ -1890,11 +1890,11 @@ public unsafe class CSharpTests
[Test] [Test]
public void TestFunctionToStaticMethod() public void TestFunctionToStaticMethod()
{ {
Assert.That(CSharp.CSharp.TestFunctionToStaticMethod(new FTIStruct()).A, Is.EqualTo(6)); Assert.That(CSharp.CSharpCool.TestFunctionToStaticMethod(new FTIStruct()).A, Is.EqualTo(6));
Assert.That(CSharp.CSharp.TestFunctionToStaticMethodStruct(new FTIStruct(), new FTIStruct() { A = 6 }), Is.EqualTo(6)); Assert.That(CSharp.CSharpCool.TestFunctionToStaticMethodStruct(new FTIStruct(), new FTIStruct() { A = 6 }), Is.EqualTo(6));
Assert.That(CSharp.CSharp.TestFunctionToStaticMethodRefStruct(new FTIStruct(), new FTIStruct() { A = 6 }), Is.EqualTo(6)); Assert.That(CSharp.CSharpCool.TestFunctionToStaticMethodRefStruct(new FTIStruct(), new FTIStruct() { A = 6 }), Is.EqualTo(6));
Assert.That(CSharp.CSharp.TestFunctionToStaticMethodConstStruct(new FTIStruct(), new FTIStruct() { A = 6 }), Is.EqualTo(6)); Assert.That(CSharp.CSharpCool.TestFunctionToStaticMethodConstStruct(new FTIStruct(), new FTIStruct() { A = 6 }), Is.EqualTo(6));
Assert.That(CSharp.CSharp.TestFunctionToStaticMethodConstRefStruct(new FTIStruct(), new FTIStruct() { A = 6 }), Is.EqualTo(6)); Assert.That(CSharp.CSharpCool.TestFunctionToStaticMethodConstRefStruct(new FTIStruct(), new FTIStruct() { A = 6 }), Is.EqualTo(6));
} }
[Test] [Test]
@ -1914,9 +1914,9 @@ public unsafe class CSharpTests
[Test] [Test]
public void TestFunctionTemplate() public void TestFunctionTemplate()
{ {
Assert.That(CSharpTemplates.FunctionTemplate(5.0), Is.EqualTo(5 + 4.2)); Assert.That(CSharpTemplatesCool.FunctionTemplate(5.0), Is.EqualTo(5 + 4.2));
Assert.That(CSharpTemplates.FunctionTemplate(6f), Is.EqualTo(6 + 4.1f)); Assert.That(CSharpTemplatesCool.FunctionTemplate(6f), Is.EqualTo(6 + 4.1f));
Assert.That(CSharpTemplates.FunctionTemplate(7), Is.EqualTo(7 + 4)); Assert.That(CSharpTemplatesCool.FunctionTemplate(7), Is.EqualTo(7 + 4));
} }
[Test] [Test]
@ -1926,11 +1926,11 @@ public unsafe class CSharpTests
var backup = myclass; var backup = myclass;
myclass.Value = 7; myclass.Value = 7;
CSharp.CSharp.ModifyCore(ref myclass); CSharp.CSharpCool.ModifyCore(ref myclass);
Assert.That(myclass.Value, Is.EqualTo(10)); Assert.That(myclass.Value, Is.EqualTo(10));
Assert.That(myclass, Is.SameAs(myclass)); Assert.That(myclass, Is.SameAs(myclass));
CSharp.CSharp.CreateCore(ref myclass); CSharp.CSharpCool.CreateCore(ref myclass);
Assert.That(myclass.Value, Is.EqualTo(20)); Assert.That(myclass.Value, Is.EqualTo(20));
Assert.That(myclass, Is.Not.SameAs(backup)); Assert.That(myclass, Is.Not.SameAs(backup));
} }
@ -1954,7 +1954,7 @@ public unsafe class CSharpTests
{ {
RuleOfThreeTester.Reset(); RuleOfThreeTester.Reset();
CallByValueInterface @interface = new CallByValueInterfaceImpl(); CallByValueInterface @interface = new CallByValueInterfaceImpl();
CSharp.CSharp.CallCallByValueInterfaceValue(@interface); CSharp.CSharpCool.CallCallByValueInterfaceValue(@interface);
Assert.That(RuleOfThreeTester.ConstructorCalls, Is.EqualTo(1)); Assert.That(RuleOfThreeTester.ConstructorCalls, Is.EqualTo(1));
Assert.That(RuleOfThreeTester.DestructorCalls, Is.EqualTo(2)); Assert.That(RuleOfThreeTester.DestructorCalls, Is.EqualTo(2));
@ -1967,7 +1967,7 @@ public unsafe class CSharpTests
{ {
RuleOfThreeTester.Reset(); RuleOfThreeTester.Reset();
CallByValueInterface @interface = new CallByValueInterfaceImpl(); CallByValueInterface @interface = new CallByValueInterfaceImpl();
CSharp.CSharp.CallCallByValueInterfaceReference(@interface); CSharp.CSharpCool.CallCallByValueInterfaceReference(@interface);
Assert.That(RuleOfThreeTester.ConstructorCalls, Is.EqualTo(1)); Assert.That(RuleOfThreeTester.ConstructorCalls, Is.EqualTo(1));
Assert.That(RuleOfThreeTester.DestructorCalls, Is.EqualTo(1)); Assert.That(RuleOfThreeTester.DestructorCalls, Is.EqualTo(1));
@ -1980,7 +1980,7 @@ public unsafe class CSharpTests
{ {
RuleOfThreeTester.Reset(); RuleOfThreeTester.Reset();
CallByValueInterface @interface = new CallByValueInterfaceImpl(); CallByValueInterface @interface = new CallByValueInterfaceImpl();
CSharp.CSharp.CallCallByValueInterfacePointer(@interface); CSharp.CSharpCool.CallCallByValueInterfacePointer(@interface);
Assert.That(RuleOfThreeTester.ConstructorCalls, Is.EqualTo(1)); Assert.That(RuleOfThreeTester.ConstructorCalls, Is.EqualTo(1));
Assert.That(RuleOfThreeTester.DestructorCalls, Is.EqualTo(1)); Assert.That(RuleOfThreeTester.DestructorCalls, Is.EqualTo(1));
@ -1991,14 +1991,14 @@ public unsafe class CSharpTests
[Test] [Test]
public void TestPointerToClass() public void TestPointerToClass()
{ {
Assert.IsTrue(CSharp.CSharp.PointerToClass.IsDefaultInstance); Assert.IsTrue(CSharp.CSharpCool.PointerToClass.IsDefaultInstance);
Assert.IsTrue(CSharp.CSharp.PointerToClass.IsValid); Assert.IsTrue(CSharp.CSharpCool.PointerToClass.IsValid);
} }
[Test] [Test]
public void TestValueTypeOutParameter() public void TestValueTypeOutParameter()
{ {
Assert.AreEqual(2, CSharp.CSharp.ValueTypeOutParameter(out var unionTestA, out var unionTestB)); Assert.AreEqual(2, CSharp.CSharpCool.ValueTypeOutParameter(out var unionTestA, out var unionTestB));
Assert.AreEqual(2, unionTestA.A); Assert.AreEqual(2, unionTestA.A);
Assert.AreEqual(2, unionTestB.B); Assert.AreEqual(2, unionTestB.B);
} }