Skip to content

fix(csharp): bind a call on a constructed generic type (Bag<T>.Make()) - #2676

Open
rohit-jsfreaky wants to merge 1 commit into
Graphify-Labs:v8from
rohit-jsfreaky:fix/csharp-call-site-type-arguments
Open

rohit-jsfreaky wants to merge 1 commit into
Graphify-Labs:v8from
rohit-jsfreaky:fix/csharp-call-site-type-arguments

Conversation

@rohit-jsfreaky

@rohit-jsfreaky rohit-jsfreaky commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2624 (the part still open on 0.9.86).

Summary

Bag<Payload>.Make() gets no calls edge. The receiver is a constructed generic type, which tree-sitter wraps in a generic_name, and the C# member-call handler only captured a receiver that was a plain identifier. The receiver was dropped, so _resolve_csharp_member_calls had nothing to bind.

The rest of #2624 (type arguments on the method name: Registry.Fetch<Payload>(), box.Read<Payload>(), Local<Payload>()) is already fixed on v8 by #3406's _csharp_bare_call_name. This PR was first written before that landed; it is now rebased onto 0.9.86 and reduced to the one case still broken.

Change

graphify/extractors/engine.py: a member call's receiver may also be a generic_name, read through _csharp_bare_call_name (the type-argument list off), so Bag<Payload>.Make() binds like any Type.M(). Type nodes are stored under the bare name. C# only; nothing else reads this branch.

This does not loosen resolution: the receiver still goes through receiver typing and the god-node guard, so an untypable receiver still gets no edge.

Tests

Five tests appended to tests/test_csharp_member_calls.py. test_constructed_generic_type_as_receiver fails on clean 0.9.86 and passes here; the other four (explicit type argument on a type receiver and on a typed local, Local<T>() / this.Local<T>(), and the #1609 guard through a generic call) pass on 0.9.86 and stay as regression tests for #2624. The generic-receiver test is split across two files on purpose: in one file the callee resolves by an in-file label match and never reaches receiver typing.

python -m pytest tests/test_csharp*.py -q          # 209 passed (0.9.86 without the fix: 1 failed)
python -m pytest tests -q                          # with my other 5 refreshed PRs applied: 3 failed, 7324 passed, 33 skipped; clean 0.9.86 on this machine: the same 3 failed, 7300 passed
python -m ruff check graphify/extractors/engine.py tests/test_csharp_member_calls.py   # All checks passed

The 3 failures (test_absolute_path_lookup_skips_getcwd x2, test_3357_minimal_reproduction_no_config_emits_calls_edge) fail on clean 0.9.86 on this Windows machine too.

🤖 Generated with Claude Code

https://claude.ai/code/session_01B8gwEpjajiWHVW3c9smuKf

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).


Graphify review — findings

This PR addresses C# call-site handling when explicit type arguments are present (e.g., X.M<T>(), Bag<Payload>.Make(), Local<Payload>()). It adds a new helper _csharp_name_without_type_args that strips the type-argument list from generic_name nodes, and updates _extract_generic to use it for callee names and receivers, while also recognizing generic_name as a valid receiver/function node type alongside identifier. The test file adds a new suite of cases covering explicit type arguments on type receivers, typed local receivers, constructed generic type receivers (split across files), unqualified/this generic calls, and a check that type-argument stripping doesn't bypass receiver typing. The changed surface is limited to the C# path in graphify/extractors/engine.py and the corresponding tests in tests/test_csharp_member_calls.py.

No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 650 functions depend on the 255 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: walk_calls() — 1 callers, 16 callees

Verification — 650 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 591 function(s) in the blast radius were not formally verified this run

· 1 more finding(s) on lines outside this diff (see the check run).

@JensD-git

Copy link
Copy Markdown
Contributor

Thank's again. Hope this PR will be released soon.

@JensD-git

Copy link
Copy Markdown
Contributor

How did this pull request backlog come about? Is there anything we can do to help here? It's unusual for completed items to sit here for two weeks.

