From c063e16c516f9b563373ebf71cb4df9ab7e9c55c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 21 Dec 2025 15:59:10 +0100 Subject: [PATCH] Display the line where a mismatch occurred. --- .../Lint/CheckRunningUpdateRule.cs | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/Lint/CheckRunningUpdateRule.cs b/OpenRA.Mods.Common/Lint/CheckRunningUpdateRule.cs index 8d46c82a1e..40d77f53e4 100644 --- a/OpenRA.Mods.Common/Lint/CheckRunningUpdateRule.cs +++ b/OpenRA.Mods.Common/Lint/CheckRunningUpdateRule.cs @@ -12,7 +12,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using OpenRA.Mods.Common.UpdateRules; using OpenRA.Mods.Common.UpdateRules.Rules; @@ -35,9 +34,27 @@ namespace OpenRA.Mods.Common.Lint if (package == null) continue; - var textData = Encoding.UTF8.GetBytes(nodes.WriteToString()); - if (!Enumerable.SequenceEqual(textData, package.GetStream(file).ReadAllBytes())) - emitError($"Mock update rule has tried to modify file {file}. Syntax mismatch detected."); + var textData = nodes.WriteToString(); + var packagesStream = package.GetStream(file); + var packageData = packagesStream.ReadAllText(); + if (!Enumerable.SequenceEqual(textData, packageData)) + { + emitError($"Mock update rule has tried to modify file {file}."); + + var packageLines = packageData.Split(["\r\n", "\n"], StringSplitOptions.None).GetEnumerator(); + var textLines = textData.Split(["\r\n", "\n"], StringSplitOptions.None).GetEnumerator(); + + var n = 1; +#pragma warning disable RCS1239 + while (packageLines.MoveNext() && textLines.MoveNext()) + { + if ((string)packageLines.Current != (string)textLines.Current) + emitError($"Syntax or whitespace mismatch detected at line {n}."); + + n++; + } +#pragma warning restore RCS1239 + } } } catch (Exception ex)