Skip to content

Fixes in PrefixResolver #63334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 21, 2025
Merged

Conversation

dariatiurina
Copy link
Contributor

Fixes in PrefixResolver

Description

This pull request improves the form binding logic and its test coverage, particularly around recursive model binding scenarios and prefix resolution. The main changes include enhancements to the FormKeyComparer for more reliable segment comparison, new and expanded unit tests for prefix handling, and the addition of a new E2E test and supporting Razor page for recursive form binding.

Changes:

  • Changed the FormKeyComparer logic in PrefixResolver.cs to improve segment comparison accuracy, especially when handling cases where one key has more segments than the other. This makes prefix resolution more robust and correct.
  • Added new unit tests in PrefixResolverTests.cs to verify correct behavior of prefix detection with and without matching entries, ensuring the resolver works for both positive and negative scenarios.
  • Introduced a new E2E test in FormWithParentBindingContextTest.cs that verifies recursive form binding works as expected, including input and form submission behavior.

Fixes #61341

@dariatiurina dariatiurina self-assigned this Aug 19, 2025
@github-actions github-actions bot added the area-blazor Includes: Blazor, Razor Components label Aug 19, 2025
@dariatiurina dariatiurina marked this pull request as ready for review August 20, 2025 07:33
@Copilot Copilot AI review requested due to automatic review settings August 20, 2025 07:33
@dariatiurina dariatiurina requested a review from a team as a code owner August 20, 2025 07:33
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request fixes issues in the PrefixResolver component to improve form binding logic, particularly for recursive model binding scenarios. The changes enhance segment comparison accuracy in the FormKeyComparer and add comprehensive test coverage to verify the fixes work correctly.

  • Refactored the FormKeyComparer logic to handle edge cases where keys have different numbers of segments
  • Added comprehensive unit tests to verify prefix detection works for both positive and negative scenarios
  • Created an E2E test with a supporting Razor page to validate recursive form binding functionality

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
PrefixResolver.cs Simplified and fixed the FormKeyComparer logic to properly handle segment comparison when keys have different segment counts
PrefixResolverTests.cs Added new unit tests to verify prefix detection behavior with matching and non-matching entries
FormWithParentBindingContextTest.cs Added E2E test to verify recursive form binding works end-to-end
RecursiveEditFormBinding.razor New test page supporting the E2E test with a recursive model structure

@dariatiurina dariatiurina force-pushed the 61341-editform-recursive branch from 9eeb34e to 4aa4eb3 Compare August 20, 2025 07:42
@ilonatommy ilonatommy added this to the 10.0-rc2 milestone Aug 20, 2025
Copy link
Member

@ilonatommy ilonatommy left a comment

Choose a reason for hiding this comment

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

Looks good

@dariatiurina dariatiurina merged commit dce2aee into dotnet:main Aug 21, 2025
29 checks passed
@dotnet-policy-service dotnet-policy-service bot modified the milestones: 10.0-rc2, 10.0-rc1 Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Model not created on post with EditForm
2 participants