Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper rewrite for await using with variable #28

Open
cincuranet opened this issue Mar 11, 2021 · 3 comments
Open

Proper rewrite for await using with variable #28

cincuranet opened this issue Mar 11, 2021 · 3 comments

Comments

@cincuranet
Copy link
Owner

For example this

await using (var test = ...)
{
}

with ConfigureAwait(false) will result in test being ConfiguredAsyncDisposable type.

@JustArchi
Copy link

JustArchi commented Mar 11, 2021

I was just about to post this. Current version of 5.0.0 calls this example code of mine as a possibility of missing ConfigureAwait(false):

await using FileStream fileStream = File.Open(sentryFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);

How am I expected to rewrite this bit to satisfy the warning? I've tried various ideas that came to my mind but they all resulted in error of converting System.Runtime.CompilerServices.ConfiguredAsyncDisposable to System.IO.FileStream (in my case).

@cincuranet
Copy link
Owner Author

cincuranet commented Mar 11, 2021 via email

@JustArchi
Copy link

Thanks a lot, that did the trick!

Leaving the answer for people that might stumble upon this as well:

FileStream fileStream = File.Open(sentryFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);

await using (fileStream.ConfigureAwait(false)) {
	// ...
}

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

No branches or pull requests

2 participants