mamift / LinqToXsdCore

LinqToXsd ported to .NET Core (targets .NET Standard 2 for generated code and .NET Core 3.1, .NET 5+ for the code generator CLI tool).
Microsoft Public License
44 stars 15 forks source link

DateTimeOffset support #59

Closed jods4 closed 10 months ago

jods4 commented 10 months ago

xs:dateTime can optionally include an offset.

As linqtoxsd generates DateTime properties for those, some information is lost during parsing and it's impossible to write xml containing timezone information.

I added one new option, very similar to previously added DateOnly support: <UseDateTimeOffset>. When it's true, linqtoxsd generates DateTimeOffset properties instead of DateTime. (This is a global settings, there's no pick-and-choose options now.)

It's a rather small change because System.Xml classes already support converting xs:dateTime into DateTimeOffset, so it mostly "just works".

I added a round-trip test to verify the behavior.

I have issues with some tests failing locally, but I honestly don't think it's related. Do you have known tests failures on master right now?

mamift commented 10 months ago

Thank you - I will find the time to review this. By the looks of it, the failing tests seem to be unrelated, but will confirm later.