Add type-aware cross-file resolver for C##355
Open
Esderal wants to merge 1 commit intosafishamsi:v4from
Open
Conversation
Builds a global type registry (classes, interfaces, structs, records with methods, fields, properties, and base types) from all .cs files, then re-walks each method body with a type-tracking scope to resolve call receivers through fields, properties, parameters, locals, this/base, and inheritance chains. Respects using directives for namespace-scoped disambiguation. Emits calls and instantiates edges for cross-file resolutions only; same-file calls remain with the per-file extractor to avoid duplication. On a 112-file C# corpus this lifts cross-file edges from 0 to ~1445 (1028 calls + 417 instantiates) and produces god-node rankings that match human intuition about subsystem hubs. Known limitations (documented in comments): - Chained calls (.A().B()) needs return-type tracking - Extension methods needs using-static + this-parameter detection - Generic type arguments collapsed to base type name - Overloads: last declaration wins on name collisions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds a global type registry (classes, interfaces, structs, records with
methods, fields, properties, and base types) from all .cs files, then
re-walks each method body with a type-tracking scope to resolve call
receivers through fields, properties, parameters, locals, this/base, and
inheritance chains. Respects using directives for namespace-scoped
disambiguation. Emits calls and instantiates edges for cross-file
resolutions only; same-file calls remain with the per-file extractor to
avoid duplication.
On a 112-file C# corpus this lifts cross-file edges from 0 to ~1445
(1028 calls + 417 instantiates) and produces god-node rankings that
match human intuition about subsystem hubs.
Known limitations (documented in comments):
Open to feedback on:
Whether instantiates is the right relation name, or if the project prefers creates / constructs
Whether same-file filtering should be opt-out behind a flag (currently always on — rationale: the per-file extractor already captures same-file calls, so emitting them again would duplicate edges)
Placement — I put the new code next to _resolve_cross_file_imports since it plays the same role for C#; happy to move it to a separate module if you'd prefer
The _CS_NOISE concept from the earlier naive version is gone entirely in this patch — type resolution replaces name-based filtering. If you'd like me to add a safety net list anyway, let me know.
First open-source PR for me, so please be blunt about anything that doesn't fit the project's style — I'd rather fix it than have it linger.