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

Require ConfigureAwait()'s "continueOnCapturedContext" is called with "false" #511

Open
omsmith opened this issue Jun 20, 2019 · 0 comments

Comments

@omsmith
Copy link
Contributor

omsmith commented Jun 20, 2019

D2L0055 requires that awaited tasks are configured, but does not enforce an opinion of the continueOnCapturedContext value. A new analyzer should be created to look at ConfigureAwait invocations and require that continueOnCapturedContext is passed false.

void Foo() {

  Task t = Task.Delay( 1000 ).ConfigureAwait( true ); // D2LXXXX: Tasks are required to be configured with 'continueOnCapturedContext' as false
  Task<int> tInt = Bar().ConfigureAwait( continueOnCapturedContext: true ); // D2LXXXX: Tasks are required to be configured with 'continueOnCapturedContext' as false

  Task.CompletedTask.ConfigureAwait( false );
  Task.FromResult( 1 ).ConfigureAwait( continueOnCapturedContext: false );

}

A codefix which replaces the invocation with ConfigureAwait( continueOnCapturedContext: false ) would be an extra bonus.

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

No branches or pull requests

1 participant