@rohit-jsfreaky
rohit-jsfreaky force-pushed the fix/csharp-call-site-type-arguments branch from 8750f61 to b0ad6e4 Compare August 25, 2026 13:32
@rohit-jsfreaky

Copy link
Copy Markdown
Contributor Author

Rebased onto v8 (0.9.49) — conflict resolved. It was append-only in tests/test_csharp_member_calls.py: the primary-constructor tests from #2836 and these #2624 tests both land at the end of the file, so both blocks are kept, upstream's first. engine.py rebased untouched.

I also re-checked that this is not already covered by #2911 / #2913, since those mention generic type arguments too. Those walk them in field / property / return / parameter position, which is type-reference resolution; the call-site callee and receiver naming is a separate path. The repro still fails the same way on 0.9.49 — 3 of 8 shapes resolve without this change, 8 of 8 with it.

Full suite on the rebased branch: 12 failed, 4986 passed, 43 skipped — the same 12 as a clean v8 checkout on this Windows machine (fifo / unix-socket / hermes / gemini path tests), none touching this change. All four C# suites pass (132).

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).

Formal verification. No changes could be formally verified in this run.


Graphify review — findings

Fixes dropped C# calls edges when a call site spells explicit type arguments (Registry.Fetch<Payload>(...), Bag<Payload>.Make(...), Local<Payload>(...)), which tree-sitter wraps in a generic_name whose verbatim text (Fetch<Payload>) never matched the bare declaration name. Adds _csharp_name_without_type_args, which returns the bare identifier off a generic_name (falling back to splitting on < for qualified generics like Demo.Bag<Payload>), and routes callee names, Type.M() receivers, and unqualified/this calls through it so type-argument lists are stripped before lookup while receiver typing still applies.

No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 692 functions depend on the 280 functions this change touches.

Health — this change adds coupling hotspots:

  • new: _extract_generic() — 18 callers, 24 callees
  • new: extract_xaml() — 19 callers, 17 callees
  • new: extract_objc() — 27 callers, 9 callees
  • new: extract_js() — 80 callers, 3 callees
  • new: extract_julia() — 17 callers, 7 callees
  • new: extract_cpp() — 27 callers, 3 callees
  • new: extract_vue() — 10 callers, 6 callees
  • new: walk() — 1 callers, 56 callees
  • …and 8 more — each is listed as a finding

Verification — 692 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 632 function(s) in the blast radius were not formally verified this run

Formal verification

Could not verify: Could not verify \_extract\_generic.

The verifier did not have enough to check \_extract\_generic, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: parameter `path` is annotated `Path` — outside the synthesizable primitive/collection set

· 16 more finding(s) on lines outside this diff (see the check run).

@JensD-git

Copy link
Copy Markdown
Contributor

Are there any plausible reasons why this hasn't been merged in weeks? The PR looks fine to me.

@JensD-git

JensD-git commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

I reported #2624. Instead of asking about timing again, here is a measurement, because the two
questions that would actually decide this PR are answerable and nobody had answered them.

1. The defect is still in the shipped release. I ran a minimal reproducer against v8 at
c9f9901, which is exactly release v0.9.55. Eight call sites, five generic, three non-generic
controls:

Case Call site v0.9.55 + this PR
A Registry.Fetch<Payload>("k") — static generic method missing edge
B box.Read<Payload>("k") — instance generic method missing edge
C Registry.Has("k") — control edge edge
D Registry.Pick(item) — control, generic method, no type arg at call site edge edge
E Bag<Payload>.Make("k") — generic receiver missing edge
F Own<Payload>("k") — unqualified missing edge
G this.Own<Payload>("k") — unqualified via this missing edge
H Plain("k") — control, unqualified edge edge

3 of 8 before, 8 of 8 after, controls unchanged. Every target member node already exists, so
nothing is missing from extraction — only the call-site-to-member match fails. Cases F and G are
the two forms named in the first comment on #2624 and were not in the original reproducer
; this
is the first confirmation of them.

