mardi 28 juin 2016

C# Reflection how to get the where clause for a generic type [duplicate]

This question already has an answer here:

(sorry if this question exists, but its proven hard to search)

I'm tasked with writing wrapper code for a 3rd party library full of static methods. (to make it more testable) I've written code that uses reflection to tear apart all the calls (over 3000) and write classes, interfaces and wrapping methods/properties for all of it. We will also get updates on this library from time to time, so I don't want to do this by hand every time.

But I do not know how to get the where clause at the end of the method. Example:

public static T Load<T>(string path) where T : Object
{
  // blah blah blah
}

using only reflection, how do I extract "where T : Object" so I can enter it in my generated code?





Aucun commentaire:

Enregistrer un commentaire