Skip to content

Commit

Permalink
Core: use FSharp.SystemTextJson library
Browse files Browse the repository at this point in the history
Use FSharp.SystemTextJson library so that all F# types,
including discriminated unions, can be serialized using
System.Text.Json.

Without it, tests would fail with error:
```
System.NotSupportedException : F# discriminated union serialization is not supported. Consider authoring a custom converter for the type.
The unsupported member type is located on type 'FsharpExchangeDotNetStandard.Currency'. Path: $.Market.BuyCurrency.
```

And after adding converters for `Currency` and `Side` types,
tests would fail at [1], indicating that something is wrong
with serizlization.

[1] https://github.com/nblockchain/FX/blob/33ce6fa6d133bf3a685053798cad6a41712514e7/src/FX.Tests/RedisIntegrationTests.cs#L62
  • Loading branch information
webwarrior-ws committed Feb 13, 2024
1 parent 343abd5 commit a0e0bbf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="FSharp.SystemTextJson" Version="1.2.42" />
<PackageVersion Include="StackExchange.Redis" Version="2.0.513" />
<PackageVersion Include="NUnit" Version="3.9.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="3.9.0" />
Expand Down
1 change: 1 addition & 0 deletions src/FX.Core/FX.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Compile Include="Exchange.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FSharp.SystemTextJson" />
<PackageReference Include="StackExchange.Redis" />
<PackageReference Include="System.Text.Json" />
</ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/FX.Core/RedisStorageLayer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ open System
open FsharpExchangeDotNetStandard

open System.Text.Json
open System.Text.Json.Serialization
open StackExchange.Redis

[<AutoOpen>]
module Serialization =
let serializationOptions = JsonSerializerOptions.Default
let serializationOptions = JsonFSharpOptions.Default().ToJsonSerializerOptions()

type OrderQuery =
{
Expand Down

0 comments on commit a0e0bbf

Please sign in to comment.