Schema.NET icon indicating copy to clipboard operation
Schema.NET copied to clipboard

Fix DateTime deserialisation to respect timezones

Open nickevansuk opened this issue 4 years ago • 6 comments

Without DateParseHandling = DateParseHandling.DateTimeOffset, the timezone gets truncated during deserialisation. Need to port some tests in to go along with this but thought I'd get this in while I was working on it.

Anyone very welcome to add a quick encode/decode test to show this working!

nickevansuk avatar Nov 10 '19 21:11 nickevansuk

Do you have time to carry this forward or do you need help?

RehanSaeed avatar Dec 06 '19 09:12 RehanSaeed

Hey @RehanSaeed sorry for being slow to move this forward. I'm shortly going on leave until the new year so my attention has been focussed elsewhere.

Help very much appreciated :)

nickevansuk avatar Dec 06 '19 09:12 nickevansuk

No problem, I'm in a similar situation. Will see if I can update your PR with these changes if I have time or maybe you will get there first.

RehanSaeed avatar Dec 06 '19 09:12 RehanSaeed

@Turnerj Have you seen this PR. The MaxDepth is a nice security addition and I'm not sure about the date handling.

RehanSaeed avatar Jun 04 '20 08:06 RehanSaeed

MaxDepth is interesting, hadn't thought about that yet. While we still use Newtonsoft.Json, it probably is a good idea to include a MaxDepth value as the default is no max depth. For System.Text.Json, the default is 64 MaxDepth.

Regarding the DateTimeOffset changes, that should be fixed from our changes to the ValuesJsonConverter for reading values as covered by these tests:

https://github.com/RehanSaeed/Schema.NET/blob/d9c7c7b6220655f0bd142f27b714d59a6cb4d432/Tests/Schema.NET.Test/ValuesJsonConverterTest.cs#L194-L216

Turnerj avatar Jun 04 '20 13:06 Turnerj

We also now have a custom SchemaSerializer class that is our middle-man to whatever serializer technology is underneath, it wouldn't be a big change to add MaxDepth to our deserialization options.

Turnerj avatar Jun 04 '20 13:06 Turnerj