Skip to content

Fix newline in verbatim strings - #186

Merged
cbengtsson merged 3 commits into
masterfrom
fix-newline-verbatimstring
Aug 18, 2026
Merged

Fix newline in verbatim strings#186
cbengtsson merged 3 commits into
masterfrom
fix-newline-verbatimstring

Conversation

@cbengtsson

Copy link
Copy Markdown
Contributor

Fixed a bug where having newline in verbatim strings would cause the parsed text to incorrectly escape newlines.

Also fixed some tests where the result didn't match the intended behaviour.

Fixed tests where result didn't match the intended behaviour
Added an additional test
@cbengtsson cbengtsson self-assigned this Aug 18, 2026
@LinusCenterstrom
LinusCenterstrom requested a lite review from Copilot August 18, 2026 14:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes parsing of verbatim (@"...") strings so embedded newlines are preserved as actual newline characters (normalized to \n) rather than being converted into the two-character escape sequence \\n, and updates/adds parser tests to match the intended behavior.

Changes:

  • Adjust verbatim-string phrase extraction to stop converting \n into \\n.
  • Update existing verbatim newline-related assertions and add a larger regression test for multi-line verbatim content.
  • Bump package/assembly versions for MN.L10n and MN.L10n.BuildTasks.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
MN.L10n/MN.L10n.csproj Package + assembly version bump to 4.1.5.
MN.L10n/L10nParser.cs Changes verbatim phrase normalization to preserve literal newlines (while still normalizing CRLF by removing \r).
MN.L10n.Tests/ParserTests.cs Updates verbatim newline expectations and adds a regression test for multi-line verbatim strings.
MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj Package version bump to 4.0.7.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread MN.L10n/L10nParser.cs
Comment on lines 161 to +167
{
var _tail = source[_pos - 1];
var _peek = source[_pos + 1];
if (source[_pos] == _stringContainer && _peek != _stringContainer &&
_tail != _stringContainer)
{
var phrase = _tokenContent.ToString().Replace("\n", "\\n").Replace("\r", "")
var phrase = _tokenContent.ToString().Replace("\r", "")
Comment thread MN.L10n/L10nParser.cs
@cbengtsson
cbengtsson merged commit b447fcf into master Aug 18, 2026
5 checks passed
@cbengtsson
cbengtsson deleted the fix-newline-verbatimstring branch August 18, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants