Skip to content

Incorrect serialization using fsi and Newtonsoft on dotnet 6.0.3xx #13493

@JonCanning

Description

@JonCanning

Install dotnet 6.0.301 on Linux. I have tried Ubuntu and Debian on WSL.

sudo apt install dotnet-sdk-6.0

Run this script using dotnet fsi

#r "nuget:Newtonsoft.Json"

open Newtonsoft.Json

JsonConvert.SerializeObject {| x = 1 |}
|> printfn "%s"

or

type R = { x: int }
JsonConvert.SerializeObject { x = 1 } |> printfn "%s"

In either case output is

{"x@":1,"x":1}

Install 6.0.203

sudo apt install dotnet-sdk-6.0=6.0.203-1

output is

{"x":1}

Serialization is correct on Windows, and when using a regular class, only records in scripts are affected

Workaround

Use dotnet fsi --multiemit-

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions