Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request updates Blazor’s RenderTreeBuilder invalid render-tree exception message to better explain that unclosed frames typically come from control-flow exiting rendering before the corresponding Close* call is reached, and adds/updates tests to validate the new messaging.
Changes:
- Expanded
InvalidOperationExceptiontext inRenderTreeBuilder.AssertTreeIsValidto cover common control-flow causes (e.g.,break,return,throw) and added a docs link. - Updated existing tests to avoid asserting the full legacy message and to validate key new message phrases.
- Added a new test intended to cover a
breakscenario.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Components/Components/src/Rendering/RenderTreeBuilder.cs | Updates the thrown exception message when frames are left unclosed. |
| src/Components/Components/test/Rendering/RenderTreeBuilderTest.cs | Updates/extends unit tests to validate the new exception message text and adds a new break-focused test. |
| src/Components/Components/test/RendererTest.cs | Updates renderer-level test assertions to match the revised message content. |
|
Review result: I do not think the diagnostic and regression test are ready to merge at the current head (
The message should instead describe the actual invariant: every opened element, component, or region must reach its matching The regression is also not causal as written. I validated this against the exact head: the identical direct assertion fails with the current implementation and passes with the corrected diagnostic and regression test. The focused Components tests then pass 125/125. This review was generated with GitHub Copilot under human direction and validated by a human. |
|
@PureWeen, Thanks for the review. I’ve addressed the diagnostic wording and regression test feedback. All 125 focused tests pass. |
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
Improve Render Output Invalid Exception Message to Clarify Common Control Flow Causes
Description
This change improves the Render output is invalid exception message emitted by RenderTreeBuilder when a render frame is left unclosed. The previous message only referenced try/catch blocks, which can make diagnosis difficult when the root cause is another form of control-flow interruption. The updated message clarifies that the exception occurs whenever rendering exits before a matching CloseElement, CloseComponent, or CloseRegion call is reached, including common scenarios such as break, continue, return, throw, goto, or early exits from try/catch blocks. Additionally, a link to the Blazor advanced scenarios documentation is included to help developers more quickly identify and resolve invalid render tree construction issues.
Before
After
Fixes #55374