[Breaking change]: System.Formats.Cbor DateTime formatting change #37378
Labels
breaking-change
Indicates a .NET Core breaking change
🏁 Release: .NET 8
Work items for the .NET 8 release
doc-idea
Indicates issues that are suggestions for new topics [org][type][category]
Pri1
High priority, do before Pri2 and Pri3
📌 seQUESTered
Identifies that an issue has been imported into Quest.
Description
Since it was released in .NET 5, the
System.Formats.Cbor
NuGet package included built-in methods for serializing and deserializingDateTimeOffset
values according to RFC 7049. Unfortunately, the implementations weren't using invariant culture when formatting/parsingDateTimeOffset
values. This can result in inconsistent or even incorrect date encodings in machines with cultures using non-Gregorian calendars.The PR in dotnet/runtime#92924 changes the DateTimeOffset behavior so that invariant culture is always being used. This can cause breaking changes for users relying on the previous behavior, including making it impossible to read date values that have been encoded with earlier versions of the System.Formats.Cbor NuGet package.
Version
.NET 8 GA
Previous behavior
The code
produces the CBOR encoding
which corresponds to
0(תש\"פ-ז'-ט\"וT14:31:21.3535941+01:00)
in CBOR diagnostic notation. This is an invalid date representation per RFC 7049.New behavior
The same code will produce the CBOR encoding
which corresponds to
0("2020-04-09T14:31:21.3535941+01:00")
in CBOR diagnostic notation.Type of breaking change
Reason for change
The previous behavior produced invalid date encodings per RFC 7049.
Recommended action
You might have to be able to read CBOR date encodings that were persisted using earlier versions of System.Formats.Cbor. This can be achieved either by
Which can be used to roundtrip the previous example as follows:
Feature area
Other (please put exact area in description textbox)
Affected APIs
Associated WorkItem - 167413
The text was updated successfully, but these errors were encountered: