2 using System.Collections.Generic;
3 using System.Runtime.CompilerServices;
6 public int i, j, k, l, m, n;
14 public static T static_dummy;
15 public static T static_t;
16 public static Foo static_f;
29 [MethodImplAttribute (MethodImplOptions.NoInlining)]
30 public GFoo3 (T i1, T i2) {
37 // Tests for generic sharing of vtypes.
38 // 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 // FIXME: Add mixed ref/noref tests, i.e. Dictionary<string, int>
44 public class GSharedTests
50 public static int Main (String[] args) {
51 return TestDriver.RunTests (typeof (Tests), args);
55 [MethodImplAttribute (MethodImplOptions.NoInlining)]
56 static void gshared<T> (T [] array, int i, int j) {
58 array [i] = array [j];
62 // Test that the gshared and gsharedvt versions don't mix
63 public static int test_0_vt_gshared () {
64 string[] sarr = new string [2] { "A", "B" };
66 gshared<string> (sarr, 0, 1);
68 Foo[] arr = new Foo [2];
69 arr [0] = new Foo () { i = 1, j = 2 };
70 arr [1] = new Foo () { i = 3, j = 4 };
72 gshared<Foo> (arr, 0, 1);
73 if (arr [0].i != 3 || arr [0].j != 4)
75 if (arr [1].i != 1 || arr [1].j != 2)
81 static void ldelem_stelem<T> (T [] array, int i, int j) {
83 array [i] = array [j];
87 public static int test_0_vt_ldelem_stelem () {
88 Foo[] arr = new Foo [2];
89 arr [0] = new Foo () { i = 1, j = 2 };
90 arr [1] = new Foo () { i = 3, j = 4 };
92 ldelem_stelem<Foo> (arr, 0, 1);
93 if (arr [0].i != 3 || arr [0].j != 4)
95 if (arr [1].i != 1 || arr [1].j != 2)
98 int[] arr2 = new int [2] { 1, 2 };
99 ldelem_stelem<int> (arr2, 0, 1);
100 if (arr2 [0] !=2 || arr2 [1] != 1)
106 [MethodImplAttribute (MethodImplOptions.NoInlining)]
107 private static void initobj<T> (T [] array, int i, int j) {
112 public static int test_0_vt_initobj () {
113 Foo[] arr = new Foo [2];
114 arr [0] = new Foo () { i = 1, j = 2 };
115 arr [1] = new Foo () { i = 3, j = 4 };
117 initobj<Foo> (arr, 0, 1);
118 if (arr [0].i != 0 || arr [0].j != 0)
120 if (arr [1].i != 3 || arr [1].j != 4)
125 [MethodImplAttribute (MethodImplOptions.NoInlining)]
126 static T ldobj_stobj<T> (ref T t1, ref T t2) {
133 public static int test_0_vt_ldobj_stobj () {
136 if (ldobj_stobj (ref i, ref j) != 6)
138 if (i != 6 || j != 0)
142 if (ldobj_stobj (ref d1, ref d2) != 2.0)
144 if (d1 != 2.0 || d2 != 0.0)
149 [MethodImplAttribute (MethodImplOptions.NoInlining)]
150 private static void box<T1, T> (T [] array, object[] arr) {
151 object x = array [0];
155 public static int test_0_vt_box () {
156 Foo[] arr = new Foo [2];
157 arr [0] = new Foo () { i = 1, j = 2 };
159 object[] arr2 = new object [16];
160 box<int, Foo> (arr, arr2);
161 if (arr2 [0].GetType () != typeof (Foo))
163 Foo f = (Foo)arr2 [0];
164 if (f.i != 1 || f.j != 2)
166 string[] arr3 = new string [16];
167 object[] arr4 = new object [16];
169 box<int, string> (arr3, arr4);
170 if (arr4 [0] != (object)arr3 [0])
175 [MethodImplAttribute (MethodImplOptions.NoInlining)]
176 private static void unbox_any<T> (T [] array, object[] arr) {
181 public static int test_0_vt_unbox_any () {
182 int[] iarr = new int [16];
183 unbox_any<int> (iarr, new object [] { 12 });
185 Foo[] arr = new Foo [2];
187 object[] arr2 = new object [16];
188 arr2 [0] = new Foo () { i = 1, j = 2 };
189 unbox_any<Foo> (arr, arr2);
190 if (arr [0].i != 1 || arr [0].j != 2)
195 interface IFaceUnbox {
196 T Unbox<T, T2> (T t, T2 t2, object o);
199 class ClassUnbox : IFaceUnbox {
200 public T Unbox<T, T2> (T t, T2 t2, object o) {
205 // unbox.any on a ref type in a gsharedvt method
206 public static int test_0_ref_gsharedvt_aot_unbox_any () {
207 IFaceUnbox iface = new ClassUnbox ();
208 string s = iface.Unbox<string, int> ("A", 2, "A");
214 [MethodImplAttribute (MethodImplOptions.NoInlining)]
215 static void ldfld_nongeneric<T> (GFoo<T>[] foo, int[] arr) {
219 [MethodImplAttribute (MethodImplOptions.NoInlining)]
220 static void ldfld<T> (GFoo<T>[] foo, T[] arr) {
224 [MethodImplAttribute (MethodImplOptions.NoInlining)]
225 static void stfld_nongeneric<T> (GFoo<T>[] foo, int[] arr) {
229 [MethodImplAttribute (MethodImplOptions.NoInlining)]
230 static void stfld<T> (GFoo<T>[] foo, T[] arr) {
234 [MethodImplAttribute (MethodImplOptions.NoInlining)]
235 static void ldflda<T> (GFoo<T>[] foo, int[] arr) {
236 arr [0] = foo [0].f.i;
239 public static int test_0_vt_ldfld_stfld () {
240 var foo = new GFoo<Foo> () { t = new Foo () { i = 1, j = 2 }, i = 5, f = new Foo () { i = 5, j = 6 } };
241 var farr = new GFoo<Foo>[] { foo };
243 /* Normal fields with a variable offset */
244 var iarr = new int [10];
245 ldfld_nongeneric<Foo> (farr, iarr);
249 stfld_nongeneric<Foo> (farr, iarr);
250 if (farr [0].i != 16)
253 /* Variable type field with a variable offset */
254 var arr = new Foo [10];
255 ldfld<Foo> (farr, arr);
256 if (arr [0].i != 1 || arr [0].j != 2)
258 arr [0] = new Foo () { i = 3, j = 4 };
259 stfld<Foo> (farr, arr);
260 if (farr [0].t.i != 3 || farr [0].t.j != 4)
263 ldflda<Foo> (farr, iarr);
270 [MethodImplAttribute (MethodImplOptions.NoInlining)]
271 static void stsfld<T> (T[] arr) {
272 GFoo<T>.static_t = arr [0];
275 [MethodImplAttribute (MethodImplOptions.NoInlining)]
276 static void ldsfld<T> (T[] arr) {
277 arr [0] = GFoo<T>.static_t;
280 [MethodImplAttribute (MethodImplOptions.NoInlining)]
281 static void ldsflda<T> (int[] iarr) {
282 iarr [0] = GFoo<T>.static_f.i;
285 public static int test_0_stsfld () {
286 Foo[] farr = new Foo [] { new Foo () { i = 1, j = 2 } };
289 if (GFoo<Foo>.static_t.i != 1 || GFoo<Foo>.static_t.j != 2)
292 Foo[] farr2 = new Foo [1];
294 if (farr2 [0].i != 1 || farr2 [0].j != 2)
297 var iarr = new int [10];
298 GFoo<Foo>.static_f = new Foo () { i = 5, j = 6 };
306 [MethodImplAttribute (MethodImplOptions.NoInlining)]
307 static object newarr<T> () {
308 object o = new T[10];
312 public static int test_0_vt_newarr () {
313 object o = newarr<Foo> ();
319 [MethodImplAttribute (MethodImplOptions.NoInlining)]
320 static Type ldtoken<T> () {
321 return typeof (GFoo<T>);
324 public static int test_0_vt_ldtoken () {
325 Type t = ldtoken<Foo> ();
326 if (t != typeof (GFoo<Foo>))
329 if (t != typeof (GFoo<int>))
335 public static int test_0_vtype_list () {
336 List<int> l = new List<int> ();
344 [MethodImplAttribute (MethodImplOptions.NoInlining)]
345 static int args_simple<T> (T t, int i) {
349 [MethodImplAttribute (MethodImplOptions.NoInlining)]
350 static int args_simple<T> (T t, int i, T t2) {
354 [MethodImplAttribute (MethodImplOptions.NoInlining)]
355 static Type args_rgctx<T> (T t, int i) {
359 [MethodImplAttribute (MethodImplOptions.NoInlining)]
360 static Type eh_in<T> (T t, int i) {
361 throw new OverflowException ();
364 [MethodImplAttribute (MethodImplOptions.NoInlining)]
365 static T return_t<T> (T t) {
369 [MethodImplAttribute (MethodImplOptions.NoInlining)]
370 T return_this_t<T> (T t) {
374 public static int test_0_gsharedvt_in () {
375 // Check that the non-generic argument is passed at the correct stack position
376 int r = args_simple<bool> (true, 42);
379 r = args_simple<Foo> (new Foo (), 43);
382 // Check that the proper rgctx is passed to the method
383 Type t = args_rgctx<int> (5, 42);
384 if (t != typeof (int))
386 var v = args_simple<GFoo2<int>> (new GFoo2<int> () { t = 11, t2 = 12 }, 44, new GFoo2<int> () { t = 11, t2 = 12 });
389 // Check that EH works properly
392 } catch (OverflowException) {
397 public static int test_0_gsharedvt_in_ret () {
398 int i = return_t<int> (42);
401 long l = return_t<long> (Int64.MaxValue);
402 if (l != Int64.MaxValue)
404 double d = return_t<double> (3.0);
407 float f = return_t<float> (3.0f);
410 short s = return_t<short> (16);
413 var v = new GFoo2<int> () { t = 55, t2 = 32 };
414 var v2 = return_t<GFoo2<int>> (v);
415 if (v2.t != 55 || v2.t2 != 32)
417 i = new GSharedTests ().return_this_t<int> (42);
423 public static int test_0_gsharedvt_in_delegates () {
424 Func<int, int> f = new Func<int, int> (return_t<int>);
430 [MethodImplAttribute (MethodImplOptions.NoInlining)]
431 static T return2_t<T> (T t) {
435 public static int test_0_gsharedvt_calls () {
436 if (return2_t (2) != 2)
438 if (return2_t ("A") != "A")
440 if (return2_t (2.0) != 2.0)
445 static GFoo3<T> newobj<T> (T t1, T t2) {
446 return new GFoo3<T> (t1, t2);
449 public static int test_0_gshared_new () {
450 var g1 = newobj (1, 2);
451 if (g1.t != 1 || g1.t2 != 2)
453 var g2 = newobj (1.0, 2.0);
454 if (g1.t != 1.0 || g1.t2 != 2.0)
460 [MethodImplAttribute (MethodImplOptions.NoInlining)]
461 static GFoo2<T> newobj_vt<T> (T t1, T t2) {
462 return new GFoo2<T> () { t = t1, t2 = t2 };
465 public static int test_0_gshared_new_vt () {
466 GFoo2<int> v1 = newobj_vt (1, 2);
467 if (v1.t != 1 || v1.t2 != 2)
469 GFoo2<double> v2 = newobj_vt (1.0, 2.0);
470 if (v2.t != 1.0 || v2.t2 != 2.0)
476 // Tests for transitioning out of gsharedvt code
479 // T1=Nullable<..> is not currently supported by gsharedvt
481 [MethodImplAttribute (MethodImplOptions.NoInlining)]
482 static T return_t_nogshared<T,T1> (T t) {
485 //Console.WriteLine ("X: " + t);
489 [MethodImplAttribute (MethodImplOptions.NoInlining)]
490 static int return_int_nogshared<T,T1> (T t) {
496 [MethodImplAttribute (MethodImplOptions.NoInlining)]
497 static A return_vtype_nogshared<T,T1> (T t) {
500 return new A () { a = 1, b = 2, c = 3 };
503 [MethodImplAttribute (MethodImplOptions.NoInlining)]
504 static T return2_t_out<T> (T t) {
505 return return_t_nogshared<T, int?> (t);
508 [MethodImplAttribute (MethodImplOptions.NoInlining)]
509 static int return2_int_out<T> (T t) {
510 return return_int_nogshared<T, int?> (t);
513 [MethodImplAttribute (MethodImplOptions.NoInlining)]
514 static A return2_vtype_out<T> (T t) {
515 return return_vtype_nogshared<T, int?> (t);
522 [Category ("!FULLAOT")]
523 public static int test_0_gsharedvt_out () {
524 if (return2_t_out (2) != 2)
526 if (return2_t_out ("A") != "A")
528 if (return2_t_out (2.0) != 2.0)
530 if (return2_t_out (2.0f) != 2.0f)
532 A a = new A () { a = 1, b = 2, c = 3 };
533 A a2 = return2_t_out (a);
534 if (a2.a != 1 || a2.b != 2 || a2.c != 3)
536 // Calls with non gsharedvt return types
537 if (return2_int_out (1) != 2)
539 A c = return2_vtype_out (a);
540 if (a2.a != 1 || a2.b != 2 || a2.c != 3)
545 public class GenericClass<T> {
546 public static T Z (IList<T> x, int index)
552 public static int test_0_generic_array_helpers () {
553 int[] x = new int[] {100, 200};
555 // Generic array helpers should be treated as gsharedvt-out
556 if (GenericClass<int>.Z (x, 0) != 100)
562 internal class IntComparer : IComparer<int>
564 public int Compare (int ix, int iy)
569 if (((uint) ix) < ((uint) iy))
575 [MethodImplAttribute (MethodImplOptions.NoInlining)]
576 static int gshared_out_iface<T> (T t1, T t2, IComparer<T> comp) {
577 return comp.Compare (t1, t2);
580 public static int test_0_gshared_out_iface () {
581 // Call out from gshared to a nongeneric method through a generic interface method
582 if (gshared_out_iface (2, 2, new IntComparer ()) != 0)
588 public int i1, i2, i3;
592 int i1, i2, i3, i4, i5;
596 [MethodImplAttribute (MethodImplOptions.NoInlining)]
597 public static void locals<T> (T t) {
598 Foo2<T> t2 = new Foo2<T> ();
602 public static int test_0_locals () {
603 // Test that instantiations of type parameters are allocated the proper local type
605 for (int j = 0; j < 10; ++j)
607 locals<Foo1> (new Foo1 () { i1 = 1, i2 = 2, i3 = 3 });
611 public interface IFace<T> {
612 T return_t_iface (T t);
615 public class Parent<T> {
616 public virtual T return_t_vcall (T t) {
617 throw new Exception ();
622 public class Child<T> : Parent<T>, IFace<T> {
623 public override T return_t_vcall (T t) {
626 public T return_t_iface (T t) {
631 [MethodImplAttribute (MethodImplOptions.NoInlining)]
632 static T return_t_vcall<T> (Parent<T> r, T t) {
633 return r.return_t_vcall (t);
636 public static int test_0_vcalls () {
637 if (return_t_vcall (new Child<int> (), 2) != 2)
640 for (int i = 0; i < 10; ++i) {
641 if (return_t_vcall (new Child<int> (), 2) != 2)
644 if (return_t_vcall (new Child<double> (), 2.0) != 2.0)
649 [MethodImplAttribute (MethodImplOptions.NoInlining)]
650 static T return_t_iface<T> (IFace<T> r, T t) {
651 return r.return_t_iface (t);
654 public static int test_0_iface_calls () {
655 if (return_t_iface (new Child<int> (), 2) != 2)
657 if (return_t_iface (new Child<double> (), 2.0) != 2.0)
666 static KeyValuePair<T1, T2> make_kvp<T1, T2> (T1 t1, T2 t2) {
667 return new KeyValuePair<T1, T2> (t1, t2);
670 static T2 use_kvp<T1, T2> (KeyValuePair<T1, T2> kvp) {
674 class ClassKVP : IFaceKVP {
675 public T do_kvp<T> (T a) {
676 var t = make_kvp (a, a);
677 // argument is an instance of a vtype instantiated with gsharedvt type arguments
682 public static int test_0_gsharedvt_ginstvt_constructed_arg () {
683 IFaceKVP c = new ClassKVP ();
684 if (c.do_kvp<long> (1) != 1)
694 class Getter : IGetter
696 public T Get<T>() { return default(T); }
699 abstract class Session
701 public abstract IGetter Getter { get; }
704 class IosSession : Session
706 private IGetter getter = new Getter();
707 public override IGetter Getter { get { return getter; } }
713 public static int test_0_regress_5156 () {
714 new IosSession().Getter.Get<ENUM_TYPE>();
729 public void OuterMethod<TArg1>(TArg1 value)
731 this.InnerMethod<TArg1, long>(value, 0);
734 private void InnerMethod<TArg1, TArg2>(TArg1 v1, TArg2 v2)
736 //Console.WriteLine("{0} {1}",v1,v2);
740 public static int test_0_regress_2096 () {
743 // The following work:
744 a.OuterMethod<int>(1);
745 a.OuterMethod<DateTime>(DateTime.Now);
748 a.OuterMethod<VT>(v);
751 // Next line will crash with Attempting to JIT compile method on device
752 // Attempting to JIT compile method
759 public void Test<T>()
761 //System.Console.WriteLine(typeof(T));
769 new B().Test<System.Collections.Generic.KeyValuePair<T, T>>();
773 public static int test_0_regress_6040 () {
774 //new B().Test<System.Collections.Generic.KeyValuePair<string, string>>();
776 new A<object>().Test();
777 new A<string>().Test();
781 class ArrayContainer<T> {
782 private T[,] container = new T[1,1];
785 [MethodImplAttribute (MethodImplOptions.NoInlining)]
787 return container [0, 0];
789 [MethodImplAttribute (MethodImplOptions.NoInlining)]
791 container [0, 0] = value;
796 [MethodImplAttribute (MethodImplOptions.NoInlining)]
797 public static int test_0_multi_dim_arrays () {
798 var c = new ArrayContainer<int> ();
800 return c.Prop == 5 ? 0 : 1;
803 [MethodImplAttribute (MethodImplOptions.NoInlining)]
804 static T2 rgctx_in_call_innner_inner<T1, T2> (T1 t1, T2 t2) {
808 [MethodImplAttribute (MethodImplOptions.NoInlining)]
809 static GFoo3<T> rgctx_in_call_inner<T> (T t) {
810 return rgctx_in_call_innner_inner (1, new GFoo3<T> ());
813 public static int test_0_rgctx_in_call () {
814 // The call is made through the rgctx call, and it needs an IN trampoline
815 var t = rgctx_in_call_inner (1);
821 [MethodImplAttribute (MethodImplOptions.NoInlining)]
822 static void arm_params1<T> (T t1, T t2, T t3, T t4, T t5, T t6) {
825 [MethodImplAttribute (MethodImplOptions.NoInlining)]
826 static void arm_params2<T> (T t1, T t2, T t3, long t4, T t5, T t6) {
829 public static int test_0_arm_param_passing () {
830 arm_params1<int> (1, 2, 3, 4, 5, 6);
831 arm_params1<int> (1, 2, 3, 4, 5, 6);
835 sealed class ScheduledItem<TAbsolute, TValue> {
836 private readonly object _scheduler;
837 private readonly TValue _state;
838 private readonly object _action;
840 public ScheduledItem(object o, TValue state, object action, TAbsolute dueTime) {
845 abstract class VirtualTimeSchedulerBase<TAbsolute, TRelative> {
846 public abstract void ScheduleAbsolute<TState>(TState state, TAbsolute dueTime);
849 class VirtualTimeScheduler<TAbsolute, TRelative> : VirtualTimeSchedulerBase<TAbsolute, TRelative> {
850 public override void ScheduleAbsolute<TState>(TState state, TAbsolute dueTime) {
851 var si = new ScheduledItem<TAbsolute, TState>(this, state, null, dueTime);
855 public static int test_0_rx_mixed_regress () {
856 var v = new VirtualTimeScheduler<long, long> ();
857 v.ScheduleAbsolute<Action> (null, 22);
862 public virtual T foo<T> (T t) {
867 class Class1 : Base {
870 public override T foo<T> (T t) {
876 class Class2 : Base {
879 public override T foo<T> (T t) {
885 [MethodImplAttribute (MethodImplOptions.NoInlining)]
886 public static void bar<T> (Base b, T t) {
890 public static int test_0_virtual_generic () {
891 Class1 c1 = new Class1 ();
892 Class2 c2 = new Class2 ();
894 if (!(c1.o is int) || ((int)c1.o != 5))
897 if (!(c1.o is double) || ((double)c1.o != 6.0))
900 if (!(c1.o is float) || ((float)c1.o != 7.0f))
903 if (!(c2.o is int) || ((int)c2.o != 5))
910 [MethodImplAttribute (MethodImplOptions.NoInlining)]
911 static string to_string<T, T2>(T t, T2 t2) {
912 return t.ToString ();
919 public static int test_0_constrained_tostring () {
920 if (to_string<int, int> (1, 1) != "1")
922 if (to_string<AnEnum, int> (AnEnum.One, 1) != "One")
924 if (to_string<string, int> ("A", 1) != "A")
929 [MethodImplAttribute (MethodImplOptions.NoInlining)]
930 static int get_hash<T, T2>(T t, T2 t2) {
931 return t.GetHashCode ();
934 public static int test_0_constrained_get_hash () {
935 if (get_hash<int, int> (1, 1) != 1.GetHashCode ())
937 if (get_hash<double, int> (1.0, 1) != 1.0.GetHashCode ())
939 if (get_hash<AnEnum, int> (AnEnum.One, 1) != AnEnum.One.GetHashCode ())
941 if (get_hash<string, int> ("A", 1) != "A".GetHashCode ())
946 [MethodImplAttribute (MethodImplOptions.NoInlining)]
947 static bool equals<T, T2>(T t, T2 t2) {
951 public static int test_0_constrained_equals () {
952 if (equals<int, int> (1, 1) != true)
954 if (equals<double, int> (1.0, 1) != true)
956 if (equals<AnEnum, int> (AnEnum.One, 1) != true)
958 if (equals<string, int> ("A", 1) != true)
963 struct Pair<T1, T2> {
968 [MethodImplAttribute (MethodImplOptions.NoInlining)]
969 public static TState call_del<TState>(TState state, Func<object, TState, TState> action) {
970 return action(null, state);
973 public static int test_0_delegate_wrappers () {
974 Func<object, Pair<int, int>, Pair<int, int>> del1 = delegate (object o, Pair<int, int> p) { return p; };
975 Func<object, Pair<int, int>, Pair<int, int>> del2 = delegate (object o, Pair<int, int> p) { return p; };
976 Func<object, Pair<double, int>, Pair<double, int>> del3 = delegate (object o, Pair<double, int> p) { return p; };
977 var r1 = call_del<Pair<int, int>> (new Pair<int, int> { First = 1, Second = 2}, del1);
978 if (r1.First != 1 || r1.Second != 2)
980 var r2 = call_del<Pair<int, int>> (new Pair<int, int> { First = 3, Second = 4}, del2);
981 if (r2.First != 3 || r2.Second != 4)
983 var r3 = call_del<Pair<double, int>> (new Pair<double, int> { First = 1.0, Second = 2}, del3);
984 if (r3.First != 1.0 || r3.Second != 2)
990 [MethodImplAttribute (MethodImplOptions.NoInlining)]
991 public object foo<T1> (T1 t1, T t, object o) {
996 class AClass : Base<long> {
998 [MethodImplAttribute (MethodImplOptions.NoInlining)]
999 public object bar<T> (T t, long time, object o) {
1000 return foo (t, time, o);
1004 public static int test_0_out_in_wrappers () {
1005 var a = new AClass ();
1007 object o2 = a.bar<long> (1024, 0, o1);
1017 class Base<TAbsolute, T2> : BIFace {
1019 public TAbsolute Clock { get; set; }
1021 public virtual object AMethod () {
1026 class BClass : Base<long, long> {
1029 public static int test_0_regress_1 () {
1030 BIFace c = new BClass ();
1031 object o = c.AMethod ();
1032 if (!(o is long) || ((long)o != 0))
1038 T unbox_any<T> (object o);
1041 class Class3 : IFace3 {
1042 public virtual T unbox_any<T> (object o) {
1047 public static int test_0_unbox_any () {
1048 IFace3 o = new Class3 ();
1049 if (o.unbox_any<int> (16) != 16)
1051 if (o.unbox_any<long> ((long)32) != 32)
1053 if (o.unbox_any<double> (2.0) != 2.0)
1056 o.unbox_any<int> (2.0);
1058 } catch (Exception) {
1064 TSource Catch<TSource, TException>(TSource t) where TException : Exception;
1067 class Class4 : IFace4 {
1068 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1069 public TSource Catch<TSource, TException>(TSource t) where TException : Exception {
1074 // Check that mixed instantiations are correctly created/found in AOT
1075 public static int test_0_constraints () {
1076 IFace4 o = new Class4 ();
1077 o.Catch<int, Exception> (1);
1081 internal static Type Process<TSource, TElement> (TSource[] arr, Action<TElement, TElement> call) {
1082 arr [0] = default (TSource);
1083 return typeof (TSource);
1090 class Class5 : IFace5 {
1091 public Type foo<T> () {
1092 return Process<KeyValuePair<long, T>, T> (new KeyValuePair<long, T> [10], null);
1096 public static int test_0_rgctx_call_from_gshared_code () {
1097 var c = new Class5 ();
1098 if (c.foo<string> () != typeof (KeyValuePair<long, string>))
1103 public class Enumbers<T> {
1104 public object Enumerate (List<KeyValuePair<T, string>> alist)
1106 return alist.ToArray ();
1110 public static int test_0_checkthis_gshared_call () {
1111 Enumbers<string> e = new Enumbers<string> ();
1116 catch (NullReferenceException) {
1125 class Class6 : IFace6 {
1126 public T[] Del<T> (T t) {
1127 var res = new T [5];
1128 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; };
1129 var v = func.BeginInvoke(t, t, t, t, null, null);
1130 res [4] = func.EndInvoke (v);
1135 // FIXME: The runtime-invoke wrapper used by BeginInvoke is not found
1136 [Category ("!FULLAOT")]
1137 public static int test_0_begin_end_invoke () {
1138 IFace6 o = new Class6 ();
1139 var arr1 = o.Del (1);
1140 if (arr1 [0] != 1 || arr1 [1] != 1 || arr1 [2] != 1 || arr1 [3] != 1 || arr1 [4] != 1)
1142 var arr2 = o.Del (2.0);
1143 if (arr2 [0] != 2.0 || arr2 [1] != 2.0 || arr2 [2] != 2.0 || arr2 [3] != 2.0 || arr2 [4] != 2.0)
1148 public class TAbstractTableItem<TC> {
1149 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1150 public static void SetProperty<TV> () { }
1152 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1153 public static void Test () {
1154 SetProperty<bool> ();
1158 public static int test_0_gsharedvt_method_on_shared_class () {
1159 TAbstractTableItem<object>.Test ();
1163 interface IFaceBox {
1164 object box<T> (T t);
1167 class ClassBox : IFaceBox {
1168 public object box<T> (T t) {
1174 public static int test_0_nullable_box () {
1175 IFaceBox c = new ClassBox ();
1177 object o = c.box<int?> (i);
1180 if (c.box<int?> (null) != null)
1182 long l = Int64.MaxValue - 1;
1183 o = c.box<long?> (l);
1186 if (c.box<long?> (null) != null)
1189 if (c.box<string> (s) != (object)s)
1194 interface IFaceUnbox2 {
1195 T unbox<T> (object o);
1198 class ClassUnbox2 : IFaceUnbox2 {
1199 public T unbox<T> (object o) {
1204 public static int test_0_nullable_unbox () {
1205 IFaceUnbox2 c = new ClassUnbox2 ();
1206 int? i = c.unbox<int?> (5);
1209 int? j = c.unbox<int?> (null);
1215 interface IConstrained {
1217 void foo_ref_arg (string s);
1220 static object constrained_res;
1222 struct ConsStruct : IConstrained {
1225 public void foo () {
1226 constrained_res = i;
1229 public void foo_ref_arg (string s) {
1230 constrained_res = s == "A" ? 42 : 0;
1234 class ConsClass : IConstrained {
1237 public void foo () {
1238 constrained_res = i;
1241 public void foo_ref_arg (string s) {
1242 constrained_res = s == "A" ? 43 : 0;
1246 interface IFaceConstrained {
1247 void constrained_void_iface_call<T, T2>(T t, T2 t2) where T2 : IConstrained;
1248 void constrained_void_iface_call_ref_arg<T, T2>(T t, T2 t2) where T2 : IConstrained;
1251 class ClassConstrained : IFaceConstrained {
1252 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1253 public void constrained_void_iface_call<T, T2>(T t, T2 t2) where T2 : IConstrained {
1257 [MethodImplAttribute (MethodImplOptions.NoInlining)]
1258 public void constrained_void_iface_call_ref_arg<T, T2>(T t, T2 t2) where T2 : IConstrained {
1259 t2.foo_ref_arg ("A");
1263 public static int test_0_constrained_void_iface_call () {
1264 IFaceConstrained c = new ClassConstrained ();
1265 var s = new ConsStruct () { i = 42 };
1266 constrained_res = null;
1267 c.constrained_void_iface_call<int, ConsStruct> (1, s);
1268 if (!(constrained_res is int) || ((int)constrained_res) != 42)
1270 constrained_res = null;
1271 c.constrained_void_iface_call_ref_arg<int, ConsStruct> (1, s);
1272 if (!(constrained_res is int) || ((int)constrained_res) != 42)
1274 var s2 = new ConsClass () { i = 43 };
1275 constrained_res = null;
1276 c.constrained_void_iface_call<int, ConsClass> (1, s2);
1277 if (!(constrained_res is int) || ((int)constrained_res) != 43)
1279 constrained_res = null;
1280 c.constrained_void_iface_call_ref_arg<int, ConsClass> (1, s2);
1281 if (!(constrained_res is int) || ((int)constrained_res) != 43)
1289 public class GSharedTests : Tests {