using System.Collections; using System.Collections.Generic; using System; using UnityEngine; using System.Reflection; using System.Runtime.InteropServices; #if CPP using UnhollowerBaseLib; using UnityEngine.SceneManagement; #endif namespace Explorer.Tests { public static class StaticTestClass { public static int StaticProperty => 5; public static int StaticField = 69; public static List StaticList = new List { "one", "two", "three", }; public static void StaticMethod() { } } public class TestClass { public static TestClass Instance => m_instance ?? (m_instance = new TestClass()); private static TestClass m_instance; public static int StaticProperty => 5; public static int StaticField = 5; public int NonStaticField; #if CPP public static IntPtr FindICall(string name) => il2cpp_resolve_icall(name); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] private static extern IntPtr il2cpp_resolve_icall([MarshalAs(UnmanagedType.LPStr)] string name); #endif #if CPP public static Il2CppSystem.Collections.Generic.HashSet ILHashSetTest; #endif public TestClass() { #if CPP ILHashSetTest = new Il2CppSystem.Collections.Generic.HashSet(); ILHashSetTest.Add("1"); ILHashSetTest.Add("2"); ILHashSetTest.Add("3"); #endif } public static string TestRefInOutGeneric(ref string arg0, in int arg1, out string arg2) { arg2 = "this is arg2"; return $"T: '{typeof(T).FullName}', ref arg0: '{arg0}', in arg1: '{arg1}', out arg2: '{arg2}'"; } // test a non-generic dictionary public Hashtable TestNonGenericDict() { return new Hashtable { { "One", 1 }, { "Two", 2 }, { "Three", 3 }, }; } // test HashSets public static HashSet HashSetTest = new HashSet { "One", "Two", "Three" }; // Test indexed parameter public string this[int arg0, string arg1] { get { return $"arg0: {arg0}, arg1: {arg1}"; } } // Test basic list public static List TestList = new List { "1", "2", "3", "etc..." }; // Test a nested dictionary public static Dictionary> NestedDictionary = new Dictionary> { { 1, new Dictionary { { "Sub 1", 123 }, { "Sub 2", 456 }, } }, { 2, new Dictionary { { "Sub 3", 789 }, { "Sub 4", 000 }, } }, }; // Test a basic method public static Color TestMethod(float r, float g, float b, float a) { return new Color(r, g, b, a); } // A method with default arguments public static Vector3 TestDefaultArgs(float arg0, float arg1, float arg2 = 5.0f) { return new Vector3(arg0, arg1, arg2); } } }