2008-03-06 Jb Evain <jbevain@novell.com>
authorJb Evain <jbevain@gmail.com>
Thu, 6 Mar 2008 08:44:33 +0000 (08:44 -0000)
committerJb Evain <jbevain@gmail.com>
Thu, 6 Mar 2008 08:44:33 +0000 (08:44 -0000)
* ILGeneratorTest.cs: add test for #367663, checking
that EmitCalli deals with null return types.

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

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

index 3a39efb7fe4b3bb02b390525a4908c24c82293b8..a9af9fd5640922e758f00ed7a841aba44b934411 100644 (file)
@@ -1,3 +1,8 @@
+2008-03-06  Jb Evain  <jbevain@novell.com>
+
+       * ILGeneratorTest.cs: add test for #367663, checking
+       that EmitCalli deals with null return types.
+
 2008-03-03  Rodrigo Kumpera  <rkumpera@novell.com>
 
        * TypeBuilderTest.cs: Added CreateTypeFailsWithInvalidMethodOverride.
index 33b3e75d0b47bbcf195d2fba388478bc0bcfde63..39ca7025c472894e9cd0b2a9a88ec74527b42715 100644 (file)
@@ -8,6 +8,7 @@
 using System;
 using System.Reflection;
 using System.Reflection.Emit;
+using System.Runtime.InteropServices;
 using System.Threading;
 
 using NUnit.Framework;
@@ -34,7 +35,7 @@ namespace MonoTests.System.Reflection.Emit
                        assemblyName.Name = "MonoTests.System.Reflection.Emit.ILGeneratorTest";
 
                        AssemblyBuilder assembly = Thread.GetDomain ().DefineDynamicAssembly (
-                               assemblyName, AssemblyBuilderAccess.Run);
+                               assemblyName, AssemblyBuilderAccess.RunAndSave);
 
                        ModuleBuilder module = assembly.DefineDynamicModule ("module1");
                        tb = module.DefineType ("T", TypeAttributes.Public);
@@ -362,6 +363,30 @@ namespace MonoTests.System.Reflection.Emit
                        Assert.IsTrue ((bool) tf.Invoke (null, new object [] { true }));
                }
 
+#if NET_2_0
+               delegate void FooFoo ();
+
+               static void Foo ()
+               {
+               }
+
+               [Test]
+               public void TestEmitCalliWithNullReturnType ()
+               {
+                       MethodBuilder mb = tb.DefineMethod ("F",
+                               MethodAttributes.Public | MethodAttributes.Static, null, new Type [] { typeof (IntPtr) });
+                       mb.SetImplementationFlags (MethodImplAttributes.NoInlining);
+                       il_gen = mb.GetILGenerator ();
+                       il_gen.Emit (OpCodes.Ldarg_0);
+                       il_gen.EmitCalli (OpCodes.Calli, CallingConvention.StdCall, null, Type.EmptyTypes);
+                       il_gen.Emit (OpCodes.Ret);
+       
+                       Type dynt = tb.CreateType ();
+                       dynt.GetMethod ("F", BindingFlags.Public | BindingFlags.Static).Invoke (
+                               null, new object [] { Marshal.GetFunctionPointerForDelegate (new FooFoo (Foo)) });
+               }
+#endif
+
                [Test]
                [ExpectedException (typeof (Exception))]
                public void TestFilterEmittingWithoutHandlerExecution ()