-
Notifications
You must be signed in to change notification settings - Fork 57
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
Possible loss of DateTime's Kind with DotNetclient #367
Comments
Hi there @zelenij Hope this helps! |
I saw the advise regarding |
@zelenij Alright, let's find out why this happens. Since you are using the dotnet client, it means that both client and server use Fable.Remoting.Json to handle all JSON-related things. In my unit test for a universal testCase "Union with DateTime conversion" <| fun () ->
let dateInput = DateTime.Now.ToUniversalTime()
let serialized = serialize (UnionWithDateTime.Date dateInput)
let deserialized = deserialize<UnionWithDateTime> serialized
match deserialized with
| Int _ -> fail()
| Date dateOutput ->
Expect.equal dateInput.Second dateOutput.Second "Seconds are the same"
Expect.equal dateInput.Minute dateOutput.Minute "Minutes are the same"
Expect.equal dateInput.Hour dateOutput.Hour "Hours are the same"
Expect.equal dateInput.Day dateOutput.Day "Days are the same"
Expect.equal dateInput.Month dateOutput.Month "Months are the same"
Expect.equal dateInput.Year dateOutput.Year "Year are the same"
Expect.equal dateInput.Kind dateOutput.Kind "Kinds are the same" Which shows that the In the dotnet client, we do use specific settings where we set /// Parses a JSON iput string to a .NET type using Fable JSON converter
let parseAs<'t> (json: string) =
let options = JsonSerializerSettings()
options.Converters.Add converter
options.DateParseHandling <- DateParseHandling.None
JsonConvert.DeserializeObject<'t>(json, options) Any chance you could provide an example of a |
Thanks, I'll do more debugging on my side to see if I can clearly rule out any other option and/or create a small standalone test to reproduce the problem |
So far I can see that by server side code prepares a
If I read the deserialiser code correctly, it then calls Maybe the Json serialisation is at fault here? |
I'm trying to upgrade my code to everything latest, .net8 and all fable related stuff, including Fable.Remoting. In one of my tests I'm checking if a certain server call returns a UTC Kind in a DateTime. It fails, because Kind is Local. This used to work with an older version of the library. I've checked the server side code and I can see that Kind is indeed UTC. Could it be that the value is lost in serialisation/deserialisation?
The text was updated successfully, but these errors were encountered: