[Breaking change]: JsonSerializer throws FormatException when deserializing Version types with leading or trailing whitespace #26292
Labels
binary incompatible
Existing binaries may encounter a breaking change in behavior.
breaking-change
Indicates a .NET Core breaking change
🏁 Release: .NET 7
Work items for the .NET 7 release
doc-idea
Indicates issues that are suggestions for new topics [org][type][category]
Pri1
High priority, do before Pri2 and Pri3
source incompatible
Source code may encounter a breaking change in behavior when targeting the new version.
Description
JsonSerializer goes from permitting leading and trailing whitespace when deserializing Version types to throwing
FormatException
. Breaking change introduced in .NET 7 Preview 1.Version
Other (please put exact version in description textbox)
Previous behavior
Provided in description.
New behavior
Provided in description.
Type of breaking change
Reason for change
We optimized the implementation of the underlying
Version
converter. This resulted in the implementation being made to align with the behavior for other primitive types supported bySystem.Text.Json
e.g.DateTime
andGuid
which also disallow leading and trailing spaces.Recommended action
To get the old behavior back, add a custom converter for the type which permits whitespace:
Feature area
Core .NET libraries
Affected APIs
All
System.Text.Json.JsonSerializer.Deserialize
method overloads.The text was updated successfully, but these errors were encountered: