🏗️ Forge: VisualTreeHelper Parity Integration#298
Conversation
- Added `VisualTreeHelper.cs` to expose `GetChildrenCount`, `GetChild`, and `GetParent`. - Delegated logic to existing `UIElement` methods `VisualChildrenCount`, `GetVisualChild`, and `Parent`. - Added accompanying unit tests in `VisualTreeHelperTests`. Co-authored-by: tedd <493224+tedd@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
… on Border - Allowed nulls on `Border.Title` and `Border.StatusBar` to eliminate compiler warnings about missing `required` modifier. Co-authored-by: tedd <493224+tedd@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a WPF-like VisualTreeHelper API to Tedd.TUI so controls and consumers can traverse the visual tree via a standard static helper rather than calling UIElement internals directly, supporting XAML/WPF parity goals.
Changes:
- Introduces
VisualTreeHelperwithGetChildrenCount,GetChild, andGetParentdelegating to existingUIElementvisual hierarchy APIs. - Updates
Border.TitleandBorder.StatusBarto nullable to reflect their optional nature. - Adds unit tests for
VisualTreeHelperand includes small test cleanups/formatting tweaks plus a forge log entry.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Tedd.TUI/VisualTreeHelper.cs | New WPF-parity helper for visual tree traversal. |
| src/Tedd.TUI/Border.cs | Makes Title/StatusBar nullable (optional) without changing behavior. |
| src/Tedd.TUI.Tests/VisualTreeHelperTests.cs | Adds coverage for the new helper methods and null-guard behavior. |
| src/Tedd.TUI.Tests/ValidatorLayoutMatrixTests.cs | Formatting-only adjustment in a test lambda. |
| src/Tedd.TUI.Tests/ValidatorGroupBoxTests.cs | Formatting-only adjustment in a test lambda. |
| src/Tedd.TUI.Tests/MarkdownViewTests.cs | Uses Assert.Single for clearer row-count assertions. |
| src/Tedd.TUI.Tests/ItemsControlTests.cs | Minor formatting in collection expressions. |
| .jules/forge.md | Documents the parity integration work item. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| using System; | ||
| using System.Collections.Generic; | ||
| using Tedd.TUI; |
| namespace Tedd.TUI | ||
| { | ||
| public static class VisualTreeHelper | ||
| { | ||
| public static int GetChildrenCount(UIElement reference) | ||
| { | ||
| if (reference == null) throw new ArgumentNullException(nameof(reference)); | ||
| return reference.VisualChildrenCount; | ||
| } | ||
|
|
||
| public static UIElement GetChild(UIElement reference, int childIndex) | ||
| { | ||
| if (reference == null) throw new ArgumentNullException(nameof(reference)); | ||
| return reference.GetVisualChild(childIndex); | ||
| } | ||
|
|
||
| public static UIElement? GetParent(UIElement reference) | ||
| { | ||
| if (reference == null) throw new ArgumentNullException(nameof(reference)); | ||
| return reference.Parent; // TUI maps VisualParent to Parent mostly, or maybe we need a dedicated VisualParent in the future? | ||
| } | ||
| } | ||
| } |
💡 Hypothesis: The TUI framework lacked the standard
VisualTreeHelperutility class, requiring controls and logic to interface directly withUIElement's internal rendering hierarchy methods (VisualChildrenCount,GetVisualChild). This architectural deficit breaks WPF/XAML isomorphism, where visual tree traversal is distinctly decoupled via theVisualTreeHelperstatic API.🎯 Execution: Engineered the
VisualTreeHelperstatic class using .NET 10.0 idioms. Mapped the coreGetChildrenCount,GetChild, andGetParentmethods to the existingUIElementstructural counterparts (VisualChildrenCount,GetVisualChild, andParent).📊 Functional Impact: The framework now supports standard XAML programmatic visual tree navigation, fulfilling a core foundational WPF parity requirement without allocating new traversal logic or modifying the underlying layout engine.
🔬 Verification Protocol:
StackPanel,Button,TextBlock).VisualTreeHelper.GetChildrenCountand verify it matches the expected visual rendering count.VisualTreeHelper.GetChildto ensure accurate retrieval of generated visual elements.VisualTreeHelperTests.PR created automatically by Jules for task 15292146790065390438 started by @tedd