Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8768 :: Resolve Addrange issue after sorting. #11423

Merged
merged 7 commits into from
Jun 12, 2024

Conversation

Epica3055
Copy link
Member

@Epica3055 Epica3055 commented May 24, 2024

Fixes #8768

Proposed changes

if tree is already sorted then we don't want to set fixed Index value. due to these reason It is misbehave.

Customer Impact

  • No

Regression?

  • Yes

Risk

  • No

Before

When the user adds a value to the treenode list and sorts it using treeview.sort(), it works fine. Subsequently, when the user adds individual trees through the add event, it functions as expected and sorts the entire tree automatically. However, if the user adds multiple values through AddRange, it does not work as expected.

After

I've fixed the sorting issue we discussed earlier, and now everything is working smoothly. When users add values individually or use treeview.sort(), the sorting works fine. Even when they add multiple values at once using AddRange, the sorting behaves as expected.

Test methodology

  • Testcase added

Test environment(s)

  • tested with .net core 8.0
Microsoft Reviewers: Open in CodeFlow

Copy link

codecov bot commented May 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.39955%. Comparing base (f53f153) to head (56b8866).
Report is 72 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #11423         +/-   ##
===================================================
+ Coverage   74.29395%   74.39955%   +0.10560%     
===================================================
  Files           3026        3032          +6     
  Lines         627152      628196       +1044     
  Branches       46758       46813         +55     
===================================================
+ Hits          465936      467375       +1439     
+ Misses        157863      157468        -395     
  Partials        3353        3353                 
Flag Coverage Δ
Debug 74.39955% <100.00000%> (+0.10560%) ⬆️
integration 17.98384% <0.00000%> (-0.00630%) ⬇️
production 47.23616% <100.00000%> (+0.20588%) ⬆️
test 96.96755% <100.00000%> (-0.02013%) ⬇️
unit 44.21834% <100.00000%> (+0.20676%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@elachlan elachlan added the waiting-review This item is waiting on review by one or more members of team label May 24, 2024
Copy link
Member

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @RutulPatel8 - I apologize that we had accidentally destroyed your branch when reviewing and trying to rebase it on the latest. This PR restores your changes with minor modifications, see the commit history, we applied the fix to the failing test, used fluent assertions in the new test and used [WinFormsTheory] instead of the [WinFormFact] on the test. You can continue working in this branch by pulling it down using GH Client gh pr checkout 11423, GitHub Desktop, or VS-Code. Or you can cherry-pick your commit c6dd018 and create a new PR.

Because this change could be breaking for someone who is not sorting nodes intentionally, it requires an opt-out switch. If you are not planning to pick it up, a team member can add this switch and finish this work. Please let us know if you have the bandwidth to wrap it up in 2 weeks. This will give us time to get this change into the next preview.

@Tanya-Solyanik Tanya-Solyanik added 📭 waiting-author-feedback The team requires more information from the author and removed waiting-review This item is waiting on review by one or more members of team labels May 24, 2024
@dotnet-policy-service dotnet-policy-service bot removed the 📭 waiting-author-feedback The team requires more information from the author label Jun 5, 2024
@@ -24,6 +24,7 @@ internal static partial class LocalAppContextSwitches
internal const string DataGridViewUIAStartRowCountAtZeroSwitchName = "System.Windows.Forms.DataGridViewUIAStartRowCountAtZero";
internal const string NoClientNotificationsSwitchName = "Switch.System.Windows.Forms.AccessibleObject.NoClientNotifications";
internal const string EnableMsoComponentManagerSwitchName = "Switch.System.Windows.Forms.EnableMsoComponentManager";
internal const string TreeNodePrevNodeDoNotUseFixedIndexWithSortedTreeViewSwitchName = "System.Windows.Forms.TreeNodeDoNotUseFixedIndexWithSortedTreeView";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use TreeNodeCollectionAddRangeRespectsSortOrder as a switch name, and make it an opt-out switch, i.e. default value should be true.

@Tanya-Solyanik Tanya-Solyanik added the 📭 waiting-author-feedback The team requires more information from the author label Jun 6, 2024
@dotnet-policy-service dotnet-policy-service bot removed the 📭 waiting-author-feedback The team requires more information from the author label Jun 11, 2024
Copy link
Member

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a minor comment, otherwise looks good

@@ -202,6 +209,16 @@ public static bool EnableMsoComponentManager
get => GetCachedSwitchValue(EnableMsoComponentManagerSwitchName, ref s_enableMsoComponentManager);
}

/// <summary>
/// Indicates whether TreeNode.PrevNode uses a fixed index to return its value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

When set to (default), API will insert nodes in the sorted order. To get behavior compatible with the previous versions of .NET and .NET Frameworek, set this switch to .

@Tanya-Solyanik Tanya-Solyanik added the 📭 waiting-author-feedback The team requires more information from the author label Jun 11, 2024
@Epica3055 Epica3055 added waiting-review This item is waiting on review by one or more members of team and removed 📭 waiting-author-feedback The team requires more information from the author labels Jun 12, 2024
@RutulPatel8
Copy link
Contributor

RutulPatel8 commented Jun 12, 2024

Hi @RutulPatel8 - I apologize that we had accidentally destroyed your branch when reviewing and trying to rebase it on the latest. This PR restores your changes with minor modifications, see the commit history, we applied the fix to the failing test, used fluent assertions in the new test and used [WinFormsTheory] instead of the [WinFormFact] on the test. You can continue working in this branch by pulling it down using GH Client gh pr checkout 11423, GitHub Desktop, or VS-Code. Or you can cherry-pick your commit c6dd018 and create a new PR.

Because this change could be breaking for someone who is not sorting nodes intentionally, it requires an opt-out switch. If you are not planning to pick it up, a team member can add this switch and finish this work. Please let us know if you have the bandwidth to wrap it up in 2 weeks. This will give us time to get this change into the next preview.

Hi @Tanya-Solyanik ,
Are you still working on these issues?
If yes then I can help you.

Let me know so I can generate PR with all existing and remaining changes.

@Tanya-Solyanik
Copy link
Member

@RutulPatel8 - thank you! We are done with the new appcontext switch and tests. This fix will ship in the next preview, assuming everything goes well, please test it on your side. But we have many other issues we are looking for help with.

@Tanya-Solyanik Tanya-Solyanik merged commit 5cefc3d into dotnet:main Jun 12, 2024
8 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 9.0 Preview6 milestone Jun 12, 2024
@dotnet-policy-service dotnet-policy-service bot removed the waiting-review This item is waiting on review by one or more members of team label Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TreeNodeCollection.AddRange works incorrectly for non-empty collection of the sorted TreeView
5 participants