Skip to content

Improve QuickGrid diagnostics for mismatched GridSort types - #67413

Merged
ilonatommy merged 15 commits into
dotnet:mainfrom
BharatRamsf3693:bug-56437-quickgrid-gridsort-mismatch
Jul 1, 2026
Merged

ilonatommy merged 15 commits into
dotnet:mainfrom
BharatRamsf3693:bug-56437-quickgrid-gridsort-mismatch

Conversation

@BharatRamsf3693

@BharatRamsf3693 BharatRamsf3693 commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Improve QuickGrid diagnostics for mismatched GridSort types

Description

This change improves the developer experience when a QuickGrid column is configured with a type that does not match the parent QuickGrid<TGridItem> item type.

Previously, a column could fail during initialization with an unclear exception when it could not be associated with its parent grid due to a generic type mismatch. This made the root cause difficult to identify and troubleshoot.

This update introduces explicit validation during column initialization to verify that the column's TGridItem type matches the parent grid's item type. When a mismatch is detected, a clear and actionable exception is thrown with guidance for resolving the issue.

Before

image

After

image

Changes included

  • Added validation in ColumnBase<TGridItem> during component initialization.
  • Detects scenarios where a column's item type does not match the parent QuickGrid item type.
  • Throws a clear InvalidOperationException when a mismatched column attempts to attach to a grid.
  • Improves diagnostics by including:
    • The column title when available, or (unnamed) when not specified.
    • The column's TGridItem type.
    • A clear indication that the parent QuickGrid item type does not match.

Example exception

The '<column-title>' Column type mismatch:
Column expects '<column-item-type>'
but does not match the parent QuickGrid's item type.

Fixes #56437

@BharatRamsf3693
BharatRamsf3693 requested a review from a team as a code owner June 25, 2026 11:38
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jun 25, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @BharatRamsf3693. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

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 improves QuickGrid’s diagnostics when a column ends up being constructed with a different TGridItem than its parent QuickGrid<TGridItem> (commonly via a mismatched GridSort<TSortItem>), by cascading the grid’s item Type to columns and validating during column registration. It also adds an E2E page and tests covering several mismatch scenarios.

Changes:

  • Cascade the grid item type (typeof(TGridItem)) from QuickGrid to descendant columns.
  • Validate column TGridItem vs. grid item type and throw a clearer InvalidOperationException on mismatch.
  • Add a dedicated test page and E2E tests to assert the improved error output in interactive server mode.

Reviewed changes

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

Show a summary per file
File Description
src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/QuickGrid/QuickGridTypeMismatch.razor Adds a test page exercising multiple QuickGrid/column type mismatch scenarios via error boundaries.
src/Components/test/E2ETest/Tests/QuickGridInteractiveTest.cs Adds E2E assertions verifying the improved mismatch diagnostics are surfaced to developers.
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor Cascades the grid item Type to descendants using a named CascadingValue.
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/Columns/ColumnBase.razor.cs Adds a named cascading parameter to receive the grid’s item Type.
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/Columns/ColumnBase.razor Implements the type mismatch validation and throws a clearer exception.

@BharatRamsf3693

Copy link
Copy Markdown
Contributor Author

All review comments have been addressed, and the implementation has been further optimized.

@ilonatommy

Copy link
Copy Markdown
Member

All review comments have been addressed

There is a "resolve conversation" button you can use under each review comment to mark that.

@ilonatommy ilonatommy added the area-blazor Includes: Blazor, Razor Components label Jun 26, 2026

@ilonatommy ilonatommy 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.

Public API changes from community PRs are not planned anymore for this release. We can take only internal fixes, otherwise it will wait for .net12.

@BharatRamsf3693

Copy link
Copy Markdown
Contributor Author

Public API changes from community PRs are not planned anymore for this release. We can take only internal fixes, otherwise it will wait for .net12.

Thanks for the clarification. The public API changes have been removed.

@ilonatommy ilonatommy 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.

Thank you! The remaining work is a small cleanup, then we can merge.

@ilonatommy ilonatommy 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.

@BharatRamsf3693 thank you for your work!

@ilonatommy
ilonatommy merged commit 18ef192 into dotnet:main Jul 1, 2026
25 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 2, 2026
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 community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve diagnostics on incorrect GridSort specification in QuickGrid

3 participants