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);