Escape quoted default values so the generated literal compiles - #113
Merged
Merged
Conversation
DefaultValueIsQuoted wrapped DefaultValue in quotes without escaping it, so a backslash, quote or newline in the value produced C# that does not compile, or that silently changes the string (\t becoming a tab). The value is now written as an escaped regular string literal. This covers the Field, Parameter, Property and EnumMember templates. Fixes #111 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019StKk4VdpfAZ5cdW5X685e
matt-edmondson
pushed a commit
that referenced
this pull request
Sep 26, 2026
Groups the two body writers together, and keeps this change from touching the same lines as the string-literal escaping in #113. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019StKk4VdpfAZ5cdW5X685e
|
This was referenced Sep 28, 2026
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 #111
What was wrong
TemplateBase.WriteDefaultValueTowrappedDefaultValuein"…"without escaping it whenDefaultValueIsQuotedwas set. A backslash, quote or newline in the value then produced C# that doesn't compile, or that silently changes the value (\tbecoming a tab). This affects the Field, Parameter, Property and EnumMember templates.Change
TemplateRendering.QuoteStringLiteralwrites the value as a regular C# string literal:\\,\",\0,\a,\b,\f,\n,\r,\tand\vget their short escapes.\uXXXXescape.WriteDefaultValueTouses the new method, and theDefaultValueIsQuoteddocs now say the value is escaped as well as quoted.SymbolDisplay.FormatLiteral.Tests
ParameterEscapesAQuotedDefaultValue: data rows for a backslash, a quote, newlines, tab and null, and another control character plus a line separator.FieldEscapesAQuotedInitialiser: the exact reproduction from the issue..sonarlint/sonar-local.props) reports only the pre-existingS8969inDocComment.cs.🤖 Generated with Claude Code
https://claude.ai/code/session_019StKk4VdpfAZ5cdW5X685e
Generated by Claude Code