Skip to content

feat(csharp): emit a node per property - #3010

Closed
durmazoguzhan wants to merge 2 commits into
Graphify-Labs:v8from
durmazoguzhan:feat-csharp-member-nodes
Closed

durmazoguzhan wants to merge 2 commits into
Graphify-Labs:v8from
durmazoguzhan:feat-csharp-member-nodes

Conversation

@durmazoguzhan

@durmazoguzhan durmazoguzhan commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3006.

C# is the only language with a class-shaped type layer whose state is missing from the graph. A property produces a references edge to its type and no node of its own:

public class Variant {
    public bool IsShowCategory { get; set; }
    public void Touch() { }
}

Nodes: Variant, .Touch(). IsShowCategory is absent, so nothing in the graph can point at it.

This emits a node per property with a defines edge, the same relation and context="field" the C++ data-member branch uses:

Variant defines IsShowCategory

Following what the tree already does

Checked by running each language rather than reading the configs:

language member relation
C++ data member defines
C struct field defines (in flight, #2971)
Swift computed / observed property function-like member node (#2220)
Swift enum case case_of
Java enum constant case_of
JS/TS class field method when callable
C# field, property nothing

#2971's argument for C is the one that applies here: the struct is C's primary data-modeling construct, so dropping it erased the type layer. Properties are C#'s.

The member node is emitted before the type checks, so it does not depend on what the property is typed as. A primitive and a generic parameter both leave a member behind even though neither produces a type reference. A property stays on defines rather than method: it is state, not a call target.

Properties only, not fields

ids.normalize_id casefolds and strips leading underscores, so _count and Count are the same id — an ordinary backing field and its property. Emitting both handed the node to whichever the parser reached first, which is the private field, and the public member vanished behind it; two case-only siblings produced one node with two identical edges. That was the review finding on the first revision.

Fields are out rather than disambiguated here. The id recipe is the single source of truth three producers have to agree on (#811, #550, #1033, #2614), and a local suffix scheme would diverge from whatever #2779 and #2810 settle on. A field's type reference is untouched, and the property path keeps a seen_ids check since two properties differing only by case are legal and land on one id.

Cost, since it is not small

On a 1457-file .NET service:

before:  9925 nodes, 29547 edges
after:  14683 nodes, 34182 edges     (+4758 nodes / +48%, +4635 edges / +16%)

A DTO-heavy corpus, which is where the ratio comes from. The added nodes are leaves and the hub structure does not move: the top god nodes are unchanged.

What this does not do

A member node on its own does not answer "which code fills this property", because no language in the tree emits a member-level usage edge. That is #3012, filed with the evidence and the open questions, including whether the node set should instead be narrowed to members something touches — which would reverse the order and make this PR the follow-up. Happy to go that way if you prefer.

Tests

tests/test_csharp_member_nodes.py, 9 tests: an auto-property, several properties on one class, a primitive-typed property, a generic-parameter-typed property, a backing field not taking the property's node, a field alone producing no member node while keeping its type reference, property type references surviving (#1591 guard), a property landing on defines while a method stays on method, and case-only sibling properties not duplicating an edge.

$ uv run pytest tests/test_csharp_member_nodes.py -q
9 passed

$ uv run pytest tests/ -q --ignore=tests/test_skillgen.py --ignore=tests/test_falkordb_integration.py
4825 passed, 1 failed

The failure is test_labeling.py::test_label_communities_batches_when_over_batch_size, order dependent and failing identically on a clean v8 checkout here. test_skillgen.py and the two FalkorDB cases also fail on clean v8 in this environment, which is why they are excluded from that run. ruff check clean.

C# was the only language with a class-shaped type layer whose state was missing
from the graph. A field or property produced a `references` edge to its type and
no node of its own, so nothing could point at a member. C++ has emitted a node
per data member with a `defines` edge for a while, Graphify-Labs#2971 is adding the same for C
structs, and Graphify-Labs#2220 gave Swift computed properties nodes. This puts C# on that
line, using the same relation and `context="field"` as the C++ branch.

The member node does not depend on what the member is typed as, so it is emitted
before the type checks: a primitive and a generic parameter both leave a member
behind even though neither produces a type reference. Properties keep landing on
`defines` rather than `method`, since a property is state, not a call target.

Cost on a 1457-file .NET service: 9925 -> 15489 nodes and 29547 -> 34989 edges,
+56% and +18%. It is a DTO-heavy corpus, which is where that ratio comes from.
The added nodes are leaves, so the hub structure is unchanged: the top god nodes
are identical except ProductService moving 259 -> 263 edges.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NCycXc9pjGzovxrZqojPUE

@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.

Worth a look — the grounded gate found no coupling regressions or blocking issues, but 1 advisory finding(s) below merit a look before merge.

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


Graphify review — findings

Emits a graph node per C# field and property (with a defines edge from the class) in _extract_generic, matching the existing C++ data-member behavior. The member node is added before the type-reference checks so primitives and generic-parameter-typed members still get a node, while the existing type-references edges are preserved. Adds tests/test_csharp_member_nodes.py covering auto-properties, multi-name declarations, const members, and the method/property distinction.

Worth a look

  • Duplicate node/edge id collision between member field and same-named property or method — graphify/extractors/engine.py:3711 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 625 functions depend on the 214 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() — 16 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 — 625 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: 565 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).

Review finding: a field and a property that normalize to the same id collided,
dropping one member and hanging a second `defines` edge on the other's node.

It reproduces, and on the pattern that matters rather than an exotic one.
`ids.normalize_id` casefolds and strips leading underscores, so `_count` and
`Count` are one id — the ordinary C# backing field and its property. Emitting
both handed the node to whichever the parser reached first, which is the private
field, so the public member disappeared behind it. `count` and `Count`, legal C#
siblings, produced one node and two identical edges.

Fields are out rather than disambiguated: the id recipe is the single source of
truth three producers have to agree on (Graphify-Labs#811, Graphify-Labs#550, Graphify-Labs#1033, Graphify-Labs#2614), and inventing
a local suffix here would diverge from whatever Graphify-Labs#2779 and Graphify-Labs#2810 settle on. In C#
the property is the state's public identity, so it is the half worth having
first. A field's type reference is untouched.

A `seen_ids` check still guards the property path, since two properties differing
only by case are legal and normalize to one id.

Cost drops with the scope: 9925 -> 14683 nodes and 29547 -> 34182 edges on a
1457-file service, +48% and +16%, down from +56% and +18%.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NCycXc9pjGzovxrZqojPUE
@durmazoguzhan

Copy link
Copy Markdown
Contributor Author

Reproduces, and on the pattern that matters rather than an exotic one. Fixed in b5f62db, and it narrowed the PR.

ids.normalize_id casefolds and strips leading underscores, so an ordinary backing field and its property are one id:

public class Counter { private int _count; public int Count { get; set; } }

Before the fix that produced a single node labelled _count and no Count at all: the private field reached add_node first, add_node returns early on a taken id, and my add_edge ran anyway. Two case-only siblings (count and Count, legal C#) produced one node with two identical defines edges.

So fields are out of this PR rather than disambiguated. The id recipe is the single source of truth three producers have to agree on (#811, #550, #1033, #2614), and inventing a local suffix scheme here would diverge from whatever #2779 and #2810 settle on. In C# the property is the state's public identity, so it is the half worth having first, and a field's type reference is untouched either way. The property path keeps a seen_ids check, since two properties differing only by case are legal and land on one id.

The scope change makes the cost smaller too: 9925 to 14683 nodes and 29547 to 34182 edges, +48% and +16%, down from +56% and +18%.

Tests are rewritten around it, 9 in total, including the backing-field case asserting the property wins and there is exactly one edge, a field alone producing no member node while keeping its type reference, and case-only sibling properties not duplicating an edge.

$ uv run pytest tests/test_csharp_member_nodes.py -q
9 passed

$ uv run pytest tests/ -q --ignore=tests/test_skillgen.py --ignore=tests/test_falkordb_integration.py
4825 passed, 1 failed

That one is test_labeling.py::test_label_communities_batches_when_over_batch_size, order dependent and failing the same way on a clean v8 checkout here. test_skillgen.py and the FalkorDB cases also fail on clean v8 in this environment, which is why they are out of that run. ruff check clean.

Separately: I split the issue this PR came from, since it had two problems in it and made the reference awkward. #3006 is now only this gap, and the usage half moved to #3012.

@durmazoguzhan durmazoguzhan changed the title feat(csharp): emit a node per field and property feat(csharp): emit a node per property Aug 24, 2026

@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

Emits a graph node per C# property in _extract_generic, with a defines edge (context field) from the owning class, guarded against duplicate ids via seen_ids. Fields stay excluded because id normalization collapses _count/Count, so a backing field would otherwise shadow the public member. Adds tests/test_csharp_member_nodes.py covering auto/primitive/generic-typed properties, backing-field precedence, case-only siblings, and retained type references.

No blocking issues surfaced. 2 lower-confidence candidates did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 626 functions depend on the 215 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() — 16 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 — 626 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: 566 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).

@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.49 via authorship-preserving cherry-pick so you keep contributor-graph credit. Thanks @durmazoguzhan! Release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.49

@safishamsi safishamsi closed this Aug 24, 2026
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#: properties are not nodes, so nothing in the graph can point at a member

2 participants