You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Fact]
public void DeserializationTest()
{
var serializer = new SerializerBuilder().Build();
var deserializer = new DeserializerBuilder().WithAttemptingUnquotedStringTypeDeserialization().Build();
// Arrange
double value = 1.2345678901234567d;
var yaml = $"Value: {value:G17}"; // Value: 1.2345678901234567
// Act
var dict = deserializer.Deserialize<IDictionary<string, object>>(yaml);
var yamlRoundTrip = serializer.Serialize(dict);
// Assert
var result = dict["Value"];
result.Should().Be(value); // NG: deserialized as `1.2345679`
}
The text was updated successfully, but these errors were encountered:
Describe the bug
float.Parse
method acceptnumber
string with higher precision than can be represented with thefloat
type.So currently when deserialize YAML with
WithAttemptingUnquotedStringTypeDeserialization
floating number is always parsed as
float type
https://github.com/aaubry/YamlDotNet/blob/master/YamlDotNet/Serialization/NodeDeserializers/ScalarNodeDeserializer.cs#L390-L391
To Reproduce
The text was updated successfully, but these errors were encountered: