From 32aaa3c9eb377a31954dae68a023f41d9af8b543 Mon Sep 17 00:00:00 2001 From: Jb Evain Date: Thu, 6 Mar 2008 08:44:33 +0000 Subject: [PATCH] 2008-03-06 Jb Evain * ILGeneratorTest.cs: add test for #367663, checking that EmitCalli deals with null return types. svn path=/trunk/mcs/; revision=97489 --- .../Test/System.Reflection.Emit/ChangeLog | 5 ++++ .../System.Reflection.Emit/ILGeneratorTest.cs | 27 ++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog b/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog index 3a39efb7fe4..a9af9fd5640 100644 --- a/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog +++ b/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog @@ -1,3 +1,8 @@ +2008-03-06 Jb Evain + + * ILGeneratorTest.cs: add test for #367663, checking + that EmitCalli deals with null return types. + 2008-03-03 Rodrigo Kumpera * TypeBuilderTest.cs: Added CreateTypeFailsWithInvalidMethodOverride. diff --git a/mcs/class/corlib/Test/System.Reflection.Emit/ILGeneratorTest.cs b/mcs/class/corlib/Test/System.Reflection.Emit/ILGeneratorTest.cs index 33b3e75d0b4..39ca7025c47 100644 --- a/mcs/class/corlib/Test/System.Reflection.Emit/ILGeneratorTest.cs +++ b/mcs/class/corlib/Test/System.Reflection.Emit/ILGeneratorTest.cs @@ -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 () -- 2.25.1