Add terminating newline to yaml strings.

This commit is contained in:
Paul Chote
2019-04-25 21:40:35 +00:00
committed by reaperrr
parent 753a0b1e3e
commit 2a085945df
2 changed files with 4 additions and 2 deletions

View File

@@ -28,7 +28,8 @@ namespace OpenRA
public static string WriteToString(this MiniYamlNodes y) public static string WriteToString(this MiniYamlNodes y)
{ {
return y.ToLines().JoinWith("\n"); // Remove all trailing newlines and restore the final EOF newline
return y.ToLines().JoinWith("\n").TrimEnd('\n') + "\n";
} }
public static IEnumerable<string> ToLines(this MiniYamlNodes y) public static IEnumerable<string> ToLines(this MiniYamlNodes y)

View File

@@ -269,7 +269,8 @@ Parent: # comment without value
var strippedYaml = @"Parent: var strippedYaml = @"Parent:
First: value containing a \# character First: value containing a \# character
Second: value".Replace("\r\n", "\n"); Second: value
".Replace("\r\n", "\n");
var result = MiniYaml.FromString(yaml).WriteToString(); var result = MiniYaml.FromString(yaml).WriteToString();
Assert.AreEqual(strippedYaml, result); Assert.AreEqual(strippedYaml, result);