Maintenant que j'y pense...
It may not be quite orthodox (still it turns out to be really
practical for me) and there may be another approach (Note I
encountered this issue in combination with method import which makes
it a little less trivial, the declaring type would not be imported
properly)

I'll leave it to you to be the judge in this matter :)

We have a generic class A<T> and we would like to introduce within
that type a reference to a generic type that wraps A<T>, for instance
a List<A<T>> (in fact import methods from that type)

Again we are using .net reflection
We would like to be able to write something of this form (for a simple
type import)

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>

where we'd rather have:
System.Collections.Generic.List`1<MyAssembly.A`1<T>>

What do you think?
Best regards,
Gabriel

On 3 juin, 18:20, Jb Evain <[email protected]> wrote:
> Hey Gabriel,
>
> On Thu, Jun 3, 2010 at 5:41 PM, Gabriel Kevorkian
>
> <[email protected]> wrote:
> > My patch works for me but I'm not sure I did everything properly.
> > Nor am I sure about the reason why DeclaringType is set twice on
> > reference (once right after new and a second time just before
> > returning)
>
> I've attached the current state of my import_context branch. It's only
> missing a few tests before I check it in.
>
> > I've had another problem with generics this time inside
> > ImportTypeSpecification() (Import.cs:124)
>
> Could you please provide a test for it, or at least, a use case that
> show an issue?
>
> Thanks!
>
> --
> Jb Evain  <[email protected]>
>
>  import.diff
> 14KAfficherTélécharger

-- 
--
mono-cecil

Reply via email to