Skip to content

Avoid overflow when clamping SplitContainer.SplitterDistance - #15519

Open
XFEstudio wants to merge 1 commit into
dotnet:mainfrom
XFEstudio:fix/winforms-splitter-distance-overflow-nov27
Open

XFEstudio wants to merge 1 commit into
dotnet:mainfrom
XFEstudio:fix/winforms-splitter-distance-overflow-nov27

Conversation

@XFEstudio

@XFEstudio XFEstudio commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

Widen the comparison that clamps SplitterDistance to the available space.

Customer Impact

Assigning int.MaxValue can overflow the calculation that adds splitter thickness. The out-of-range distance then gets stored and gives Panel2 a negative dimension. The guard now clamps to the existing maximum.

Regression?

Introduction point unknown. Reproduced on .NET 10 and the upstream baseline.

Risk

Only the comparison arithmetic changes. The test covers horizontal and vertical orientation and checks the resulting bounds.

Test methodology

2 regression cases failed on the baseline. 2 related tests passed with 0 skipped after the fix. The test project built with 0 warnings and 0 errors. Windows validation.

Test environment(s)

Windows x64 Debug with the repository .NET 12 SDK.

Developed with AI assistance and independently reviewed by an AI agent.

Microsoft Reviewers: Open in CodeFlow

@XFEstudio
XFEstudio requested a review from a team as a code owner November 27, 2026 06:08
@codecov

codecov Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 41.23472%. Comparing base (d7f39b1) to head (a122cb9).

Additional details and impacted files
@@              Coverage Diff              @@
##                main      #15519   +/-   ##
=============================================
  Coverage   41.23472%   41.23472%           
=============================================
  Files            247         247           
  Lines           9897        9897           
  Branches        1049        1049           
=============================================
  Hits            4081        4081           
  Misses          5621        5621           
  Partials         195         195           
Flag Coverage Δ
Debug 41.23472% <ø> (ø)
production 43.92353% <ø> (ø)
test 19.92786% <ø> (ø)
unit 43.92353% <ø> (ø)

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.

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.

1 participant