Skip to content

Conversation

@LinusCenterstrom
Copy link
Collaborator

This seems to be required for the string to match runtime.
This is similar to how we handle verbatim strings in c#

This seems to be required for the string to match runtime. This is similar to how we handle verbatim strings in c#
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes carriage return characters from JavaScript template strings to ensure runtime string consistency, aligning its handling with C# verbatim strings.

  • Updated L10nParser.cs to remove "\r" from strings with a backtick (`) container.
  • Added a test in ParserTests.cs verifying that a JS template string with "\r\n" is correctly normalized to "\n".

Reviewed Changes

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

File Description
MN.L10n/L10nParser.cs Added handling for removing "\r" from JS template strings.
MN.L10n.Tests/ParserTests.cs Added a test verifying the proper handling of newline normalization in JS template strings.
Files not reviewed (2)
  • MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj: Language not supported
  • MN.L10n/MN.L10n.csproj: Language not supported

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where JavaScript template strings inadvertently include carriage return characters. The changes include:

  • Removing "\r" characters from phrases when the string container is a backtick.
  • Adding a unit test to verify the behavior of JS template strings.

Reviewed Changes

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

File Description
MN.L10n/L10nParser.cs Added handling for JS template strings by stripping "\r".
MN.L10n.Tests/ParserTests.cs Added a new test to verify correct newline behavior.
Files not reviewed (2)
  • MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj: Language not supported
  • MN.L10n/MN.L10n.csproj: Language not supported
Comments suppressed due to low confidence (1)

MN.L10n.Tests/ParserTests.cs:173

  • [nitpick] Consider adding a test case with a JS template string that contains a carriage return (\r) without a newline (\n) to ensure all scenarios are covered.
var src = "_s(`Hello\r\nbrother!`)";

@LinusCenterstrom LinusCenterstrom changed the title fix: Remove \r from js template strings fix Remove \r from js template strings Mar 31, 2025
@LinusCenterstrom LinusCenterstrom changed the title fix Remove \r from js template strings fix: Remove \r from js template strings Mar 31, 2025
@LinusCenterstrom LinusCenterstrom merged commit 416f7e6 into master Apr 1, 2025
3 of 4 checks passed
@LinusCenterstrom LinusCenterstrom deleted the js-templatestring-newlinefix branch April 1, 2025 07:30
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