Repository navigation
fix(csharp): credit calls in accessors, indexers and operators to that member - #5056
rohit-jsfreaky wants to merge 1 commit into
Conversation
…t member A C# property's accessor bodies, an indexer and a user-defined operator or conversion were never walked, so every call made inside them was lost. On Dapper, AutoMapper and Newtonsoft.Json (Roslyn answer key) that is 144 call links made from property/indexer accessors and 186 from conversion operators, none found. - A property's `get`/`set` bodies and an expression body (`int P => F();`) are walked with the existing property node as the caller. An auto-accessor has no body and an initializer runs in the constructor, so neither adds calls. Only the declaration that owns the property node is walked: when the id is already another member's (an explicit `IFoo.Name` property spelled like a method `Name()`), its calls are dropped instead of being credited to that member. - An indexer is a `this[]` node beside the properties (`defines`, context `field`), id `_make_id(type_id, "this")`, salted per signature (including an explicit interface) and away from a member spelled `This`. - An operator or conversion is a `.operator +()` / `.operator int()` node owned through `method`; its id always carries a hash of the signature, since several conversions share one parameter list. - A property/indexer counts as owned by its type for caller lookups (in-file unqualified calls, `this.`/`base.` member calls, the partial-type own-type preference), like a method. It is never a call target by name, and `operator` is kept out of the member-call index. - No existing node id moves (checked on all three projects). - AST cache schema 40. Calls TO properties, indexers and operators are not linked: in these projects they are about 3,500 property get/set links (more than half to auto-properties), 27 indexer and 60 conversion links, against 0 user-defined binary operator calls. Linking them needs member-access typing and a decision on the relation, so it is left out. Co-Authored-By: Claude <[email protected]>
|
Thanks for the pull request, @rohit-jsfreaky. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; formal verification proved 0 of 4 changed function(s) (4 not verified).
Formal verification. PR-changed functions: 0/4 verified (0 proven, 0 may-equivalent, 0 distinguished) · 4 not verified (3 vacuous, 1 unsupported).
Not verified on this run: \_resolve\_csharp\_member\_calls (vacuous: never exercised), extract (vacuous: never exercised), \_csharp\_pre\_scan\_name\_collisions (vacuous: never exercised), \_extract\_generic (unsupported).
Graphify review — findings
Adds C# property and indexer accessor bodies (including expression bodies) to the call walk, with the member as the caller and owned by its type for unqualified, this./base. and partial-type lookups, like a method. Indexers become this[] nodes with a signature-salted id kept distinct from a member spelled This, and user-defined operators and conversions become .operator +() / .operator int() nodes whose ids hash the signature, since several conversions share one parameter list. These members are never call targets by name, existing ids don't move, and the AST cache schema goes to 40, so cached extractions re-run.
Review partial — this diff was larger than one review pass covers, so later files were not reviewed; some findings may be missing.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 5207 functions depend on the 899 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
walk()— 1 callers, 82 callees
Verification — 5207 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: 4518 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
526 of 526 test file(s) selected (100%) via static blast radius.
Escalated to a full run for safety (
noncode-change,uncovered-code) — the selection is not trustworthy on its own (see below). CI should run the whole suite.
tests/pi.test.ts— full-run-safetytests/test_4874_jvm_resolution.py— impact, full-run-safetytests/test_4909_reference_binding_scale.py— full-run-safetytests/test_4978_reconcile_cost.py— impact, full-run-safetytests/test_4992_ts_import_types.py— impact, full-run-safetytests/test_affected_cli.py— full-run-safetytests/test_affected_defines.py— full-run-safetytests/test_affected_member_seed.py— full-run-safetytests/test_affected_overrides.py— impact, full-run-safetytests/test_affected_path_file_node.py— full-run-safetytests/test_affected_seed_reference_forms.py— full-run-safetytests/test_agents_platform.py— full-run-safetytests/test_alias_folding.py— impact, full-run-safetytests/test_analyze.py— impact, full-run-safetytests/test_anthropic_custom_endpoint.py— full-run-safetytests/test_antigravity_install.py— full-run-safetytests/test_apm_fallback_version.py— full-run-safetytests/test_architecture_doc.py— full-run-safetytests/test_astro_extraction.py— impact, full-run-safetytests/test_astro_import_ids.py— impact, full-run-safetytests/test_atomic_canvas_export.py— full-run-safetytests/test_atomic_version_stamp.py— full-run-safetytests/test_atomic_writes.py— full-run-safetytests/test_backend_env_isolation.py— full-run-safetytests/test_backend_extras.py— full-run-safetytests/test_backend_opt_in.py— full-run-safetytests/test_benchmark.py— full-run-safetytests/test_benchmark_raw_graph.py— full-run-safetytests/test_benchmark_real_query.py— full-run-safetytests/test_binary_media_words.py— impact, full-run-safetytests/test_blade_extractor.py— impact, full-run-safetytests/test_build.py— impact, full-run-safetytests/test_build_located_semantic_identity.py— impact, full-run-safetytests/test_build_merge_dedup_scope.py— impact, full-run-safetytests/test_build_merge_ghost_fold_4955.py— impact, full-run-safetytests/test_build_merge_hyperedges_and_prune.py— impact, full-run-safetytests/test_build_merge_shrink_guard.py— impact, full-run-safetytests/test_builtin_global_type_refs.py— impact, full-run-safetytests/test_c_include_resolution.py— impact, full-run-safetytests/test_cache.py— impact, full-run-safetytests/test_cache_long_paths.py— impact, full-run-safetytests/test_cache_stale_import_target.py— impact, full-run-safetytests/test_cache_windows_case_4925.py— impact, full-run-safetytests/test_callflow_html.py— full-run-safetytests/test_cargo_introspect.py— full-run-safetytests/test_cargo_missing_manifest.py— full-run-safetytests/test_carried_hyperedge_remap.py— impact, full-run-safetytests/test_case_only_decl_ids_4904.py— impact, full-run-safetytests/test_case_sensitive_resolution.py— impact, full-run-safetytests/test_charmap_encoding.py— impact, full-run-safety- … and 476 more
non-code file(s) changed (
ARCHITECTURE.md) → running the full suite for safety (a code graph can't see config/fixture/data deps)
changed code file(s) with no mapped test (
ARCHITECTURE.md) — a coverage gap or a missing link — running the full suite rather than only the selected tests
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Formal verification
Could not verify: Could not verify \_resolve\_csharp\_member\_calls.
The verifier did not have enough to check \_resolve\_csharp\_member\_calls, 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: no capturable inputs from the test suite; property tier: non-vacuity: domain too small (only 1 distinct inputs exercised, need 3) — 'no divergence' would be near-vacuous
Could not verify: Could not verify extract.
The verifier did not have enough to check extract, 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: no capturable inputs from the test suite; property tier: not verifiable: all 90 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly TypeError — names the real obstacle, not a sampling gap)
Could not verify: Could not verify \_csharp\_pre\_scan\_name\_collisions.
The verifier did not have enough to check \_csharp\_pre\_scan\_name\_collisions, 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: no capturable inputs from the test suite; property tier: not verifiable: all 253 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly AttributeError — names the real obstacle, not a sampling gap)
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: no capturable inputs from the test suite; property tier: parameter `config` is annotated `LanguageConfig` — outside the synthesizable primitive/collection set
· 1 grounded finding(s) anchored inline below.
| csharp_method_scopes[id(body)] = (decl, class_nid) | ||
| function_bodies.append((member_nid, body)) | ||
|
|
||
| def walk(node, parent_class_nid: str | None = None) -> None: |
There was a problem hiding this comment.
walk()
fans out to 82 callees (efferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
#5058, #5060, #5062, #5054 and #5056 each change per-file Solidity or C# extraction output and each bumped _AST_CACHE_SCHEMA to 40 on their own. Landed together in one release window they share a single bump; this folds their descriptions into one chained schema-40 comment over the prior 39 so a warm cache re-runs the affected Solidity and C# extractions exactly once. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed on |
Closes #5055
What does this PR do?
Calls made inside C# getters, setters, indexers and operators are now credited to that member:
int Sum => base.Twice();). The calls are credited to the property node._make_id(type, "this"), salted per signature. Explicit-interface indexers (IFoo.this[...]) are kept apart._make_id(type, "operator", <signature hash>).Calls inside these bodies resolve the same way as calls inside methods: own type first, typed receivers across files,
base.calls, and partial types split across files.An accessor body is walked only when its own declaration created the node. Without that guard, an explicit-interface property
IRun.Nextshared the id of a methodNext(), and its calls turned into a self-loop on the method. There is a test for it.On the three projects below, no existing node id changed or disappeared. All 151 new nodes are indexers or operators. AST cache schema 39 -> 40. #5052 and #5054 also bump it to 40, so whichever lands second takes the next number.
Diff:
extractors/engine.py+113 / -6,extract.py+19 / -1, an ARCHITECTURE.md note, 9 tests in the newtests/test_csharp_member_nodes.py.Numbers
Newtonsoft.Json, Dapper and AutoMapper, compared with Roslyn (same harness as #5003):
callsedgesNo kind drops. Of the 6 new "wrong" edges:
[GeneratedRegex]partial methods. The harness calls them external only because their bodies are source-generated.GetType()binds to Newtonsoft's ownJToken.GetTypeinstead ofobject.GetType(), the same mistake v8 already makes inside methods.Not in this PR
obj.Name,obj.Name = x): Roslyn finds 3,488 of these on these projects, about half of them on auto-properties. That is data access rather than calls. It needs member-access typing and a choice of relation, so it belongs in its own PR. (feat(csharp): link a property/field read to the member it reads #3120 tried reads only. It records writes as reads, and it no longer applies to v8.)Type of change
Verification & Invariants
Invariants:
Existing node ids never change.
A member's body is walked only when that member's own declaration created the node, so calls are never credited to a different member that shares the id.
Read the CONTRIBUTING.md guide.
Reproduced the issue and identified the invariant.
Made the smallest fix necessary.
Added a regression test (if bug fix) or isolated boundary test.
Kept the PR description synchronized with the final implementation.
Documented any limitations / unsupported cases explicitly.
How was this tested?
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (Not needed: no skill fragments changed.)🤖 Generated with Claude Code