using System.Threading;
using System.Threading.Tasks;
-class Tests {
-
+#if MOBILE
+class GenericsTests
+#else
+class Tests
+#endif
+{
struct TestStruct {
public int i;
public int j;
}
}
+#if !MOBILE
class Enumerator <T> : MyIEnumerator <T> {
T MyIEnumerator<T>.Current {
get {
return true;
}
}
+#endif
+#if !MOBILE
static int Main (string[] args)
{
return TestDriver.RunTests (typeof (Tests), args);
}
+#endif
public static int test_1_nullable_unbox ()
{
public static int test_0_constrained_vtype_box () {
GenericClass<TestStruct> t = new GenericClass<TestStruct> ();
+#if MOBILE
+ return t.toString (new TestStruct ()) == "GenericsTests+TestStruct" ? 0 : 1;
+#else
return t.toString (new TestStruct ()) == "Tests+TestStruct" ? 0 : 1;
+#endif
}
public static int test_0_constrained_vtype () {
return 0;
}
+#if !MOBILE
public static int test_0_variance_reflection () {
// covariance on IEnumerator
if (!typeof (MyIEnumerator<object>).IsAssignableFrom (typeof (MyIEnumerator<string>)))
return 6;
return 0;
}
+#endif
public static int test_0_ldvirtftn_generic_method () {
- new Tests ().ldvirtftn<string> ();
+ new GenericsTests ().ldvirtftn<string> ();
return the_type == typeof (string) ? 0 : 1;
}
/* Test that treating arrays as generic collections works with full-aot */
public static int test_0_fullaot_array_wrappers () {
- Tests[] arr = new Tests [10];
- enumerate<Tests> (arr);
+ GenericsTests[] arr = new GenericsTests [10];
+ enumerate<GenericsTests> (arr);
return 0;
}
}
public static int test_0_full_aot_nullable_unbox_from_gshared_code () {
- if (!new Tests ().IsNull2<FooStruct> (null))
+ if (!new GenericsTests ().IsNull2<FooStruct> (null))
return 1;
- if (new Tests ().IsNull2<FooStruct> (new FooStruct ()))
+ if (new GenericsTests ().IsNull2<FooStruct> (new FooStruct ()))
return 2;
return 0;
}
public static int test_0_partial_sharing () {
if (PartialShared1 (new List<string> (), 1) != typeof (string))
return 1;
- if (PartialShared1 (new List<Tests> (), 1) != typeof (Tests))
+ if (PartialShared1 (new List<GenericsTests> (), 1) != typeof (GenericsTests))
return 2;
if (PartialShared2 (new List<string> (), 1) != typeof (int))
return 3;
- if (PartialShared2 (new List<Tests> (), 1) != typeof (int))
+ if (PartialShared2 (new List<GenericsTests> (), 1) != typeof (int))
return 4;
return 0;
}
return result;
}
+ class SyncClass<T> {
+ [MethodImpl(MethodImplOptions.Synchronized)]
+ public Type getInstance() {
+ return typeof (T);
+ }
+ }
+
+ [Category ("GSHAREDVT")]
+ static int test_0_synchronized_gshared () {
+ var c = new SyncClass<string> ();
+ if (c.getInstance () != typeof (string))
+ return 1;
+ return 0;
+ }
+
class Response {
}
return 0;
}
#endif
+
+ public static int test_0_delegate_callvirt_fullaot () {
+ Func<string> f = delegate () { return "A"; };
+ var f2 = (Func<Func<string>, string>)Delegate.CreateDelegate (typeof
+(Func<Func<string>, string>), null, f.GetType ().GetMethod ("Invoke"));
+
+ var s = f2 (f);
+ return s == "A" ? 0 : 1;
+ }
+
+ public interface ICovariant<out R>
+ {
+ }
+
+ // Deleting the `out` modifier from this line stop the problem
+ public interface IExtCovariant<out R> : ICovariant<R>
+ {
+ }
+
+ public class Sample<R> : ICovariant<R>
+ {
+ }
+
+ public interface IMyInterface
+ {
+ }
+
+ public static int test_0_variant_cast_cache () {
+ object covariant = new Sample<IMyInterface>();
+
+ var foo = (ICovariant<IMyInterface>)(covariant);
+
+ try {
+ var extCovariant = (IExtCovariant<IMyInterface>)covariant;
+ return 1;
+ } catch {
+ return 0;
+ }
+ }
}
+
+#if !MOBILE
+class GenericsTests : Tests
+{
+}
+#endif