aaubry / YamlDotNet

YamlDotNet is a .NET library for YAML
MIT License
2.48k stars 466 forks source link

Fix tests running in cultures using different cultures #837

Closed EdwardCooke closed 10 months ago

EdwardCooke commented 10 months ago

Fixes #792

Also adds the ability to specify the number format for the project, defaults to yaml standard.

To specify the number format when serializing or deserializing, use a custom YamlFormatter, setting the NumberFormat property to what you want, for example, CultureInfo.CurrentCulture.NumberFormat and pass that in to the builders with the WithYamlFormatter method.

Full example, to use the current culture's number format,

var serializer = new SerializerBuilder()
    .WithYamlFormatter(
        new YamlFormatter
        {
            NumberFormat = CultureInfo.CurrentCulture.NumberFormat
        }
    ).Build();
aaubry commented 10 months ago

This feature has been released in version 13.3.1.