Hi Jean-Baptiste,
I looked at your diff for import_context
In method ImportMethod (SR.MethodBase method, IGenericContext
context), I believe

DeclaringType = ImportType(method.DeclaringType, context)

is not correct.
You should be reusing the type stored in declaring_type (not importing
the one from the resolved method), in other words, have this instead:

DeclaringType = declaring_type

HTH,
Gabriel


On 3 juin, 21:14, Gabriel Kevorkian <[email protected]>
wrote:
> 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]>- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -

-- 
--
mono-cecil

Reply via email to