vendredi 8 septembre 2017

How can I get all closed types of a certain generic type?

I'm working in a large solution that somewhere in its base assemblies it has a generic type:

public class MyHelper<T>

Multiple higher-level projects might use this class to instantiate field variables like this:

public class Foo {
    ...
    private MyHelper<double> _h1;
    private MyHelper<AnotherClass> _h2;
    ...
}

On an even higher level, I want to collect some statistics about what's going on. So I'm interested to get all closed types of MyHelper<T>. In my example, this would be: MyHelper<double> and MyHelper<AnotherClass>.

Ideally, the solution doesn't have to know about all possible assemblies that reference the MyHelper<T> assembly. I would be great to somehow extract this information from what was loaded in the system so far.





Aucun commentaire:

Enregistrer un commentaire