2008-07-22 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Tue, 22 Jul 2008 20:19:54 +0000 (20:19 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Tue, 22 Jul 2008 20:19:54 +0000 (20:19 -0000)
* TypeBuilderTest.cs: Added tests for the special cased behavior
of GetMethod.

svn path=/trunk/mcs/; revision=108512

mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog
mcs/class/corlib/Test/System.Reflection.Emit/TypeBuilderTest.cs

index 77e912f7932696c764ec2490676dcce676592809..2d97ff48e7905de84af08d97a40d3b26e9a60600 100644 (file)
@@ -1,3 +1,8 @@
+2008-07-22 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * TypeBuilderTest.cs: Added tests for the special cased behavior
+       of GetMethod.
+
 2008-07-17 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * MethodOnTypeBuilderInstTest.cs: Disable new tests as the change
index 4276fbb07efe96834a1012ed84153173e01d5784..d5497c48ee5714dae67dc42acf9f2a0e1707242f 100644 (file)
@@ -2032,6 +2032,51 @@ namespace MonoTests.System.Reflection.Emit
                }
 
 #if NET_2_0
+               [Test]
+               public void GetMethod_RejectMethodFromInflatedTypeBuilder () {
+                       TypeBuilder tb = module.DefineType (genTypeName ());
+                       tb.DefineGenericParameters ("T");
+                       MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
+
+                       Type ginst = tb.MakeGenericType (typeof (int));
+                       
+                       MethodInfo mi = TypeBuilder.GetMethod (ginst, mb);
+                       try {
+                               TypeBuilder.GetMethod (ginst, mi);
+                               Assert.Fail ("#1");
+                       } catch (ArgumentException ex) {
+                               Assert.AreEqual ("method", ex.ParamName, "#5");
+                       }
+               }
+
+               [Test]
+               [Category ("NotDotNet")]
+               public void GetMethod_AcceptMethodFromInflatedTypeBuilder_UnderCompilerContext () {
+                       AssemblyName assemblyName = new AssemblyName ();
+                       assemblyName.Name = ASSEMBLY_NAME;
+
+                       assembly =
+                               Thread.GetDomain ().DefineDynamicAssembly (
+                                       assemblyName, AssemblyBuilderAccess.RunAndSave | (AssemblyBuilderAccess)0x800, Path.GetTempPath ());
+
+                       module = assembly.DefineDynamicModule ("module1");
+                       
+                       TypeBuilder tb = module.DefineType (genTypeName ());
+                       tb.DefineGenericParameters ("T");
+                       MethodBuilder mb = tb.DefineMethod ("create", MethodAttributes.Public, typeof (void), Type.EmptyTypes);
+
+                       Type ginst = tb.MakeGenericType (typeof (int));
+                       
+                       MethodInfo mi = TypeBuilder.GetMethod (ginst, mb);
+
+                       try {
+                               TypeBuilder.GetMethod (ginst, mi);
+                       } catch (ArgumentException ex) {
+                               Assert.Fail ("#1");
+                       }
+               }
+
+
                [Test]
                // Test that changes made to the method builder after a call to GetMethod ()
                // are visible