-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not call Task.WhenAll with a single argument #33806
Comments
Estimates:
|
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: using System.Threading.Tasks;
namespace MyNamespace
{
class Sample
{
public static void Main()
{
Task task = ...;
// Instead of this
await Task.WhenAll(task);
// Suggest this
await task;
// Instead of this
await Task.WhenAll(GetTask());
// Suggest this
await GetTask();
// Analyzer should trigger, but should not offer a fix because whenResult is used somewhere else
Task whenResult = Task.WhenAll(task);
DoSomethingWithTask(whenResult);
}
static Task GetTask()
{
return ...;
}
static void DoSomethingWithTask(Task task)
{
...;
}
}
}
|
async Task M(Task task)
{
// Before
await Task.WhenAll(task);
// After
await task;
} |
Thanks for the correction, and thanks for approving. |
@ryzngard Here's a getting started guide as well. Included in there is our typical "Definition of Done" for creating .NET Libraries analyzers. |
This was implemented as CA1842/1843. Thanks! |
There's no reason to call
WhenAll
with a singleTask
; just use theTask
.Category: Performance
The text was updated successfully, but these errors were encountered: