[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


https://bugzilla.novell.com/show_bug.cgi?id=354757

User rkumpera at novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=354757#c12





--- 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 =
System.Threading.Thread.GetDomain().DefineDynamicAssembly(name,
AssemblyBuilderAccess.RunAndSave);
                ModuleBuilder mod = asmbuild.DefineDynamicModule("dyn_module",
"res.exe");

                TypeBuilder G = mod.DefineType("G", TypeAttributes.Public);
                G.DefineGenericParameters("T");
                ConstructorInfo ctor =
G.DefineDefaultConstructor(MethodAttributes.Public);

                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]);
                param.SetCustomAttribute(myCABuilder);

                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