Merge pull request #901 from Blewzman/FixAggregateExceptionGetBaseException
[mono.git] / mono / mini / gshared.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Collections.ObjectModel;
4 using System.Runtime.CompilerServices;
5 using System.Threading.Tasks;
6
7 struct Foo {
8         public int i, j, k, l, m, n;
9 }
10
11 struct GFoo<T> {
12         public T dummy;
13         public T t;
14         public int i;
15         public Foo f;
16         public static T static_dummy;
17         public static T static_t;
18         public static Foo static_f;
19 }
20
21 struct GFoo2<T> {
22         public T t, t2;
23 }
24
25 class GFoo3<T> {
26         public T t, t2;
27
28         public GFoo3 () {
29         }
30
31         [MethodImplAttribute (MethodImplOptions.NoInlining)]
32         public GFoo3 (T i1, T i2) {
33                 t = i1;
34                 t2 = i2;
35         }
36 }
37
38 //
39 // Tests for generic sharing of vtypes.
40 // The tests use arrays to pass/receive values to keep the calling convention of the methods stable, which is a current limitation of the runtime support for gsharedvt.
41 //
42
43 // FIXME: Add mixed ref/noref tests, i.e. Dictionary<string, int>
44
45 #if MOBILE
46 public class GSharedTests
47 #else
48 public class Tests
49 #endif
50 {
51 #if !MOBILE
52         public static int Main (String[] args) {
53                 return TestDriver.RunTests (typeof (Tests), args);
54         }
55 #endif
56
57         [MethodImplAttribute (MethodImplOptions.NoInlining)]
58         static void gshared<T> (T [] array, int i, int j) {
59                 T tmp = array [i];
60                 array [i] = array [j];
61                 array [j] = tmp;
62         }
63
64         // Test that the gshared and gsharedvt versions don't mix
65         public static int test_0_vt_gshared () {
66                 string[] sarr = new string [2] { "A", "B" };
67
68                 gshared<string> (sarr, 0, 1);
69
70                 Foo[] arr = new Foo [2];
71                 arr [0] = new Foo () { i = 1, j = 2 };
72                 arr [1] = new Foo () { i = 3, j = 4 };
73
74                 gshared<Foo> (arr, 0, 1);
75                 if (arr [0].i != 3 || arr [0].j != 4)
76                         return 1;
77                 if (arr [1].i != 1 || arr [1].j != 2)
78                         return 2;
79
80                 return 0;
81         }
82
83         static void ldelem_stelem<T> (T [] array, int i, int j) {
84                 T tmp = array [i];
85                 array [i] = array [j];
86                 array [j] = tmp;
87         }
88
89         public static int test_0_vt_ldelem_stelem () {
90                 Foo[] arr = new Foo [2];
91                 arr [0] = new Foo () { i = 1, j = 2 };
92                 arr [1] = new Foo () { i = 3, j = 4 };
93
94                 ldelem_stelem<Foo> (arr, 0, 1);
95                 if (arr [0].i != 3 || arr [0].j != 4)
96                         return 1;
97                 if (arr [1].i != 1 || arr [1].j != 2)
98                         return 2;
99
100                 int[] arr2 = new int [2] { 1, 2 };
101                 ldelem_stelem<int> (arr2, 0, 1);
102                 if (arr2 [0] !=2 || arr2 [1] != 1)
103                         return 3;
104
105                 return 0;
106         }
107
108         [MethodImplAttribute (MethodImplOptions.NoInlining)]
109         private static void initobj<T> (T [] array, int i, int j) {
110                 T x = default(T);
111                 array [i] = x;
112         }
113
114         public static int test_0_vt_initobj () {
115                 Foo[] arr = new Foo [2];
116                 arr [0] = new Foo () { i = 1, j = 2 };
117                 arr [1] = new Foo () { i = 3, j = 4 };
118
119                 initobj<Foo> (arr, 0, 1);
120                 if (arr [0].i != 0 || arr [0].j != 0)
121                         return 1;
122                 if (arr [1].i != 3 || arr [1].j != 4)
123                         return 2;
124                 return 0;
125         }
126
127         [MethodImplAttribute (MethodImplOptions.NoInlining)]
128         static T ldobj_stobj<T> (ref T t1, ref T t2) {
129                 t1 = t2;
130                 T t = t2;
131                 t2 = default(T);
132                 return t;
133         }
134
135         public static int test_0_vt_ldobj_stobj () {
136                 int i = 5;
137                 int j = 6;
138                 if (ldobj_stobj (ref i, ref j) != 6)
139                         return 1;
140                 if (i != 6 || j != 0)
141                         return 2;
142                 double d1 = 1.0;
143                 double d2 = 2.0;
144                 if (ldobj_stobj (ref d1, ref d2) != 2.0)
145                         return 3;
146                 if (d1 != 2.0 || d2 != 0.0)
147                         return 4;               
148                 return 0;
149         }
150
151         [MethodImplAttribute (MethodImplOptions.NoInlining)]
152         private static void box<T1, T> (T [] array, object[] arr) {
153                 object x = array [0];
154                 arr [0] = x;
155         }
156
157         public static int test_0_vt_box () {
158                 Foo[] arr = new Foo [2];
159                 arr [0] = new Foo () { i = 1, j = 2 };
160
161                 object[] arr2 = new object [16];
162                 box<int, Foo> (arr, arr2);
163                 if (arr2 [0].GetType () != typeof (Foo))
164                         return 1;
165                 Foo f = (Foo)arr2 [0];
166                 if (f.i != 1 || f.j != 2)
167                         return 2;
168                 string[] arr3 = new string [16];
169                 object[] arr4 = new object [16];
170                 arr3 [0] = "OK";
171                 box<int, string> (arr3, arr4);
172                 if (arr4 [0] != (object)arr3 [0])
173                         return 3;
174                 return 0;
175         }
176
177         [MethodImplAttribute (MethodImplOptions.NoInlining)]
178         private static void unbox_any<T> (T [] array, object[] arr) {
179                 T t = (T)arr [0];
180                 array [0] = t;
181         }
182
183         public static int test_0_vt_unbox_any () {
184                 int[] iarr = new int [16];
185                 unbox_any<int> (iarr, new object [] { 12 });
186
187                 Foo[] arr = new Foo [2];
188
189                 object[] arr2 = new object [16];
190                 arr2 [0] = new Foo () { i = 1, j = 2 };
191                 unbox_any<Foo> (arr, arr2);
192                 if (arr [0].i != 1 || arr [0].j != 2)
193                         return 2;
194                 return 0;
195         }
196
197         interface IFaceUnbox {
198                 T Unbox<T, T2> (T t, T2 t2, object o);
199         }
200
201         class ClassUnbox : IFaceUnbox {
202                 public T Unbox<T, T2> (T t, T2 t2, object o) {
203                         return (T)o;
204                 }
205         }
206
207         // unbox.any on a ref type in a gsharedvt method
208         public static int test_0_ref_gsharedvt_aot_unbox_any () {
209                 IFaceUnbox iface = new ClassUnbox ();
210                 string s = iface.Unbox<string, int> ("A", 2, "A");
211                 if (s != "A")
212                         return 1;
213                 return 0;
214         }
215
216         public static int test_0_unbox_any_enum () {
217                 IFaceUnbox iface = new ClassUnbox ();
218                 AnEnum res = iface.Unbox<AnEnum, int> (AnEnum.One, 0, 1);
219                 if (res != AnEnum.Two)
220                         return 1;
221                 res = iface.Unbox<AnEnum, int> (AnEnum.One, 0, AnEnum.Two);
222                 if (res != AnEnum.Two)
223                         return 2;
224                 return 0;
225         }
226
227         [MethodImplAttribute (MethodImplOptions.NoInlining)]
228         static void ldfld_nongeneric<T> (GFoo<T>[] foo, int[] arr) {
229                 arr [0] = foo [0].i;
230         }
231
232         [MethodImplAttribute (MethodImplOptions.NoInlining)]
233         static void ldfld<T> (GFoo<T>[] foo, T[] arr) {
234                 arr [0] = foo [0].t;
235         }
236
237         [MethodImplAttribute (MethodImplOptions.NoInlining)]
238         static void stfld_nongeneric<T> (GFoo<T>[] foo, int[] arr) {
239                 foo [0].i = arr [0];
240         }
241
242         [MethodImplAttribute (MethodImplOptions.NoInlining)]
243         static void stfld<T> (GFoo<T>[] foo, T[] arr) {
244                 foo [0].t = arr [0];
245         }
246
247         [MethodImplAttribute (MethodImplOptions.NoInlining)]
248         static void ldflda<T> (GFoo<T>[] foo, int[] arr) {
249                 arr [0] = foo [0].f.i;
250         }
251
252         public static int test_0_vt_ldfld_stfld () {
253                 var foo = new GFoo<Foo> () { t = new Foo () { i = 1, j = 2 }, i = 5, f = new Foo () { i = 5, j = 6 } };
254                 var farr = new GFoo<Foo>[] { foo };
255
256                 /* Normal fields with a variable offset */
257                 var iarr = new int [10];
258                 ldfld_nongeneric<Foo> (farr, iarr);
259                 if (iarr [0] != 5)
260                         return 1;
261                 iarr [0] = 16;
262                 stfld_nongeneric<Foo> (farr, iarr);
263                 if (farr [0].i != 16)
264                         return 2;
265
266                 /* Variable type field with a variable offset */
267                 var arr = new Foo [10];
268                 ldfld<Foo> (farr, arr);
269                 if (arr [0].i != 1 || arr [0].j != 2)
270                         return 3;
271                 arr [0] = new Foo () { i = 3, j = 4 };
272                 stfld<Foo> (farr, arr);
273                 if (farr [0].t.i != 3 || farr [0].t.j != 4)
274                         return 4;
275
276                 ldflda<Foo> (farr, iarr);
277                 if (iarr [0] != 5)
278                         return 5;
279
280                 return 0;
281         }
282
283         [MethodImplAttribute (MethodImplOptions.NoInlining)]
284         static void stsfld<T> (T[] arr) {
285                 GFoo<T>.static_t = arr [0];
286         }
287
288         [MethodImplAttribute (MethodImplOptions.NoInlining)]
289         static void ldsfld<T> (T[] arr) {
290                 arr [0] = GFoo<T>.static_t;
291         }
292
293         [MethodImplAttribute (MethodImplOptions.NoInlining)]
294         static void ldsflda<T> (int[] iarr) {
295                 iarr [0] = GFoo<T>.static_f.i;
296         }
297         
298         public static int test_0_stsfld () {
299                 Foo[] farr = new Foo [] { new Foo () { i = 1, j = 2 } };
300                 stsfld<Foo> (farr);
301
302                 if (GFoo<Foo>.static_t.i != 1 || GFoo<Foo>.static_t.j != 2)
303                         return 1;
304
305                 Foo[] farr2 = new Foo [1];
306                 ldsfld<Foo> (farr2);
307                 if (farr2 [0].i != 1 || farr2 [0].j != 2)
308                         return 2;
309
310                 var iarr = new int [10];
311                 GFoo<Foo>.static_f = new Foo () { i = 5, j = 6 };
312                 ldsflda<Foo> (iarr);
313                 if (iarr [0] != 5)
314                         return 3;
315
316                 return 0;
317         }
318
319         [MethodImplAttribute (MethodImplOptions.NoInlining)]
320         static object newarr<T> () {
321                 object o = new T[10];
322                 return o;
323         }
324
325         public static int test_0_vt_newarr () {
326                 object o = newarr<Foo> ();
327                 if (!(o is Foo[]))
328                         return 1;
329                 return 0;
330         }
331
332         [MethodImplAttribute (MethodImplOptions.NoInlining)]
333         static Type ldtoken<T> () {
334                 return typeof (GFoo<T>);
335         }
336
337         public static int test_0_vt_ldtoken () {
338                 Type t = ldtoken<Foo> ();
339                 if (t != typeof (GFoo<Foo>))
340                         return 1;
341                 t = ldtoken<int> ();
342                 if (t != typeof (GFoo<int>))
343                         return 2;
344
345                 return 0;
346         }
347
348         public static int test_0_vtype_list () {
349                 List<int> l = new List<int> ();
350
351                 l.Add (5);
352                 if (l.Count != 1)
353                         return 1;
354                 return 0;
355         }
356
357         [MethodImplAttribute (MethodImplOptions.NoInlining)]
358         static int args_simple<T> (T t, int i) {
359                 return i;
360         }
361
362         [MethodImplAttribute (MethodImplOptions.NoInlining)]
363         static int args_simple<T> (T t, int i, T t2) {
364                 return i;
365         }
366
367         [MethodImplAttribute (MethodImplOptions.NoInlining)]
368         static Type args_rgctx<T> (T t, int i) {
369                 return typeof (T);
370         }
371
372         [MethodImplAttribute (MethodImplOptions.NoInlining)]
373         static Type eh_in<T> (T t, int i) {
374                 throw new OverflowException ();
375         }
376
377         [MethodImplAttribute (MethodImplOptions.NoInlining)]
378         static T return_t<T> (T t) {
379                 return t;
380         }
381
382         [MethodImplAttribute (MethodImplOptions.NoInlining)]
383         T return_this_t<T> (T t) {
384                 return t;
385         }
386
387         public static int test_0_gsharedvt_in () {
388                 // Check that the non-generic argument is passed at the correct stack position
389                 int r = args_simple<bool> (true, 42);
390                 if (r != 42)
391                         return 1;
392                 r = args_simple<Foo> (new Foo (), 43);
393                 if (r != 43)
394                         return 2;
395                 // Check that the proper rgctx is passed to the method
396                 Type t = args_rgctx<int> (5, 42);
397                 if (t != typeof (int))
398                         return 3;
399                 var v = args_simple<GFoo2<int>> (new GFoo2<int> () { t = 11, t2 = 12 }, 44, new GFoo2<int> () { t = 11, t2 = 12 });
400                 if (v != 44)
401                         return 4;
402                 // Check that EH works properly
403                 try {
404                         eh_in<int> (1, 2);
405                 } catch (OverflowException) {
406                 }
407                 return 0;
408         }
409
410         public static int test_0_gsharedvt_in_ret () {
411                 int i = return_t<int> (42);
412                 if (i != 42)
413                         return 1;
414                 long l = return_t<long> (Int64.MaxValue);
415                 if (l != Int64.MaxValue)
416                         return 2;
417                 double d = return_t<double> (3.0);
418                 if (d != 3.0)
419                         return 3;
420                 float f = return_t<float> (3.0f);
421                 if (f != 3.0f)
422                         return 4;
423                 short s = return_t<short> (16);
424                 if (s != 16)
425                         return 5;
426                 var v = new GFoo2<int> () { t = 55, t2 = 32 };
427                 var v2 = return_t<GFoo2<int>> (v);
428                 if (v2.t != 55 || v2.t2 != 32)
429                         return 6;
430                 i = new GSharedTests ().return_this_t<int> (42);
431                 if (i != 42)
432                         return 7;
433                 return 0;
434         }
435
436         public static int test_0_gsharedvt_in_delegates () {
437                 Func<int, int> f = new Func<int, int> (return_t<int>);
438                 if (f (42) != 42)
439                         return 1;
440                 return 0;
441         }
442
443         [MethodImplAttribute (MethodImplOptions.NoInlining)]
444         static T return2_t<T> (T t) {
445                 return return_t (t);
446         }
447
448         public static int test_0_gsharedvt_calls () {
449                 if (return2_t (2) != 2)
450                         return 1;
451                 if (return2_t ("A") != "A")
452                         return 2;
453                 if (return2_t (2.0) != 2.0)
454                         return 3;
455                 return 0;
456         }
457
458         static GFoo3<T> newobj<T> (T t1, T t2) {
459                 return new GFoo3<T> (t1, t2);
460         }
461         
462         public static int test_0_gshared_new () {
463                 var g1 = newobj (1, 2);
464                 if (g1.t != 1 || g1.t2 != 2)
465                         return 1;
466                 var g2 = newobj (1.0, 2.0);
467                 if (g1.t != 1.0 || g1.t2 != 2.0)
468                         return 2;
469
470                 return 0;
471         }
472
473         [MethodImplAttribute (MethodImplOptions.NoInlining)]
474         static GFoo2<T> newobj_vt<T> (T t1, T t2) {
475                 return new GFoo2<T> () { t = t1, t2 = t2 };
476         }
477
478         public static int test_0_gshared_new_vt () {
479                 GFoo2<int> v1 = newobj_vt (1, 2);
480                 if (v1.t != 1 || v1.t2 != 2)
481                         return 1;
482                 GFoo2<double> v2 = newobj_vt (1.0, 2.0);
483                 if (v2.t != 1.0 || v2.t2 != 2.0)
484                         return 2;
485                 return 0;
486         }
487
488         //
489         // Tests for transitioning out of gsharedvt code
490         //
491
492         // T1=Nullable<..> is not currently supported by gsharedvt
493
494         [MethodImplAttribute (MethodImplOptions.NoInlining)]
495         static T return_t_nogshared<T,T1> (T t) {
496                 object o = t;
497                 T t2 = (T)o;
498                 //Console.WriteLine ("X: " + t);
499                 return t;
500         }
501
502         [MethodImplAttribute (MethodImplOptions.NoInlining)]
503         static int return_int_nogshared<T,T1> (T t) {
504                 object o = t;
505                 T t2 = (T)o;
506                 return 2;
507         }
508
509         [MethodImplAttribute (MethodImplOptions.NoInlining)]
510         static A return_vtype_nogshared<T,T1> (T t) {
511                 object o = t;
512                 T t2 = (T)o;
513                 return new A () { a = 1, b = 2, c = 3 };
514         }
515
516         [MethodImplAttribute (MethodImplOptions.NoInlining)]
517         static T return2_t_out<T> (T t) {
518                 return return_t_nogshared<T, int?> (t);
519         }
520
521         [MethodImplAttribute (MethodImplOptions.NoInlining)]
522         static int return2_int_out<T> (T t) {
523                 return return_int_nogshared<T, int?> (t);
524         }
525
526         [MethodImplAttribute (MethodImplOptions.NoInlining)]
527         static A return2_vtype_out<T> (T t) {
528                 return return_vtype_nogshared<T, int?> (t);
529         }
530
531         struct A {
532                 public int a, b, c;
533         }
534
535         [Category ("!FULLAOT")]
536         public static int test_0_gsharedvt_out () {
537                 if (return2_t_out (2) != 2)
538                         return 1;
539                 if (return2_t_out ("A") != "A")
540                         return 2;
541                 if (return2_t_out (2.0) != 2.0)
542                         return 3;
543                 if (return2_t_out (2.0f) != 2.0f)
544                         return 4;
545                 A a = new A () { a = 1, b = 2, c = 3 };
546                 A a2 = return2_t_out (a);
547                 if (a2.a != 1 || a2.b != 2 || a2.c != 3)
548                         return 5;
549                 // Calls with non gsharedvt return types
550                 if (return2_int_out (1) != 2)
551                         return 6;
552                 A c = return2_vtype_out (a);
553                 if (a2.a != 1 || a2.b != 2 || a2.c != 3)
554                         return 7;
555                 return 0;
556         }
557
558         public class GenericClass<T> {
559                 public static T Z (IList<T> x, int index)
560                 {
561                         return x [index];
562                 }
563         }
564
565         public static int test_0_generic_array_helpers () {
566                 int[] x = new int[] {100, 200};
567
568                 // Generic array helpers should be treated as gsharedvt-out
569                 if (GenericClass<int>.Z (x, 0) != 100)
570                         return 1;
571
572                 return 0;
573         }
574
575         internal class IntComparer : IComparer<int>
576         {
577                 public int Compare (int ix, int iy)
578                 {
579                         if (ix == iy)
580                                 return 0;
581
582                         if (((uint) ix) < ((uint) iy))
583                                 return -1;
584                         return 1;
585                 }
586         }
587
588         [MethodImplAttribute (MethodImplOptions.NoInlining)]
589         static int gshared_out_iface<T> (T t1, T t2, IComparer<T> comp) {
590                 return comp.Compare (t1, t2);
591         }
592
593         public static int test_0_gshared_out_iface () {
594                 // Call out from gshared to a nongeneric method through a generic interface method
595                 if (gshared_out_iface (2, 2, new IntComparer ()) != 0)
596                         return 1;
597                 return 0;
598         }
599
600         struct Foo1 {
601                 public int i1, i2, i3;
602         }
603
604         struct Foo2<T> {
605                 int i1, i2, i3, i4, i5;
606                 public T foo;
607         }
608
609         [MethodImplAttribute (MethodImplOptions.NoInlining)]    
610         public static void locals<T> (T t) {
611                 Foo2<T> t2 = new Foo2<T> ();
612                 object o = t2;
613         }
614
615         public static int test_0_locals () {
616                 // Test that instantiations of type parameters are allocated the proper local type
617                 int i = 1;
618                 for (int j = 0; j < 10; ++j)
619                         i ++;
620                 locals<Foo1> (new Foo1 () { i1 = 1, i2 = 2, i3 = 3 });
621                 return 0;
622         }
623
624         public interface IFace<T> {
625                 T return_t_iface (T t);
626         }
627
628         public class Parent<T> {
629                 public virtual T return_t_vcall (T t) {
630                         throw new Exception ();
631                         return t;
632                 }
633         }
634
635         public class Child<T> : Parent<T>, IFace<T> {
636                 public override T return_t_vcall (T t) {
637                         return t;
638                 }
639                 public T return_t_iface (T t) {
640                         return t;
641                 }
642         }
643
644         [MethodImplAttribute (MethodImplOptions.NoInlining)]
645         static T return_t_vcall<T> (Parent<T> r, T t) {
646                 return r.return_t_vcall (t);
647         }
648
649         public static int test_0_vcalls () {
650                 if (return_t_vcall (new Child<int> (), 2) != 2)
651                         return 1;
652                 // Patching
653                 for (int i = 0; i < 10; ++i) {
654                         if (return_t_vcall (new Child<int> (), 2) != 2)
655                                 return 2;
656                 }
657                 if (return_t_vcall (new Child<double> (), 2.0) != 2.0)
658                         return 3;
659                 return 0;
660         }
661
662         [MethodImplAttribute (MethodImplOptions.NoInlining)]
663         static T return_t_iface<T> (IFace<T> r, T t) {
664                 return r.return_t_iface (t);
665         }
666
667         public static int test_0_iface_calls () {
668                 if (return_t_iface (new Child<int> (), 2) != 2)
669                         return 1;
670                 if (return_t_iface (new Child<double> (), 2.0) != 2.0)
671                         return 3;
672                 return 0;
673         }
674
675         interface IFaceKVP {
676                 T do_kvp<T> (T a);
677         }
678
679         static KeyValuePair<T1, T2> make_kvp<T1, T2> (T1 t1, T2 t2) {
680                 return new KeyValuePair<T1, T2> (t1, t2);
681         }
682
683         static T2 use_kvp<T1, T2> (KeyValuePair<T1, T2> kvp) {
684                 return kvp.Value;
685         }
686
687         class ClassKVP : IFaceKVP {
688                 public T do_kvp<T> (T a) {
689                         var t = make_kvp (a, a);
690                         // argument is an instance of a vtype instantiated with gsharedvt type arguments
691                         return use_kvp (t);
692                 }
693         }
694
695         public static int test_0_gsharedvt_ginstvt_constructed_arg () {
696                 IFaceKVP c = new ClassKVP ();
697                 if (c.do_kvp<long> (1) != 1)
698                         return 1;
699                 return 0;
700         }
701
702         interface IGetter
703         {
704                 T Get<T>();
705         }
706
707         class Getter : IGetter
708         {
709                 public T Get<T>() { return default(T); }
710         }
711
712         abstract class Session
713         {
714                 public abstract IGetter Getter { get; }
715         }
716
717         class IosSession : Session
718         {
719                 private IGetter getter = new Getter();
720                 public override IGetter Getter { get { return getter; } }
721         }
722
723         enum ENUM_TYPE {
724         }
725
726         public static int test_0_regress_5156 () {
727                 new IosSession().Getter.Get<ENUM_TYPE>();
728                 return 0;
729         }
730
731         public struct VT
732         {
733                 public Action a;
734         }
735
736         public class D
737         {
738         }
739
740         public class A3
741         {
742                 public void OuterMethod<TArg1>(TArg1 value)
743                 {
744                         this.InnerMethod<TArg1, long>(value, 0);
745                 }
746
747                 private void InnerMethod<TArg1, TArg2>(TArg1 v1, TArg2 v2)
748                 {
749                         //Console.WriteLine("{0} {1}",v1,v2);
750                 }
751         }
752
753         public static int test_0_regress_2096 () {
754                 var a = new A3();
755
756                 // The following work:
757                 a.OuterMethod<int>(1);
758                 a.OuterMethod<DateTime>(DateTime.Now);
759
760                 var v = new VT();
761                 a.OuterMethod<VT>(v);
762
763                 var x = new D();
764                 // Next line will crash with Attempting to JIT compile method on device
765                 //  Attempting to JIT compile method
766                 a.OuterMethod<D>(x);
767                 return 0;
768         }
769
770         public class B
771         {
772                 public void Test<T>()
773                 {
774                         //System.Console.WriteLine(typeof(T));
775                 }
776         }
777
778         public class A<T>
779         {
780                 public void Test()
781                 {
782                         new B().Test<System.Collections.Generic.KeyValuePair<T, T>>();
783                 }
784         }
785
786     public static int test_0_regress_6040 () {
787         //new B().Test<System.Collections.Generic.KeyValuePair<string, string>>();
788         new A<int>().Test();
789         new A<object>().Test();
790         new A<string>().Test();
791                 return 0;
792     }
793
794         class ArrayContainer<T> {
795                 private T[,] container = new T[1,1];
796
797                 public T Prop {
798                         [MethodImplAttribute (MethodImplOptions.NoInlining)]
799                         get {
800                                 return container [0, 0];
801                         }
802                         [MethodImplAttribute (MethodImplOptions.NoInlining)]
803                         set {
804                                 container [0, 0] = value;
805                         }
806                 }
807         }
808
809         [MethodImplAttribute (MethodImplOptions.NoInlining)]
810         public static int test_0_multi_dim_arrays () {
811                 var c = new ArrayContainer<int> ();
812                 c.Prop = 5;
813                 return c.Prop == 5 ? 0 : 1;
814         }
815
816         [MethodImplAttribute (MethodImplOptions.NoInlining)]
817         static T2 rgctx_in_call_innner_inner<T1, T2> (T1 t1, T2 t2) {
818                 return t2;
819         }
820
821         [MethodImplAttribute (MethodImplOptions.NoInlining)]
822         static GFoo3<T> rgctx_in_call_inner<T> (T t) {
823                 return rgctx_in_call_innner_inner (1, new GFoo3<T> ());
824         }
825
826     public static int test_0_rgctx_in_call () {
827                 // The call is made through the rgctx call, and it needs an IN trampoline
828                 var t = rgctx_in_call_inner (1);
829                 if (t is GFoo3<int>)
830                         return 0;
831                 return 1;
832         }
833
834         [MethodImplAttribute (MethodImplOptions.NoInlining)]
835         static void arm_params1<T> (T t1, T t2, T t3, T t4, T t5, T t6) {
836         }
837
838         [MethodImplAttribute (MethodImplOptions.NoInlining)]
839         static void arm_params2<T> (T t1, T t2, T t3, long t4, T t5, T t6) {
840         }
841
842         public static int test_0_arm_param_passing () {
843                 arm_params1<int> (1, 2, 3, 4, 5, 6);
844                 arm_params1<int> (1, 2, 3, 4, 5, 6);
845                 return 0;
846         }
847
848         sealed class ScheduledItem<TAbsolute, TValue> {
849                 private readonly object _scheduler;
850                 private readonly TValue _state;
851                 private readonly object _action;
852
853                 public ScheduledItem(object o, TValue state, object action, TAbsolute dueTime) {
854                         _state = state;
855                 }
856         }
857
858     abstract class VirtualTimeSchedulerBase<TAbsolute, TRelative> {
859         public abstract void ScheduleAbsolute<TState>(TState state, TAbsolute dueTime);
860         }
861
862         class VirtualTimeScheduler<TAbsolute, TRelative> : VirtualTimeSchedulerBase<TAbsolute, TRelative> {
863                 public override void ScheduleAbsolute<TState>(TState state, TAbsolute dueTime) {
864                         var si = new ScheduledItem<TAbsolute, TState>(this, state, null, dueTime);
865                 }
866         }
867
868         public static int test_0_rx_mixed_regress () {
869                 var v = new VirtualTimeScheduler<long, long> ();
870                 v.ScheduleAbsolute<Action> (null, 22);
871                 return 0;
872         }
873
874         public class Base {
875                 public virtual T foo<T> (T t) {
876                         return t;
877                 }
878         }
879
880         class Class1 : Base {
881                 public object o;
882
883                 public override T foo<T> (T t) {
884                         o = t;
885                         return t;
886                 }
887         }
888
889         class Class2 : Base {
890                 public object o;
891
892                 public override T foo<T> (T t) {
893                         o = t;
894                         return t;
895                 }
896         }
897
898         [MethodImplAttribute (MethodImplOptions.NoInlining)]
899         public static void bar<T> (Base b, T t) {
900                 b.foo (t);
901         }
902
903         public static int test_0_virtual_generic () {
904                 Class1 c1 = new Class1 ();
905                 Class2 c2 = new Class2 ();
906                 bar (c1, 5);
907                 if (!(c1.o is int) || ((int)c1.o != 5))
908                         return 1;
909                 bar (c1, 6.0);
910                 if (!(c1.o is double) || ((double)c1.o != 6.0))
911                         return 2;
912                 bar (c1, 7.0f);
913                 if (!(c1.o is float) || ((float)c1.o != 7.0f))
914                         return 3;
915                 bar (c2, 5);
916                 if (!(c2.o is int) || ((int)c2.o != 5))
917                         return 4;
918                 bar (c2, 6.0);
919                 bar (c2, 7.0f);
920                 return 0;
921         }
922
923         [MethodImplAttribute (MethodImplOptions.NoInlining)]
924         static string to_string<T, T2>(T t, T2 t2) {
925                 return t.ToString ();
926         }
927
928         enum AnEnum {
929                 One,
930                 Two
931         };
932
933         public static int test_0_constrained_tostring () {
934                 if (to_string<int, int> (1, 1) != "1")
935                         return 1;
936                 if (to_string<AnEnum, int> (AnEnum.One, 1) != "One")
937                         return 2;
938                 if (to_string<string, int> ("A", 1) != "A")
939                         return 3;
940                 return 0;
941         }
942
943         [MethodImplAttribute (MethodImplOptions.NoInlining)]
944         static int get_hash<T, T2>(T t, T2 t2) {
945                 return t.GetHashCode ();
946         }
947
948         public static int test_0_constrained_get_hash () {
949                 if (get_hash<int, int> (1, 1) != 1.GetHashCode ())
950                         return 1;
951                 if (get_hash<double, int> (1.0, 1) != 1.0.GetHashCode ())
952                         return 2;
953                 if (get_hash<AnEnum, int> (AnEnum.One, 1) != AnEnum.One.GetHashCode ())
954                         return 3;
955                 if (get_hash<string, int> ("A", 1) != "A".GetHashCode ())
956                         return 4;
957                 return 0;
958         }
959
960         [MethodImplAttribute (MethodImplOptions.NoInlining)]
961         static bool equals<T, T2>(T t, T2 t2) {
962                 return t.Equals (t);
963         }
964
965         public static int test_0_constrained_equals () {
966                 if (equals<int, int> (1, 1) != true)
967                         return 1;
968                 if (equals<double, int> (1.0, 1) != true)
969                         return 2;
970                 if (equals<AnEnum, int> (AnEnum.One, 1) != true)
971                         return 3;
972                 if (equals<string, int> ("A", 1) != true)
973                         return 4;
974                 return 0;
975         }
976
977         interface IGetType {
978                 Type gettype<T, T2>(T t, T2 t2);
979         }
980
981         public class CGetType : IGetType {
982                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
983                 public Type gettype<T, T2>(T t, T2 t2) {
984                         return t.GetType ();
985                 }
986         }
987
988         public static int test_0_constrained_gettype () {
989                 IGetType c = new CGetType ();
990                 if (c.gettype<int, int> (1, 1) != typeof (int))
991                         return 1;
992                 if (c.gettype<string, int> ("A", 1) != typeof (string))
993                         return 2;
994                 return 0;
995         }
996
997         struct Pair<T1, T2> {
998                 public T1 First;
999                 public T2 Second;
1000         }
1001
1002         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1003         public static TState call_del<TState>(TState state, Func<object, TState, TState> action) {
1004                 return action(null, state);
1005         }
1006
1007         public static int test_0_delegate_wrappers () {
1008                 Func<object, Pair<int, int>, Pair<int, int>> del1 = delegate (object o, Pair<int, int> p) { return p; };
1009                 Func<object, Pair<int, int>, Pair<int, int>> del2 = delegate (object o, Pair<int, int> p) { return p; };
1010                 Func<object, Pair<double, int>, Pair<double, int>> del3 = delegate (object o, Pair<double, int> p) { return p; };
1011                 var r1 = call_del<Pair<int, int>> (new Pair<int, int> { First = 1, Second = 2}, del1);
1012                 if (r1.First != 1 || r1.Second != 2)
1013                         return 1;
1014                 var r2 = call_del<Pair<int, int>> (new Pair<int, int> { First = 3, Second = 4}, del2);
1015                 if (r2.First != 3 || r2.Second != 4)
1016                         return 2;
1017                 var r3 = call_del<Pair<double, int>> (new Pair<double, int> { First = 1.0, Second = 2}, del3);
1018                 if (r3.First != 1.0 || r3.Second != 2)
1019                         return 3;
1020                 return 0;
1021         }
1022
1023         class Base<T> {
1024                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1025                 public object foo<T1> (T1 t1, T t, object o) {
1026                         return o;
1027                 }
1028         }
1029
1030         class AClass : Base<long> {
1031
1032                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1033                 public object bar<T> (T t, long time, object o) {
1034                         return foo (t, time, o);
1035                 }
1036         }
1037
1038         public static int test_0_out_in_wrappers () {
1039                 var a = new AClass ();
1040                 object o1 = "A";
1041                 object o2 = a.bar<long> (1024, 0, o1);
1042                 if (o1 != o2)
1043                         return 1;
1044                 return 0;               
1045         }
1046
1047                 interface BIFace {
1048                         object AMethod ();
1049                 }
1050
1051                 class Base<TAbsolute, T2> : BIFace {
1052
1053                         public TAbsolute Clock { get; set; }
1054
1055                         public virtual object AMethod () {
1056                                 return Clock;
1057                         }
1058                 }
1059
1060                 class BClass : Base<long, long> {
1061                 }
1062
1063         public static int test_0_regress_1 () {
1064                 BIFace c = new BClass ();
1065                 object o = c.AMethod ();
1066                 if (!(o is long) || ((long)o != 0))
1067                         return 1;
1068                 return 0;
1069         }
1070
1071         interface IFace3 {
1072                 T unbox_any<T> (object o);
1073         }
1074
1075         class Class3 : IFace3 {
1076                 public virtual T unbox_any<T> (object o) {
1077                         return (T)o;
1078                 }
1079         }
1080
1081         public static int test_0_unbox_any () {
1082                 IFace3 o = new Class3 ();
1083                 if (o.unbox_any<int> (16) != 16)
1084                         return 1;
1085                 if (o.unbox_any<long> ((long)32) != 32)
1086                         return 2;
1087                 if (o.unbox_any<double> (2.0) != 2.0)
1088                         return 3;
1089                 try {
1090                         o.unbox_any<int> (2.0);
1091                         return 4;
1092                 } catch (Exception) {
1093                 }
1094                 return 0;
1095         }
1096
1097         interface IFace4 {
1098                 TSource Catch<TSource, TException>(TSource t)  where TException : Exception;
1099         }
1100
1101         class Class4 : IFace4 {
1102                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1103                         public TSource Catch<TSource, TException>(TSource t)  where TException : Exception {
1104                         return t;
1105                 }
1106         }
1107
1108         // Check that mixed instantiations are correctly created/found in AOT
1109         public static int test_0_constraints () {
1110                 IFace4 o = new Class4 ();
1111                 o.Catch<int, Exception> (1);
1112                 return 0;
1113         }
1114
1115         internal static Type Process<TSource, TElement> (TSource[] arr, Action<TElement, TElement> call) {
1116                 arr [0] = default (TSource);
1117                 return typeof (TSource);
1118         }
1119
1120         interface IFace5 {
1121                 Type foo<T> ();
1122         }
1123
1124         class Class5 : IFace5 {
1125                 public Type foo<T> () {
1126                         return Process<KeyValuePair<long, T>, T> (new KeyValuePair<long, T> [10], null);
1127                 }
1128         }
1129
1130         public static int test_0_rgctx_call_from_gshared_code () {
1131                 var c = new Class5 ();
1132                 if (c.foo<string> () != typeof (KeyValuePair<long, string>))
1133                         return 1;
1134                 return 0;
1135         }
1136
1137         public class Enumbers<T> {
1138                 public object Enumerate (List<KeyValuePair<T, string>> alist)
1139                 {
1140                         return alist.ToArray ();
1141                 }
1142         }
1143
1144         public static int test_0_checkthis_gshared_call () {
1145                 Enumbers<string> e = new Enumbers<string> ();
1146                 try {
1147                         e.Enumerate (null);
1148                         return 1;
1149                 }
1150                 catch (NullReferenceException) {
1151                 }
1152                 return 0;
1153         }
1154
1155         interface IFace6 {
1156                 T[] Del<T> (T t);
1157         }
1158
1159         class Class6 : IFace6 {
1160                 public T[] Del<T> (T t) {
1161                         var res = new T [5];
1162                         Func<T, T, T, T, T> func = delegate(T t1, T t2, T t3, T t4) { res [0] = t1; res [1] = t2; res [2] = t3; res [3] = t4; return t1; };
1163                         var v = func.BeginInvoke(t, t, t, t, null, null);
1164                         res [4] = func.EndInvoke (v);
1165                         return res;
1166                 }
1167         }
1168
1169         // FIXME: The runtime-invoke wrapper used by BeginInvoke is not found
1170         [Category ("!FULLAOT")]
1171         public static int test_0_begin_end_invoke () {
1172                 IFace6 o = new Class6 ();
1173                 var arr1 = o.Del (1);
1174                 if (arr1 [0] != 1 || arr1 [1] != 1 || arr1 [2] != 1 || arr1 [3] != 1 || arr1 [4] != 1)
1175                         return 1;
1176                 var arr2 = o.Del (2.0);
1177                 if (arr2 [0] != 2.0 || arr2 [1] != 2.0 || arr2 [2] != 2.0 || arr2 [3] != 2.0 || arr2 [4] != 2.0)
1178                         return 2;
1179                 return 0;
1180         }
1181
1182         public class TAbstractTableItem<TC> {
1183                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1184                 public static void SetProperty<TV> () {    }
1185
1186                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1187                 public static void Test () {
1188                         SetProperty<bool> ();
1189                 }
1190         }
1191
1192         public static int test_0_gsharedvt_method_on_shared_class () {
1193        TAbstractTableItem<object>.Test ();
1194            return 0;
1195         }
1196
1197         interface IFaceBox {
1198                 object box<T> (T t);
1199         }
1200
1201         class ClassBox : IFaceBox {
1202                 public object box<T> (T t) {
1203                         object o = t;
1204                         return o;
1205                 }
1206         }
1207
1208         public static int test_0_nullable_box () {
1209                 IFaceBox c = new ClassBox ();
1210                 int i = 5;
1211                 object o = c.box<int?> (i);
1212                 if ((int)o != i)
1213                         return 1;
1214                 if (c.box<int?> (null) != null)
1215                         return 2;
1216                 long l = Int64.MaxValue - 1;
1217                 o = c.box<long?> (l);
1218                 if ((long)o != l)
1219                         return 3;
1220                 if (c.box<long?> (null) != null)
1221                         return 4;
1222                 string s = "A";
1223                 if (c.box<string> (s) != (object)s)
1224                         return 5;
1225                 return 0;
1226         }
1227
1228         interface IFaceUnbox2 {
1229                 T unbox<T> (object o);
1230         }
1231
1232         class ClassUnbox2 : IFaceUnbox2 {
1233                 public T unbox<T> (object o) {
1234                         return (T)o;
1235                 }
1236         }
1237
1238         public static int test_0_nullable_unbox () {    
1239                 IFaceUnbox2 c = new ClassUnbox2 ();
1240                 int? i = c.unbox<int?> (5);
1241                 if (i != 5)
1242                         return 1;
1243                 int? j = c.unbox<int?> (null);
1244                 if (j != null)
1245                         return 2;
1246                 return 0;
1247         }
1248
1249         interface IConstrained {
1250                 void foo ();
1251                 void foo_ref_arg (string s);
1252         }
1253
1254         interface IConstrained<T3> {
1255                 void foo_gsharedvt_arg (T3 s);
1256                 T3 foo_gsharedvt_ret (T3 s);
1257         }
1258
1259         static object constrained_res;
1260
1261         struct ConsStruct : IConstrained {
1262                 public int i;
1263
1264                 public void foo () {
1265                         constrained_res = i;
1266                 }
1267
1268                 public void foo_ref_arg (string s) {
1269                         constrained_res = s == "A" ? 42 : 0;
1270                 }
1271         }
1272
1273         class ConsClass : IConstrained {
1274                 public int i;
1275
1276                 public void foo () {
1277                         constrained_res = i;
1278                 }
1279
1280                 public void foo_ref_arg (string s) {
1281                         constrained_res = s == "A" ? 43 : 0;
1282                 }
1283         }
1284
1285         struct ConsStruct<T> : IConstrained<T> {
1286                 public void foo_gsharedvt_arg (T s) {
1287                         constrained_res = s;
1288                 }
1289
1290                 public T foo_gsharedvt_ret (T s) {
1291                         return s;
1292                 }
1293         }
1294
1295         struct ConsStructThrow : IConstrained {
1296                 public void foo () {
1297                         throw new Exception ();
1298                 }
1299
1300                 public void foo_ref_arg (string s) {
1301                 }
1302         }
1303
1304         interface IFaceConstrained {
1305                 void constrained_void_iface_call<T, T2>(T t, T2 t2) where T2 : IConstrained;
1306                 void constrained_void_iface_call_ref_arg<T, T2>(T t, T2 t2) where T2 : IConstrained;
1307                 void constrained_void_iface_call_gsharedvt_arg<T, T2, T3>(T t, T2 t2, T3 t3) where T2 : IConstrained<T>;
1308                 T constrained_iface_call_gsharedvt_ret<T, T2, T3>(T t, T2 t2, T3 t3) where T2 : IConstrained<T>;
1309                 T2 constrained_normal_call<T, T2>(T t, T2 t2) where T2 : VClass;
1310         }
1311
1312         class ClassConstrained : IFaceConstrained {
1313                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1314                 public void constrained_void_iface_call<T, T2>(T t, T2 t2) where T2 : IConstrained {
1315                         t2.foo ();
1316                 }
1317
1318                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1319                 public void constrained_void_iface_call_ref_arg<T, T2>(T t, T2 t2) where T2 : IConstrained {
1320                         t2.foo_ref_arg ("A");
1321                 }
1322
1323                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1324                 public void constrained_void_iface_call_gsharedvt_arg<T, T2, T3>(T t, T2 t2, T3 t3) where T2 : IConstrained<T> {
1325                         t2.foo_gsharedvt_arg (t);
1326                 }
1327
1328                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1329                 public T constrained_iface_call_gsharedvt_ret<T, T2, T3>(T t, T2 t2, T3 t3) where T2 : IConstrained<T> {
1330                         return t2.foo_gsharedvt_ret (t);
1331                 }
1332
1333                 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1334                 public T2 constrained_normal_call<T, T2>(T t, T2 t2) where T2 : VClass {
1335                         /* This becomes a constrained call even through 't2' is forced to be a reference type by the constraint */
1336                         return (T2)t2.foo (5);
1337                 }
1338         }
1339
1340         class VClass {
1341                 public virtual VClass foo (int i) {
1342                         return this;
1343                 }
1344         }
1345
1346         public static int test_0_constrained_void_iface_call () {
1347                 IFaceConstrained c = new ClassConstrained ();
1348                 var s = new ConsStruct () { i = 42 };
1349                 constrained_res = null;
1350                 c.constrained_void_iface_call<int, ConsStruct> (1, s);
1351                 if (!(constrained_res is int) || ((int)constrained_res) != 42)
1352                         return 1;
1353                 constrained_res = null;
1354                 c.constrained_void_iface_call_ref_arg<int, ConsStruct> (1, s);
1355                 if (!(constrained_res is int) || ((int)constrained_res) != 42)
1356                         return 2;
1357                 var s2 = new ConsClass () { i = 43 };
1358                 constrained_res = null;
1359                 c.constrained_void_iface_call<int, ConsClass> (1, s2);
1360                 if (!(constrained_res is int) || ((int)constrained_res) != 43)
1361                         return 3;
1362                 constrained_res = null;
1363                 c.constrained_void_iface_call_ref_arg<int, ConsClass> (1, s2);
1364                 if (!(constrained_res is int) || ((int)constrained_res) != 43)
1365                         return 4;
1366                 return 0;
1367         }
1368
1369         public static int test_0_constrained_eh () {
1370                 var s2 = new ConsStructThrow () { };
1371                 try {
1372                         IFaceConstrained c = new ClassConstrained ();
1373                         c.constrained_void_iface_call<int, ConsStructThrow> (1, s2);
1374                         return 1;
1375                 } catch (Exception) {
1376                         return 0;
1377                 }
1378         }
1379
1380         public static int test_0_constrained_void_iface_call_gsharedvt_arg () {
1381                 // This tests constrained calls through interfaces with one gsharedvt arg, like IComparable<T>.CompareTo ()
1382                 IFaceConstrained c = new ClassConstrained ();
1383
1384                 var s = new ConsStruct<int> ();
1385                 constrained_res = null;
1386                 c.constrained_void_iface_call_gsharedvt_arg<int, ConsStruct<int>, int> (42, s, 55);
1387                 if (!(constrained_res is int) || ((int)constrained_res) != 42)
1388                         return 1;
1389
1390                 var s2 = new ConsStruct<string> ();
1391                 constrained_res = null;
1392                 c.constrained_void_iface_call_gsharedvt_arg<string, ConsStruct<string>, int> ("A", s2, 55);
1393                 if (!(constrained_res is string) || ((string)constrained_res) != "A")
1394                         return 2;
1395
1396                 return 0;
1397         }
1398
1399         public static int test_0_constrained_iface_call_gsharedvt_ret () {
1400                 IFaceConstrained c = new ClassConstrained ();
1401
1402                 var s = new ConsStruct<int> ();
1403                 int ires = c.constrained_iface_call_gsharedvt_ret<int, ConsStruct<int>, int> (42, s, 55);
1404                 if (ires != 42)
1405                         return 1;
1406
1407                 var s2 = new ConsStruct<string> ();
1408                 string sres = c.constrained_iface_call_gsharedvt_ret<string, ConsStruct<string>, int> ("A", s2, 55);
1409                 if (sres != "A")
1410                         return 2;
1411
1412                 return 0;
1413         }
1414
1415         public static int test_0_constrained_normal_call () {
1416                 IFaceConstrained c = new ClassConstrained ();
1417
1418                 var o = new VClass ();
1419                 var res = c.constrained_normal_call<int, VClass> (1, o);
1420                 return res == o ? 0 : 1;
1421         }
1422
1423         public static async Task<T> FooAsync<T> (int i, int j) {
1424                 Task<int> t = new Task<int> (delegate () { return 42; });
1425                 var response = await t;
1426                 return default(T);
1427         }
1428
1429         [MethodImplAttribute (MethodImplOptions.NoInlining)]
1430         public static void call_async<T> (int i, int j) {
1431                 Task<T> t = FooAsync<T> (1, 2);
1432                 // FIXME: This doesn't work
1433                 //t.RunSynchronously ();
1434         }
1435
1436         // In AOT mode, the async infrastructure depends on gsharedvt methods
1437         public static int test_0_async_call_from_generic () {
1438                 call_async<string> (1, 2);
1439                 return 0;
1440         }
1441
1442         public static int test_0_array_helper_gsharedvt () {
1443                 var arr = new AnEnum [16];
1444                 var c = new ReadOnlyCollection<AnEnum> (arr);
1445                 return c.Contains (AnEnum.Two) == false ? 0 : 1;
1446         }
1447 }
1448
1449 // #13191
1450 public class MobileServiceCollection<TTable, TCol>
1451 {
1452         public async Task<int> LoadMoreItemsAsync(int count = 0) {
1453                 await Task.Delay (1000);
1454                 int results = await ProcessQueryAsync ();
1455                 return results;
1456         }
1457
1458         protected async virtual Task<int> ProcessQueryAsync() {
1459                 await Task.Delay (1000);
1460                 throw new Exception ();
1461         }
1462 }
1463
1464 #if !MOBILE
1465 public class GSharedTests : Tests {
1466 }
1467 #endif