Skip to content
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

How do I serialize an F# record without having it output duplicate fields with @ signs at the end? #1034

Open
mrakgr opened this issue Jan 17, 2025 · 2 comments

Comments

@mrakgr
Copy link

mrakgr commented Jan 17, 2025

Example code:

#r "nuget: YamlDotNet, 16.3.0"
open YamlDotNet
open System

[<CLIMutable>]
type t = {
    qwer : string
    asdf : int
}

let t = {
    qwer = "hello"
    asdf = 1234
}

let serializer = new Serialization.Serializer()
serializer.Serialize(Console.Out, t)

Here is what it outputs when I run it.

qwer@: hello
asdf@: 1234
qwer: hello
asdf: 1234

How do I prevent it from generating those extraneus duplicate fields ending in @?

@mrakgr
Copy link
Author

mrakgr commented Jan 17, 2025

Here is another example. The results this library is giving me are bonkers.

#r "nuget: YamlDotNet, 16.3.0"
open YamlDotNet.Serialization
open YamlDotNet.Serialization.NamingConventions

[<CLIMutable>]
type t = {
    Qwerty : string
    Asdf : int
}

let t = {
    Qwerty = "hello"
    Asdf = 1234
}

let serializer =
    SerializerBuilder()
        .WithNamingConvention(CamelCaseNamingConvention.Instance)
        .Build()

serializer.Serialize([|t;t;t|])
|> printfn "%s"

Running the script with dotnet fsi gives me:

- &o0
  qwerty@: hello
  asdf@: 1234
  qwerty: hello
  asdf: 1234
- *o0
- *o0

@mrakgr
Copy link
Author

mrakgr commented Jan 17, 2025

The library does have tests that look sensible, so I am confused what the problem is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant