DotNetAnalyzers / AsyncUsageAnalyzers

Now superseded by Microsoft/vs-threading
https://github.com/Microsoft/vs-threading
Other
121 stars 18 forks source link

Await inside usings. #54

Open JohanLarsson opened 7 years ago

JohanLarsson commented 7 years ago
using (var webClient = new WebClient())
{
    return webClient.DownloadStringTaskAsync(address);
}

We talked about this in chat, this can lead to situations where it is undefined if the IDisposable is disposed or not.

tugberkugurlu commented 7 years ago

This would be amazing to have but I imagine would be a bit hard to figure out.

AArnott commented 6 years ago

I think we could spec this as flagging when these conditions hold:

  1. The method does not use the async keyword in its signature.
  2. A return statement appears within a using block, with an expression that is an invocation
JohanLarsson commented 6 years ago

https://github.com/DotNetAnalyzers/IDisposableAnalyzers/blob/master/documentation/IDISP013.md

JohanLarsson commented 6 years ago

For 2 we probably want an exception for Task.FromResult()