Skip to content

Add ListBox selection refresh tests - #15392

Merged
Shyam-Gupta merged 2 commits into
mainfrom
dev/shgu/winforms-lst-005-selection-refresh
Nov 11, 2026
Merged

Shyam-Gupta merged 2 commits into
mainfrom
dev/shgu/winforms-lst-005-selection-refresh

Conversation

@Shyam-Gupta

@Shyam-Gupta Shyam-Gupta commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Proposed changes

  • Add ListBox selection/refresh tests across all four selection modes, with and without a live handle.
  • Check selected items and indices after each refresh, sorting, item removal, clearing/repopulation, and rejected selection requests.
  • Extend the CheckedListBox cached-count regression test to both handle states. Assert after the scrollbar-triggered refresh and each explicit refresh, reading the count before other selection views can repair the cache.

Customer Impact

  • Protects selection state and selected-item/index consistency from regressions. No runtime behavior changes.

Regression?

  • No; test-only coverage.

Risk

  • Low. No product code or public API changes.

Validation

From the repository root in a normal, non-elevated Windows session:

  • .\build.cmd -verbosity minimal — passed, 0 warnings and 0 errors.
  • With DOTNET_ROOT set to the repo-local .dotnet directory, the command below passed five consecutive times: 30 passed, 0 failed, 0 skipped on each run.
& .\artifacts\bin\System.Windows.Forms.Tests\Debug\net12.0-windows7.0\System.Windows.Forms.Tests.exe --filter-method 'System.Windows.Forms.Tests.ListBoxTests.ListBox_RefreshItems_*' --filter-method 'System.Windows.Forms.Tests.CheckedListBoxTests.CheckedListBox_HorizontalScrollbar_SetWithCachedSelectedItemsCount_PreservesSelection' --report-trx
Microsoft Reviewers: Open in CodeFlow

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 8981916f-b78c-470d-9503-d75b61e46645

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the test-only selection-refresh regression coverage.

No open issues 🎉

What changed in this PR

Adds regression coverage for WinForms selection state during item refreshes. The changes are test-only, with no production code or public API changes.

Changes:

  • Cover all four ListBox selection modes, with and without a native handle.
  • Verify selection consistency after item mutations, sorting, clearing/repopulation, repeated refreshes, and rejected selection requests.
  • Extend the CheckedListBox cached selection-count regression test to both handle states and repeated refreshes.
File Description
src/​test/​unit/​System.Windows.Forms/​System/​Windows/​Forms/​ListBoxTests.cs Adds three selection-refresh theories and a shared selection-consistency assertion helper.
src/​test/​unit/​System.Windows.Forms/​CheckedListBoxTests.cs Expands cached selection-count coverage with handle-state cases, repeated refreshes, and a selected-index assertion.

Review effort: Balanced

@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.79260%. Comparing base (8a95231) to head (70d2117).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@              Coverage Diff              @@
##                main      #15392   +/-   ##
=============================================
  Coverage   39.79260%   39.79260%           
=============================================
  Files            246         246           
  Lines           9836        9836           
  Branches        1036        1036           
=============================================
  Hits            3914        3914           
  Misses          5741        5741           
  Partials         181         181           
Flag Coverage Δ
Debug 39.79260% <ø> (ø)
production 42.31695% <ø> (ø)
test 19.92786% <ø> (ø)
unit 42.31695% <ø> (ø)

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Check every refresh before rebuilding again, exercise rejected selections after refresh, and explain the cache-sensitive test setup.

Co-authored-by: Copilot App <[email protected]>
@dotnet-policy-service dotnet-policy-service Bot added the draft draft PR label Nov 11, 2026
@Shyam-Gupta
Shyam-Gupta marked this pull request as ready for review November 11, 2026 18:43
@Shyam-Gupta
Shyam-Gupta requested a review from a team as a code owner November 11, 2026 18:43
@Shyam-Gupta Shyam-Gupta added area-test coverage and removed draft draft PR labels Nov 11, 2026
@Shyam-Gupta
Shyam-Gupta merged commit 43590dd into main Nov 11, 2026
8 checks passed
@Shyam-Gupta
Shyam-Gupta deleted the dev/shgu/winforms-lst-005-selection-refresh branch November 11, 2026 20:00
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants