Fix newline in verbatim strings - #186
Merged
Merged
Conversation
Fixed tests where result didn't match the intended behaviour Added an additional test
LinusCenterstrom
approved these changes
Aug 18, 2026
There was a problem hiding this comment.
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
\ninto\\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 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", "") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.