Skip to content

Add OperationCanceledException exceptions automatically #8776

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

Closed
wants to merge 3 commits into from

Conversation

gewarren
Copy link
Contributor

@gewarren gewarren commented Jan 10, 2023

Used a utility I wrote to automatically add OperationCanceledException exceptions with reason "The cancellation token was canceled" to methods that accept a CancellationToken parameter.

Example preview.

Contributes to #7840.
Replaces #8745.

cc @stephentoub

@ghost ghost assigned gewarren Jan 10, 2023
@ghost ghost added the area-Meta Concerns something that extends across runtime area boundaries, for example, IDisposable. label Jan 10, 2023
@learn-build-service-prod

This comment was marked as outdated.

@stephentoub
Copy link
Member

Thanks, @gewarren, but I'm confused. Typically <exception/> indicates exceptions that are thrown out of a method, but in the case of OperationCanceledException, with an async / Task-returning method, it should always be stored into the resulting task.

@gewarren
Copy link
Contributor Author

gewarren commented Jan 11, 2023

Thanks, @gewarren, but I'm confused. Typically <exception/> indicates exceptions that are thrown out of a method, but in the case of OperationCanceledException, with an async / Task-returning method, it should always be stored into the resulting task.

@stephentoub Yes, I agree with that, but in my notes from our meeting in November this was one of the things we decided to do as a stop-gap measure. I'm happy to close this, or perhaps we can still use the <exception> tag but note that it's a stored exception? Something like:

<exception cref="T:System.OperationCanceledException">The cancellation token was canceled. This exception is stored into the returned <see cref="T:System.Threading.Tasks.Task`1" />.</exception>

@stephentoub
Copy link
Member

stephentoub commented Jan 12, 2023

perhaps we can still use the tag but note that it's a stored exception? Something like:

Did we discuss just doing that for all the exceptions, e.g. copyimg from the sync counterpart and adding that verbiage in the exception tag itself? I wonder if that'd be sufficient to just call this whole thing done.

@gewarren
Copy link
Contributor Author

perhaps we can still use the tag but note that it's a stored exception? Something like:

Did we discuss just doing that for all the exceptions, e.g. copying from the sync counterpart and adding that verbiage in the exception tag itself? I wonder if that'd be sufficient to just call this whole thing done.

@stephentoub We didn't discuss that, but it seems like a good idea to me. Thoughts @antonfirsov @BillWagner? We could run the tool periodically to catch any new exceptions that were added to the synchronous method.

@BillWagner
Copy link
Member

We could run the tool periodically to catch any new exceptions that were added to the synchronous method.

I like this plan. It keeps us moving forward.

Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

This is a great improvement. Let's :shipit:

@gewarren gewarren marked this pull request as draft September 26, 2023 18:33
@gewarren
Copy link
Contributor Author

Converted to draft PR until I add in the extra text on the end.

@learn-build-service-prod
Copy link

Learn Build status updates of commit 01e30fc:

❌ Validation status: errors

Please follow instructions here which may help to resolve issue.

File Status Preview URL Details
❌Error Details

  • [Error: CannotMergeCommit] Cannot merge commit 01e30fc6ebbfd203c70c698af687c9cf2c421127 in branch operationcanceledexceptions of repository https://github.com/gewarren/dotnet-api-docs into branch main (commit 5d696e23da385cf61d686f3e8ba2f580f9723880). Please follow this documentation: https://help.github.com/articles/resolving-a-merge-conflict-using-the-command-line/ to use git.exe to resolve you content conflicts locally and then push to remote.

For more details, please refer to the build report.

Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them.

For any questions, please:

@gewarren
Copy link
Contributor Author

gewarren commented Oct 3, 2023

Closing and replacing due to too many conflicts.

@gewarren gewarren closed this Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Meta Concerns something that extends across runtime area boundaries, for example, IDisposable.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants