Analyzer: Warn when passing a Task<T> or ValueTask<T> to Minimal API Results.* methods #36408
Labels
analyzer
Indicates an issue which is related to analyzer experience
area-minimal
Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
feature-minimal-actions
Controller-like actions for endpoint routing
Milestone
Is your feature request related to a problem? Please describe.
Playing around with Minimal APIs, I wrote some code similar to the below without noticing I'd forgotten to await the method:
Calling
/do-thing
then returned some JSON similar to the below:Easily fixed by updating the method signature appropriately, but an easy enough mistake to make.
Describe the solution you'd like
An analyzer that warns if a "task-like" type (
Task
,Task<T>
,ValueTask
,ValueTask<T>
) is passed to one of the staticResults
methods (likeResults.Json(object? data, ...)
) for a parameter of typeobject?
.The text was updated successfully, but these errors were encountered: