summaryrefslogtreecommitdiff
path: root/tests/src/JIT/Generics/Typeof/refTypesdynamic.cs
blob: adac1886a364eda37fce27483fd9d2ff9c384ac6 (plain)
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//

/* Cases for some shared generics (generics instantiated over reference types, both sealed and unsealed). 
 */

using System;
using System.Reflection;
using System.Runtime.CompilerServices;

class X<T>
{
    public static int x_count = 1;
    public virtual void incCount()
    {
        if (typeof(T) == typeof(class_int))
            x_count *= 2;
        else if (typeof(T) == typeof(class_string))
            x_count *= 3;
        else if (typeof(T) == typeof(class_double))
            x_count *= 5;
        else if (typeof(T) == typeof(class_void))
            x_count *= 7;
        else if (typeof(T) == typeof(X<class_int>) || typeof(T) == typeof(X<class_double>))
            x_count *= 11;
        else if (typeof(T) == typeof(X<class_string>) || typeof(T) == null)
            x_count *= 13;
        else
            Console.WriteLine("ERROR: Unknown type {0}", typeof(T));
    }
}

class class_int
{
    public static void printName() { Console.WriteLine("class_int"); }
}

class class_string
{
    public static void printName() { Console.WriteLine("class_string"); }
}

class class_double
{
    public static void printName() { Console.WriteLine("class_double"); }
}

class class_void
{
    public static void printName() { Console.WriteLine("class_void"); }
}

class A : X<class_int>
{
    public static int a_count = 1;
    public override void incCount() { a_count *= 17; }
}

class B : X<class_string>
{
    public static int b_count = 1;
    public override void incCount() { b_count *= 19; }
}

class C : A
{
    public static int c_count = 1;
    public override void incCount() { c_count *= 23; }
}

class D : B
{
    public static int d_count = 1;
    public override void incCount() { d_count *= 31; }
}

sealed class CS : A
{
    public static int cs_count = 1;
    public override void incCount() { cs_count *= 37; }
}

sealed class DS : B
{
    public static int ds_count = 1;
    public override void incCount() { ds_count *= 41; }
}

class mainMethod
{
    public static bool failed = false;
    public static void checkGetType<T>(X<T> x)
    {
        if (x.GetType() == typeof(DS)) (new DS()).incCount();
        if (x.GetType() == typeof(CS)) (new CS()).incCount();
        if (x.GetType() == typeof(D)) (new D()).incCount();
        if (x.GetType() == typeof(C)) (new C()).incCount();
        if (x.GetType() == typeof(B)) (new B()).incCount();
        if (x.GetType() == typeof(A)) (new A()).incCount();
        if (x.GetType() == typeof(X<class_int>)) (new X<class_int>()).incCount();
        if (x.GetType() == typeof(X<class_string>)) (new X<class_string>()).incCount();
        if (x.GetType() == typeof(X<class_double>)) (new X<class_double>()).incCount();
        if (x.GetType() == typeof(X<X<class_int>>)) (new X<X<class_int>>()).incCount();
        if (x.GetType() == typeof(X<X<class_string>>)) (new X<X<class_string>>()).incCount();
        if (x.GetType() == typeof(X<X<class_double>>)) (new X<X<class_double>>()).incCount();
        if (x.GetType() == null) (new X<class_string>()).incCount();
    }

