Skip to content

fix(analyzers): keep escaped braces literal in the E128015 fix - #175

Merged
e128 merged 1 commit into
mainfrom
fix/e128015-escaped-braces
Nov 17, 2026
Merged

e128 merged 1 commit into
mainfrom
fix/e128015-escaped-braces

Conversation

@e128

@e128 e128 commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Executive Summary

The E128015 code fix emitted a broken interpolated string when the format string held doubled braces. The scanner split each brace pair into two InterpolatedStringTextToken nodes, so {{x}} became { then { in the emitted source and changed the runtime value. The fix now scans literal runs: doubled braces stay inside one text token, with escaped source syntax in Text and the original content in ValueText.

Code Changes

  • StringFormatToInterpolationCodeFixProvider walks the format string as literal runs between placeholders. ProcessOpenBrace and ProcessLiteralText collapse into ProcessPlaceholder and AddLiteralText.
  • A literal run carries its whole substring, so a doubled brace is never split across tokens.
  • CreateTextContent keeps escaped source syntax in Text and the format content in ValueText, which is what the binder consumes.
  • An unmatched or stray brace still declines the fix, as before.
  • The changed assembly is the code fixer that packs into the E128.Analyzers package.

Tests and Tooling

  • Added StringFormat_EscapedBraces_StayLiteral and StringFormat_EscapedBracesBesidePlaceholder_StayLiteral to StringFormatToInterpolationE128CodeFixTests.
  • scripts/check.sh --all passed: shell lint, format check, build, and test.
  • Analyzer release files are clean and the README rule table shows no drift. No rule row changed, so no release promotion ran and no analyzer version bump applied.

Review Guide

  • StringFormatToInterpolationCodeFixProvider.BuildInterpolatedString: confirm the literal-run boundaries.
  • CreateTextContent: confirm the Text and ValueText split.

Rollback

Revert the commit. The fix only widens which format strings the fixer accepts, so reverting restores the old behavior without touching analyzer diagnostics.

Links

  • Rule: E128015

🤖 Generated with Claude Code

- scan the format string into literal runs, so doubled braces stay in one text token
- escape source syntax in Text and keep the format content in ValueText
- add regression tests for escaped braces alone and beside a placeholder
- update the code fix output lode note and drop the redundant AnalysisMode lines

Co-Authored-By: Claude
@e128
e128 merged commit d6121e2 into main Nov 17, 2026
2 checks passed
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.

1 participant