Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
In a QuickGrid on an interactive server mode page, when you specify a SortBy property in a TemplateColumn, but mess up the type of the GridSort argument (for instance, after you changed the type of the items), all you get as a developer is a hard to decipher and debug NullReferenceException. When turning off prerendering, the stack trace is minimal:
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.AspNetCore.Components.QuickGrid.ColumnBase`1.BuildRenderTree(RenderTreeBuilder __builder)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost: Error: Unhandled exception in circuit 'XXXX'.
Which only reveals that the exception happens while rendering some quickgrid somewhere. By the way, it seems the only way to let Visual Studio break on such an exception, with all "Break When Thrown" options turned on, is to enable the debugging option "Prevent using precompiled images on module load (Managed only, resets on restart)". Not that debugging reveals anything here.
Describe the solution you'd like
Ideally of course a compile-time error about the mismatch between the type behind the value of QuickGrid Items and the TGridItem type parameter of GridSort, but I bet if that was easy, we wouldn't even have to specify a GridSort type argument at all. Anything more at runtime, like mentioning the actual TGridItem type, or just the fact that it happens in a GridSort instance, or that it's not related to the actual data rendered, would help.
Additional context
This github project has the standard blazor web app with one additional commit that replaces the weather table by a (misconfigured) QuickGrid. Tested in 8.0.400 and 9.0.100 previews.
Activity
MackinnonBuck commentedon Jun 25, 2024
We're adding the
buglabel not as an indication that there's a defect in the framework, but just to indicate that we should be throwing an exception other than aNullReferenceException.