Reject non-finite range values#9
Merged
Merged
Conversation
…ite-range-values # Conflicts: # Lessons.md
There was a problem hiding this comment.
Pull request overview
This PR hardens ModernOverlay’s numeric UI components by preventing NaN/infinite values from entering core range state, avoiding downstream render-geometry corruption (e.g., slider thumb positions and progress fill calculations).
Changes:
- Added finite-value validation for
RangeBase.Minimum,RangeBase.Maximum, andRangeBase.Value. - Added finite-value validation for
NumberBox.Minimum,NumberBox.Maximum, andNumberBox.Value. - Added a regression test for non-finite range assignments and documented the lesson in
Lessons.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/ModernOverlay.Tests/OverlayUiRangeNumericTests.cs | Adds regression coverage asserting ArgumentOutOfRangeException on NaN/∞ inputs for Slider and NumberBox. |
| src/ModernOverlay.UI/Controls.cs | Enforces finite-only assignments into RangeBase range state via a centralized helper. |
| src/ModernOverlay.UI/AdvancedControls.cs | Enforces finite-only assignments into NumberBox range state via a centralized helper. |
| Lessons.md | Records the “reject non-finite numeric inputs before clamping/render math” lesson for future work. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Minimum,Maximum, andValueassignments inRangeBasecontrols.Minimum,Maximum, andValueassignments inNumberBox.NaN/infinity inputs and record the numeric-state lesson inLessons.md.Root cause
Range controls validated
SmallChange,LargeChange, andNumberBox.Step, but the core range state acceptedNaNand infinity. Those values can bypass clamping and later poison render calculations such as slider thumb position and progress fill geometry.Validation
dotnet test tests\ModernOverlay.Tests\ModernOverlay.Tests.csproj --configuration Debug --filter "FullyQualifiedName~RangeControlsRejectNonFiniteNumericValues"dotnet test tests\ModernOverlay.Tests\ModernOverlay.Tests.csproj --configuration Debug --filter "FullyQualifiedName~OverlayUiRangeNumericTests"dotnet test tests\ModernOverlay.Tests\ModernOverlay.Tests.csproj --configuration Release --filter "FullyQualifiedName~RangeControlsRejectNonFiniteNumericValues"dotnet test tests\ModernOverlay.Tests\ModernOverlay.Tests.csproj --configuration Debug --logger trxgit diff --check