[tests] Use 2.1 profile assembly names for mobile
[mono.git] / mcs / class / corlib / Test / System.Reflection / MonoGenericClassTest.cs
index ee3e20267d047fd7a0370218f906c7e5fe903041..bb124cf2a2084df0f1a82bbd72d3a903a9998bd3 100644 (file)
@@ -7,6 +7,8 @@
 // Copyright 2011 Xamarin Inc (http://www.xamarin.com).
 //
 
+#if !MONOTOUCH
+
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -23,7 +25,6 @@ using System.Runtime.CompilerServices;
 
 namespace MonoTests.System.Reflection.Emit
 {
-#if NET_2_0
        [TestFixture]
        public class MonoGenericClassTest
        {
@@ -67,10 +68,10 @@ namespace MonoTests.System.Reflection.Emit
 
                        Assert.AreEqual ("type", inst.Name, "#1");
                        Assert.AreEqual ("foo", inst.Namespace, "#2");
-#if NET_4_0
+#if NET_4_0 && !MOBILE
                        Assert.AreEqual ("foo.type[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]", inst.FullName, "#3");
                        Assert.AreEqual ("foo.type[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], MonoTests.System.Reflection.Emit.MonoGenericClassTest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", inst.AssemblyQualifiedName, "#4");
-#elif NET_2_1
+#elif NET_2_1 || MOBILE
                        Assert.AreEqual ("foo.type[[System.Double, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]", inst.FullName, "#3");
                        Assert.AreEqual ("foo.type[[System.Double, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], MonoTests.System.Reflection.Emit.MonoGenericClassTest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", inst.AssemblyQualifiedName, "#4");
 #else
@@ -89,47 +90,6 @@ namespace MonoTests.System.Reflection.Emit
                        Assert.AreEqual (b, resB.Length, prefix + 2);
                }
 
-               [Test]
-               [Category ("NotDotNet")]
-               // CompilerContext no longer supported
-               [Category ("NotWorking")]
-               public void GetMethodsWorkWithFunkyInstantiations ()
-               {
-                       SetUp (AssemblyBuilderAccess.RunAndSave | (AssemblyBuilderAccess)0x800);
-                       TypeBuilder tb = module.DefineType ("Base", TypeAttributes.Public, typeof (object));
-
-                       var a = typeof (IList<>).GetGenericArguments () [0];
-                       var b = tb.DefineGenericParameters ("T") [0];
-
-                       CheckInst ("#A", typeof (Collection<>).MakeGenericType (new Type [] {a}), 12, 16);
-                       CheckInst ("#B", typeof (Collection<>).MakeGenericType (new Type[] { b }), 12, 16);
-
-                       var tb2 = module.DefineType ("Child", TypeAttributes.Public, typeof (Collection<>).MakeGenericType (tb.MakeGenericType (typeof (int))));
-                       tb2.DefineGenericParameters ("K");
-
-                       CheckInst ("#C", tb2.MakeGenericType (typeof (double)), 0, 16);
-                       
-               }
-
-               [Test]
-               [Category ("NotDotNet")]
-               // CompilerContext no longer supported
-               [Category ("NotWorking")]
-               public void GetEventMustWorkUnderCompilerContext ()
-               {
-                       SetUp (AssemblyBuilderAccess.RunAndSave | (AssemblyBuilderAccess)0x800);
-                       var tb = module.DefineType ("foo.type");
-                       tb.DefineGenericParameters ("T");
-
-                       var ginst = tb.MakeGenericType (typeof (double));
-                       
-                       try {
-                               ginst.GetEvent ("foo", BindingFlags.Public | BindingFlags.Instance);
-                       } catch (NotSupportedException) {
-                               Assert.Fail ("#1");
-                       }
-               }
-
                [Test]
                public void MethodsThatRaiseNotSupported ()
                {
@@ -138,10 +98,10 @@ namespace MonoTests.System.Reflection.Emit
 
                        var ginst = tb.MakeGenericType (typeof (double));
 
-                       /*try { //FIXME this doesn't work yet
+                       try {
                                ginst.GetElementType ();
                                Assert.Fail ("#1");
-                       } catch (NotSupportedException) {  }*/
+                       } catch (NotSupportedException) {  }
                        try {
                                ginst.GetInterface ("foo", true);
                                Assert.Fail ("#2");
@@ -190,6 +150,14 @@ namespace MonoTests.System.Reflection.Emit
                                ginst.GetCustomAttributes (typeof (int), true);
                                Assert.Fail ("#13");
                        } catch (NotSupportedException) {  }
+                       try {
+                               ginst.IsAssignableFrom (ginst);
+                               Assert.Fail ("#14");
+                       } catch (NotSupportedException) {  }
+                       try {
+                               ginst.GetNestedTypes (BindingFlags.Public);
+                               Assert.Fail ("#14");
+                       } catch (NotSupportedException) {  }
                }
 
                [Test]
@@ -208,7 +176,35 @@ namespace MonoTests.System.Reflection.Emit
                        /*This must not throw*/
                        rtInst.IsDefined (typeof (int), true);
                }
-       }
 
-#endif
+               public class Bar<T> {
+                       public class Foo<U> {}
+               }
+
+               [Test]
+               public void DeclaringTypeMustReturnNonInflatedType ()
+               {
+                       var ut = new TypeDelegator (typeof (int));
+                       var ut2 = typeof(Bar<>.Foo<>);
+                       var t = ut2.MakeGenericType (ut, ut);
+                       Assert.AreSame (typeof (Bar<>), t.DeclaringType, "#1");
+               }
+
+               public class Base<T> {}
+               public class SubClass<K> : Base<K> {}
+
+               [Test]
+               public void BaseTypeMustReturnNonInflatedType ()
+               {
+                       var ut = new TypeDelegator (typeof (int));
+                       var ut2 = typeof(SubClass<>);
+                       var t = ut2.MakeGenericType (ut);
+                       //This is Base<K> where K is SubClass::K
+                       var expected = typeof (Base<>).MakeGenericType (typeof (SubClass<>).GetGenericArguments ()[0]);
+                       Assert.AreSame (expected, t.BaseType, "#1");
+                       
+               }
+       }
 }
+
+#endif
\ No newline at end of file