The following method raises CA1859, suggesting that the return type is changed to List<string>:
private static IList<string> GetList()
{
return new List<string>();
}
The same pattern is however not detected for async methods returning a Task<T>. The following code does not suggest that Task<IList<string>> is changed to Task<List<string>>:
Analyzer
Diagnostic ID: CA1859
Describe the improvement
The following method raises CA1859, suggesting that the return type is changed to
List<string>
:The same pattern is however not detected for async methods returning a
Task<T>
. The following code does not suggest thatTask<IList<string>>
is changed toTask<List<string>>
:The above examples are trivialised versions of a real async method where I noticed returning an
IList<T>
wasn't suggesting the use of aList<T>
.Describe suggestions on how to achieve the rule
Change the rule to consider the real type that is used to create the
Task<T>
.Additional context
None.