Skip to content

[Master] Disable ConfigureAwait analyzer (RS0003) for C# tests#6975

Merged
davkean merged 1 commit intodotnet:masterfrom
davkean:configureawait
Nov 23, 2015
Merged

[Master] Disable ConfigureAwait analyzer (RS0003) for C# tests#6975
davkean merged 1 commit intodotnet:masterfrom
davkean:configureawait

Conversation

@davkean
Copy link
Copy Markdown
Member

@davkean davkean commented Nov 23, 2015

This was already disabled for VB, also disabling it for C#.

@davkean
Copy link
Copy Markdown
Member Author

davkean commented Nov 23, 2015

tag @dotnet/roslyn-ide @CyrusNajmabadi

@jasonmalinowski
Copy link
Copy Markdown
Member

👍. Are there existing ConfigureAwaits that can now be removed?

@jaredpar
Copy link
Copy Markdown
Member

What's the motivation for this change? In general I prefer to hold shipping code and test code to the same quality bar. Hence my first thought when reading this was "why is this necessary for source code but not test code?"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Sort rules 😄

@jasonmalinowski
Copy link
Copy Markdown
Member

Test code you want ConfigureAwait(true) (i.e. the default) so we're clearly running on the test scheduler if it's WpfFact. Product code we never want that. So yes, this isn't a matter of quality bars, but rather the domains are actually different.

@jaredpar
Copy link
Copy Markdown
Member

Why are the domains different though? It's not immediately obvious to me.

Perhaps your response should be attached to a comment on top of the disable.

@jasonmalinowski
Copy link
Copy Markdown
Member

In our product code for the workspaces and higher, we always want to ConfigureAwait(false) to ensure all continuations run on the thread pool. That way people can do .Result on a task rather than risk deadlocks. This is an API guarantee we make. For tests, they're either already running on the thread pool (so ConfigureAwait(false) doesn't do anything) or they're running on our STA thread stuff, and we want to run the continuation there. So ConfigureAwait(false) would be a bug.

Make sense?

@jaredpar
Copy link
Copy Markdown
Member

Makes sense. I still think this should be documented somewhere.

@jasonmalinowski
Copy link
Copy Markdown
Member

@davkean, can you add a comment to the ruleset file?

@davkean
Copy link
Copy Markdown
Member Author

davkean commented Nov 23, 2015

Added a comment and sorted it, but make note this is UI edited file - so now everyone's going to have to edit it by hand.

This was already disabled for VB, also disabling it for C#.
@davkean
Copy link
Copy Markdown
Member Author

davkean commented Nov 23, 2015

Whoops, pushed again with the changes I said I made.

@sharwell
Copy link
Copy Markdown
Contributor

I'm not happy with this change. I prefer ConfigureAwait always be used, whether true or false, so the intention is clear. I don't see test code as an exception to this.

@davkean
Copy link
Copy Markdown
Member Author

davkean commented Nov 23, 2015

@sharwell Your concern is noted, but as a team, we've decided to move tests away from having to specify this, given the behavior is almost always correct.

davkean added a commit that referenced this pull request Nov 23, 2015
[Master] Disable ConfigureAwait analyzer (RS0003) for C# tests
@davkean davkean merged commit 58b81db into dotnet:master Nov 23, 2015
@davkean davkean deleted the configureawait branch November 23, 2015 22:14
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

I'm not happy with this change. I prefer ConfigureAwait always be used, whether true or false, so the intention is clear. I don't see test code as an exception to this.

I disagree (mainly because I have to maintain this code). In test code, 100% (or really, like 99.9999999%) of the code is supposed to use ConfigureAwait(true). That means a massive amount of clutter and obfuscation of code just to maintain the status-quo.

In test code, the default is correct and never changed. This is vastly different from the rest of our product code. For that code, almost all code needs ConfigureAwait(false), and some code critically does not need that. As such, we want to call out explicitly both cases and we want people to always have to think about this.

In test code you don't need to think about it, and it is just a tax.

@jaredpar
Copy link
Copy Markdown
Member

@CyrusNajmabadi that reasoning makes sense.

However we're now sending a bit of a mixed message. It's not required anymore but there is a large amount of test code out there which makes it appear that it's required (I know as I added quite a bit of it). Have we thought about quickly cleaning this up and removing the unnecessary uses?

@davkean
Copy link
Copy Markdown
Member Author

davkean commented Nov 23, 2015

@jaredpar Yep we've talked about, if you only you were in our team room. :)

I'll file a issue to track removing it.

@jaredpar
Copy link
Copy Markdown
Member

@davkean I'm down the hall. If you all would just shout your discussions we wouldn't have to communicate via github.

@sharwell
Copy link
Copy Markdown
Contributor

@jaredpar But then I would have to hunt you down for excluding the community! 😆

@davkean
Copy link
Copy Markdown
Member Author

davkean commented Nov 24, 2015

Don't worry, I can shout pretty loudly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants