-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[release/10.0] Add DateOnly and TimeOnly serializer primitives with restrictions #119915
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
Open
github-actions
wants to merge
10
commits into
release/10.0
Choose a base branch
from
backport/pr-119835-to-release/10.0
base: release/10.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5,056
−2,912
Conversation
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
…g xsd:time while ignoring offsets
…eed to make the test conditional so it doesn't fail AggressiveTrimming test runs.
mangod9
approved these changes
Sep 22, 2025
StephenMolloy
approved these changes
Sep 22, 2025
/backport to release/10.0-rc2 |
Started backporting to release/10.0-rc2: https://github.com/dotnet/runtime/actions/runs/17953990302 |
@StephenMolloy backporting to "release/10.0-rc2" failed, the patch most likely resulted in conflicts: $ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Add DateOnly and TimeOnly as primities for XmlSerializer - With Tests
Applying: Add option to tag TimeOnly fields with DataType=time to allow handling xsd:time while ignoring offsets
Applying: Add DateOnly and TimeOnly as primities for DCS - With Tests
Applying: Add tests for schema import/export considerations.
Applying: Copilot PR feedback.
Applying: Address some PR feedback.
Applying: Different approach to managing AppContext switches and caching
.git/rebase-apply/patch:163: trailing whitespace.
warning: 1 line adds whitespace errors.
Using index info to reconstruct a base tree...
M src/libraries/System.Private.Xml/src/System/Xml/Core/LocalAppContextSwitches.cs
M src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/System.Private.Xml/src/System/Xml/Core/LocalAppContextSwitches.cs
Auto-merging src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs
CONFLICT (content): Merge conflict in src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0007 Different approach to managing AppContext switches and caching
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
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.
Backport of #119835 to release/10.0
/cc @StephenMolloy
Customer Impact
This has been a customer ask for a while – This PR introduces first-class (primitive) serializer support for
DateOnly
andTimeOnly
in XmlSerializer and DataContractSerializer, closing a gap as these types see growing real-world adoption—especially via EF scaffolding and modern data models that already emit them. Treating them as primitives with strict, canonical ISO wire forms and restricted XSD simple types prevents silent data loss (e.g., from offset-bearing times) and enables clean schema export/import parity with existing primitives. The approach extends primitive registration tables, adds focused parse/format delegates, and offers an attribute-based escape hatch for legacy xs:time interop while remaining purely additive and backward compatible.Regression
Not a regression.
DateOnly
andTimeOnly
were not .Net data types when our serializers were originally designed.Testing
Many tests are included with the PR.
Risk
Low. The change is additive (introducing new primitive serializers without altering existing DateTime/DateTimeOffset behavior), uses well‑bounded canonical text formats, guards against data loss via restrictive XSD pattern facets, and is backed by comprehensive round‑trip, schema export/import, override, and backward‑compat tests—so remaining exposure is limited mainly to unforeseen edge cases in newly added parsing/formatting paths.
IMPORTANT: If this backport is for a servicing release, please verify that:
release/X.0-staging
, notrelease/X.0
.Package authoring no longer needed in .NET 9
IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.