Repository navigation
fix(plugin): close C# raw strings on the matching quote count - #1346
Merged
mldangelo-oai merged 1 commit intoOct 7, 2026
Merged
Conversation
C# 11 raw string literals can open with four or more quotes so that the content may contain """. The generic triple-quote handling closed such a literal at the first inner """, reopened on the trailing quotes, and masked the rest of the file, so later members and types were missing from the structural preview. For .cs files, measure the opening quote run and close on the same run through the existing raw-string terminator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mldangelo-oai
approved these changes
Oct 7, 2026
mldangelo-oai
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the clear reproduction and focused fix. Valid C# raw strings with longer delimiters were hiding later methods and classes from ranking previews. Matching the opening quote count through the existing raw-string state fixes that without adding another parser path.
I reproduced the before/after behavior and checked ordinary, verbatim, and representative interpolated strings. The 144 preview tests, Ruff lint/format, TypeScript CI build, and both portable source compatibility checks passed locally. The parameterized regression cases are proportionate to the change. Approved.
Merged
3 tasks done
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.
Summary
After the C++ (#1279) and Go (#1235) raw-string fixes, I tried C# raw strings against the same masking code and they break in a similar way. C# 11 lets a raw string open with four or more quotes so the content can contain
""".mask_c_style_sourcetreats any"""as a plain triple quote, so it closes the literal at the first inner""", opens a new string on the leftover quotes and masks the rest of the file.With this file:
the preview stops at
class Service, andmethod Service.Visibleandclass Afterare gone. One-line literals like""""" contains """" and { """""hit the same thing.Changes
.csfiles, match the whole opening quote run and close on a run of the same length, using theraw_terminatorpath that C++ and Go raw strings already go through. Three-quote literals close exactly as before, and triple quotes in other languages are untouched.tests/test_rank_preview.pywith three-, four- and five-quote literals that contain braces, with declarations before and after.Interpolated raw strings (
$$"""") take the same path, since the$prefix passes through before the quote run. I checked one by hand with{{x}}and"""inside: main dropsService.VisibleandAfter, this branch keeps them. Verbatim@""""strings and"" + "{"give the same outline on both.Testing
On macOS with Python 3.12, Node 24.21.0 and pnpm 11.25.0:
ruff checkandruff format --checkwithplugins/codex-security/pyproject.toml: passpnpm --dir sdk/typescript run build:ci: passnode .github/scripts/check_plugin_source_compatibility.mjs: pass, and itsnode --testsuite: 9 passedpython -m pytest plugins/codex-security/tests -q -n 4 --dist worksteal --max-worker-restart 0: 1622 passed, 3 skippedWith main's
rank_preview.py, thefour-quotesandfive-quotescases fail (the outline stops atclass Service) andthree-quotesstill passes. With the fix, all 144 tests intest_rank_preview.pypass.Risk and rollout
Only
.csstructural previews change, and only for literals that open with four or more quotes. No CLI, schema or migration changes.Public disclosure review
🤖 Generated with Claude Code