fix(csharp): index C# 14 extension declaration members - #2191
lorenzozanee wants to merge 1 commit into
Conversation
Signed-off-by: lorenzozanee <wyz0707@proton.me>
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
|
I believe you tagged me by accident. Only @DeusData can review PRs. |
| extract_csharp_extension_members(ctx, ts_node_named_child(node, i), class_node, class_qn, | ||
| spec); | ||
| } | ||
| } |
There was a problem hiding this comment.
extract_csharp_extension_members (extract_defs.c:5020-5037) only recognizes local_function_statement and method_declaration. A property member of an extension block, e.g. public int P => x;, cannot parse as a statement inside the constructor's block, so the grammar emits an ERROR node there instead and the property is silently dropped: no Method, no Field, nothing.
Checked against tree-sitter-c-sharp 0.23.5 in a clean container (closest I could get to the vendored grammar without building this repo; the method-only case parses exactly as this PR's own comment describes, which is why I'd expect this to generalize):
$ node -e 'const P=require("tree-sitter"),C=require("tree-sitter-c-sharp");
const p=new P(); p.setLanguage(C);
const t=p.parse("public static class E { extension(int x) { public int P => x; } }");
console.log("hasError:",t.rootNode.hasError);'
hasError: true
Same result whether the property is the extension's only member or sits beside a method. Worth at least detecting (ts_node_has_error) and skipping loudly rather than dropping the member with no signal.
Summary
C# 14 extension declarations are represented by older tree-sitter grammars as a constructor named
extension. The indexer skipped the constructor body, so members such asSumPositivewere absent from the graph. This change recovers method declarations from that body through the existing method-definition path.Fixes #2071
Testing
bash scripts/test.sh --suites grammar_regression,grammar_labels,cs_lspgit diff --checkReviewers