Diagnostic ID : CA1849
Description
According to the documentation the CA1849 :
All methods where an Async-suffixed equivalent exists will produce this warning when called from a Task-returning method. In addition, calling Task.Wait(), Task.Result, or Task.GetAwaiter().GetResult() will produce this warning.
The warning is triggered as expected when calling .Wait() or .Result but not when calling .GetAwaiter().GetResult().
Steps to reproduce
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisMode>All</AnalysisMode>
</PropertyGroup>
</Project>
public static async Task<string> ReadFileAsync()
{
// The following line does not trigger the CA1849 rule
var content = File.ReadAllTextAsync("input.txt").GetAwaiter().GetResult();
return content;
}
Expected Behavior
CA1849 is raised
Actual Behavior
No warning are raised
Diagnostic ID : CA1849
Description
According to the documentation the CA1849 :
The warning is triggered as expected when calling .Wait() or .Result but not when calling .GetAwaiter().GetResult().
Steps to reproduce
Expected Behavior
CA1849 is raised
Actual Behavior
No warning are raised