dimanche 10 février 2019

Resolve generics with Mono.Cecil

I have a hierarchy of types of unknown depth. But at the and, this hierarchy implements IPlugin<T> or IPlugin<T1, T2> interface (from the other .dll). How can I resolve <T> or <T1, T2> generics? This generics position can be random on the top class.

Example:

// other .dll
interface IPlugin<T> {}
interface IPlugin<T1, T2> {}

// my code
class PluginBase<T1, T2>: IPlugin<T2, T1> {}
class AnotherClass<T1, T2, T3>: PluginBase<T3, T1> {}
class Plugin: AnotherClass<string, int, char> {}

From this example i expect string and char type definition.





Aucun commentaire:

Enregistrer un commentaire