From 95b13a4d79d69dc9e51e73dc33939ccea7683705 Mon Sep 17 00:00:00 2001 From: Zaid Ajaj Date: Sun, 3 Dec 2023 22:23:23 +0100 Subject: [PATCH] Fable.Remoting.DotnetClient v3.32 :rocket: fixes #354 --- .../Fable.Remoting.DotnetClient.fsproj | 4 ++-- Fable.Remoting.DotnetClient/Proxy.fs | 5 ++++- .../DotnetClient/DotnetClient.fsproj | 2 +- .../DotnetClient/Program.fs | 10 ++++++++++ .../DotnetClient/paket.references | 7 +------ Fable.Remoting.IntegrationTests/Shared/ServerImpl.fs | 9 +++++++++ Fable.Remoting.IntegrationTests/Shared/SharedTypes.fs | 9 ++++++++- 7 files changed, 35 insertions(+), 11 deletions(-) diff --git a/Fable.Remoting.DotnetClient/Fable.Remoting.DotnetClient.fsproj b/Fable.Remoting.DotnetClient/Fable.Remoting.DotnetClient.fsproj index 933025aa..2f1e545c 100644 --- a/Fable.Remoting.DotnetClient/Fable.Remoting.DotnetClient.fsproj +++ b/Fable.Remoting.DotnetClient/Fable.Remoting.DotnetClient.fsproj @@ -7,10 +7,10 @@ fsharp;fable;remoting;rpc;webserver;json Zaid Ajaj - 3.31.0 + 3.32.0 net462;netstandard2.0;net6.0 true - Update MsgPack to work on dotnet 8 + Fix strings being inferred as dates when parsing the JSON diff --git a/Fable.Remoting.DotnetClient/Proxy.fs b/Fable.Remoting.DotnetClient/Proxy.fs index cfada014..7b9f3eb8 100644 --- a/Fable.Remoting.DotnetClient/Proxy.fs +++ b/Fable.Remoting.DotnetClient/Proxy.fs @@ -24,7 +24,10 @@ module Proxy = /// Parses a JSON iput string to a .NET type using Fable JSON converter let parseAs<'t> (json: string) = - JsonConvert.DeserializeObject<'t>(json, converter) + let options = JsonSerializerSettings() + options.Converters.Add converter + options.DateParseHandling <- DateParseHandling.None + JsonConvert.DeserializeObject<'t>(json, options) /// Parses a byte array to a .NET type using Message Pack let parseAsBinary<'t> (data: byte[]) = diff --git a/Fable.Remoting.IntegrationTests/DotnetClient/DotnetClient.fsproj b/Fable.Remoting.IntegrationTests/DotnetClient/DotnetClient.fsproj index 56e29b3a..2dd5dc90 100644 --- a/Fable.Remoting.IntegrationTests/DotnetClient/DotnetClient.fsproj +++ b/Fable.Remoting.IntegrationTests/DotnetClient/DotnetClient.fsproj @@ -13,7 +13,7 @@ - + diff --git a/Fable.Remoting.IntegrationTests/DotnetClient/Program.fs b/Fable.Remoting.IntegrationTests/DotnetClient/Program.fs index a73c6c50..8c9bbb50 100644 --- a/Fable.Remoting.IntegrationTests/DotnetClient/Program.fs +++ b/Fable.Remoting.IntegrationTests/DotnetClient/Program.fs @@ -546,6 +546,16 @@ let dotnetClientTests = let! output = server.echoMapTask expected |> Async.AwaitTask Expect.equal output expected "Echoed map is correct" } + + testCaseAsync "IServer.getPostTimestamp" <| async { + let! output = server.getPostTimestamp() + Expect.equal output staticTimestampText "Timestamp is correct" + } + + testCaseAsync "IServer.getPostTimestamp_Result" <| async { + let! output = server.getPostTimestamp_Result() + Expect.equal output (Ok staticTimestampText) "Timestamp is correct" + } ] let testConfig = { Expecto.Tests.defaultConfig with diff --git a/Fable.Remoting.IntegrationTests/DotnetClient/paket.references b/Fable.Remoting.IntegrationTests/DotnetClient/paket.references index a796b207..f87d8284 100644 --- a/Fable.Remoting.IntegrationTests/DotnetClient/paket.references +++ b/Fable.Remoting.IntegrationTests/DotnetClient/paket.references @@ -1,6 +1 @@ -FSharp.Core -Expecto -Suave - -group Client -Fable.Core \ No newline at end of file +Expecto \ No newline at end of file diff --git a/Fable.Remoting.IntegrationTests/Shared/ServerImpl.fs b/Fable.Remoting.IntegrationTests/Shared/ServerImpl.fs index 04ae74c7..d4ff224e 100644 --- a/Fable.Remoting.IntegrationTests/Shared/ServerImpl.fs +++ b/Fable.Remoting.IntegrationTests/Shared/ServerImpl.fs @@ -128,6 +128,8 @@ let serverBinary : IBinaryServer = { echoMapTask = fun map -> Task.FromResult map } +let staticTimestampText = "2023-12-03T11:49:41" + // Async.result : 'a -> Async<'a> // a simple implementation, just return whatever value you get (echo the input) let server : IServer = { @@ -230,4 +232,11 @@ let server : IServer = { pureTask = Task.FromResult 42 echoMapTask = fun map -> Task.FromResult map + getPostTimestamp = fun () -> async { + return staticTimestampText + } + + getPostTimestamp_Result = fun () -> async { + return Ok staticTimestampText + } } \ No newline at end of file diff --git a/Fable.Remoting.IntegrationTests/Shared/SharedTypes.fs b/Fable.Remoting.IntegrationTests/Shared/SharedTypes.fs index 95c9b3b1..a6e98bc8 100644 --- a/Fable.Remoting.IntegrationTests/Shared/SharedTypes.fs +++ b/Fable.Remoting.IntegrationTests/Shared/SharedTypes.fs @@ -2,7 +2,9 @@ module SharedTypes open System open System.Threading.Tasks +#if FABLE_COMPILER open Fable.Core +#endif type Record = { Prop1 : string @@ -55,8 +57,9 @@ type SomeEnum = | Val0 = 0 | Val1 = 1 | Val2 = 2 - +#if FABLE_COMPILER [] +#endif type SomeStringEnum = | FirstString | SecondString @@ -294,6 +297,8 @@ type IBinaryServer = { #endif } +type PostTimestamp = string + type IServer = { // primitive types simpleUnit : unit -> Async @@ -397,6 +402,8 @@ type IServer = { command: CommandLabel * RequesterIdentifier * Requests.Command -> Async echoPosition : Position -> Async simulateLongComputation: int -> Async + getPostTimestamp: unit -> Async + getPostTimestamp_Result: unit -> Async> // mixed Task on the server, Async in JS #if TASK_AS_ASYNC || FABLE_COMPILER