Skip to content

feat(extract): extend extract_razor() with MVC/CSHTML view patterns#1085

Open
adrianabadin wants to merge 1 commit into
safishamsi:v8from
adrianabadin:feat/cshtml-mvc-razor-extraction
Open

feat(extract): extend extract_razor() with MVC/CSHTML view patterns#1085
adrianabadin wants to merge 1 commit into
safishamsi:v8from
adrianabadin:feat/cshtml-mvc-razor-extraction

Conversation

@adrianabadin
Copy link
Copy Markdown

Summary

  • Extends extract_razor() in graphify/extract.py with ASP.NET MVC Razor view patterns that were missing from the existing Blazor-focused implementation
  • Adds a tests/fixtures/sample.cshtml fixture covering all new patterns
  • Adds 11 new tests to test_dotnet.py (26/26 pass)
  • Adds Razor/CSHTML guidance to the skill-windows.md subagent prompt

New edge types extracted from .cshtml files

Pattern Relation
Layout = ~/Views/Shared/_Layout.cshtml extends
Html.Partial / PartialAsync / RenderPartial includes
Component.InvokeAsync(Name) invokes_component
@section Name defines_section
@RenderSection / @RenderSectionAsync renders_section
asp-controller + asp-action (proximity-correlated) navigates_to
asp-page=... links_to_page
<form method=post asp-action=...> submits_post_to / submits_get_to
Non-standard elements with asp-* attributes uses_taghelper

Motivation

.cshtml files were already in CODE_EXTENSIONS and routed to extract_razor(), but the function only handled Blazor patterns (@using, @inject, @inherits, @page, PascalCase components, @code methods). ASP.NET MVC views use a different set of constructs — layout inheritance, partial views, ViewComponents, Tag Helpers, form submissions — that produced empty graphs for MVC projects.

Validated on a real ASP.NET MVC project (42 .cshtml files): 112 nodes and 150 edges extracted, 0 errors.

Test plan

  • All existing tests pass: python -m pytest tests/test_dotnet.py → 26 passed
  • New fixture sample.cshtml covers all 9 new edge types
  • test_cshtml_missing_file verifies error handling is consistent with existing .razor behavior

🤖 Generated with Claude Code

Adds support for Razor MVC view-specific constructs that were missing
from the Blazor-focused extract_razor() implementation:

- Layout = ... → extends edge
- Html.Partial / PartialAsync / RenderPartial / RenderPartialAsync → includes edge
- Component.InvokeAsync(Name) → invokes_component edge
- @section Name → defines_section edge
- @RenderSection / @RenderSectionAsync → renders_section edge
- asp-controller + asp-action correlation (within 3-line proximity) → navigates_to edge
- asp-page → links_to_page edge
- <form method=post asp-action=...> → submits_post_to / submits_get_to edge
- Non-standard HTML elements with asp-* attrs → uses_taghelper edge (TagHelper convention)

Also adds:
- tests/fixtures/sample.cshtml: MVC Razor view fixture covering all new patterns
- 11 new tests in test_dotnet.py for .cshtml extraction
- Razor/CSHTML guidance in skill-windows.md subagent prompt

All 26 tests in test_dotnet.py pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
adrianabadin added a commit to adrianabadin/memory-context that referenced this pull request Jun 2, 2026
Temporarily points setup.mjs and bootstrap.mjs at the fork
adrianabadin/graphify feat/cshtml-mvc-razor-extraction, which extends
extract_razor() with MVC CSHTML patterns (Layout, Html.Partial,
asp-controller/action, form submissions, TagHelpers).

PR submitted upstream: safishamsi/graphify#1085.
Revert once the PR is merged and a new version is on PyPI.

Also updates README: documents fork dependency with revert instructions,
corrects graphifyy attribution (obra to safishamsi), adds PR link.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant