YamlDotNet
YamlDotNet copied to clipboard
Deserialization exception when running quick start example on Linux
trafficstars
Describe the bug
When running the deserialization example from the README when published for Linux64 (in WSL) a get following exception:
Exception during deserialization
at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser, Type, SerializerState, IValueDeserializer)
at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser, Type, SerializerState, IValueDeserializer)
at YamlDotNet.Serialization.Deserializer.Deserialize(IParser, Type)
at YamlDotNet.Serialization.Deserializer.Deserialize[T](IParser)
at YamlDotNet.Serialization.Deserializer.Deserialize[T](TextReader)
at YamlDotNet.Serialization.Deserializer.Deserialize[T](String)
Unhandled exception. (Line: 2, Col: 1, Idx: 2) - (Line: 2, Col: 1, Idx: 2): Exception during deserialization
It works on Windows.
To Reproduce Try to add the steps needed to reproduce the problem. Feel free to open a pull request with a failing test if that makes sense. Otherwise, at least provide some code and / or YAML that reproduce the issue.
static void TestYaml()
{
var yml = @"
name: George Washington
age: 89
height_in_inches: 5.75
addresses:
home:
street: 400 Mockingbird Lane
city: Louaryland
state: Hawidaho
zip: 99970
";
try
{
var deserializer = new DeserializerBuilder()
.WithNamingConvention(UnderscoredNamingConvention.Instance) // see height_in_inches in sample yml
.Build();
//yml contains a string containing your YAML
var p = deserializer.Deserialize<Person>(yml); // Exception here
var h = p.Addresses["home"];
System.Console.WriteLine($"{p.Name} is {p.Age} years old and lives at {h.Street} in {h.City}, {h.State}.");
// Output:
// George Washington is 89 years old and lives at 400 Mockingbird Lane in Louaryland, Hawidaho.
}
catch (Exception ex)
{
Console.WriteLine($"{ex.Message}\n{ex.StackTrace}");
throw;
}
}
Then publish for
Then run. (I ran in WSL but I don't see why it shouldn't fail on the real thing).
Thanks