fix(razor): resolve @inject types across files - #3188
Conversation
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 2 advisory finding(s) below merit a look before merge.
Graphify review — findings
Extends .NET cross-file type resolution to treat .razor and .cshtml files as C# sources, so their inherits/implements/references edges get re-pointed and rewired to real definitions instead of dangling on shadow stubs. Reworks Razor @using to emit structured imports edges carrying using_kind/alias/target_fqn metadata (namespace, static, or alias forms), and changes @inject to produce a sourceless references node keyed by the injected type's ref token so it resolves to the project-defined service.
Worth a look
- @using regex now matches directive lines that are not namespace imports (e.g. @using var x = ...) —
graphify/extractors/razor.py:41· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- Razor using blocks are misclassified as namespace imports —
graphify/extractors/razor.py:41· 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 — 1732 functions depend on the 308 functions this change touches.
Health — this change adds coupling hotspots:
- new:
extract()— 504 callers, 42 callees - new:
_rebuild_code()— 98 callers, 50 callees - new:
extract_xaml()— 19 callers, 17 callees - new:
extract_js()— 85 callers, 3 callees - new:
dispatch_command()— 2 callers, 122 callees - new:
_get_extractor()— 26 callers, 6 callees - new:
run_pipeline()— 8 callers, 13 callees - new:
collect_files()— 17 callers, 6 callees - …and 25 more — each is listed as a finding
Verification — 1732 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: 1575 function(s) in the blast radius were not formally verified this run
· 1 grounded finding(s) anchored inline below; 32 more finding(s) on lines outside this diff (see the check run).
| from graphify.security import sanitize_metadata | ||
|
|
||
|
|
||
| def extract_razor(path: Path) -> dict: |
There was a problem hiding this comment.
extract_razor()
14 callers depend on it (afferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
|
Shipped in v0.9.52 via authorship-preserving cherry-pick. Thanks @hopstreax! This partially addresses #3187 (cross-file @Inject now resolves); a bare @Inject of a file-scoped-namespace type still dangles, so #3187 stays open for that follow-up. Release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.52 |
Summary
Fixes #3187.
Blazor
.razorand.cshtml@injectdirectives were previously emitted as file-localimportsstubs and never reached the C# cross-file type resolver. This caused each Razor file to create a duplicate node for the same project-defined service.This change:
@injectas areferencesedge with C# resolver metadata.@injectstubs without a Razor-localsource_file..razorand.cshtmlfiles to participate in the existing C# type-resolution pass.@usingas animportsedge while adding the metadata required for namespace scoping.@using, and qualified namespaces.Validation
tests/test_dotnet.py tests/test_csharp_type_resolution.py— 84 passedtests/test_languages.py -k "razor or csharp"— 20 passedtests/test_extract.py— 201 passed, 1 known Windows MAX_PATH failuregit diff --check— cleanThe known
tests/test_extract.pyfailure is Windows-specific (MAX_PATH) and unrelated to this change.