[Mono-bugs] [Bug 354757] IsGenericMethodDefinition returns false for open generic method

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Jan 23 22:41:48 EST 2008


User rkumpera at novell.com added comment

--- Comment #12 from Rodrigo Kumpera <rkumpera at novell.com>  2008-01-23 20:41:48 MST ---
The issue now seens to be that inflated generic MethodBuilders won't carry
custom attributes when inflated. This is why gtest-045 fails. The following
code demonstrate this issue:

using System;
using System.Reflection;
using System.Reflection.Emit;

public class Entry

        public static void CheckMethod(MethodInfo info) {
                foreach (ParameterInfo pi in info.GetParameters()) {
                        Console.WriteLine ("param {0} has attribute {1}", pi,
pi.IsDefined (typeof(ParamArrayAttribute), false));

        public static void Main() {
                AssemblyName name = new AssemblyName("Asm");
                AssemblyBuilder asmbuild =
                ModuleBuilder mod = asmbuild.DefineDynamicModule("dyn_module",

                TypeBuilder G = mod.DefineType("G", TypeAttributes.Public);
                ConstructorInfo ctor =

                MethodBuilder M = G.DefineMethod("M", MethodAttributes.Public,
typeof(void), new Type[1] { typeof (string[]) });
                Type MParam = M.DefineGenericParameters("T")[0];

                ParameterBuilder param = M.DefineParameter (1,
ParameterAttributes.None, "Test");

                ConstructorInfo classCtorInfo =
typeof(ParamArrayAttribute).GetConstructor (new Type [0]);
                CustomAttributeBuilder myCABuilder =  new
CustomAttributeBuilder(classCtorInfo, new Object[0]);

                Type GObj = G.MakeGenericType (typeof(object));
                MethodInfo GObjM = TypeBuilder.GetMethod (GObj, M);
                CheckMethod (GObjM.MakeGenericMethod (MParam));

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list