Skip to content

Commit

Permalink
Fable.Remoting.DotnetClient v3.32 🚀 fixes #354
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaid-Ajaj committed Dec 3, 2023
1 parent 7852d31 commit 95b13a4
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<PackageIconUrl></PackageIconUrl>
<PackageTags>fsharp;fable;remoting;rpc;webserver;json</PackageTags>
<Authors>Zaid Ajaj</Authors>
<Version>3.31.0</Version>
<Version>3.32.0</Version>
<TargetFrameworks>net462;netstandard2.0;net6.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReleaseNotes>Update MsgPack to work on dotnet 8</PackageReleaseNotes>
<PackageReleaseNotes>Fix strings being inferred as dates when parsing the JSON</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<Compile Include="Http.fs" />
Expand Down
5 changes: 4 additions & 1 deletion Fable.Remoting.DotnetClient/Proxy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<ItemGroup>
<ProjectReference Include="../../Fable.Remoting.DotnetClient/Fable.Remoting.DotnetClient.fsproj" />
<ProjectReference Include="../../Fable.Remoting.Suave/Fable.Remoting.Suave.fsproj" />
<ProjectReference Include="../../Fable.Remoting.Suave/Fable.Remoting.Suave.fsproj" />
</ItemGroup>

<Import Project="..\..\.paket\Paket.Restore.targets" />
Expand Down
10 changes: 10 additions & 0 deletions Fable.Remoting.IntegrationTests/DotnetClient/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
FSharp.Core
Expecto
Suave

group Client
Fable.Core
Expecto
9 changes: 9 additions & 0 deletions Fable.Remoting.IntegrationTests/Shared/ServerImpl.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
}
}
9 changes: 8 additions & 1 deletion Fable.Remoting.IntegrationTests/Shared/SharedTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ module SharedTypes

open System
open System.Threading.Tasks
#if FABLE_COMPILER
open Fable.Core
#endif

type Record = {
Prop1 : string
Expand Down Expand Up @@ -55,8 +57,9 @@ type SomeEnum =
| Val0 = 0
| Val1 = 1
| Val2 = 2

#if FABLE_COMPILER
[<StringEnum>]
#endif
type SomeStringEnum =
| FirstString
| SecondString
Expand Down Expand Up @@ -294,6 +297,8 @@ type IBinaryServer = {
#endif
}

type PostTimestamp = string

type IServer = {
// primitive types
simpleUnit : unit -> Async<int>
Expand Down Expand Up @@ -397,6 +402,8 @@ type IServer = {
command: CommandLabel * RequesterIdentifier * Requests.Command -> Async<OperationErrorMessage>
echoPosition : Position -> Async<Position>
simulateLongComputation: int -> Async<unit>
getPostTimestamp: unit -> Async<PostTimestamp>
getPostTimestamp_Result: unit -> Async<Result<PostTimestamp, string>>

// mixed Task on the server, Async in JS
#if TASK_AS_ASYNC || FABLE_COMPILER
Expand Down

0 comments on commit 95b13a4

Please sign in to comment.