Skip to content

Clamp ProgressBar increments before narrowing to Int32 - #15535

Open
XFEstudio wants to merge 1 commit into
dotnet:mainfrom
XFEstudio:fix/winforms-progressbar-increment-overflow-nov30
Open

XFEstudio wants to merge 1 commit into
dotnet:mainfrom
XFEstudio:fix/winforms-progressbar-increment-overflow-nov30

Conversation

@XFEstudio

@XFEstudio XFEstudio commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

Add the increment to the current value in a 64-bit integer, clamp it to the configured range, and store the result in ProgressBar.Value. Both Increment and PerformStep use this code path.

Customer Impact

At a value of 1, adding int.MaxValue currently sends a progress bar with range 0–100 back to 0. It should finish at 100. The new cases exercise both APIs, with and without an existing control handle.

Regression?

The issue reproduces on .NET 10 and the current main baseline. Its introduction point is unknown.

Risk

The change affects additions that would overflow a 32-bit integer. Marquee handling and the native position update keep their existing paths.

Test methodology

All eight overflow cases failed on the baseline and the other 64 selected cases passed. On the candidate, all 78 related tests passed with zero skipped. Both builds completed with zero warnings or errors. Windows validation.

Test environment(s)

Windows x64, Debug, 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 30, 2026 01:14
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