feat: add C# language support - #46
Open
reinhardtb wants to merge 1 commit into
Open
Conversation
Adds tree-sitter-c-sharp (v0.21.3) as a dependency and implements full C# extraction in the Tier-1 code graph. Supported constructs: - class, struct, interface, record, enum declarations - method, constructor, property declarations - base_list heritage (extends + implements) - using_directive imports - invocation_expression calls with member_access_expression resolution - visibility detection (public modifier = exported) - Field, variable, and parameter type bindings Files changed: - src/graph/extract.ts: Language type, languageOf, CS_KINDS, GRAMMARS, describeCSharp, heritageEdges, calleeName, isImport, importSpecifier, csExported, csTypeName - src/graph/bindings.ts: defName, isClassNode, handleCSharp, csTypeName - src/graph/types.ts: Kind type comments updated for C# coverage - test/graph-csharp.test.ts: 6 test cases covering classes/interfaces/ enums/records/structs, methods/constructors/visibility, heritage edges, call edges, import edges, contains edges Verified: 274 files (131 C# + 27 TSX + 116 TS) parsed on mm-signum codebase, producing 2256 nodes and 3010 edges. All 526 tests pass.
Collaborator
|
Thanks, this is valuable and we’d like to move it forward. Recent changes to main introduced conflicts. Could you rebase onto the latest main, resolve them, and rerun the test suite? We’ll review it promptly afterward. |
|
+1 on this, C# support would be awesome |
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
Adds C# language support to Graft, enabling the Tier-1 code graph to index .NET codebases.
What's implemented
Language detection:
.csfiles mapped to"csharp"language type.Construct extraction:
class_declaration,struct_declaration,interface_declaration,record_declaration,enum_declaration→ class/struct/interface/class/enummethod_declaration,constructor_declaration,property_declaration→ methodbase_listheritage edges (first = extends, rest = implements)using_directiveimport edgesinvocation_expressioncall edges withmember_access_expressionreceiver resolutionpublicmodifier detectionBindings: Field declarations, variable declarations, and parameter type annotations for receiver-type resolution on member calls.
Dependencies:
tree-sitter-c-sharp@0.21.3(compatible withtree-sitter@0.21.x).Verification
Tested on mm-signum, a .NET 10 multi-tenant IoT platform:
Test coverage
6 test cases in
test/graph-csharp.test.ts: