镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

fix(plugin): close C# raw strings on the matching quote count - #1346

Merged
mldangelo-oai merged 1 commit into
openai:mainfrom
ilaigold:fix/plugin-csharp-raw-string-quotes
Oct 7, 2026
Merged

mldangelo-oai merged 1 commit into
openai:mainfrom
ilaigold:fix/plugin-csharp-raw-string-quotes

Conversation

@ilaigold

@ilaigold ilaigold commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

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_source treats 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:

class Before {}
class Service {
  string Text = """"
    { "a": """ }
    """";
  void Visible() {}
}
class After {}

the preview stops at class Service, and method Service.Visible and class After are gone. One-line literals like """"" contains """" and { """"" hit the same thing.

Changes

  • For .cs files, match the whole opening quote run and close on a run of the same length, using the raw_terminator path that C++ and Go raw strings already go through. Three-quote literals close exactly as before, and triple quotes in other languages are untouched.
  • Add a parametrized test in tests/test_rank_preview.py with 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 drops Service.Visible and After, 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 check and ruff format --check with plugins/codex-security/pyproject.toml: pass
  • pnpm --dir sdk/typescript run build:ci: pass
  • node .github/scripts/check_plugin_source_compatibility.mjs: pass, and its node --test suite: 9 passed
  • python -m pytest plugins/codex-security/tests -q -n 4 --dist worksteal --max-worker-restart 0: 1622 passed, 3 skipped

With main's rank_preview.py, the four-quotes and five-quotes cases fail (the outline stops at class Service) and three-quotes still passes. With the fix, all 144 tests in test_rank_preview.py pass.

Risk and rollout

Only .cs structural previews change, and only for literals that open with four or more quotes. No CLI, schema or migration changes.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

🤖 Generated with Claude Code

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>
@github-actions github-actions Bot added the bug Something isn't working label Oct 7, 2026

@mldangelo-oai mldangelo-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mldangelo-oai
mldangelo-oai merged commit f88b7f5 into openai:main Oct 7, 2026
104 of 107 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 7, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants