Skip to content

Add doc comment on AsyncValidationAttribute to not make threading assumptions#129172

Open
Youssef1313 wants to merge 1 commit into
mainfrom
dev/ygerges/doc-comment
Open

Add doc comment on AsyncValidationAttribute to not make threading assumptions#129172
Youssef1313 wants to merge 1 commit into
mainfrom
dev/ygerges/doc-comment

Conversation

@Youssef1313

Copy link
Copy Markdown
Member

Calling this out explicitly in the doc comment so attribute authors are very well aware.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-componentmodel-dataannotations
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 AsyncValidationAttribute documentation about avoiding threading assumptions (possible parallel invocation).

Comment on lines 9 to 12
/// <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>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd agree with Copilot's feedback here

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🤖 Copilot Code Review — PR #129172

Holistic Assessment

Motivation: 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> XML doc comment. Simple and low-risk.

Summary: ✅ LGTM. This is a safe, helpful documentation improvement that makes an important threading contract explicit for implementers of AsyncValidationAttribute.


Detailed Findings

✅ Correctness — Threading guidance is accurate

The statement that implementations "may or may not be called in parallel" is architecturally sound. IsValidAsync returns a Task<ValidationResult?>, and callers (e.g., the validation framework) could reasonably await multiple such tasks concurrently. Explicitly documenting this assumption is valuable.

💡 Style — Consider using <remarks> for implementation guidance

Per docs.prompt.md, <summary> should be a brief description of what the type does, while <remarks> is intended for "additional information, which can include implementation details, usage notes, or any other relevant context." The threading guidance is clearly a usage note for implementers rather than a description of the type's purpose.

That said, placing it in <summary> maximizes visibility in IntelliSense tooltips, which has practical value given how critical this guidance is. This is a minor stylistic point and not blocking.


Models contributing to this review: claude-opus-4.6

Generated by Code Review for issue #129172 · ● 2.2M ·

@ViveliDuCh ViveliDuCh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Modulo the comment left. Thanks!

Comment on lines 9 to 12
/// <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>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd agree with Copilot's feedback here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants