feat(csharp): register operators, conversion operators, and finalizers as member nodes#728
feat(csharp): register operators, conversion operators, and finalizers as member nodes#728vitali87 wants to merge 1 commit into
Conversation
…s as member nodes
There was a problem hiding this comment.
Code Review
This pull request introduces support for C# operator overloads, conversion operators, and destructors/finalizers. It ensures these elements are correctly named, registered as members, and treated as reachability roots in dead code analysis since they are invoked via syntax or the garbage collector rather than explicit named calls. Corresponding unit tests have been added to verify these behaviors. There are no review comments, so no feedback is provided.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Greptile SummaryThis PR adds C# member registration for operators, conversion operators, and finalizers. The main changes are:
Confidence Score: 5/5Safe to merge with minimal risk. The change is narrowly scoped and keeps synthesized naming consistent across FQN resolution, signature extraction, ingestion, and dead-code handling. Targeted tests cover the changed C# definition and reachability behavior. No review issues were identified. No files require special attention.
What T-Rex did
Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Parser as C# tree-sitter node
participant Synth as csharp.utils.synthesize_method_name
participant FQN as language_spec._csharp_get_name
participant Ingest as parsers.utils.ingest_method
participant Graph as Graph method node
participant Dead as dead_code roots
Parser->>Synth: operator/conversion/finalizer node
Synth-->>FQN: synthesized scope leaf
Synth-->>Ingest: registered method leaf
Ingest->>Graph: method qn with signature when needed
Graph->>Dead: candidate method
Dead->>Dead: root if `.cs` and leaf starts `operator_` or `~`
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Parser as C# tree-sitter node
participant Synth as csharp.utils.synthesize_method_name
participant FQN as language_spec._csharp_get_name
participant Ingest as parsers.utils.ingest_method
participant Graph as Graph method node
participant Dead as dead_code roots
Parser->>Synth: operator/conversion/finalizer node
Synth-->>FQN: synthesized scope leaf
Synth-->>Ingest: registered method leaf
Ingest->>Graph: method qn with signature when needed
Graph->>Dead: candidate method
Dead->>Dead: root if `.cs` and leaf starts `operator_` or `~`
Reviews (1): Last reviewed commit: "feat(csharp): register operators, conver..." | Re-trigger Greptile |
What
Closes a known C# Phase-1 gap: operator overloads, conversion operators, and finalizers (destructors) now register as member nodes.
operator +) and conversion operators (implicit/explicit operator T) have nonamefield in tree-sitter-c-sharp 0.23.5, soingest_methoddropped them. They now get a synthesized leaf:operator_<symbol>/operator_<target-type>, plus the parameter signature so overloaded operators (operator +(Vec,Vec)vsoperator +(Vec,int)) stay distinct nodes.~Foo) do have anamefield equal to the type name, which collided with the constructor; they are now prefixed with~.csharp.utils.synthesize_method_nameand shared by_csharp_get_name(FQN scope walk),extract_method_signature, andingest_method, so the scope walk and the registered node qn agree.Dead-code correctness
Now that these register, an unused operator (invoked by
a + bsyntax) or finalizer (invoked by the GC) would surface as a false-positive dead-code hit. Added_is_csharp_operator_or_finalizer_root(mirrors the existing C++ operator root) so both are reachability roots on.csfiles.Tests (red → green)
test_members_generics_and_operators/test_operator_overloads_and_conversions_are_distinct: operators, conversion operators (by target type), and finalizers register with the right names and distinct overload signatures.test_operator_and_finalizer_are_roots: neither is reported dead without an incoming CALLS edge.Full suite: 5022 passed, 10 skipped. ruff + ty clean.