Merge pull request #11464 from Phrohdoh/miniyaml-dont-strip-empty-lines

Do not remove empty entries in MiniYaml.FromString
This commit is contained in:
Oliver Brakmann
2016-06-18 10:19:32 +02:00
committed by GitHub
2 changed files with 16 additions and 1 deletions

View File

@@ -254,7 +254,7 @@ namespace OpenRA
public static List<MiniYamlNode> FromString(string text, string fileName = "<no filename available>")
{
return FromLines(text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries), fileName);
return FromLines(text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None), fileName);
}
public static List<MiniYamlNode> Merge(IEnumerable<List<MiniYamlNode>> sources)

View File

@@ -154,5 +154,20 @@ Test:
Assert.IsFalse(result.First(n => n.Key == "MockString").Value.Nodes.Any(n => n.Key == "AString"),
"MockString value should have been removed, but was not.");
}
[TestCase(TestName = "Empty lines should count toward line numbers")]
public void EmptyLinesShouldCountTowardLineNumbers()
{
var yaml = @"
TestA:
Nothing:
TestB:
Nothing:
";
var result = MiniYaml.FromString(yaml).First(n => n.Key == "TestB");
Assert.AreEqual(5, result.Location.Line);
}
}
}