Add optional parent-child linking when importing NodeSet2.xml #3396
+226
−1
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.
Proposed changes
When importing nodes from NodeSet2.xml using
UANodeSet.Import(), parent-child relationships were not established. This causedGetChildren()to return empty and prevented proper hierarchy navigation.Root cause: The import process stored ParentNodeId in the Handle property but never established the bidirectional parent-child relationship in memory.
Solution: Added post-processing step that:
linkParentChildparameter (defaults tofalsefor backward compatibility)Example usage:
Changes:
UANodeSetHelpers.cs: Added LinkParentChildRelationships() method, integrated into Import() with optionallinkParentChildparameter (defaults to false)UANodeSetHelpersTests.cs: Added ParentChildReferencesTest() verifying hierarchy navigation when enabled, and ParentChildReferencesDefaultBehaviorTest() verifying backward compatibilityRelated Issues
Types of changes
Checklist
Further comments
The feature is opt-in to maintain backward compatibility. Default behavior is unchanged - parent-child relationships are NOT established unless explicitly requested via the
linkParentChildparameter. This ensures existing code continues to work without modifications. All 7 UANodeSetHelpersTests pass, including new tests verifying both the feature functionality and backward compatibility.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.