From 048fd4da2e5a57cbc1ebebc57d5302ae5b1d2557 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Sun, 9 Sep 2007 21:27:40 +0000 Subject: [PATCH] 2007-09-09 Zoltan Varga * MethodBuilderTest.cs: Add a new test. svn path=/trunk/mcs/; revision=85542 --- .../Test/System.Reflection.Emit/ChangeLog | 4 ++++ .../MethodBuilderTest.cs | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog b/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog index 792b7dcf786..8cd4187b2a7 100644 --- a/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog +++ b/mcs/class/corlib/Test/System.Reflection.Emit/ChangeLog @@ -1,3 +1,7 @@ +2007-09-09 Zoltan Varga + + * MethodBuilderTest.cs: Add a new test. + 2007-09-02 Gert Driesen * TypeBuilderTest.cs: Split up and improved ignored GetField(s) tests diff --git a/mcs/class/corlib/Test/System.Reflection.Emit/MethodBuilderTest.cs b/mcs/class/corlib/Test/System.Reflection.Emit/MethodBuilderTest.cs index 145014aaa8a..8fa9801aea7 100644 --- a/mcs/class/corlib/Test/System.Reflection.Emit/MethodBuilderTest.cs +++ b/mcs/class/corlib/Test/System.Reflection.Emit/MethodBuilderTest.cs @@ -857,6 +857,26 @@ namespace MonoTests.System.Reflection.Emit Assert.IsTrue (attr.BestFitMapping, "#2"); Assert.IsTrue (attr.ThrowOnUnmappableChar, "#3"); } + + [Test] + public void GenericTypeParameterBuilder_Dynamic () + { + TypeBuilder tb = module.DefineType (genTypeName (), TypeAttributes.Public); + MethodBuilder mb = tb.DefineMethod ("box_int", + MethodAttributes.Public|MethodAttributes.Static, typeof (object), new Type [] { typeof (int) }); + + GenericTypeParameterBuilder[] pars = mb.DefineGenericParameters (new string [] { "foo" }); + + ILGenerator ilgen = mb.GetILGenerator (); + ilgen.Emit (OpCodes.Ldarg_0); + ilgen.Emit (OpCodes.Box, pars [0]); + ilgen.Emit (OpCodes.Ret); + + Type t = tb.CreateType (); + MethodInfo mi = t.GetMethod ("box_int"); + MethodInfo mi2 = mi.MakeGenericMethod (new Type [] { typeof (int) }); + Assert.AreEqual (1, mi2.Invoke (null, new object [] { 1 })); + } #endif } } -- 2.25.1