    public static void checkIs<T>(X<T> x)
    {
        //start from X<class_T>
        if (x is X<X<class_double>>) (new X<X<class_double>>()).incCount();
        if (x is X<X<class_string>>) (new X<X<class_string>>()).incCount();
        if (x is X<X<class_int>>) (new X<X<class_int>>()).incCount();
        if (x is X<class_double>) (new X<class_double>()).incCount();
        if (x is X<class_string>) (new X<class_string>()).incCount();
        if (x is X<class_int>) (new X<class_int>()).incCount();
        if (x is A) (new A()).incCount();
        if (x is B) (new B()).incCount();
        if (x is C) (new C()).incCount();
        if (x is D) (new D()).incCount();
        if (x is CS) (new CS()).incCount();
        if (x is DS) (new DS()).incCount();
    }
    public static void checkAs<T>(X<T> x)
    {
        X<X<class_double>> x6 = x as X<X<class_double>>;
        if (x6 != null) (new X<X<class_double>>()).incCount();
        X<X<class_string>> x5 = x as X<X<class_string>>;
        if (x5 != null) (new X<X<class_string>>()).incCount();
        X<X<class_int>> x4 = x as X<X<class_int>>;
        if (x4 != null) (new X<X<class_int>>()).incCount();
        X<class_double> x3 = x as X<class_double>;
        if (x3 != null) (new X<class_double>()).incCount();
        X<class_string> x2 = x as X<class_string>;
        if (x2 != null) (new X<class_string>()).incCount();
        X<class_int> x1 = x as X<class_int>;
        if (x1 != null) (new X<class_int>()).incCount();
        A a = x as A;
        if (a != null) (new A()).incCount();
        B b = x as B;
        if (b != null) (new B()).incCount();
        C c = x as C;
        if (c != null) (new C()).incCount();
        D d = x as D;
        if (d != null) (new D()).incCount();
        CS cs = x as CS;
        if (cs != null) (new CS()).incCount();
        DS ds = x as DS;
        if (ds != null) (new DS()).incCount();

    }
    public static void checkGetTypeStringCast(X<class_string> x)
    {
        if (x.GetType() == typeof(DS)) ((DS)x).incCount();
        if (x.GetType() == typeof(D)) ((D)x).incCount();
        if (x.GetType() == typeof(B)) ((B)x).incCount();
        if (x.GetType() == typeof(X<class_string>)) ((X<class_string>)x).incCount();
        if (x.GetType() == null) ((X<class_string>)x).incCount();
    }
    public static void checkGetTypeIntCast(X<class_int> x)
    {
        if (x.GetType() == typeof(CS)) ((CS)x).incCount();
        if (x.GetType() == typeof(C)) ((C)x).incCount();
        if (x.GetType() == typeof(A)) ((A)x).incCount();
        if (x.GetType() == typeof(X<class_int>)) ((X<class_int>)x).incCount();
        if (x.GetType() == null) ((X<class_int>)x).incCount();

    }
    public static void checkIsStringCast(X<class_string> x)
    {
        if (x is X<class_string>) ((X<class_string>)x).incCount();
        if (x is B) ((B)x).incCount();
        if (x is D) ((D)x).incCount();
        if (x is DS) ((DS)x).incCount();

    }
    public static void checkIsIntCast(X<class_int> x)
    {
        if (x is X<class_int>) ((X<class_int>)x).incCount();
        if (x is A) ((A)x).incCount();
        if (x is C) ((C)x).incCount();
        if (x is CS) ((CS)x).incCount();

    }
    public static void checkAsStringCast(X<class_string> x)
    {
        X<class_string> x2 = x as X<class_string>;
        if (x2 != null) ((X<class_string>)x).incCount();
        B b = x as B;
        if (b != null) ((B)x).incCount();
        D d = x as D;
        if (d != null) ((D)x).incCount();
        DS ds = x as DS;
        if (ds != null) ((DS)x).incCount();

    }
    public static void checkAsIntCast(X<class_int> x)
    {
        X<class_int> x1 = x as X<class_int>;
        if (x1 != null) ((X<class_int>)x).incCount();
        A a = x as A;
        if (a != null) ((A)x).incCount();
        C c = x as C;
        if (c != null) ((C)x).incCount();
        CS cs = x as CS;
        if (cs != null) ((CS)x).incCount();
    }

    public static void checkCount(ref int actual, int expected, string message)
    {
        if (actual != expected)
        {
            Console.WriteLine("FAILED: {0}", message);
            failed = true;
        }
        actual = 1;
    }

