dotnet / dotnet/aspnetcore

[Validation] QuickGrid column item type mismatch

Closed
#69,133 2 comments 0 reactions 1 assignee Claimed by @surya3655 View on GitHub
area-blazor Validation validation-scenario
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

**Scenario contact:** @dariatiurina

## Scenario

A `QuickGrid` column is generically typed, so a column declared for one item type inside a grid of another used to fail somewhere deep in the rendering with a message that did not say what was wrong. .NET 11 detects the mismatch and reports it naming the column and the type it expected.

Validate that the mismatch is caught, that the message is enough to find the offending column, and that it says something useful when the column has no `Title` to name it by.

## Minimum build

.NET 11 RC1.

## Configurations to cover

* Blazor Web App
* [x] Static SSR
* [x] Interactive Server
* [ ] Interactive WebAssembly
* [ ] Interactive Auto
* [ ] Standalone WebAssembly
* [ ] Hybrid (MAUI)

## Also exercise

* [ ] Published output
* [ ] An existing .NET 10 app upgraded to .NET 11
* [ ] Trimming or ahead-of-time compilation
* [ ] More than one server instance, or a proxy in front
* [ ] Hot Reload
* [ ] An IDE as well as the command line
* [ ] Container
* [x] N/A

## What to build

Two record types with different shapes, and a correctly typed `QuickGrid` over a list of the first. Start with a working column, then add one whose own generic item type is the second record type. Keep the parent grid and its `Items` argument compatible so the intended mismatch reaches column initialization.

Use reusable column components to represent a plausible integration mistake. If a wrapper variant fails compilation before a column renders, record that separately: it has not exercised the runtime diagnostic.

Make separate variants for a titled mismatch, an untitled mismatch, and a mismatch inside a `TemplateColumn`. Use separate pages or repair one variant before introducing the next, so the first exception does not prevent observing the others.

## Things to try

* Build the app and see whether anything is reported at compile time.
* Run it and open the page in Development, then in Production.
* Look at the `dotnet run` console output.
* Compare the message for the column with a `Title` against the one with no `Title`.
* Try the mismatch inside a `TemplateColumn`.
* Give a mismatched column a `GridSort` and see whether the message changes.
* Fix the mismatch and confirm the page renders normally afterwards.

## Expected behavior

The mismatch is reported with a message that identifies the column and the expected item type, rather than a null reference or an unrelated cascading-value error.

### Must hold

* A column whose item type does not match its grid throws `InvalidOperationException`.
* The message contains the column's `Title` and the full name of the item type the column expected.
* When the column has no `Title`, the message identifies it as `(unnamed)` rather than leaving the name blank.
* The diagnostic reaches the server log without a debugger. Development may show details in the browser, while Production keeps the browser response generic.
* Correcting the item type makes the page render with no further change.

### Expected differences between configurations

* A Development failure during initial server rendering can show the developer exception page. A failure on an already-interactive circuit uses the circuit's error handling instead. Production must not be required to expose exception details to visitors; confirm the diagnostic in the server log.

## Evidence to capture

* The verbatim message for each variant: with a `Title`, with no `Title`, and inside a `TemplateColumn`.
* Where each message appeared, in the console or browser, and whether the build reported anything before runtime initialization.

## Documentation to use

* [ASP.NET Core Blazor QuickGrid component](https://learn.microsoft.com/aspnet/core/blazor/components/quickgrid?view=aspnetcore-11.0)

No documentation is expected to cover this: it is a diagnostic, and the message is meant to stand on its own. Judge it on that basis and say whether you could have fixed the page from the message alone.

## What to report

Report results using the format described in the [validation testing manual](https://github.com/dotnet/aspnetcore/issues/68479). Include link to a repository with the test app.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.