Skip to content
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

Support JSON parsing object to DateTimeOffset and preserve timezone offset in JsonObjectConverter #16732

Merged
merged 1 commit into from
Jul 4, 2024

Conversation

ronaldbarendse
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

If there's an existing issue for this PR then this fixes #16587.

Description

Although I initially thought the CMS data type configuration migration (executed when upgrading v13 to v14) caused Deploy to write updated UDA files, it is actually due to the JsonObjectConverter (that's used by the IConfigurationEditorJsonSerializer for reading and writing data type configuration) not correctly parsing DataTimeOffset values.

This custom JsonConverter takes care of deserializing JSON values into object instances to their simple/primitive types (boolean, integer, date or string), instead of a boxed JsonElement (see https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/migrate-from-newtonsoft?pivots=dotnet-9-0#deserialization-of-object-properties). I assume this has been copied from the example in the Microsoft documentation, which clearly isn't really suitable to be used in production 🫤 Removing this converter would be a massive breaking change, as values will be parsed differently when deserializing, but I would suggest looking into thing for a future major release, as this also contains multiple performance issues (loading everything into lists, casting, creating generic types and new instances via reflection, etc.)...

@bergmania
Copy link
Member

Thanks for the PR.. Sadly this is super required by the block editors currently.

@bergmania bergmania merged commit 4643b7d into v14/dev Jul 4, 2024
17 checks passed
@bergmania bergmania deleted the v14/bugfix/jsonobjectconverter-datetimeoffset branch July 4, 2024 05:36
bergmania pushed a commit that referenced this pull request Jul 4, 2024
@bergmania
Copy link
Member

Cherry picked to 14.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants