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

Remove ConfigureAwait(false) in tests? #3742

Open
bjornhellander opened this issue Dec 3, 2023 · 4 comments
Open

Remove ConfigureAwait(false) in tests? #3742

bjornhellander opened this issue Dec 3, 2023 · 4 comments

Comments

@bjornhellander
Copy link
Contributor

@MartyIX asked why we have ConfigureAwait(false) in the test projects: #3719 (comment)

In later xUnit versions, there is an analyzer which warns about this due to potential parallelization issues (https://xunit.net/xunit.analyzers/rules/xUnit1030), so it seems to be a valid question.

@bjornhellander
Copy link
Contributor Author

I found this which contained some background to xUnit1130: xunit/xunit#2628

I kind of "hoped" that running too many tests in parallel could have a negative impact on execution time etc, but after benchmarking a bit on my laptop with and without ConfigureAwait I don't see any clear differences. Will try it on github for a while too, in case it behaves differently there.

@MartyIX
Copy link
Contributor

MartyIX commented Dec 4, 2023

@MartyIX asked why we have ConfigureAwait(false) in the test projects: #3719 (comment)

it's not about all ConfigureAwait(false) calls but rather those that are directly in [Fact]/[Theory] methods (i.e. top-level ones).

In general, one might want to run a group of tests in a serial fashion, using ConfigureAwait(false) improperly can imho break that feature. In my mind, the we are talking here more about correctness than about some performance speedups.

Anyway, since nobody noticed this issue to this day, it might be a non-issue in practice. So maybe it can be qualified as "nice to have".

@bjornhellander
Copy link
Contributor Author

Ok, then I misunderstood the reasoning behind it. Thanks for clarifying! I am pretty sure there is no correctness issue related to it in this repository at this moment, but it seems like a good idea to follow their analyzers. A decision will need to be taken when xunit is updated, at the latest.

@sharwell
Copy link
Member

We will likely have to disable xUnit1030, because there are many places in Roslyn where ConfigureAwait(false) is used and we don't have control over those.

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

3 participants