From e0aee30b6e967f1ed5896b6ec8d203b247f662dd Mon Sep 17 00:00:00 2001 From: Christoffer Bengtsson Date: Tue, 18 Aug 2026 16:21:33 +0200 Subject: [PATCH 1/3] Fix tests for newline in verbatim strings Fixed tests where result didn't match the intended behaviour Added an additional test --- MN.L10n.Tests/ParserTests.cs | 39 ++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/MN.L10n.Tests/ParserTests.cs b/MN.L10n.Tests/ParserTests.cs index 4ae8f41..2733f90 100644 --- a/MN.L10n.Tests/ParserTests.cs +++ b/MN.L10n.Tests/ParserTests.cs @@ -65,7 +65,7 @@ public void TestParserWithVerbatimLinebreak() var parser = new L10nParser(); var result = parser.Parse(src).ToList(); Assert.Single(result); - Assert.Equal(@"Hej\nNej", result[0].Phrase.Trim()); + Assert.Equal("Hej\nNej", result[0].Phrase.Trim()); } [Fact] @@ -164,7 +164,7 @@ public void TestEscapedStringContainerCharacterVerbatim() var parser = new L10nParser(); var result = parser.Parse(src).ToList(); Assert.Single(result); - Assert.Equal(@"Hej ""bror""\nNej", result[0].Phrase.Trim()); + Assert.Equal("Hej \"bror\"\nNej", result[0].Phrase.Trim()); } [Fact] @@ -176,5 +176,40 @@ public void TestNewlineInJsTemplateString() Assert.Single(result); Assert.Equal("Hello\nbrother!", result[0].Phrase.Trim()); } + + [Fact] + public void TestNewLineInVerbatimString() + { + var src = @" +var body = _s(@""(Detta är ett automatiserat meddelande)

+Användaruppgifter för $product$

+Dessa uppgifter har registrerats i $product$. Du har möjlighet att ändra på uppgifterna genom att logga in.

+Kontouppgifter
+Företagskonto: $companyName$ +

Namn: $fullname$ +
Användarnamn: $username$ +
E-post: $email$ +
Adress: $address$ +
Ort: $city$ +
Postnr: $zip$ +
Telefon: $phone$"", + new + { + companyName = user.CompanyName, + fullname = mailToUser.Fullname, + username = mailToUser.Username, + email = mailToUser.Email, + address = mailToUser.Address1, + city = mailToUser.City, + zip = mailToUser.Zipcode, + phone = mailToUser.Phone, + product = productName, + }); +"; + var parser = new L10nParser(); + var result = parser.Parse(src).ToList(); + Assert.Single(result); + Assert.Equal("(Detta är ett automatiserat meddelande)

\nAnvändaruppgifter för $product$

\nDessa uppgifter har registrerats i $product$. Du har möjlighet att ändra på uppgifterna genom att logga in.

\nKontouppgifter
\nFöretagskonto: $companyName$\n

Namn: $fullname$\n
Användarnamn: $username$\n
E-post: $email$\n
Adress: $address$\n
Ort: $city$\n
Postnr: $zip$\n
Telefon: $phone$", result[0].Phrase.Trim()); + } } } From d3733d2acbe086a97f5f06609e41a39430f474fe Mon Sep 17 00:00:00 2001 From: Christoffer Bengtsson Date: Tue, 18 Aug 2026 16:21:51 +0200 Subject: [PATCH 2/3] Fixed a bugg with newline in verbatim strings --- MN.L10n/L10nParser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MN.L10n/L10nParser.cs b/MN.L10n/L10nParser.cs index d035869..0b9b1df 100644 --- a/MN.L10n/L10nParser.cs +++ b/MN.L10n/L10nParser.cs @@ -164,7 +164,7 @@ bool TryPeek(int forward) if (source[_pos] == _stringContainer && _peek != _stringContainer && _tail != _stringContainer) { - var phrase = _tokenContent.ToString().Replace("\n", "\\n").Replace("\r", "") + var phrase = _tokenContent.ToString().Replace("\r", "") .Replace("\"\"", "\\\""); // Hoppa över sista \ om den är escape:ad From e882364791804ec2351656606545853569166ad2 Mon Sep 17 00:00:00 2001 From: Christoffer Bengtsson Date: Tue, 18 Aug 2026 16:22:20 +0200 Subject: [PATCH 3/3] Bump version numbers --- MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj | 2 +- MN.L10n/MN.L10n.csproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj b/MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj index c542006..d6139b0 100644 --- a/MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj +++ b/MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj @@ -6,7 +6,7 @@ Exe MN.L10n.BuildTasks.Program true - 4.0.6 + 4.0.7 Chris Gårdenberg MultiNet Interactive AB diff --git a/MN.L10n/MN.L10n.csproj b/MN.L10n/MN.L10n.csproj index c50c1b0..bb9b7f0 100644 --- a/MN.L10n/MN.L10n.csproj +++ b/MN.L10n/MN.L10n.csproj @@ -12,14 +12,14 @@ Translation package https://github.com/MultinetInteractive/MN.L10n git © 20XX MultiNet Interactive AB - 4.1.4 + 4.1.5 latest True Now includes analyzer Library - 4.1.4 + 4.1.5