Skip to content

Conversation

@stephentoub
Copy link
Member

.NET 8 introduces new overloads of ConfigureAwait. One of the options is SuppressThrowing, but it's not supported by Task<T>, since that would then lead to returning a possibly invalid T. This rule flags use of SuppressThrowing so that you get a build-time rather than execution-time error.

Contributes to dotnet/runtime#22144 (comment)

@stephentoub stephentoub requested a review from a team as a code owner June 5, 2023 21:42
…aitOptions.SuppressThrowing

.NET 8 introduces new overloads of ConfigureAwait.  One of the options is SuppressThrowing, but it's not supported by `Task<T>`, since that would then lead to returning a possibly invalid T.  This rule flags use of SuppressThrowing so that you get a build-time rather than execution-time error.
@stephentoub stephentoub force-pushed the configureawaitoptions branch from 2ad880d to 8045013 Compare June 6, 2023 17:39
@codecov
Copy link

codecov bot commented Jun 6, 2023

Codecov Report

Merging #6669 (8045013) into main (2b6ab8d) will decrease coverage by 0.01%.
The diff coverage is 97.29%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6669      +/-   ##
==========================================
- Coverage   96.40%   96.39%   -0.01%     
==========================================
  Files        1379     1381       +2     
  Lines      322253   322401     +148     
  Branches    10460    10463       +3     
==========================================
+ Hits       310657   310794     +137     
- Misses       9103     9112       +9     
- Partials     2493     2495       +2     

@stephentoub stephentoub requested a review from buyaa-n June 6, 2023 20:12
Copy link

@buyaa-n buyaa-n left a comment

Choose a reason for hiding this comment

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

LGTM

@stephentoub stephentoub merged commit 0bcd02b into dotnet:main Jun 28, 2023
@stephentoub stephentoub deleted the configureawaitoptions branch June 28, 2023 00:09

Rule ID | Category | Severity | Notes
--------|----------|----------|-------
CA2261 | Usage | Warning | DoNotUseConfigureAwaitWithSuppressThrowing, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2250)
Copy link

@StephenCleary StephenCleary Nov 3, 2023

Choose a reason for hiding this comment

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

Should this be https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2261 ?

I believe this is the equivalent line in main:

CA2261 | Usage | Warning | DoNotUseConfigureAwaitWithSuppressThrowing, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2250)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. No idea how it ended up like that.

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

Successfully merging this pull request may close these issues.

5 participants