You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Do not call Task.WhenAll with a single argument #33806
If the API review folks agree, we can group this proposal with #33807.
If they prefer a separate rule ID, then please approve separately.
Here is a usage example:
usingSystem.Threading.Tasks;namespaceMyNamespace{classSample{publicstaticvoidMain(){Tasktask=...;// Instead of thisawaitTask.WhenAll(task);// Suggest thisawaittask;// Instead of thisawaitTask.WhenAll(GetTask());// Suggest thisawaitGetTask();// Analyzer should trigger, but should not offer a fix because whenResult is used somewhere elseTaskwhenResult=Task.WhenAll(task);DoSomethingWithTask(whenResult);}staticTaskGetTask(){return...;}staticvoidDoSomethingWithTask(Tasktask){...;}}}
This analyzer should not affect any of the other WhenAll overloads, because they take a Task[]. Only this overload, which takes a params Task[] task would be affected.
This analyzer should also have a fixer, except for the 3rd case indicated in the usage example.
Suggested severity: Info.
Suggested milestone if approved: 6.0 (seems simple to address).
Edit: Removed the incorrect Wait() usages and added await as described in the video.
Activity
jeffhandley commentedon Mar 21, 2020
Estimates:
carlossanlop commentedon Oct 30, 2020
If the API review folks agree, we can group this proposal with #33807.
If they prefer a separate rule ID, then please approve separately.
Here is a usage example:
This analyzer should not affect any of the other
WhenAlloverloads, because they take aTask[]. Only this overload, which takes aparams Task[] taskwould be affected.This analyzer should also have a fixer, except for the 3rd case indicated in the usage example.
Suggested severity: Info.
Suggested milestone if approved: 6.0 (seems simple to address).
Edit: Removed the incorrect
Wait()usages and addedawaitas described in the video.terrajobst commentedon Feb 4, 2021
Video
Wait():carlossanlop commentedon Feb 4, 2021
Thanks for the correction, and thanks for approving.
carlossanlop commentedon Feb 5, 2021
This is also yours, @ryzngard, per your request in #33807. Thanks for your help! Let us know if you have any questions.
jeffhandley commentedon Feb 5, 2021
@ryzngard Here's a getting started guide as well. Included in there is our typical "Definition of Done" for creating .NET Libraries analyzers.
ryzngard commentedon Apr 22, 2021
@jeffhandley @terrajobst checked into https://github.com/dotnet/roslyn-analyzers/tree/release/6.0.1xx-preview4
stephentoub commentedon Jul 13, 2021
This was implemented as CA1842/1843. Thanks!