Repository navigation
fix(razor): extract methods from @functions blocks, not just @code - #3908
rajatnagda45 wants to merge 1 commit into
Conversation
@code is the Blazor (.razor) spelling of an embedded C# member block; @functions is the equivalent Razor Pages / MVC (.cshtml) spelling. Both compile to class members, and this extractor serves both file types, but only @code was matched. A .cshtml page that declared its methods inside an @functions block lost every one of them. Match @functions alongside @code in the block regex; the existing brace-balanced body scan and method extraction are reused unchanged.
|
Thanks for the pull request, @rajatnagda45. 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.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify review — findings
Extends the Razor extractor's method-block detection to recognise @functions blocks alongside @code, so methods declared in .cshtml (Razor Pages/MVC) files are now extracted as class members instead of being dropped. Adds test_razor_finds_functions_block_methods covering the .cshtml @functions spelling.
No blocking issues surfaced.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 606 functions depend on the 600 functions this change touches.
Health — this change adds coupling hotspots:
- new:
extract_razor()— 15 callers, 4 callees
Verification — 606 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: 606 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
2 of 304 test file(s) selected (1%) via static blast radius.
tests/test_dotnet.py— impacttests/test_languages.py— impact, changed-test
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.
· 1 grounded finding(s) anchored inline below.
| @@ -9,7 +9,7 @@ | |||
|
|
|||
|
|
|||
| def extract_razor(path: Path) -> dict: | |||
There was a problem hiding this comment.
extract_razor()
15 callers depend on it (afferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
…ction HTML node-info field fix (#3918), Kotlin annotated-inferred-property crash (#3915/#3899), SQL DDL-before-DO (#3900), Razor @functions (#3908), Blade @extends (#3907), and imported-module resolution (#3898). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Shipped in v0.9.72 (now on PyPI) via an authorship-preserving cherry-pick, so your commit keeps contributor-graph credit. Thanks @rajatnagda45! Razor @functions blocks are extracted, not just @code. |
What does this PR do?
@codeis the Blazor (.razor) spelling of an embedded C# member block;@functionsis the equivalent Razor Pages / MVC (.cshtml) spelling. Both compile to class members, and this extractor serves both file types (.razorand.cshtmlroute here), but only@codewas matched. A.cshtmlpage that declares its methods inside an@functions { }block lost every one of them — the methods simply weren't nodes.Before:
SquareandGreetabsent. After: both extracted, exactly as their@codeequivalents already were.Type of change
Verification & Invariants
Invariant protected: extraction completeness — a real, source-backed member block must not be dropped just because it uses the other legal spelling. The fix is a single alternation in the block-detecting regex (
@(?:code|functions)\s*\{); the existing brace-balanced body scan and method extraction are reused unchanged, so there is no new heuristic and no determinism/ambient-state impact.@codebehaviour).How was this tested?
Graphify-specific checklist