> > So if I can
> > generate a testcase that generates a GenericParameter instance whose
> > Owner is a GenericInstanceType, then this is a bug, right?
>
> Indeed so. Most indeedly.

OK, here we go.


using System;
using System.Linq;
using Mono.Cecil;

namespace Timwi.Temp
{
    static class Program
    {
        static void Main()
        {
            var assembly =
AssemblyDefinition.ReadAssembly(System.Reflection.Assembly.GetExecutingAssembly().Location);
            foreach (var types in assembly.MainModule.Types.Where(t =>
t.FullName == "Timwi.Temp.Program"))
                foreach (var meth in types.Methods.Where(m => m.Name
== "Main"))
                    foreach (var instr in
meth.Body.Instructions.Where(instr => instr.Operand is MethodReference
&& ((MethodReference) instr.Operand).ReturnType is GenericParameter))
                    {
                        var gen = ((MethodReference)
instr.Operand).ReturnType as GenericParameter;
                        if (gen.Owner is GenericInstanceType)
                        {
                            Console.WriteLine("Owner is a
GenericInstanceType. Full method signature:");
 
Console.WriteLine(instr.Operand.ToString());
                        }
                    }

            Console.ReadLine();
        }
    }
}


The above code generates the following output for me:

Owner is a GenericInstanceType. Full method signature:
!0
System.Collections.Generic.IEnumerator`1<Mono.Cecil.TypeDefinition>::get_Current()
Owner is a GenericInstanceType. Full method signature:
!0
System.Collections.Generic.IEnumerator`1<Mono.Cecil.MethodDefinition>::get_Current()
Owner is a GenericInstanceType. Full method signature:
!0
System.Collections.Generic.IEnumerator`1<Mono.Cecil.Cil.Instruction>::get_Current()

-- 
--
mono-cecil

Reply via email to