Warning CA1849 ignores previous await
- Dominant language
- No language data
- Stars
- 4.8k
- Forks
- 6.1k
- Avg merge
- 19h 10m
- Merged PRs (30d)
- 268
Description
If a Task is already guaranteed to be completed, this warning makes no sense.
For example:
```
await task.ConfigureAwait(false);
DoSomething(task.Result);
```
Or:
```
await Task.WhenAll(task1, taks2).ConfigureAwait(false);
DoSomething(task1.Result, task2.Result);
```
Both examples rise this warning. The "suggested" way, without assigning any result varibles, would be to await twice, which doesn't make sense and makes the code completely unreadable:
```
await Task.WhenAll(task1, taks2).ConfigureAwait(false);
DoSomething(await task1.ConfigureAwait(false), await task2.ConfigureAwait(false));
```
---
#### Document Details
⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*
* ID: 4637a020-3411-c088-d05f-28e1a487d7a8
* Version Independent ID: ea5d80fc-2578-a157-6f3c-b85794ab0fa0
* Content: [CA1849: Call async methods when in an async method - .NET](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1849)
* Content Source: [docs/fundamentals/code-analysis/quality-rules/ca1849.md](https://github.com/dotnet/docs/blob/main/docs/fundamentals/code-analysis/quality-rules/ca1849.md)
* Product: **dotnet-fundamentals**
* GitHub Login: @mahdiva
* Microsoft Alias: **gewarren**
Contributor guide
Assessment
This issue has not been assessed yet.