From 3201501cc0754f0a71887c924fa75aca7384eaed Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Wed, 1 Mar 2023 14:45:27 -0300 Subject: [PATCH] Fix build issue when string resource has newlines The value when no Comment is provided in teh resource file is used to make up the code comment for the generated property. This breaks if the value has newlines in it. A workaround is for users to provide a shorter description in the resx, but we now also sanitize the value by replacing newlines with a whitespace. --- src/ThisAssembly.Strings/Model.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ThisAssembly.Strings/Model.cs b/src/ThisAssembly.Strings/Model.cs index a65d6aa6..3693b9f2 100644 --- a/src/ThisAssembly.Strings/Model.cs +++ b/src/ThisAssembly.Strings/Model.cs @@ -51,7 +51,11 @@ public static ResourceArea Load(IEnumerable data, string rootArea) if (valueElement == null) continue; - var comment = element.Element("comment")?.Value?.Replace("<", "<").Replace(">", ">"); + var comment = element.Element("comment")?.Value? + .Replace("<", "<") + .Replace(">", ">") + .Replace("\r\n", " ").Replace("\n", " "); + var areaParts = id.Split(new[] { "_" }, StringSplitOptions.RemoveEmptyEntries); if (areaParts.Length <= 1) {