Document async validation cancellation contract - #132794
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c5c574e4-16c6-4f14-9125-3cd4120763df
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-componentmodel-dataannotations |
Contributor
There was a problem hiding this comment.
Pull request overview
Documents the cancellation/short-circuiting contract for AsyncValidationAttribute async validation so implementers understand they must observe cancellation promptly, and callers understand how to bound validation duration.
Changes:
- Add
<remarks>toIsValidAsyncdocumenting that implementations must stop promptly when cancellation is requested, and that the infrastructure may cancel after a failure and awaits started tasks. - Add
<remarks>toGetValidationResultAsyncdescribing the same behavior for derived implementations and suggesting timeout-configured cancellation tokens for callers.
tarekgh
reviewed
Aug 26, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c5c574e4-16c6-4f14-9125-3cd4120763df
tarekgh
approved these changes
Aug 26, 2026
This was referenced Aug 27, 2026
Closed
Member
Author
Member
Author
|
/backport to release/11.0 |
Contributor
|
Started backporting to |
4 tasks
artl93
pushed a commit
that referenced
this pull request
Aug 28, 2026
Backport of #132794 to release/11.0 /cc @jeffhandley @tarekgh ## Customer Impact - [ ] Customer reported - [x] Found internally Async DataAnnotations validation is new in .NET 11 (#128656). The reliability fix #132685, backported for RC2 as #132705, moves validation task creation inside the cancel-and-await cleanup scope so no task can outlive the public `Validator` call and keep using caller-owned state. Review of that backport surfaced one residual edge that cannot be fixed in code: a validator that ignores its `CancellationToken`. Because cancellation is cooperative, cleanup must still await such a validator, and a timeout would only trade the stall for returning while a rogue task still uses caller-owned state. The agreed resolution was to document the contract. This PR adds remarks on `AsyncValidationAttribute` that implementations must observe the token, and that callers wanting a time bound should pass one linked to a timeout. Without it, the new scenario's cancellation contract ships significantly incomplete in the .NET 11 API docs. The underlying need was identified during security review. This meets the .NET 11 bug bar as: - A significantly incomplete scenario for a feature new in the release — the documented cancellation contract for async DataAnnotations validation. - A reliability guarantee: the documented contract is what stops implementers from reintroducing the escaped-background-work race that #132705 fixed. ## Regression - [ ] Yes - [x] No Not a regression. Async DataAnnotations validation is new in .NET 11 (#128656); this completes that new feature's documented contract rather than restoring prior behavior. ## Testing Documentation-only change: XML doc comment remarks on `AsyncValidationAttribute`. No API surface, IL, or runtime behavior changes, so there is nothing to unit-test and no new tests were added. Verified by building `System.ComponentModel.Annotations` so the doc comments and any `<see cref>` references resolve. Existing `System.ComponentModel.Annotations.Tests` are unaffected. ## Risk Minimal. The change touches only XML documentation comments in one file. It adds no API, no code, no IL, and does not alter validation results, task ordering, or cancellation behavior. The only review surface is wording accuracy. > [!NOTE] > This pull request description was generated with GitHub Copilot. Co-authored-by: Viviana Dueñas <50237907+ViveliDuCh@users.noreply.github.com> Copilot-Session: c5c574e4-16c6-4f14-9125-3cd4120763df
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AsyncValidationAttributeimplementations must observe cancellation promptly.This is the documentation follow-up requested in #132705 (comment).
Testing
build.cmd clr+libs -rc Releasedotnet.cmd build src\libraries\System.ComponentModel.Annotations\src\System.ComponentModel.Annotations.csprojSystem.ComponentModel.Annotations.Tests: 984 passedMicrosoft.Extensions.Options.Tests: 335 passedMicrosoft.Extensions.Options.SourceGeneration.Tests: 136 passedMicrosoft.Extensions.Options.SourceGeneration.Unit.Tests: 185 passed, 1 skippedNote
This pull request description was generated with GitHub Copilot.