I resisted the idea of mentioning I had tried this one (to no
avail) :)

In the above,

a_def.Equals(a_of_t) == true

with IsGenericType == IsGenericTypeDefinition == true
In fact, it figures if you think about it.

Gabriel

On 3 juin, 19:37, Jb Evain <[email protected]> wrote:
> Hey,
>
> On Thu, Jun 3, 2010 at 7:07 PM, Gabriel Kevorkian
>
> <[email protected]> wrote:
> > var assembly = AssemblyDefinition.ReadAssembly(@"MyAssembly.dll", new
> > ReaderParameters() { ReadSymbols = true });
> > var type = assembly.MainModule.Types.FirstOrDefault(t =>
> > "A`1".Equals(t.Name));
> > var list_of_a =
> > type.Module.Import(typeof(List<>).MakeGenericType(typeof(MyAssembly.A<>)),
> > type);
>
> > and have the T of MyAssembly.A<> be bound according to the context
> > passed as extra parameter to Import.
>
> > in the current implementation this will yield something of the form
> > System.Collections.Generic.List`1<MyAssembly.A`1>
>
> Yeah that's normal.
>
> You have to:
>
> var a_def = typeof (MyAssembly.A<>);
> var a_of_t = a_def.MakeGenericType (a_def.GetGenericArguments () [0]);
>
> var list = type.Module.Import (typeof (List<>).MakeGenericType (a_of_t), 
> type);
>
> --
> Jb Evain  <[email protected]>

-- 
--
mono-cecil

Reply via email to