lundi 9 août 2021

Unespected result with type.GenericTypeArguments

with reflection I'm getting list of a Method of a Controller, successfully.

to get the arguments of a returntype of a method I'm using *.GenericTypeArguments in this way:

Some MethodInfo x.GenericTypeArguments.Select(a => a.Name);

When method is like it:

public async Task<ApiResult> SomeMethod();

im getting the good result: "ApiResult"

But when the return tyle has a list like:

public async Task<List<string>> SomeMethod();

I'm getting -> Task,List,System.Linq.Enumerable+SelectArrayIterator`2[System.Type,System.String] instead of Task,List,String

same for

public async Task<Dictionary<string,string>> SomeMethod();

expected Task,Dictionary,string,string

retrieved Task,Dictionary,System.Linq.Enumerable+SelectArrayIterator`2[System.Type,System.String]

Somebody can help to explain ?

Thankyou for help





Aucun commentaire:

Enregistrer un commentaire