Skip to content

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 19, 2025

Backport of #119835 to release/10.0

/cc @StephenMolloy

Customer Impact

  • Customer reported
  • Found internally

This has been a customer ask for a while – This PR introduces first-class (primitive) serializer support for DateOnly and TimeOnly 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

  • Yes
  • No

Not a regression. DateOnly and TimeOnly 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:

  • The PR target branch is release/X.0-staging, not release/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.

@StephenMolloy StephenMolloy added the Servicing-consider Issue for next servicing release review label Sep 19, 2025
@StephenMolloy StephenMolloy self-requested a review September 19, 2025 22:22
@StephenMolloy StephenMolloy self-assigned this Sep 19, 2025
@StephenMolloy StephenMolloy added this to the 10.0.0 milestone Sep 19, 2025
…eed to make the test conditional so it doesn't fail AggressiveTrimming test runs.
@StephenMolloy StephenMolloy added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Sep 22, 2025
@StephenMolloy
Copy link
Member

/backport to release/10.0-rc2

Copy link
Contributor Author

Started backporting to release/10.0-rc2: https://github.com/dotnet/runtime/actions/runs/17953990302

Copy link
Contributor Author

@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
Labels
area-Serialization Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants