ok, i have an assembly "A" just with these three things:

//interface for template
public interface IFoo<T>
{
}

//template
public class Foo<T> : IFoo<T>
{}

//target
[ExtendWith(typeof(Foo<int>))]
public class Target
{

}

>From another assembly "B",  I am  trying to modify this one, in order to
make Target implement IFoo<int> (just that for now).

So, i look all types that has the ExtendWith attribute, and then i read the
constructor arguments and i get a GenericInstanceType pointing to Foo<int>

and i have the Type Definition of Target.

So, what is the best way to get IFoo<int> from the GenericInstanceType?

If i do genericInstanceType.Resolve().Interfaces <- these generic instance
types doesn't have the arguments...








2011/1/20 Jb Evain <[email protected]>

> Hi José,
>
> On Thu, Jan 20, 2011 at 11:33 PM, José F. Romaniello
> <[email protected]> wrote:
> > private static TypeReference CloseInterface(
> > TypeReference @interface,
> > IEnumerable<TypeReference> genericArguments)
> > {
> > if ([email protected]) return @interface;
> > var genericInstanceType = new GenericInstanceType(@interface.Resolve());
> > genericInstanceType.GenericArguments.AddRange(genericArguments);
> > return genericInstanceType;
> > }
> > and:
> > myGenericInstanceType.Resolve().Interfaces( i =>
> > i.CloseInterface(myGenericInstanceType.Arguments))
>
> To help you, it's nice to indicate what you have, but it would really
> help if you could indicate what you're trying to get, because the
> above looks quite wrong :)
>
> Jb
>
> --
> --
> mono-cecil

-- 
--
mono-cecil

Reply via email to