Skip to content

feat(code): parse C# comments with the C# grammar - #1196

Open
Eljees wants to merge 1 commit into
vale-cli:v3from
Eljees:feat/csharp-comments
Open

Eljees wants to merge 1 commit into
vale-cli:v3from
Eljees:feat/csharp-comments

Conversation

@Eljees

@Eljees Eljees commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

.cs and .csx files are parsed with the C grammar, which doesn't know C#'s verbatim, raw or interpolated strings. On the new fixture, v3 lints a // inside a """ raw string (10:16) and misses the comment after @"C:\temp\" (15:37).

This adds a C# extractor on the csharp grammar go-tree-sitter already vendors, following the Kotlin one (#1183), and maps .cs, .csx and the csharp/c# notebook kernels to it. Tests: testdata/comments/{in,out}/12.cs and an e2e csharp case.

Assisted-by: Claude Code

`.cs` and `.csx` files were parsed with the C grammar, which does not know C#'s verbatim,
raw or interpolated strings. A comment after `@"C:\temp\"` was swallowed by the string, and
a `//` inside a `"""` raw string literal was linted as a comment.

Add a C# extractor on the grammar go-tree-sitter already vendors, and map `.cs`, `.csx`
and the csharp and c# notebook kernels to it. `// ReSharper disable|restore` and
`// NOSONAR` are treated as directives.

Signed-off-by: Eljees <57435526+Eljees@users.noreply.github.com>
Assisted-by: Claude Code
@github-actions

Copy link
Copy Markdown

Before this is reviewed, please read the AI-Assisted Contributions section of the contributing guide and make sure this change meets it: you can explain every line, the description is your own and brief, it fixes a bug you hit or a feature agreed in an issue, it does not touch undocumented options, and any substantial tool use is noted.

@Eljees

Eljees commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

This adds support for parsing C# comments with the C# grammar instead of falling back to a generic/unsupported path, so vale actually checks prose inside C# comments the way it already does for other C-family languages. I can walk through every line of the diff. I used an LLM as a coding assistant while writing the patch -- I direct the change, review and test all of it myself, and use tools like this in my regular AppSec work. The change doesn't touch any undocumented options.

This branch has not been deployed

No deployments
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