    public static void checkAllCounts(ref int x_actual, int ds, int cs, int d, int c, int b, int a, int x, string dsm, string csm, string dm, string cm, string bm, string am, string xm)
    {
        /*
        printCount(ref DS.ds_count, ds, dsm);
        printCount(ref CS.cs_count, cs, csm);
        printCount(ref D.d_count, d, dm);
        printCount(ref C.c_count, c, cm);
        printCount(ref B.b_count, b, bm);
        printCount(ref A.a_count, a, am);
        printCount(ref x_actual, x, xm);
        */
        checkCount(ref DS.ds_count, ds, dsm);
        checkCount(ref CS.cs_count, cs, csm);
        checkCount(ref D.d_count, d, dm);
        checkCount(ref C.c_count, c, cm);
        checkCount(ref B.b_count, b, bm);
        checkCount(ref A.a_count, a, am);
        checkCount(ref x_actual, x, xm);
    }

    public static void printCount(ref int actual, int expected, string message)
    {
        Console.Write("{0}, ", actual);
        actual = 1;
    }

    public static void callCheckGetType()
    {
        int i = 0;
        checkGetType(new X<X<class_double>>());
        checkAllCounts(ref X<X<class_double>>.x_count, 1, 1, 1, 1, 1, 1, 11, "DS Count after GetType and typeof", "CS Count after GetType and typeof", "D Count after GetType and typeof", "C Count after GetType and typeof", "B Count after GetType and typeof", "A Count after GetType and typeof", "X Count after GetType and typeof");
        Console.WriteLine("-----------{0}", i++);
        checkGetType(new X<X<class_string>>());
        checkAllCounts(ref X<X<class_string>>.x_count, 1, 1, 1, 1, 1, 1, 13, "DS Count after GetType and typeof", "CS Count after GetType and typeof", "D Count after GetType and typeof", "C Count after GetType and typeof", "B Count after GetType and typeof", "A Count after GetType and typeof", "X Count after GetType and typeof");
        Console.WriteLine("-----------{0}", i++);
        checkGetType(new X<X<class_int>>());
        checkAllCounts(ref X<X<class_int>>.x_count, 1, 1, 1, 1, 1, 1, 11, "DS Count after GetType and typeof", "CS Count after GetType and typeof", "D Count after GetType and typeof", "C Count after GetType and typeof", "B Count after GetType and typeof", "A Count after GetType and typeof", "X Count after GetType and typeof");
        Console.WriteLine("-----------{0}", i++);
        checkGetType(new X<class_double>());
        checkAllCounts(ref X<class_double>.x_count, 1, 1, 1, 1, 1, 1, 5, "DS Count after GetType and typeof", "CS Count after GetType and typeof", "D Count after GetType and typeof", "C Count after GetType and typeof", "B Count after GetType and typeof", "A Count after GetType and typeof", "X Count after GetType and typeof");
        Console.WriteLine("-----------{0}", i++);
        checkGetType(new X<class_string>());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 1, 1, 1, 1, 3, "DS Count after GetType and typeof", "CS Count after GetType and typeof", "D Count after GetType and typeof", "C Count after GetType and typeof", "B Count after GetType and typeof", "A Count after GetType and typeof", "X Count after GetType and typeof");
        Console.WriteLine("-----------{0}", i++);
        checkGetType(new X<class_int>());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 1, 1, 1, 2, "DS Count after GetType and typeof", "CS Count after GetType and typeof", "D Count after GetType and typeof", "C Count after GetType and typeof", "B Count after GetType and typeof", "A Count after GetType and typeof", "X Count after GetType and typeof");
        Console.WriteLine("-----------{0}", i++);
        checkGetType(new A());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 1, 1, 17, 1, "DS Count after GetType and typeof", "CS Count after GetType and typeof", "D Count after GetType and typeof", "C Count after GetType and typeof", "B Count after GetType and typeof", "A Count after GetType and typeof", "X Count after GetType and typeof");
        Console.WriteLine("-----------{0}", i++);
        checkGetType(new B());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 1, 1, 19, 1, 1, "DS Count after GetType and typeof", "CS Count after GetType and typeof", "D Count after GetType and typeof", "C Count after GetType and typeof", "B Count after GetType and typeof", "A Count after GetType and typeof", "X Count after GetType and typeof");
        Console.WriteLine("-----------{0}", i++);
        checkGetType(new C());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 23, 1, 1, 1, "DS Count after GetType and typeof", "CS Count after GetType and typeof", "D Count after GetType and typeof", "C Count after GetType and typeof", "B Count after GetType and typeof", "A Count after GetType and typeof", "X Count after GetType and typeof");
        Console.WriteLine("-----------{0}", i++);
        checkGetType(new D());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 31, 1, 1, 1, 1, "DS Count after GetType and typeof", "CS Count after GetType and typeof", "D Count after GetType and typeof", "C Count after GetType and typeof", "B Count after GetType and typeof", "A Count after GetType and typeof", "X Count after GetType and typeof");
        Console.WriteLine("-----------{0}", i++);
        checkGetType(new CS());
        checkAllCounts(ref X<class_int>.x_count, 1, 37, 1, 1, 1, 1, 1, "DS Count after GetType and typeof", "CS Count after GetType and typeof", "D Count after GetType and typeof", "C Count after GetType and typeof", "B Count after GetType and typeof", "A Count after GetType and typeof", "X Count after GetType and typeof");
        Console.WriteLine("-----------{0}", i++);
        checkGetType(new DS());
        checkAllCounts(ref X<class_string>.x_count, 41, 1, 1, 1, 1, 1, 1, "DS Count after GetType and typeof", "CS Count after GetType and typeof", "D Count after GetType and typeof", "C Count after GetType and typeof", "B Count after GetType and typeof", "A Count after GetType and typeof", "X Count after GetType and typeof");
        Console.WriteLine("-----------{0}", i++);
    }

    public static void callCheckIs()
    {
        int i = 0;
        checkIs(new X<X<class_double>>());
        checkAllCounts(ref X<X<class_double>>.x_count, 1, 1, 1, 1, 1, 1, 11, "DS Count after checking is", "CS Count after checking is", "D Count after checking is", "C Count after checking is", "B Count after checking is", "A Count after checking is", "X Count after checking is");
        Console.WriteLine("-----------{0}", i++);
        checkIs(new X<X<class_string>>());
        checkAllCounts(ref X<X<class_string>>.x_count, 1, 1, 1, 1, 1, 1, 13, "DS Count after checking is", "CS Count after checking is", "D Count after checking is", "C Count after checking is", "B Count after checking is", "A Count after checking is", "X Count after checking is");
        Console.WriteLine("-----------{0}", i++);
        checkIs(new X<X<class_int>>());
        checkAllCounts(ref X<X<class_int>>.x_count, 1, 1, 1, 1, 1, 1, 11, "DS Count after checking is", "CS Count after checking is", "D Count after checking is", "C Count after checking is", "B Count after checking is", "A Count after checking is", "X Count after checking is");
        Console.WriteLine("-----------{0}", i++);
        checkIs(new X<class_double>());
        checkAllCounts(ref X<class_double>.x_count, 1, 1, 1, 1, 1, 1, 5, "DS Count after checking is", "CS Count after checking is", "D Count after checking is", "C Count after checking is", "B Count after checking is", "A Count after checking is", "X Count after checking is");
        Console.WriteLine("-----------{0}", i++);
        checkIs(new X<class_string>());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 1, 1, 1, 1, 3, "DS Count after checking is", "CS Count after checking is", "D Count after checking is", "C Count after checking is", "B Count after checking is", "A Count after checking is", "X Count after checking is");
        Console.WriteLine("-----------{0}", i++);
        checkIs(new X<class_int>());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 1, 1, 1, 2, "DS Count after checking is", "CS Count after checking is", "D Count after checking is", "C Count after checking is", "B Count after checking is", "A Count after checking is", "X Count after checking is");
        Console.WriteLine("-----------{0}", i++);
        checkIs(new A());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 1, 1, 17, 2, "DS Count after checking is", "CS Count after checking is", "D Count after checking is", "C Count after checking is", "B Count after checking is", "A Count after checking is", "X Count after checking is");
        Console.WriteLine("-----------{0}", i++);
        checkIs(new B());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 1, 1, 19, 1, 3, "DS Count after checking is", "CS Count after checking is", "D Count after checking is", "C Count after checking is", "B Count after checking is", "A Count after checking is", "X Count after checking is");
        Console.WriteLine("-----------{0}", i++);
        checkIs(new C());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 23, 1, 17, 2, "DS Count after checking is", "CS Count after checking is", "D Count after checking is", "C Count after checking is", "B Count after checking is", "A Count after checking is", "X Count after checking is");
        Console.WriteLine("-----------{0}", i++);
        checkIs(new D());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 31, 1, 19, 1, 3, "DS Count after checking is", "CS Count after checking is", "D Count after checking is", "C Count after checking is", "B Count after checking is", "A Count after checking is", "X Count after checking is");
        Console.WriteLine("-----------{0}", i++);
        checkIs(new CS());
        checkAllCounts(ref X<class_int>.x_count, 1, 37, 1, 1, 1, 17, 2, "DS Count after checking is", "CS Count after checking is", "D Count after checking is", "C Count after checking is", "B Count after checking is", "A Count after checking is", "X Count after checking is");
        Console.WriteLine("-----------{0}", i++);
        checkIs(new DS());
        checkAllCounts(ref X<class_string>.x_count, 41, 1, 1, 1, 19, 1, 3, "DS Count after checking is", "CS Count after checking is", "D Count after checking is", "C Count after checking is", "B Count after checking is", "A Count after checking is", "X Count after checking is");
        Console.WriteLine("-----------{0}", i++);
    }

    public static void callCheckAs()
    {
        int i = 0;
        checkAs(new X<X<class_double>>());
        checkAllCounts(ref X<X<class_double>>.x_count, 1, 1, 1, 1, 1, 1, 11, "DS Count after checking as", "CS Count after checking as", "D Count after checking as", "C Count after checking as", "B Count after checking as", "A Count after checking as", "X Count after checking as");
        Console.WriteLine("-----------{0}", i++);
        checkAs(new X<X<class_string>>());
        checkAllCounts(ref X<X<class_string>>.x_count, 1, 1, 1, 1, 1, 1, 13, "DS Count after checking as", "CS Count after checking as", "D Count after checking as", "C Count after checking as", "B Count after checking as", "A Count after checking as", "X Count after checking as");
        Console.WriteLine("-----------{0}", i++);
        checkAs(new X<X<class_int>>());
        checkAllCounts(ref X<X<class_int>>.x_count, 1, 1, 1, 1, 1, 1, 11, "DS Count after checking as", "CS Count after checking as", "D Count after checking as", "C Count after checking as", "B Count after checking as", "A Count after checking as", "X Count after checking as");
        Console.WriteLine("-----------{0}", i++);
        checkAs(new X<class_double>());
        checkAllCounts(ref X<class_double>.x_count, 1, 1, 1, 1, 1, 1, 5, "DS Count after checking as", "CS Count after checking as", "D Count after checking as", "C Count after checking as", "B Count after checking as", "A Count after checking as", "X Count after checking as");
        Console.WriteLine("-----------{0}", i++);
        checkAs(new X<class_string>());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 1, 1, 1, 1, 3, "DS Count after checking as", "CS Count after checking as", "D Count after checking as", "C Count after checking as", "B Count after checking as", "A Count after checking as", "X Count after checking as");
        Console.WriteLine("-----------{0}", i++);
        checkAs(new X<class_int>());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 1, 1, 1, 2, "DS Count after checking as", "CS Count after checking as", "D Count after checking as", "C Count after checking as", "B Count after checking as", "A Count after checking as", "X Count after checking as");
        Console.WriteLine("-----------{0}", i++);
        checkAs(new A());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 1, 1, 17, 2, "DS Count after checking as", "CS Count after checking as", "D Count after checking as", "C Count after checking as", "B Count after checking as", "A Count after checking as", "X Count after checking as");
        Console.WriteLine("-----------{0}", i++);
        checkAs(new B());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 1, 1, 19, 1, 3, "DS Count after checking as", "CS Count after checking as", "D Count after checking as", "C Count after checking as", "B Count after checking as", "A Count after checking as", "X Count after checking as");
        Console.WriteLine("-----------{0}", i++);
        checkAs(new C());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 23, 1, 17, 2, "DS Count after checking as", "CS Count after checking as", "D Count after checking as", "C Count after checking as", "B Count after checking as", "A Count after checking as", "X Count after checking as");
        Console.WriteLine("-----------{0}", i++);
        checkAs(new D());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 31, 1, 19, 1, 3, "DS Count after checking as", "CS Count after checking as", "D Count after checking as", "C Count after checking as", "B Count after checking as", "A Count after checking as", "X Count after checking as");
        Console.WriteLine("-----------{0}", i++);
        checkAs(new CS());
        checkAllCounts(ref X<class_int>.x_count, 1, 37, 1, 1, 1, 17, 2, "DS Count after checking as", "CS Count after checking as", "D Count after checking as", "C Count after checking as", "B Count after checking as", "A Count after checking as", "X Count after checking as");
        Console.WriteLine("-----------{0}", i++);
        checkAs(new DS());
        checkAllCounts(ref X<class_string>.x_count, 41, 1, 1, 1, 19, 1, 3, "DS Count after checking as", "CS Count after checking as", "D Count after checking as", "C Count after checking as", "B Count after checking as", "A Count after checking as", "X Count after checking as");
        Console.WriteLine("-----------{0}", i++);
    }

    public static void callCheckGetTypeStringCast()
    {
        int i = 0;
        checkGetTypeStringCast(new X<class_string>());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 1, 1, 1, 1, 3, "DS Count after GetType and typeof string cast", "CS Count after GetType and typeof string cast", "D Count after GetType and typeof string cast", "C Count after GetType and typeof string cast", "B Count after GetType and typeof string cast", "A Count after GetType and typeof string cast", "X Count after GetType and typeof string cast");
        Console.WriteLine("-----------{0}", i++);
        checkGetTypeStringCast(new B());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 1, 1, 19, 1, 1, "DS Count after GetType and typeof string cast", "CS Count after GetType and typeof string cast", "D Count after GetType and typeof string cast", "C Count after GetType and typeof string cast", "B Count after GetType and typeof string cast", "A Count after GetType and typeof string cast", "X Count after GetType and typeof string cast");
        Console.WriteLine("-----------{0}", i++);
        checkGetTypeStringCast(new D());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 31, 1, 1, 1, 1, "DS Count after GetType and typeof string cast", "CS Count after GetType and typeof string cast", "D Count after GetType and typeof string cast", "C Count after GetType and typeof string cast", "B Count after GetType and typeof string cast", "A Count after GetType and typeof string cast", "X Count after GetType and typeof string cast");
        Console.WriteLine("-----------{0}", i++);
        checkGetTypeStringCast(new DS());
        checkAllCounts(ref X<class_string>.x_count, 41, 1, 1, 1, 1, 1, 1, "DS Count after GetType and typeof string cast", "CS Count after GetType and typeof string cast", "D Count after GetType and typeof string cast", "C Count after GetType and typeof string cast", "B Count after GetType and typeof string cast", "A Count after GetType and typeof string cast", "X Count after GetType and typeof string cast");
        Console.WriteLine("-----------{0}", i++);
    }

    public static void callCheckGetTypeIntCast()
    {
        int i = 0;
        checkGetTypeIntCast(new X<class_int>());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 1, 1, 1, 2, "DS Count after GetType and typeof int cast", "CS Count after GetType and typeof int cast", "D Count after GetType and typeof int cast", "C Count after GetType and typeof int cast", "B Count after GetType and typeof int cast", "A Count after GetType and typeof int cast", "X Count after GetType and typeof int cast");
        Console.WriteLine("-----------{0}", i++);
        checkGetTypeIntCast(new A());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 1, 1, 17, 1, "DS Count after GetType and typeof int cast", "CS Count after GetType and typeof int cast", "D Count after GetType and typeof int cast", "C Count after GetType and typeof int cast", "B Count after GetType and typeof int cast", "A Count after GetType and typeof int cast", "X Count after GetType and typeof int cast");
        Console.WriteLine("-----------{0}", i++);
        checkGetTypeIntCast(new C());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 23, 1, 1, 1, "DS Count after GetType and typeof int cast", "CS Count after GetType and typeof int cast", "D Count after GetType and typeof int cast", "C Count after GetType and typeof int cast", "B Count after GetType and typeof int cast", "A Count after GetType and typeof int cast", "X Count after GetType and typeof int cast");
        Console.WriteLine("-----------{0}", i++);
        checkGetTypeIntCast(new CS());
        checkAllCounts(ref X<class_int>.x_count, 1, 37, 1, 1, 1, 1, 1, "DS Count after GetType and typeof int cast", "CS Count after GetType and typeof int cast", "D Count after GetType and typeof int cast", "C Count after GetType and typeof int cast", "B Count after GetType and typeof int cast", "A Count after GetType and typeof int cast", "X Count after GetType and typeof int cast");
        Console.WriteLine("-----------{0}", i++);
    }

    public static void callCheckIsStringCast()
    {
        int i = 0;
        checkIsStringCast(new X<class_string>());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 1, 1, 1, 1, 3, "DS Count after check is string cast ", "CS Count after check is string cast ", "D Count after check is string cast ", "C Count after check is string cast ", "B Count after check is string cast ", "A Count after check is string cast ", "X Count after check is string cast ");
        Console.WriteLine("-----------{0}", i++);
        checkIsStringCast(new B());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 1, 1, 361, 1, 1, "DS Count after check is string cast ", "CS Count after check is string cast ", "D Count after check is string cast ", "C Count after check is string cast ", "B Count after check is string cast ", "A Count after check is string cast ", "X Count after check is string cast ");
        Console.WriteLine("-----------{0}", i++);
        checkIsStringCast(new D());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 29791, 1, 1, 1, 1, "DS Count after check is string cast ", "CS Count after check is string cast ", "D Count after check is string cast ", "C Count after check is string cast ", "B Count after check is string cast ", "A Count after check is string cast ", "X Count after check is string cast ");
        Console.WriteLine("-----------{0}", i++);
        checkIsStringCast(new DS());
        checkAllCounts(ref X<class_string>.x_count, 68921, 1, 1, 1, 1, 1, 1, "DS Count after check is string cast ", "CS Count after check is string cast ", "D Count after check is string cast ", "C Count after check is string cast ", "B Count after check is string cast ", "A Count after check is string cast ", "X Count after check is string cast ");
        Console.WriteLine("-----------{0}", i++);
    }

    public static void callCheckIsIntCast()
    {
        int i = 0;
        checkIsIntCast(new X<class_int>());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 1, 1, 1, 2, "DS Count after check is int cast", "CS Count after check is int cast", "D Count after check is int cast", "C Count after check is int cast", "B Count after check is int cast", "A Count after check is int cast", "X Count after check is int cast");
        Console.WriteLine("-----------{0}", i++);
        checkIsIntCast(new A());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 1, 1, 289, 1, "DS Count after check is int cast", "CS Count after check is int cast", "D Count after check is int cast", "C Count after check is int cast", "B Count after check is int cast", "A Count after check is int cast", "X Count after check is int cast");
        Console.WriteLine("-----------{0}", i++);
        checkIsIntCast(new C());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 12167, 1, 1, 1, "DS Count after check is int cast", "CS Count after check is int cast", "D Count after check is int cast", "C Count after check is int cast", "B Count after check is int cast", "A Count after check is int cast", "X Count after check is int cast");
        Console.WriteLine("-----------{0}", i++);
        checkIsIntCast(new CS());
        checkAllCounts(ref X<class_int>.x_count, 1, 50653, 1, 1, 1, 1, 1, "DS Count after check is int cast", "CS Count after check is int cast", "D Count after check is int cast", "C Count after check is int cast", "B Count after check is int cast", "A Count after check is int cast", "X Count after check is int cast");
        Console.WriteLine("-----------{0}", i++);
    }

    public static void callCheckAsStringCast()
    {
        int i = 0;
        checkAsStringCast(new X<class_string>());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 1, 1, 1, 1, 3, "DS Count after check as string cast ", "CS Count after check as string cast ", "D Count after check as string cast ", "C Count after check as string cast ", "B Count after check as string cast ", "A Count after check as string cast ", "X Count after check as string cast ");
        Console.WriteLine("-----------{0}", i++);
        checkAsStringCast(new B());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 1, 1, 361, 1, 1, "DS Count after check as string cast ", "CS Count after check as string cast ", "D Count after check as string cast ", "C Count after check as string cast ", "B Count after check as string cast ", "A Count after check as string cast ", "X Count after check as string cast ");
        Console.WriteLine("-----------{0}", i++);
        checkAsStringCast(new D());
        checkAllCounts(ref X<class_string>.x_count, 1, 1, 29791, 1, 1, 1, 1, "DS Count after check as string cast ", "CS Count after check as string cast ", "D Count after check as string cast ", "C Count after check as string cast ", "B Count after check as string cast ", "A Count after check as string cast ", "X Count after check as string cast ");
        Console.WriteLine("-----------{0}", i++);
        checkAsStringCast(new DS());
        checkAllCounts(ref X<class_string>.x_count, 68921, 1, 1, 1, 1, 1, 1, "DS Count after check as string cast ", "CS Count after check as string cast ", "D Count after check as string cast ", "C Count after check as string cast ", "B Count after check as string cast ", "A Count after check as string cast ", "X Count after check as string cast ");
        Console.WriteLine("-----------{0}", i++);
    }

    public static void callCheckAsIntCast()
    {
        int i = 0;
        checkAsIntCast(new X<class_int>());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 1, 1, 1, 2, "DS Count after check as int cast", "CS Count after check as int cast", "D Count after check as int cast", "C Count after check as int cast", "B Count after check as int cast", "A Count after check as int cast", "X Count after check as int cast");
        Console.WriteLine("-----------{0}", i++);
        checkAsIntCast(new A());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 1, 1, 289, 1, "DS Count after check as int cast", "CS Count after check as int cast", "D Count after check as int cast", "C Count after check as int cast", "B Count after check as int cast", "A Count after check as int cast", "X Count after check as int cast");
        Console.WriteLine("-----------{0}", i++);
        checkAsIntCast(new C());
        checkAllCounts(ref X<class_int>.x_count, 1, 1, 1, 12167, 1, 1, 1, "DS Count after check as int cast", "CS Count after check as int cast", "D Count after check as int cast", "C Count after check as int cast", "B Count after check as int cast", "A Count after check as int cast", "X Count after check as int cast");
        Console.WriteLine("-----------{0}", i++);
        checkAsIntCast(new CS());
        checkAllCounts(ref X<class_int>.x_count, 1, 50653, 1, 1, 1, 1, 1, "DS Count after check as int cast", "CS Count after check as int cast", "D Count after check as int cast", "C Count after check as int cast", "B Count after check as int cast", "A Count after check as int cast", "X Count after check as int cast");
        Console.WriteLine("-----------{0}", i++);
    }

    public static int Main()
    {
        callCheckGetType();
        callCheckIs();
        callCheckAs();
        callCheckGetTypeStringCast();
        callCheckGetTypeIntCast();
        callCheckIsStringCast();
        callCheckIsIntCast();
        callCheckAsStringCast();
        callCheckAsIntCast();
        if (failed) return 101; else return 100;
    }
}