I am trying to get the properties of a return type of a method using reflection.
I am getting the return type of the method using MethodInfo.ReturnType
, which yields my a type of Task<T>
since my method is async
. Using GetProperties
on this type yields me with the properties belonging to Task
: Result
, Exception
, AsyncState
. However, I want to get the properties of the underlying type T.
var myMethodInfo = MyType.GetMethod("MyMethod");
var returnType = myMethodInfo.ReturnType;
var myProperties = returnType.GetProperties(); // [Result, Exception, AsyncState]
How can I get the properties of the underlying type T in Task in stead of the properties of Task?
Aucun commentaire:
Enregistrer un commentaire