2. The patch still applies to the current head. git cherry-pick of pull/2676/head onto
v8 at c9f9901 merges clean — graphify/extractors/engine.py auto-merged, no conflict, no
second rebase needed.

3. The red tests are pre-existing and environmental, not caused by this PR. The rebase note
mentions a failing count, which is the kind of thing that quietly stalls a merge, so I measured
both sides on one machine, one interpreter, Windows, full suite:

failed passed skipped
v8 @ c9f9901, unpatched 17 5383 45
same tree + this PR 17 5388 45

The two failing sets are name-for-name identical (diff of the two FAILED lists is empty), and
passed rises by exactly 5 — the five tests this PR adds. Every one of the 17 is platform-bound:
os.mkfifo / os.symlink unavailable (tests/test_non_regular_files.py, 5), Windows holding a
directory handle so rmdir raises WinError 32 (tests/test_watch.py, 2), and POSIX path,
shebang and install-destination assertions (test_hooks.py, test_install*.py,
test_uninstall_scope.py, test_languages.py, test_merge_chunks_validation.py, 10). None of
them touches extraction. tests/test_csharp_member_calls.py + tests/test_dotnet.py: 89 passed
with the patch.

4. One honest caveat, which I raised in the issue myself. A generic call site whose receiver
name exists in the corpus but is not visible from the calling file now gets an edge where it
previously stayed silent. Measured on a three-file case (a corpus Corp.Internal.TextCodec, a
caller in Corp.App that imports a foreign namespace of the same type name, and a control in the
corpus namespace): unpatched, the non-generic call already produces both the correct edge and
the wrong one; patched, the generic call behaves exactly the same way. So this PR does not
introduce a new failure mode — it makes the generic form as good, and as fallible, as the
non-generic form has always been. Whether that is acceptable is a maintainer call; it is the
corpus-wide name fallback, not something this patch invents.

5. It is now the last gap in this path. v0.9.55 already emits references[generic_arg] for
these very call sites (#2911), and the code comment there states the call-site branch was
deliberately left to a separate change. #2913 and #2836 closed the declaration side. The receiver
table is filled and the type arguments are recorded; only the calls edge for an explicitly
generic call site is still dropped.

Weight in a real estate, ~15,300 C# files across seven roots, mixed .NET Framework and net8,
counted on the syntax tree (not by regex):

  • qualified generic calls (A/B): 272 lost calls edges, counted pairwise and each pattern
    checked against the source — that figure is from the issue and unchanged.
  • generic receiver (E): 23 call sites.
  • unqualified (F): 2159 call sites; via this (G): 628. These two shapes resolve against
    the caller's own class or a base class, so their targets are in-corpus by construction. I have
    not yet measured how many currently resolve, so I am not claiming that as a win — only that the
    shape is common, and it is the shape nothing has addressed so far.

@rohit-jsfreaky

Copy link
Copy Markdown
Contributor Author

Rebased onto 0.9.86. #3406 already strips type arguments from the method name, so this PR now covers only the case still broken there: a call on a constructed generic type (Bag<Payload>.Make()) gets no edge. The fix reuses _csharp_bare_call_name. The other 4 tests stay as regression tests; they pass on 0.9.86. Description updated to match.

@rohit-jsfreaky rohit-jsfreaky changed the title fix(csharp): strip call-site type arguments from generic calls fix(csharp): bind a call on a constructed generic type (Bag<T>.Make()) Oct 12, 2026
@rohit-jsfreaky
rohit-jsfreaky force-pushed the fix/csharp-call-site-type-arguments branch from 5832e82 to c14d2a8 Compare October 15, 2026 16:53
@rohit-jsfreaky
rohit-jsfreaky force-pushed the fix/csharp-call-site-type-arguments branch from c14d2a8 to 6b76340 Compare October 18, 2026 17:56

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.

C#: explicit type arguments at a call site (X.M<T>(...)) drop the calls edge

2 participants