Repository navigation
Escape VB multiline string values in regular C# literals - #1292
Open
CosmonautJones wants to merge 1 commit into
Open
CosmonautJones wants to merge 1 commit into
CosmonautJones wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Fixes #1173
Fixes #1096
Problem
When a VB string contains only a newline, or uses lone CR/LF characters, the converter chooses a regular C# string but copies physical line breaks into it. The output does not compile. The same problem affects newline-only text between interpolations.
Solution
Use Roslyn's C# literal formatter on the string's semantic value in the shared nonverbatim escaping path, then escape quotation marks explicitly. This preserves the existing verbatim-selection rule and emits escapes such as
\r\nthat compile to the original characters. Both ordinary and interpolated strings use the corrected helper.Validation
Tested commit:
afe981e96d00597af675e1380eb1b899669ad251.net10.0; the active runtime was verified as 10.0.13.DeeplyNestedBinaryExpressionShouldNotStackOverflowAsync(marked too slow),LinqAggregateSumAsync, andLinqGroupJoinAsync(unsupported conversions tracked by VB -> C#: Query Expression Syntax not fully implemented #29).The .NET 10 validation used separate
dotnet cleananddotnet build Tests/Tests.csproj -c Release -f net10.0 --no-restore, followed by filtereddotnet test Tests/Tests.csproj -c Release -f net10.0 --no-build --no-restoreruns. An initial combined rebuild using--no-incrementalfailed before tests because compatibility-package source files were omitted; separate clean/build succeeded without source changes.Upstream CI run 39945459112 still awaits maintainer approval and has executed no jobs. These are successful local .NET 10 results, not a claim that the full upstream build/publish/VSIX/web/VS2026 pipeline passed.
Process