Author: kumpera
Date: 2007-09-27 10:40:44 -0400 (Thu, 27 Sep 2007)
New Revision: 86501

Added:
   trunk/mono/mono/tests/generic_type_definition.2.cs
Modified:
   trunk/mono/mono/tests/ChangeLog
   trunk/mono/mono/tests/Makefile.am
Log:
2007-09-27 Rodrigo Kumpera  <[EMAIL PROTECTED]>

        * generic_type_definition.2.cs: added

        * Makefile.am: added generic_type_definition.2.cs




Modified: trunk/mono/mono/tests/ChangeLog
===================================================================
--- trunk/mono/mono/tests/ChangeLog     2007-09-27 14:40:13 UTC (rev 86500)
+++ trunk/mono/mono/tests/ChangeLog     2007-09-27 14:40:44 UTC (rev 86501)
@@ -1,3 +1,10 @@
+2007-09-27 Rodrigo Kumpera  <[EMAIL PROTECTED]>
+
+       * generic_type_definition.2.cs: added
+
+       * Makefile.am: added generic_type_definition.2.cs
+
+
 2007-09-22 Rodrigo Kumpera  <[EMAIL PROTECTED]>
 
        * bug-327438.2.il: added

Modified: trunk/mono/mono/tests/Makefile.am
===================================================================
--- trunk/mono/mono/tests/Makefile.am   2007-09-27 14:40:13 UTC (rev 86500)
+++ trunk/mono/mono/tests/Makefile.am   2007-09-27 14:40:44 UTC (rev 86501)
@@ -298,7 +298,8 @@
        generics-sharing.2.cs   \
        bug-80392.2.cs          \
        dynamic-method-access.2.cs      \
-       bug-82194.2.cs
+       bug-82194.2.cs  \
+       generic_type_definition.2.cs
 
 TEST_IL2_SRC = find-method.2.il        \
        bug-79215.2.il  \

Added: trunk/mono/mono/tests/generic_type_definition.2.cs
===================================================================
--- trunk/mono/mono/tests/generic_type_definition.2.cs  2007-09-27 14:40:13 UTC 
(rev 86500)
+++ trunk/mono/mono/tests/generic_type_definition.2.cs  2007-09-27 14:40:44 UTC 
(rev 86501)
@@ -0,0 +1,76 @@
+using System;
+using System.Threading;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace TestApp
+{
+       public class A<T> {
+               public T fld;
+       }
+
+    class Program
+    {
+               static AssemblyBuilder assembly;
+               static ModuleBuilder module;
+               static string ASSEMBLY_NAME = 
"MonoTests.System.Reflection.Emit.TypeBuilderTest";
+
+               static void SetUp ()
+               {
+                       AssemblyName assemblyName = new AssemblyName ();
+                       assemblyName.Name = ASSEMBLY_NAME;
+
+                       assembly =
+                               Thread.GetDomain ().DefineDynamicAssembly (
+                                       assemblyName, 
AssemblyBuilderAccess.RunAndSave, ".");
+
+                       module = assembly.DefineDynamicModule ("module1", 
"Module1.dll");
+               }
+
+               static int Main()
+               {
+                       Type gtd = typeof (A<>);
+                       Type oi = gtd.MakeGenericType (gtd.GetGenericArguments 
());
+
+                       if (oi != gtd) {
+                               Console.WriteLine ("fully open instantiation of 
static type not the same of the generic type definition");
+                               return 1;
+                       }
+
+                       SetUp ();
+                       TypeBuilder tb = module.DefineType ("Nullable`1", 
TypeAttributes.Public);
+                       Type[] args = tb.DefineGenericParameters ("T");
+                       Type type = tb.MakeGenericType (args);
+
+                       if (type == tb) {
+                               Console.WriteLine ("fully open instantiation of 
TypeBuilder is the same of the TypeBuilder");
+                               return 2;
+                       }
+               
+                       Type res = tb.CreateType ();
+                       Type oires = res.MakeGenericType 
(res.GetGenericArguments ());
+
+                       if (res != oires) {
+                               Console.WriteLine ("fully open instantiation 
not the same of the generic type definition for the TypeBuilder created type");
+                               return 3;
+                       }
+
+                       try {
+                               type.GetConstructors ();
+                       } catch (Exception e) {
+                               Console.WriteLine ("fully open instantiation of 
TypeBuilder must have GetConstructors working {0}", e);
+                               return 4;
+                       }
+
+
+                       try {
+                               oires.GetConstructors ();
+                       } catch (Exception e) {
+                               Console.WriteLine ("fully open instantiation of 
the TypeBuilder created type must have GetConstructors working {0}", e);
+                               return 5;
+                       }
+
+                       return 0;
+               }
+       }
+}

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to