Hy,

I was getting an exception while importing a method from another
assembly.
After (a lot) of debugging, I was able to reproduce a small test case
to reproduce the bug.

Suppose we have an assembly "Assembly1" already containing a reference
to the IEnumerable<T> class.

class MyClass : IEnumerable<string>
{
}

Now, if I want to import the method GetEnumerator() of the type
"System.Collections.Generic.IEnumerable`1" into the Assembly1. I get
the ArgumentOutOfRangeException in GenericParameterCollection.This[].

public GenericParameter this [int index]{
   get {
                return List [index] as GenericParameter; // <- Here
the exception is thrown.
   }
   set { List [index] = value; }
}


I think the bug comes from loading type references of the Assembly1.
When I looked into Assembly1.MainModule.TypeReferences
["System.Collections.Generic.IEnumerable`1"], it contains a
TypeReference instance with HasGenerics set to false !!!

P.S. I uploaded a file TestImportingBug.zip to reproduce the bug.
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to