Tests: Add new test assemblies for C# features (#36)
* Add new test assemblies for C# features Three of these test assemblies go over several important features of C#, organized by C# language version. PartialGenericTypes stresses closed and partially closed generics. Finally, VTablesAndLayout tests the layout of classes when translated to C++, and also contains code which calls vtable and interface functions to test reverse engineering. * Tests: Update .csproj * Tests: Update .csproj Co-authored-by: Katy Coe <djkaty@users.noreply.github.com>
This commit is contained in:
57
Il2CppTests/TestSources/CSharp1.cs
Normal file
57
Il2CppTests/TestSources/CSharp1.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
|
||||
/* C# 1.0 feature test */
|
||||
namespace Il2CppTests.TestSources
|
||||
{
|
||||
public class SimpleClass : SimpleInterface
|
||||
{
|
||||
public SimpleStruct ss;
|
||||
public int i;
|
||||
|
||||
public static SimpleStruct StaticFunc(SimpleStruct ss) {
|
||||
Console.WriteLine(ss);
|
||||
return new SimpleStruct();
|
||||
}
|
||||
|
||||
public SimpleStruct InstanceFunc(SimpleStruct ss) {
|
||||
Console.WriteLine(ss);
|
||||
return this.ss;
|
||||
}
|
||||
|
||||
public int func(int val) {
|
||||
return val + 42;
|
||||
}
|
||||
|
||||
public delegate SimpleStruct SimpleDelegate(SimpleStruct ss);
|
||||
public event SimpleDelegate SimpleEvent;
|
||||
public int SimpleProperty {
|
||||
get { return 0; }
|
||||
set { SimpleEvent(ss); }
|
||||
}
|
||||
}
|
||||
|
||||
public struct SimpleStruct : SimpleInterface
|
||||
{
|
||||
public SimpleClass sc;
|
||||
public int i;
|
||||
|
||||
public static SimpleStruct StaticFunc(SimpleStruct ss) {
|
||||
Console.WriteLine(ss);
|
||||
return new SimpleStruct();
|
||||
}
|
||||
|
||||
public SimpleClass InstanceFunc(SimpleStruct ss) {
|
||||
Console.WriteLine(ss);
|
||||
return this.sc;
|
||||
}
|
||||
|
||||
public int func(int val) {
|
||||
return ((SimpleInterface)sc).func(val) + 13;
|
||||
}
|
||||
}
|
||||
|
||||
public interface SimpleInterface
|
||||
{
|
||||
int func(int val);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user