14
14
15
15
namespace UnityExplorer . Tests
16
16
{
17
- public struct TestValueStruct
18
- {
19
- public const object TestIgnoreThis = null ;
20
- public const string TestIgnoreButValid = "" ;
21
-
22
- public string aString ;
23
- public int anInt ;
24
- public float aFloat ;
25
- public bool aBool ;
26
- public Vector3 AVector3 ;
27
- public Vector4 aVector4 ;
28
- public DateTime aDateTime ;
29
- public Color32 aColor32 ;
30
- public CameraClearFlags clearFlags ;
31
- }
32
-
33
- public enum TestEnum : long
34
- {
35
- Neg50 = - 50 ,
36
- Neg1 = - 1 ,
37
- Zero = 0 ,
38
- One = 1 ,
39
- Pos49 = 49 ,
40
- Implicit50 ,
41
- Also50 = 50 ,
42
- AlsoAlso50 = 50 ,
43
- } ;
44
- public enum TestEnum2 : ulong
45
- {
46
- Min = ulong . MinValue ,
47
- Max = ulong . MaxValue
48
- }
49
- [ Flags ]
50
- public enum TestFlags : int
51
- {
52
- All = - 1 ,
53
- Zero = 0 ,
54
- Ok = 1 ,
55
- Two = 2 ,
56
- Three = 4 ,
57
- Four = 8 ,
58
- Five = 16 ,
59
- Six = 32 ,
60
- Seven = 64 ,
61
- Thirteen = Six | Seven ,
62
- Fifteen = Four | Five | Six ,
63
- }
64
-
65
17
public static class TestClass
66
18
{
67
19
public static void ATestMethod ( string s , float f , Vector3 vector , DateTime date , Quaternion quater , bool b , CameraClearFlags enumvalue )
68
20
{
69
21
ExplorerCore . Log ( $ "{ s } , { f } , { vector . ToString ( ) } , { date } , { quater . eulerAngles . ToString ( ) } , { b } , { enumvalue } ") ;
70
22
}
71
23
72
- public static TestValueStruct AATestStruct ;
73
-
74
- public static string AAATooLongString = new string ( '#' , UIManager . MAX_INPUTFIELD_CHARS + 2 ) ;
75
- public static string AAAMaxString = new string ( '@' , UIManager . MAX_INPUTFIELD_CHARS ) ;
76
-
77
- public static TestEnum AATestEnumOne = TestEnum . Neg50 ;
78
- public static TestEnum2 AATestEnumTwo = TestEnum2 . Max ;
79
- public static TestFlags AATestFlags = TestFlags . Thirteen ;
80
- public static BindingFlags AATestbinding ;
81
- public static HideFlags AAHideFlags ;
82
-
83
24
public static List < int > AWritableList = new List < int > { 1 , 2 , 3 , 4 , 5 } ;
84
25
public static Dictionary < string , int > AWritableDict = new Dictionary < string , int > { { "one" , 1 } , { "two" , 2 } } ;
85
26
@@ -121,7 +62,7 @@ public static void ATestMethod(string s, float f, Vector3 vector, DateTime date,
121
62
}
122
63
} ;
123
64
124
- public static IDictionary DictTest = new Dictionary < object , object >
65
+ public static IDictionary ARandomDictionary = new Dictionary < object , object >
125
66
{
126
67
{ 1 , 2 } ,
127
68
{ "one" , "two" } ,
@@ -132,6 +73,13 @@ public static void ATestMethod(string s, float f, Vector3 vector, DateTime date,
132
73
{ "subdict" , new Dictionary < object , object > { { "key" , "value" } } }
133
74
} ;
134
75
76
+ public static Hashtable TestHashtable = new Hashtable
77
+ {
78
+ { "one" , "value" } ,
79
+ { "two" , "value" } ,
80
+ { "three" , "value" } ,
81
+ } ;
82
+
135
83
public const int ConstantInt = 5 ;
136
84
137
85
public static Color AColor = Color . magenta ;
@@ -194,17 +142,23 @@ private static object GetRandomObject()
194
142
195
143
#if CPP
196
144
197
- public static Il2CppSystem . Collections . IList AAAAAAACppList ;
145
+ public static Il2CppSystem . Collections . IList IL2CPP_IList ;
146
+ public static Il2CppSystem . Collections . Generic . List < string > IL2CPP_ListString ;
147
+ public static Il2CppSystem . Collections . Generic . HashSet < string > IL2CPP_HashSet ;
148
+
149
+ public static Il2CppSystem . Collections . Generic . Dictionary < string , string > IL2CPP_Dict ;
150
+ public static Il2CppSystem . Collections . Hashtable IL2CPP_HashTable ;
151
+ public static Il2CppSystem . Collections . IDictionary IL2CPP_IDict ;
198
152
199
- public static string testStringOne = "Test" ;
200
- public static Il2CppSystem . Object testStringTwo = "string boxed as cpp object" ;
201
- public static Il2CppSystem . String testStringThree = "string boxed as cpp string" ;
153
+ public static string IL2CPP_systemString = "Test" ;
154
+ public static Il2CppSystem . Object IL2CPP_objectString = "string boxed as cpp object" ;
155
+ public static Il2CppSystem . String IL2CPP_il2cppString = "string boxed as cpp string" ;
202
156
public static string nullString = null ;
203
157
204
- public static List < Il2CppSystem . Object > CppBoxedList ;
205
- public static Il2CppStructArray < int > CppIntStructArray ;
206
- public static Il2CppStringArray CppStringArray ;
207
- public static Il2CppReferenceArray < Il2CppSystem . Object > CppReferenceArray ;
158
+ public static List < Il2CppSystem . Object > IL2CPP_listOfBoxedObjects ;
159
+ public static Il2CppStructArray < int > IL2CPP_structArray ;
160
+ public static Il2CppStringArray IL2CPP_stringArray ;
161
+ public static Il2CppReferenceArray < Il2CppSystem . Object > IL2CPP_ReferenceArray ;
208
162
209
163
public static Il2CppSystem . Object cppBoxedInt ;
210
164
public static Il2CppSystem . Int32 cppInt ;
@@ -239,10 +193,32 @@ static TestClass()
239
193
BigList . Add ( i . ToString ( ) ) ;
240
194
241
195
#if CPP
196
+ IL2CPP_Dict = new Il2CppSystem . Collections . Generic . Dictionary < string , string > ( ) ;
197
+ IL2CPP_Dict . Add ( "key1" , "value1" ) ;
198
+ IL2CPP_Dict . Add ( "key2" , "value2" ) ;
199
+ IL2CPP_Dict . Add ( "key3" , "value3" ) ;
200
+
201
+ IL2CPP_HashTable = new Il2CppSystem . Collections . Hashtable ( ) ;
202
+ IL2CPP_HashTable . Add ( "key1" , "value1" ) ;
203
+ IL2CPP_HashTable . Add ( "key2" , "value2" ) ;
204
+ IL2CPP_HashTable . Add ( "key3" , "value3" ) ;
205
+
206
+ var dict2 = new Il2CppSystem . Collections . Generic . Dictionary < string , string > ( ) ;
207
+ dict2 . Add ( "key1" , "value1" ) ;
208
+ IL2CPP_IDict = dict2 . TryCast < Il2CppSystem . Collections . IDictionary > ( ) ;
209
+
242
210
var list = new Il2CppSystem . Collections . Generic . List < Il2CppSystem . Object > ( 5 ) ;
243
211
list . Add ( "one" ) ;
244
212
list . Add ( "two" ) ;
245
- AAAAAAACppList = list . TryCast < Il2CppSystem . Collections . IList > ( ) ;
213
+ IL2CPP_IList = list . TryCast < Il2CppSystem . Collections . IList > ( ) ;
214
+
215
+ IL2CPP_ListString = new Il2CppSystem . Collections . Generic . List < string > ( ) ;
216
+ IL2CPP_ListString . Add ( "hello," ) ;
217
+ IL2CPP_ListString . Add ( "world!" ) ;
218
+
219
+ IL2CPP_HashSet = new Il2CppSystem . Collections . Generic . HashSet < string > ( ) ;
220
+ IL2CPP_HashSet . Add ( "one" ) ;
221
+ IL2CPP_HashSet . Add ( "two" ) ;
246
222
247
223
CppBoxedDict = new Dictionary < Il2CppSystem . String , Il2CppSystem . Object > ( ) ;
248
224
CppBoxedDict . Add ( "1" , new Il2CppSystem . Int32 { m_value = 1 } . BoxIl2CppObject ( ) ) ;
@@ -255,44 +231,44 @@ static TestClass()
255
231
cppVector3Boxed = Vector3 . down . BoxIl2CppObject ( ) ;
256
232
257
233
258
- CppBoxedList = new List < Il2CppSystem . Object > ( ) ;
259
- CppBoxedList . Add ( ( Il2CppSystem . String ) "boxedString" ) ;
260
- CppBoxedList . Add ( new Il2CppSystem . Int32 { m_value = 5 } . BoxIl2CppObject ( ) ) ;
261
- CppBoxedList . Add ( Color . red . BoxIl2CppObject ( ) ) ;
234
+ IL2CPP_listOfBoxedObjects = new List < Il2CppSystem . Object > ( ) ;
235
+ IL2CPP_listOfBoxedObjects . Add ( ( Il2CppSystem . String ) "boxedString" ) ;
236
+ IL2CPP_listOfBoxedObjects . Add ( new Il2CppSystem . Int32 { m_value = 5 } . BoxIl2CppObject ( ) ) ;
237
+ IL2CPP_listOfBoxedObjects . Add ( Color . red . BoxIl2CppObject ( ) ) ;
262
238
263
239
try
264
240
{
265
241
var cppType = Il2CppType . Of < CameraClearFlags > ( ) ;
266
242
if ( cppType != null )
267
243
{
268
244
var boxedEnum = Il2CppSystem . Enum . Parse ( cppType , "Color" ) ;
269
- CppBoxedList . Add ( boxedEnum ) ;
245
+ IL2CPP_listOfBoxedObjects . Add ( boxedEnum ) ;
270
246
}
271
247
272
248
var structBox = Vector3 . one . BoxIl2CppObject ( ) ;
273
- CppBoxedList . Add ( structBox ) ;
249
+ IL2CPP_listOfBoxedObjects . Add ( structBox ) ;
274
250
275
251
}
276
252
catch ( Exception ex )
277
253
{
278
254
ExplorerCore . LogWarning ( $ "Test fail: { ex } ") ;
279
255
}
280
256
281
- CppIntStructArray = new UnhollowerBaseLib . Il2CppStructArray < int > ( 5 ) ;
282
- CppIntStructArray [ 0 ] = 0 ;
283
- CppIntStructArray [ 1 ] = 1 ;
284
- CppIntStructArray [ 2 ] = 2 ;
285
- CppIntStructArray [ 3 ] = 3 ;
286
- CppIntStructArray [ 4 ] = 4 ;
287
-
288
- CppStringArray = new UnhollowerBaseLib . Il2CppStringArray ( 2 ) ;
289
- CppStringArray [ 0 ] = "hello, " ;
290
- CppStringArray [ 1 ] = "world!" ;
291
-
292
- CppReferenceArray = new UnhollowerBaseLib . Il2CppReferenceArray < Il2CppSystem . Object > ( 3 ) ;
293
- CppReferenceArray [ 0 ] = new Il2CppSystem . Int32 { m_value = 5 } . BoxIl2CppObject ( ) ;
294
- CppReferenceArray [ 1 ] = null ;
295
- CppReferenceArray [ 2 ] = ( Il2CppSystem . String ) "whats up" ;
257
+ IL2CPP_structArray = new UnhollowerBaseLib . Il2CppStructArray < int > ( 5 ) ;
258
+ IL2CPP_structArray [ 0 ] = 0 ;
259
+ IL2CPP_structArray [ 1 ] = 1 ;
260
+ IL2CPP_structArray [ 2 ] = 2 ;
261
+ IL2CPP_structArray [ 3 ] = 3 ;
262
+ IL2CPP_structArray [ 4 ] = 4 ;
263
+
264
+ IL2CPP_stringArray = new UnhollowerBaseLib . Il2CppStringArray ( 2 ) ;
265
+ IL2CPP_stringArray [ 0 ] = "hello, " ;
266
+ IL2CPP_stringArray [ 1 ] = "world!" ;
267
+
268
+ IL2CPP_ReferenceArray = new UnhollowerBaseLib . Il2CppReferenceArray < Il2CppSystem . Object > ( 3 ) ;
269
+ IL2CPP_ReferenceArray [ 0 ] = new Il2CppSystem . Int32 { m_value = 5 } . BoxIl2CppObject ( ) ;
270
+ IL2CPP_ReferenceArray [ 1 ] = null ;
271
+ IL2CPP_ReferenceArray [ 2 ] = ( Il2CppSystem . String ) "whats up" ;
296
272
297
273
cppBoxedInt = new Il2CppSystem . Int32 ( ) { m_value = 5 } . BoxIl2CppObject ( ) ;
298
274
cppInt = new Il2CppSystem . Int32 { m_value = 420 } ;
0 commit comments