Skip to content
This repository has been archived by the owner on Nov 8, 2018. It is now read-only.

Await inside usings. #54

Open
JohanLarsson opened this issue Sep 29, 2016 · 4 comments
Open

Await inside usings. #54

JohanLarsson opened this issue Sep 29, 2016 · 4 comments

Comments

@JohanLarsson
Copy link

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
Copy link

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

@AArnott
Copy link

AArnott commented May 2, 2018

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
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants