[release/6.0] Fix TimeSpan support in sourcegen #62191
Merged
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 #62130 to release/6.0
/cc @eiriktsarpalis
Customer Impact
This is a customer reported bug (#62082). System.Text.Json added support for
TimeSpan
serialization (see #54186), however this was not extended to source generators. As a result, reflection and sourcegen serializers by default diverge in their handling of TimeSpan instances. While it is fairly straightforward for users to work around the issue, we believe this should be addressed in servicing sooner rather than later when we ship the next major release.Testing
Added integration tests verifying serialization and deserialization support for
TimeSpan
in source generators.Risk
Low to minimal. Product code change simply flags
TimeSpan
as a "known type" thereby defaulting generated code to the built-in converter.