-
Notifications
You must be signed in to change notification settings - Fork 659
/
Copy pathCLRBindingTest.cs
182 lines (155 loc) · 5.62 KB
/
CLRBindingTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
using ILRuntime.Runtime.CLRBinding;
using ILRuntime.Runtime.Intepreter;
using ILRuntimeTest;
using ILRuntimeTest.TestFramework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace TestCases
{
class CLRBindingTest
{
public static void CLRBindingTest01()
{
byte[] mAllMissionData = new byte[10];
int missionID = 2;
ILRuntimeTest.TestFramework.TestClass3.setBit(ref mAllMissionData[(missionID - 1) >> 2], (missionID - 1) & 3, 1);
}
public static void CLRBindingTest02()
{
int[][] val = new int[10][];
ILRuntimeTest.TestBase.StaticGenericMethods.ArrayMethod(val);
}
public static void CLRBindingTest03()
{
int[][][] val = new int[10][][];
ILRuntimeTest.TestBase.StaticGenericMethods.ArrayMethod(val);
}
public static void CLRBindingTest04()
{
ILRuntimeTest.TestBase.TestSession.LastSession.Appdomain.AllowUnboundCLRMethod = false;
}
public static void CLRBindingTest05()
{
ILRuntimeTest.TestFramework.TestCLRBinding binding = new ILRuntimeTest.TestFramework.TestCLRBinding();
binding.Emit(binding);
}
public static void CLRBindingTest06()
{
ILRuntimeTest.TestFramework.TestCLRBinding binding = new ILRuntimeTest.TestFramework.TestCLRBinding();
CLRBindingTest06Sub(binding, binding);
}
static void CLRBindingTest06Sub<T>(ILRuntimeTest.TestFramework.TestCLRBinding binding, T obj)
{
binding.LoadAsset("222", obj);
}
public static void CLRBindingTest07()
{
ILRuntimeTest.TestFramework.TestCLRBinding binding = new ILRuntimeTest.TestFramework.TestCLRBinding();
CLRBindingTest07Sub(binding, "");
}
public static void CLRBindingTest08()
{
ILRuntimeTest.TestFramework.TestCLRBinding binding = new ILRuntimeTest.TestFramework.TestCLRBinding();
CLRBindingTest07Sub2(binding, 12334);
}
static void CLRBindingTest07Sub<T>(ILRuntimeTest.TestFramework.TestCLRBinding binding, T obj)
{
CLRBindingTest06Sub(binding, obj);
}
static void CLRBindingTest07Sub2<K, V>(K binding, V obj) where K : ILRuntimeTest.TestFramework.TestCLRBinding
{
CLRBindingTest07Sub(binding, obj);
}
public static void CLRBindingTest09()
{
Test a = new Test();
a.Test4();
}
/// <summary>
/// 单例模式基类
/// </summary>
public abstract class ISingleton<T> where T : ISingleton<T>, new()
{
private static T _Instance = null;
/// <summary>
/// 获取单例实例
/// </summary>
/// <returns></returns>
public static T Instance
{
[ILRuntimeTest(Ignored = true)]
get
{
if (_Instance == null)
{
_Instance = new T();
}
return _Instance;
}
}
}
public class Test2
{
}
public class Test : ISingleton<Test>
{
public enum TestType
{
Test1,
Test2
}
private Dictionary<TestType, List<Test2>> _TestList = new Dictionary<TestType, List<Test2>>();
public async Task<T> Test3<T>(TestType testType = TestType.Test1, string str = "") where T : Test2, new()
{
T test = new T();
if (!this._TestList.ContainsKey(testType))
{
this._TestList.Add(testType, new List<Test2>());
}
this._TestList[testType].Add(test);
return test;
}
public async void Test4()
{
await Test.Instance.Test3<Test2>();
}
}
public static void CLRBindingTestEnd()
{
ILRuntimeTest.TestBase.TestSession.LastSession.Appdomain.AllowUnboundCLRMethod = true;
}
public static void CLRBindingTestMissing01()
{
ILRuntimeTest.TestFramework.TestCLRBinding binding = new ILRuntimeTest.TestFramework.TestCLRBinding();
binding.MissingMethod();
}
public static void CLRBindingTestMissing02()
{
ILRuntimeTest.TestFramework.TestCLRBinding binding = new ILRuntimeTest.TestFramework.TestCLRBinding();
binding.MissingMethodGeneric<TestCls2>(null);
}
public static void CLRBindingTestMissing03()
{
ILRuntimeTest.TestFramework.TestCLRBinding binding = new ILRuntimeTest.TestFramework.TestCLRBinding();
binding.missingField = 123;
}
public static void CLRBindingTestMissing04()
{
ILRuntimeTest.TestFramework.TestCLRBinding binding = new ILRuntimeTest.TestFramework.TestCLRBinding();
binding.Emit<MissingType>(null);
}
public static void CLRBindingTestMissing05()
{
ILRuntimeTest.TestFramework.TestCLRBinding binding = new ILRuntimeTest.TestFramework.TestCLRBinding();
binding.MissingMethodGeneric<MissingType>(null);
}
public static void CLRBindingTestMissing08()
{
MissingType mt = new MissingType();
}
}
}