Add doc comment on AsyncValidationAttribute to not make threading assumptions#129172
Add doc comment on AsyncValidationAttribute to not make threading assumptions#129172Youssef1313 wants to merge 1 commit into
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-componentmodel-dataannotations |
There was a problem hiding this comment.
Pull request overview
Updates the XML doc comment on AsyncValidationAttribute (System.ComponentModel.Annotations) to warn attribute implementers not to assume single-threaded / non-parallel execution when async validation is performed.
Changes:
- Add an explicit note in
AsyncValidationAttributedocumentation about avoiding threading assumptions (possible parallel invocation).
| /// <summary> | ||
| /// Base class for validation attributes that require asynchronous operations, such as database lookups or API calls. | ||
| /// Derived classes should never make any threading assumptions. Implementations of this attribute may or may not be called in parallel. | ||
| /// </summary> |
There was a problem hiding this comment.
I'd agree with Copilot's feedback here
🤖 Copilot Code Review — PR #129172Holistic AssessmentMotivation: Justified. Async validation attributes may reasonably be called in parallel by the framework, and making this explicit in documentation helps implementers avoid subtle concurrency bugs. Approach: Adds a single sentence to the class-level Summary: ✅ LGTM. This is a safe, helpful documentation improvement that makes an important threading contract explicit for implementers of Detailed Findings✅ Correctness — Threading guidance is accurateThe statement that implementations "may or may not be called in parallel" is architecturally sound. 💡 Style — Consider using
|
ViveliDuCh
left a comment
There was a problem hiding this comment.
Modulo the comment left. Thanks!
| /// <summary> | ||
| /// Base class for validation attributes that require asynchronous operations, such as database lookups or API calls. | ||
| /// Derived classes should never make any threading assumptions. Implementations of this attribute may or may not be called in parallel. | ||
| /// </summary> |
There was a problem hiding this comment.
I'd agree with Copilot's feedback here
Calling this out explicitly in the doc comment so attribute authors are very well aware.