[Mono-bugs] [Bug 652952] New: MakeGenericMethod does not work on generic type definitions

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Nov 11 08:31:20 EST 2010



           Summary: MakeGenericMethod does not work on generic type
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Major
          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 = "sre";
        AssemblyBuilder asmbuild = System.Threading.Thread.GetDomain
().DefineDynamicAssembly (asmname, AssemblyBuilderAccess.RunAndSave);
        ModuleBuilder modbuild = asmbuild.DefineDynamicModule ("modulename",

        TypeBuilder myType = modbuild.DefineType ("Sample",
        var tp = myType.DefineGenericParameters ("T");

        var m_a = myType.DefineMethod ("MethodA", MethodAttributes.Public);
        var m_a_targ = m_a.DefineGenericParameters ("TA");

        var m_b = myType.DefineMethod ("Methodb", MethodAttributes.Public);
        m_b.DefineGenericParameters ("TB");

        var ilgen = m_a.GetILGenerator ();
        ilgen.Emit (OpCodes.Ldarg_0);
        ilgen.Emit (OpCodes.Call, m_b.MakeGenericMethod (m_a_targ));
        ilgen.Emit (OpCodes.Ret);

        ilgen = m_b.GetILGenerator ();
        ilgen.Emit (OpCodes.Ret);

        myType.CreateType ();

        asmbuild.Save ("sre.exe");


Mono produces invalid call

call instance void class Sample::Methodb<!!0> ()

instead of

call instance void class Sample<!T>::Methodb<!!0> ()

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