Skip to content

Make EditContext.Validate obsolete#67662

Merged
oroztocil merged 3 commits into
mainfrom
copilot/validation-obsolete-sync-validate
Jul 8, 2026
Merged

Make EditContext.Validate obsolete#67662
oroztocil merged 3 commits into
mainfrom
copilot/validation-obsolete-sync-validate

Conversation

@oroztocil

Copy link
Copy Markdown
Member

Marks the synchronous EditContext.Validate() method as [Obsolete] in favor of ValidateAsync(), completing the API shape approved in the async form validation API review.

The affected call sites are updated as well: the Blazor Web project template and a Components test asset now call ValidateAsync(), while the EditContext tests that intentionally cover the synchronous API suppress the obsoletion warning. A couple of sync-only tests were also relocated from the async test suite to the sync one.

Fixes #66956

Builds on the Blazor async form validation improvements in #67323.

@oroztocil oroztocil marked this pull request as ready for review July 8, 2026 08:30
@oroztocil oroztocil requested a review from a team as a code owner July 8, 2026 08:30
Copilot AI review requested due to automatic review settings July 8, 2026 08:30

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

This PR obsoletes the synchronous EditContext.Validate() API in favor of ValidateAsync(), aligning Blazor Forms with the approved async validation API shape and updating key call sites and tests accordingly.

Changes:

  • Mark EditContext.Validate() as [Obsolete] to steer callers toward ValidateAsync().
  • Update a Blazor Web project template page and a Components test asset to call ValidateAsync() (with await).
  • Adjust Forms test coverage: suppress the new obsoletion warning where tests intentionally exercise Validate(), and relocate some sync-only tests.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Account/Pages/Login.razor Switch login form validation to await editContext.ValidateAsync() to avoid calling the now-obsolete sync API.
src/Components/Web/src/Forms/EditForm.cs Update public docs to reference ValidateAsync() for manual validation scenarios.
src/Components/test/testassets/BasicTestApp/FormsTest/NotifyPropertyChangedValidationComponent.razor Update submit handler to async Task and validate with await ValidateAsync().
src/Components/Forms/test/EditContextTest.cs Suppress CS0618 and add/relocate a sync-Validate() behavior test that asserts exceptions propagate.
src/Components/Forms/test/EditContextDataAnnotationsExtensionsTest.cs Suppress CS0618 since tests intentionally call the obsolete Validate() API.
src/Components/Forms/test/EditContextAsyncTest.cs Suppress CS0618 and relocate/remove sync-only Validate() tests from the async-focused suite.
src/Components/Forms/src/EditContext.cs Apply [Obsolete] to Validate() to complete the async validation API shape.

Comment thread src/Components/Web/src/Forms/EditForm.cs
@oroztocil oroztocil enabled auto-merge (squash) July 8, 2026 09:24
@oroztocil

Copy link
Copy Markdown
Member Author

/ba-g Unrelated failures and timeouts

@oroztocil oroztocil merged commit 4b9040e into main Jul 8, 2026
23 of 25 checks passed
@oroztocil oroztocil deleted the copilot/validation-obsolete-sync-validate branch July 8, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal] Async form validation support in Blazor

4 participants