Skip to content

Commit

Permalink
Fix build issue when string resource has newlines
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kzu committed Mar 1, 2023
1 parent 9ccb3e3 commit 561c16e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ThisAssembly.Strings/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ public static ResourceArea Load(IEnumerable<XElement> data, string rootArea)
if (valueElement == null)
continue;

var comment = element.Element("comment")?.Value?.Replace("<", "&lt;").Replace(">", "&gt;");
var comment = element.Element("comment")?.Value?
.Replace("<", "&lt;")
.Replace(">", "&gt;")
.Replace("\r\n", " ").Replace("\n", " ");

var areaParts = id.Split(new[] { "_" }, StringSplitOptions.RemoveEmptyEntries);
if (areaParts.Length <= 1)
{
Expand Down

0 comments on commit 561c16e

Please sign in to comment.