I have method like this:
public async Task<IEnumerable<DataResponse>> GetAsync() { ... }
I use reflection and I want to get the type "DataResponse", but I get type "Task<IEnumerable>"
static void Main(string[] args)
{
var assemblies = GetAssemblies();
IEnumerable<Type> controllers =
assemblies.SelectMany(a => a.GetTypes().Where(t => t.IsSubclassOf(typeof(ControllerBase))));
foreach (var controller in controllers)
{
var methods = controller.GetMethods();
foreach (var methodInfo in methods)
{
var returnType = methodInfo.ReturnType;
}
}
}
How do I get types excluding standard types ("task", "IEnumerable", e.t.c)?