[Mono-bugs] [Bug 648391] New: TypeBuilder.GetConstructor does not check ctor argument

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Oct 21 12:45:54 EDT 2010



           Summary: TypeBuilder.GetConstructor does not check ctor
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: rkumpera at novell.com
        ReportedBy: msafar at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

Compile & Run

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

class Program
    static void Main ()
        AssemblyName asmname = new AssemblyName ();
        asmname.Name = "assemfilename.exe";
        AssemblyBuilder asmbuild = System.Threading.Thread.GetDomain ().
                    DefineDynamicAssembly (asmname,
        ModuleBuilder modbuild = asmbuild.DefineDynamicModule ("modulename",

        TypeBuilder myType = modbuild.DefineType ("Sample",

        string[] typeParamNames = { "TFirst" };
        GenericTypeParameterBuilder[] typeParams =
            myType.DefineGenericParameters (typeParamNames);

        var ctor = myType.DefineDefaultConstructor (MethodAttributes.Public);

        var ctori = TypeBuilder.GetConstructor (myType.MakeGenericType (typeof
(int)), ctor);
        var ctorii = TypeBuilder.GetConstructor (myType.MakeGenericType (typeof
(bool)), ctori);
        Console.WriteLine (ctorii);


NET throws

System.ArgumentException: The specified constructor must be declared on a
generic type definition.
Parameter name: constructor
   at System.Reflection.Emit.TypeBuilder.GetConstructor(Type type,
fo constructor)
   at Program.Main()


I have not tested it but same issue may exist with TypeBuilder.GetMethod

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