using System.Threading;
using System.Threading.Tasks;
-#if MOBILE
+#if __MOBILE__
class GenericsTests
#else
class Tests
}
}
-#if !MOBILE
+#if !__MOBILE__
class Enumerator <T> : MyIEnumerator <T> {
T MyIEnumerator<T>.Current {
get {
}
#endif
-#if !MOBILE
+#if !__MOBILE__
static int Main (string[] args)
{
return TestDriver.RunTests (typeof (Tests), args);
public static int test_0_constrained_vtype_box () {
GenericClass<TestStruct> t = new GenericClass<TestStruct> ();
-#if MOBILE
+#if __MOBILE__
return t.toString (new TestStruct ()) == "GenericsTests+TestStruct" ? 0 : 1;
#else
return t.toString (new TestStruct ()) == "Tests+TestStruct" ? 0 : 1;
return 0;
}
+ interface NonGenericInterface {
+ int return_field ();
+ }
+
+ interface GenericInterface<T> : NonGenericInterface {
+ T not_used ();
+ }
+
+ struct ImplementGenericInterface<T> : GenericInterface<T> {
+ public Object padding1;
+ public Object padding2;
+ public Object padding3;
+ public T[] arr_t;
+
+ public ImplementGenericInterface (T[] arr_t) {
+ this.padding1 = null;
+ this.padding2 = null;
+ this.padding3 = null;
+ this.arr_t = arr_t;
+ }
+
+ public T not_used () {
+ return arr_t [0];
+ }
+
+ public int return_field () {
+ return arr_t.Length;
+ }
+ }
+
+ public static int test_8_struct_implements_generic_interface () {
+ int[] arr = {1, 2, 3, 4};
+ NonGenericInterface s = new ImplementGenericInterface<int> (arr);
+ return s.return_field () + s.return_field ();
+ }
+
public static int test_0_generic_get_value_optimization_vtype () {
TestStruct[] arr = new TestStruct[] { new TestStruct (100, 200), new TestStruct (300, 400) };
IEnumerator<TestStruct> enumerator = GenericClass<TestStruct>.Y (arr);
return 0;
}
-#if !MOBILE
+#if !__MOBILE__
public static int test_0_variance_reflection () {
// covariance on IEnumerator
if (!typeof (MyIEnumerator<object>).IsAssignableFrom (typeof (MyIEnumerator<string>)))
}
[Category ("!FULLAOT")]
+ [Category ("!BITCODE")]
public static int test_0_regress_668095_synchronized_gshared () {
return DoSomething (new DefaultRetriever ());
}
return 0;
}
+ class AClass {
+ }
+
+ class BClass : AClass {
+ }
+
+ public static int test_0_fullaot_variant_iface () {
+ var arr = new BClass [10];
+ var enumerable = (IEnumerable<AClass>)arr;
+ enumerable.GetEnumerator ();
+ return 0;
+ }
+
struct Record : Foo2<Record>.IRecord {
int counter;
int Foo2<Record>.IRecord.DoSomething () {
test("a", "b", "c", "d", "e", "f", "g", "h");
return delegate_8_args_res == "h" ? 0 : 1;
}
+
+ static void throw_catch_t<T> () where T: Exception {
+ try {
+ throw new NotSupportedException ();
+ } catch (T) {
+ }
+ }
+
+ public static int test_0_gshared_catch_open_type () {
+ throw_catch_t<NotSupportedException> ();
+ return 0;
+ }
+
+ class ThrowClass<T> where T: Exception {
+ public void throw_catch_t () {
+ try {
+ throw new NotSupportedException ();
+ } catch (T) {
+ }
+ }
+ }
+
+ public static int test_0_gshared_catch_open_type_instance () {
+ var c = new ThrowClass<NotSupportedException> ();
+ c.throw_catch_t ();
+ return 0;
+ }
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public static bool is_ref_or_contains_refs<T> () {
+ return RuntimeHelpers.IsReferenceOrContainsReferences<T> ();
+ }
+
+ class IsRefClass<T> {
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public bool is_ref () {
+ return RuntimeHelpers.IsReferenceOrContainsReferences<T> ();
+ }
+ }
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public static bool is_ref_or_contains_refs_gen_ref<T> () {
+ return RuntimeHelpers.IsReferenceOrContainsReferences<GenStruct<T>> ();
+ }
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public static bool is_ref_or_contains_refs_gen_noref<T> () {
+ return RuntimeHelpers.IsReferenceOrContainsReferences<NoRefGenStruct<T>> ();
+ }
+
+ struct GenStruct<T> {
+ T t;
+ }
+
+ struct NoRefGenStruct<T> {
+ }
+
+ struct RefStruct {
+ string s;
+ }
+
+ struct NestedRefStruct {
+ RefStruct r;
+ }
+
+ struct NoRefStruct {
+ int i;
+ }
+
+ struct AStruct3<T1, T2, T3> {
+ T1 t1;
+ T2 t2;
+ T3 t3;
+ }
+
+ public static int test_0_isreference_intrins () {
+ if (RuntimeHelpers.IsReferenceOrContainsReferences<int> ())
+ return 1;
+ if (!RuntimeHelpers.IsReferenceOrContainsReferences<string> ())
+ return 2;
+ if (!RuntimeHelpers.IsReferenceOrContainsReferences<RefStruct> ())
+ return 3;
+ if (!RuntimeHelpers.IsReferenceOrContainsReferences<NestedRefStruct> ())
+ return 4;
+ if (RuntimeHelpers.IsReferenceOrContainsReferences<NoRefStruct> ())
+ return 5;
+ // Generic code
+ if (is_ref_or_contains_refs<int> ())
+ return 6;
+ // Shared code
+ if (!is_ref_or_contains_refs<string> ())
+ return 7;
+ // Complex type from shared code
+ if (!is_ref_or_contains_refs_gen_ref<string> ())
+ return 8;
+ if (is_ref_or_contains_refs_gen_ref<int> ())
+ return 9;
+ if (is_ref_or_contains_refs_gen_noref<string> ())
+ return 10;
+
+ // Complex type from shared class method
+ var c1 = new IsRefClass<AStruct3<int, int, int>> ();
+ if (c1.is_ref ())
+ return 11;
+ var c2 = new IsRefClass<AStruct3<string, int, int>> ();
+ if (!c2.is_ref ())
+ return 12;
+
+ return 0;
+ }
}
-#if !MOBILE
+#if !__MOBILE__
class GenericsTests : Tests
{
}