This repository has been archived by the owner. It is now read-only.
This repository has been archived by the owner. It is now read-only.
Analyzer for wrong usage of async methods #164
Open
Description
Example async method:
public Task<string> DoSomethingAsync(string str)
{
return Task.FromResult(str);
}
Examples of wrong usage:
public async Task Scenario1Async()
{
var usedCorrectly = await DoSomethingAsync("helloworld");
// obviously wrong, but could happen for fire-and-forget cases where you don't check eg the boolean result
var blatantlywrong = DoSomethingAsync("get it going");
}
public async Task Scenario2Async()
{
var usedCorrectly = await DoSomethingAsync("helloworld");
// If you have models that happen to have an Id property (very likely when working with dbs)
var stillwrong = DoSomethingAsync("guess what");
var x = stillwrong.Id;
}
public void Scenario3()
{
// Creatively wrong
List<string> somestrings = new List<string>() { "Hello", "World" };
var result = somestrings.Select(DoSomethingAsync).ToList();
Console.WriteLine(result[1]);
}