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

Clean up exposure and handling of CancellationToken #612

Merged
merged 5 commits into from May 1, 2023

Conversation

stephentoub
Copy link
Member

Motivation and Context

Clean up exposure and handling of CancellationToken in public APIs.

Description

  • In public API, they should always be the last parameter (unless they can't be, e.g. due to a params array), named "cancellationToken", and be non-nullable.
  • Ensure they're forwarded appropriately from one API to the next. There may be some more missing cases, but I fixed all the ones I found.
  • Make the XML docs consistent.
  • Remove unnecessary cancellation-related analyzer suppressions

One issue I noticed I haven't addressed here:

  • Some APIs take both an SKContext and a CancellationToken separately. If both are supplied, one of the tokens (either the explicitly passed one or the one from the SKContext) might be ignored. If they're not the same token and they're both cancelable, a combined token should really be passed on to the target so that the target ends up monitoring both.

Contribution Checklist

- In public API, they should always be the last parameter (unless they can't be, e.g. due to a params array), named "cancellationToken", and be non-nullable.
- Ensure they're forwarded appropriately from one API to the next. There may be some more missing cases, but I fixed all the ones I found.
- Make the XML docs consistent.
- Remove unnecessary cancellation-related analyzer suppressions

One issue I noticed I haven't addressed here:
- Some APIs take both an SKContext and a CancellationToken separately.  If both are supplied, one of the tokens (either the explicitly passed one or the one from the SKContext) might be ignored.  If they're not the same token and they're both cancelable, a combined token should really be passed on to the target so that the target ends up monitoring both.
@github-actions github-actions bot added .NET Issue or Pull requests regarding .NET code kernel.core labels Apr 24, 2023
@lemillermicrosoft lemillermicrosoft added the PR: ready to merge PR has been approved by all reviewers, and is ready to merge. label Apr 24, 2023
dluc
dluc previously requested changes Apr 25, 2023
Copy link
Collaborator

@dluc dluc left a comment

Choose a reason for hiding this comment

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

to be reviewed offline

@dluc
Copy link
Collaborator

dluc commented Apr 25, 2023

Todo: for ISKFunction and Plan it would be nice having the cancellation token as an optional parameter, without ever forcing the user to pass one. There are a lot of changes so I'll have to check the code locally. As a guideline, if the context is available, I would assume it has a valid cancellation token. If the context is created locally though, that's false so we need to check for that scenario. If the context is null and the user didn't pass a cancellation token I think we should log a warning (or an error).

@lemillermicrosoft lemillermicrosoft added the PR: ready for review All feedback addressed, ready for reviews label Apr 26, 2023
@dluc dluc added PR: feedback to address Waiting for PR owner to address comments/questions and removed PR: ready for review All feedback addressed, ready for reviews PR: ready to merge PR has been approved by all reviewers, and is ready to merge. labels Apr 28, 2023
@github-actions github-actions bot added the kernel Issues or pull requests impacting the core kernel label Apr 28, 2023
@shawncal shawncal dismissed dluc’s stale review May 1, 2023 06:25

No changes requested.

@shawncal shawncal merged commit 4d4ca97 into microsoft:main May 1, 2023
11 checks passed
codebrain pushed a commit to searchpioneer/semantic-kernel that referenced this pull request May 16, 2023
### Motivation and Context

Clean up exposure and handling of CancellationToken in public APIs.

### Description

- In public API, they should always be the last parameter (unless they
can't be, e.g. due to a params array), named "cancellationToken", and be
non-nullable.
- Ensure they're forwarded appropriately from one API to the next. There
may be some more missing cases, but I fixed all the ones I found.
- Make the XML docs consistent.
- Remove unnecessary cancellation-related analyzer suppressions
dehoward pushed a commit to lemillermicrosoft/semantic-kernel that referenced this pull request Jun 1, 2023
### Motivation and Context

Clean up exposure and handling of CancellationToken in public APIs.

### Description

- In public API, they should always be the last parameter (unless they
can't be, e.g. due to a params array), named "cancellationToken", and be
non-nullable.
- Ensure they're forwarded appropriately from one API to the next. There
may be some more missing cases, but I fixed all the ones I found.
- Make the XML docs consistent.
- Remove unnecessary cancellation-related analyzer suppressions
golden-aries pushed a commit to golden-aries/semantic-kernel that referenced this pull request Oct 10, 2023
### Motivation and Context

Clean up exposure and handling of CancellationToken in public APIs.

### Description

- In public API, they should always be the last parameter (unless they
can't be, e.g. due to a params array), named "cancellationToken", and be
non-nullable.
- Ensure they're forwarded appropriately from one API to the next. There
may be some more missing cases, but I fixed all the ones I found.
- Make the XML docs consistent.
- Remove unnecessary cancellation-related analyzer suppressions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code PR: feedback to address Waiting for PR owner to address comments/questions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants