Add Roslyn expression support for ChildSelector.Child#85
Open
Copilot wants to merge 5 commits into
Open
Conversation
Agent-Logs-Url: https://github.com/microsoft/Forge/sessions/5090e205-a541-4795-b05a-efbc60e6307a Co-authored-by: kijujjav <48494090+kijujjav@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add C# Roslyn expression support for ChildSelector.Child values
Add Roslyn expression support for May 15, 2026
ChildSelector.Child
Agent-Logs-Url: https://github.com/microsoft/Forge/sessions/c25a512f-ba32-4a47-8da6-036e171268e3 Co-authored-by: kijujjav <48494090+kijujjav@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/Forge/sessions/6d4d3599-429c-4b68-8a8c-f9283ce09ef4 Co-authored-by: kijujjav <48494090+kijujjav@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR extends Forge TreeWalker’s ChildSelector.Child to support dynamic resolution via the existing Roslyn expression pipeline (e.g., C#|...), enabling schemas to compute the next child node key at runtime.
Changes:
- Updated
TreeWalkerSession.SelectChildto evaluateChildSelector.ChildusingEvaluateDynamicProperty(..., typeof(string)). - Documented dynamic
ChildSelector.Childsupport in the contract (ForgeTree.cs), schema validation rules, andREADME.md. - Added unit tests covering literal child selection, dynamic child selection, and invalid dynamic child type failures.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates example and documentation to mention dynamic ChildSelector.Child support. |
| Forge.TreeWalker/src/TreeWalkerSession.cs | Evaluates ChildSelector.Child via dynamic property evaluation when selecting a child. |
| Forge.TreeWalker/Forge.TreeWalker.csproj | No functional change (formatting/whitespace only). |
| Forge.TreeWalker/contracts/ForgeTree.cs | Updates contract documentation to describe dynamic Child capability. |
| Forge.TreeWalker/contracts/ForgeSchemaValidationRules.json | Adds schema description clarifying that Child may be a dynamic expression. |
| Forge.TreeWalker.UnitTests/test/TreeWalkerUnitTests.cs | Adds tests validating literal/dynamic child selection and invalid-type failure. |
| Forge.TreeWalker.UnitTests/test/ForgeSchemaHelper.cs | Adds helper schemas used by the new unit tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
536
to
540
| // Empty expressions default to true. Otherwise, evaluate the expression. | ||
| if (string.IsNullOrWhiteSpace(cs.ShouldSelect) && !string.IsNullOrWhiteSpace(cs.Child)) | ||
| { | ||
| return cs.Child; | ||
| return (string)await this.EvaluateDynamicProperty(cs.Child, typeof(string)).ConfigureAwait(false); | ||
| } |
| Assert.AreEqual("LiteralLeaf", this.session.GetCurrentTreeNode().GetAwaiter().GetResult(), "Expected the literal child selector to visit LiteralLeaf."); | ||
| } | ||
|
|
||
| [TestMethod] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
.csprojedits.csprojchanges while preserving non-.csprojbuild fixesOriginal prompt
This pull request was created from Copilot chat.