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>)))
return 0;
}
+ [Category ("GSHAREDVT")]
public static int test_6_partial_sharing_linq () {
var messages = new List<Message> ();
}
[Category ("!FULLAOT")]
+ [Category ("!BITCODE")]
public static int test_0_regress_668095_synchronized_gshared () {
return DoSomething (new DefaultRetriever ());
}
}
// #2155
+ [Category ("GSHAREDVT")]
public static int test_0_fullaot_sflda_cctor () {
List<Doc> documents = new List<Doc>();
documents.Add(new Doc { Name = "Doc1", Type = DocType.One } );
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 () {
MyClass<FooStruct2>.foo ();
return 0;
}
+
+ enum AnEnum {
+ A,
+ B
+ }
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public static string constrained_tostring<T> (T t) {
+ return t.ToString ();
+ }
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public static bool constrained_equals<T> (T t1, T t2) {
+ var c = EqualityComparer<T>.Default;
+
+ return c.Equals (t1, t2);
+ }
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public static int constrained_gethashcode<T> (T t) {
+ return t.GetHashCode ();
+ }
+
+ public static int test_0_constrained_partial_sharing () {
+ string s;
+
+ s = constrained_tostring<int> (5);
+ if (s != "5")
+ return 1;
+ s = constrained_tostring<AnEnum> (AnEnum.B);
+ if (s != "B")
+ return 2;
+
+ if (!constrained_equals<int> (1, 1))
+ return 3;
+ if (constrained_equals<int> (1, 2))
+ return 4;
+ if (!constrained_equals<AnEnum> (AnEnum.A, AnEnum.A))
+ return 5;
+ if (constrained_equals<AnEnum> (AnEnum.A, AnEnum.B))
+ return 6;
+
+ int i = constrained_gethashcode<int> (5);
+ if (i != 5)
+ return 7;
+ i = constrained_gethashcode<AnEnum> (AnEnum.B);
+ if (i != 1)
+ return 8;
+ return 0;
+ }
+
+ enum Enum1 {
+ A,
+ B
+ }
+
+ enum Enum2 {
+ A,
+ B
+ }
+
+ public static int test_0_partial_sharing_ginst () {
+ var l1 = new List<KeyValuePair<int, Enum1>> ();
+ l1.Add (new KeyValuePair<int, Enum1>(5, Enum1.A));
+ if (l1 [0].Key != 5)
+ return 1;
+ if (l1 [0].Value != Enum1.A)
+ return 2;
+ var l2 = new List<KeyValuePair<int, Enum2>> ();
+ l2.Add (new KeyValuePair<int, Enum2>(5, Enum2.B));
+ if (l2 [0].Key != 5)
+ return 3;
+ if (l2 [0].Value != Enum2.B)
+ return 4;
+ return 0;
+ }
+
+ static object delegate_8_args_res;
+
+ public static int test_0_delegate_8_args () {
+ delegate_8_args_res = null;
+ Action<string, string, string, string, string, string, string,
+ string> test = (a, b, c, d, e, f, g, h) =>
+ {
+ delegate_8_args_res = h;
+ };
+ 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
{
}