SharpYaml
SharpYaml copied to clipboard
Inaccurate SyntaxErrorException exception information
trafficstars
I'm using the library to validate if a file is correctly formatted or not. Here is the simplified code:
public static bool Validate(string filename)
{
try
{
var content = File.ReadAllText(filename);
var yaml = new YamlStream();
yaml.Load(new StringReader(content));
return true;
}
catch(SyntaxErrorException ex)
{
Console.Error.WriteLine($"{filename} invalid: {ex.Start.ToString()}");
return false;
}
}
When I use the following content:
name: alex
age: 1 #just one space to trigger error
The following is written to the console:
test.yaml invalid: Lin: 1, Col: 4, Chr: 15
I would expect Line number to be 2. Similarly column and char do not appear correct either.