Add C# 11 raw string literal support
Implementation Plan for Raw String Literals (C# 11)
Following the plan in docs/plans/raw-strings/plan.md and tracking progress in docs/plans/raw-strings/todo.md.
All Phases Complete ✅
Code Review Feedback ✅
- [x] Add comprehensive brace escaping tests
- [x] Refactor state management - remove CurrentQuotes overloading
- [x] Use local variables for temporary scanning state
- [x] Implement correct brace escaping logic (odd/even group counting)
- [x] Fix test expectations for brace escaping
Implementation Complete! 🎉
Status: All 601 tests passing!
Raw string literal scanning is now fully functional for:
- ✅ Single-line and multi-line non-interpolated raw strings (
"""text""") - ✅ Single-line interpolated raw strings with holes (
$"""text {expr}""",$$"""text {{expr}}""") - ✅ Multi-line interpolated raw strings with holes (
$"""\ntext {expr}\n""") - ✅ Nested string combinations (raw in raw, raw in regular, regular in raw)
- ✅ Complex expressions in holes (brackets, switch expressions with braces)
- ✅ Brace escaping in interpolated raw strings (
$$"""{{{{literal}}}}""",$$"""{{{x}}}""")
Architecture:
All scanning processes characters one at a time without relying on buffer assumptions, making the scanner ready for potential streaming/chunked input support. The implementation uses a local variable (rawQuoteOrBraceCount) for temporary state tracking instead of overloading fields in InterpolationState, improving code maintainability.
Original prompt
This section details on the original issue you should resolve
<issue_title>Implement support for raw string literals (C# 11)</issue_title> <issue_description>Add support for raw string literals, that were introduced with C# 11 by creating a PR that targets the existing
rawstringbranch (when it will be merged)
- Implement the feature according to the plan in
docs/plans/raw-strings/plan.md- Track the phases of the implementation in
docs/plans/raw-strings/todo.md. A phase is complete if all tests are passing. Create a Git commit for each phase before moving on to the next phase.</issue_description>
<agent_instructions>See instructions in issue #55</agent_instructions>
Comments on the Issue (you are @copilot in this section)
- Fixes atifaziz/CSharpMinifier#55
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.