Use AddRange switch to preserve equal-node order#29
Open
Rick-Xu-WTG wants to merge 1 commit into
Open
Conversation
Set TreeNodeCollectionAddRangeRespectsSortOrder to false in the demo startup and make the existing AddRange switch affect the fixed-index path while AddRange is in progress. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
b039efa to
3e57e9e
Compare
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.
What
Use the existing WinForms AppContext switch to restore the legacy AddRange order for the demo scenario:
The demo now sets the switch at startup before the first sorted
AddRangecall.Why
The reversal happens only when the Pallet nodes compare equal.
AddRangeiterates nodes backwards, andAddSortedinserts a new equal item after existing equal items. With equal comparisons, that turns the input order into a full reverse.The switch from dotnet#11423 already controls whether AddRange sets
FixedIndex, butSorted=truestill enteredAddSortedbefore the fixed-index path could matter. This PR keeps the source change minimal: while AddRange is usingFixedIndex, skip the sorted insertion/sort path so the switch can actually restore the legacy order.Verification
Builds: