-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Windows] Fixed the ArgumentOutOfRangeException when setting the null to MinimumDate property in DatePicker #30973
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
Conversation
|
Hey there @@NanthiniMahalingam! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an ArgumentOutOfRangeException that occurs when setting the MinimumDate property of DatePicker to null on Windows. The issue arises because the platform attempts to set DateTime.MinValue, which causes UTC conversion issues outside the valid range. The fix aligns with native WinUI behavior by setting the minimum date to 100 years prior to the current date when null is specified.
Key changes:
- Updated DatePicker minimum date handling logic to avoid DateTime.MinValue
- Added conditional logic to set a safe default minimum date (100 years back)
- Added a device test to verify the fix prevents the exception
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Core/src/Platform/Windows/DatePickerExtensions.cs | Updated UpdateMinimumDate method to handle null MinimumDate by setting it to 100 years back instead of DateTime.MinValue |
| src/Controls/tests/DeviceTests/Elements/DatePicker/DatePickerTests.Windows.cs | Added test case to verify setting MinimumDate to null doesn't throw ArgumentOutOfRangeException |
Comments suppressed due to low confidence (1)
src/Controls/tests/DeviceTests/Elements/DatePicker/DatePickerTests.Windows.cs:60
- The test only verifies that no exception is thrown but doesn't validate that the MinDate is actually set to the expected value (100 years back). Consider adding an assertion to verify the platform control's MinDate property is set correctly.
// If we reach here without exception, the test passes
|
/rebase |
af8f003 to
daf6e93
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issue Details
Root Cause
Description of Changes
Reference:
https://github.com/microsoft/microsoft-ui-xaml/blob/2aa50f0dff795cbd948588ee0e62cac7da3a396f/src/dxaml/xcp/components/DependencyObject/DependencyProperty.cpp#L253
Issues Fixed
Fixes #30922
Output
After_30922.mp4