Repository navigation
Handle XmlConvert unspecified DateTimeOffset at local time-zone boundaries - #130815
Merged
Merged
Conversation
|
Azure Pipelines: 15 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: mconnew <[email protected]>
Copilot
AI
changed the title
[WIP] Fix ArgumentOutOfRangeException in XmlConvert.ToDateTimeOffset
Handle XmlConvert unspecified DateTimeOffset at local time-zone boundaries
Jul 15, 2026
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-xml |
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the System.Xml.Schema.XsdDateTime → DateTimeOffset conversion for Unspecified kinds to avoid exceptions at the DateTime min/max boundaries when the local UTC offset would push the UTC instant outside DateTimeOffset’s representable range. It also adds regression coverage that runs under isolated processes with a controlled time zone.
Changes:
- Clamp
DateTime.MinValue/DateTime.MaxValueconversions toDateTimeOffset.MinValue/DateTimeOffset.MaxValueonly for the non-representable local-offset boundary cases. - Add Unix
RemoteExecutortests that varyTZand validate boundary behavior for both positive and negative offsets. - Enable
RemoteExecutorsupport inSystem.Private.Xmltests viaIncludeRemoteExecutor.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/libraries/System.Private.Xml/src/System/Xml/Schema/XsdDateTime.cs | Adds boundary-only clamping logic for Unspecified → DateTimeOffset conversions. |
| src/libraries/System.Private.Xml/tests/XmlConvert/XmlConvertEndOfDayTests.cs | Adds RemoteExecutor-based timezone-isolated regression tests for min/max boundary conversions. |
| src/libraries/System.Private.Xml/tests/System.Private.Xml.Tests.csproj | Enables RemoteExecutor for the test project. |
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
mconnew
approved these changes
Jul 15, 2026
Co-authored-by: tarekgh <[email protected]>
tarekgh
approved these changes
Jul 15, 2026
This branch was previously deployed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #130814
XmlConvert.ToDateTimeOffsetcould throw for unspecified local times at theDateTimeboundaries when applying the local UTC offset would push the value outsideDateTimeOffset's representable UTC range. This updates the XML conversion path to clamp only the boundary cases that cannot be represented, while preserving existing behavior for representable offsets.Conversion fix
System.Xml.Schema.XsdDateTime's implicitDateTimeOffsetconversion forXsdDateTimeKind.Unspecified.DateTimeOffset.MinValueonly whenDateTime.MinValuewith a non-negative local offset would underflow.DateTimeOffset.MaxValueonly whenDateTime.MaxValuewith a non-positive local offset would overflow.Regression coverage
RemoteExecutor-based Unix tests that changeTZand validate both sides of the boundary behavior.0001-01-01T00:00:00in positive-offset and negative-offset local time zones9999-12-31T23:59:59.9999999in positive-offset and negative-offset local time zonesTest infrastructure
RemoteExecutorforSystem.Private.Xmltests so the time-zone-sensitive cases can run in isolated processes.