Skip to content

[Bug]: C#: a member call on a chained or invoked receiver binds to the caller's own same-named method #4418

Closed

Description

@nixvideojuego-ui

What happened?

A C# member call whose receiver has no capturable name binds to the caller's own same-named method as an EXTRACTED calls edge. This covers a member chain (run.Sequence.Apply(), s.Items.Count()), an invocation (Pick().look.LateUpdate()) and a new X(...).M(). The receiver's type is ignored.

In extractors/engine.py, the C# defer rule is:

_csharp_defer = (
    config.ts_module == "tree_sitter_c_sharp"
    and is_member_call and member_receiver
)

It only fires when member_receiver was captured. That happens for a plain identifier, this, base, this.field or a cast. For every other receiver shape, the call falls through to label_to_nid.get(callee_name), the per-file bare-name map, and lands on whatever method in the file shares the name. For a typed chain this happens even though receiver_chain (#4246) was computed and would have resolved it correctly.

Expected: no edge from the bare-name map for a C# member call. A typed chain should resolve through receiver_chain, and anything untypable should get no edge (fail-closed, as #1609 intended).

This is the C# twin of #4082 (TypeScript).

Steps to reproduce

import os, tempfile
from pathlib import Path
from graphify.extract import extract

os.chdir(tempfile.mkdtemp())
Path("Model.cs").write_text(
    "namespace Demo {\n"
    "    public class Sequence { public void Apply() { } }\n"
    "    public class Run { public Sequence Sequence; }\n"
    "}\n")
Path("Controller.cs").write_text(
    "namespace Demo {\n"
    "    public class Controller {\n"
    "        public void Apply() { }\n"
    "        public void Tick(Run run) { run.Sequence.Apply(); }\n"
    "        public void LateUpdate() { Pick().look.LateUpdate(); }\n"
    "        object Pick() { return null; }\n"
    "    }\n"
    "}\n")
r = extract([Path("Model.cs"), Path("Controller.cs")], cache_root=Path(".cache"))
label = {n["id"]: n["label"] for n in r["nodes"]}
for e in r["edges"]:
    if e["relation"] == "calls":
        print(label[e["source"]], "->", label[e["target"]], f"({e['target']})", e["confidence"])

Error output or graph output

.Tick() -> .Apply() (controller_demo_controller_apply) EXTRACTED          <- wrong class: should be Sequence.Apply
.LateUpdate() -> .LateUpdate() (controller_demo_controller_lateupdate) EXTRACTED   <- false self-loop
.LateUpdate() -> .Pick() (controller_demo_controller_pick) EXTRACTED

On a 1,512-file Unity C# codebase (game code plus vendored UniTask, LeanTween and MsgPack), 309 of the 516 calls self-loops came from this path. Typical cases:

  • LINQ s.cats.Count(...) bound to a local Count();
  • transform.gameObject.SetActive(...) bound to a local SetActive();
  • anim.Play(...) bound to a local Play().

Graphify version

0.9.89 (v8 e8eb76e)

Operating System

Windows (11)

Python Version

3.14

Installation Method

uv / pip (graphifyy)

Activity

  1. github-actions commented on Oct 13, 2026

    @github-actions

    Thanks for opening this issue, @nixvideojuego-ui. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. added a commit that references this issue on Oct 13, 2026
    f41ec2e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions