From 2a085945dfc77e2fa710bec4df084e2963a6d504 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 25 Apr 2019 21:40:35 +0000 Subject: [PATCH] Add terminating newline to yaml strings. --- OpenRA.Game/MiniYaml.cs | 3 ++- OpenRA.Test/OpenRA.Game/MiniYamlTest.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenRA.Game/MiniYaml.cs b/OpenRA.Game/MiniYaml.cs index c651b543ab..f2de00ba91 100644 --- a/OpenRA.Game/MiniYaml.cs +++ b/OpenRA.Game/MiniYaml.cs @@ -28,7 +28,8 @@ namespace OpenRA 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 ToLines(this MiniYamlNodes y) diff --git a/OpenRA.Test/OpenRA.Game/MiniYamlTest.cs b/OpenRA.Test/OpenRA.Game/MiniYamlTest.cs index 5994b1819e..e41ddde6e4 100644 --- a/OpenRA.Test/OpenRA.Game/MiniYamlTest.cs +++ b/OpenRA.Test/OpenRA.Game/MiniYamlTest.cs @@ -269,7 +269,8 @@ Parent: # comment without value var strippedYaml = @"Parent: First: value containing a \# character - Second: value".Replace("\r\n", "\n"); + Second: value +".Replace("\r\n", "\n"); var result = MiniYaml.FromString(yaml).WriteToString(); Assert.AreEqual(strippedYaml, result);