Fix ListViewGroup ownership validation in Add and Insert#14716
Open
abineshPalanisamy wants to merge 4 commits into
Open
Fix ListViewGroup ownership validation in Add and Insert#14716abineshPalanisamy wants to merge 4 commits into
abineshPalanisamy wants to merge 4 commits into
Conversation
Added fix for the Fix_Issue_4001
…e_4001 Addressed the review corrections and add unit test cases for Fix_Issue_4001
Updated the test cases for Fix_Issue_4001
LeafShi1
reviewed
Jul 10, 2026
Updated the review correction for the Fix_Issue_4001
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.
Fixes #4001
Proposed changes
ListViewGroupCollection.Add(ListViewGroup group)to prevent adding aListViewGroupthat already belongs to anotherListView.ListViewGroupCollection.Insert(int index, ListViewGroup group)to prevent inserting aListViewGroupthat already belongs to anotherListView.SR.OnlyOneControlresource string for the exception message.ArgumentExceptionwhen theListViewGroupargument is already associated with a differentListView.ListViewbefore being added to another.Root cause
ListViewGroupis expected to belong to only oneListView.ListViewGroup.ListViewstores the owningListView.ListViewGroupCollection.AddandInsertdid not validate whether the group already belonged to anotherListView.ListViewGroupinstance could be added to multipleListViewGroupCollectioninstances.ListView,group.ListViewwas overwritten with the latestListView.ListViewcontrols contained the same group in theirGroupscollection,group.ListViewpointed only to the lastListView.Customer Impact
ListViewGroupfrom being shared across multipleListViewcontrols.ListViewGroupCollectionandListViewGroup.ListView.ListViewcontrols.Regression?
Risk
ListViewGroupCollection.AddandListViewGroupCollection.Insert.AddRange,IList.Add, andIList.Insertbehavior is covered because these paths delegate toAddorInsert.ListView.Screenshots
Before
ListViewGroupCollection_Before_fix.mp4
After
ListViewGroupCollection_After_fix.mp4
Test methodology
ListViewGroupinstance to two differentListViewcontrols.ListViewGroupCollectioninstances,group.ListViewpointed only to the lastListView,ListViewGroupCollection.AddthrowsArgumentExceptionwhen the group already belongs to anotherListView.ListViewGroupCollection.InsertthrowsArgumentExceptionwhen the group already belongs to anotherListView.IList.AddthrowsArgumentException.IList.InsertthrowsArgumentException.AddRange(ListViewGroup[])throwsArgumentException.ListViewand adding it to another works correctly.ListViewand adding the group to another works correctly.ListViewownership scenarios.Accessibility testing
Test environment(s)
Microsoft Reviewers: Open in CodeFlow