Make EditContext.Validate obsolete#67662
Merged
Merged
Conversation
Co-authored-by: oroztocil <79744616+oroztocil@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
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 towardValidateAsync(). - Update a Blazor Web project template page and a Components test asset to call
ValidateAsync()(withawait). - 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. |
ilonatommy
approved these changes
Jul 8, 2026
Member
Author
|
/ba-g Unrelated failures and timeouts |
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.
Marks the synchronous
EditContext.Validate()method as[Obsolete]in favor ofValidateAsync(), 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 theEditContexttests 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.