Blazor: .razor files are parsed as raw C#, so members of `@code { }` are lost and most components report parse_unusable (0.12.1)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- csharp
调研方向
Start by reading the .razor parsing path and the existing .razor.cs handling, then compare their graph output using the provided Pages/Items.razor example. Check get_file_outline and parse status after extracting component members; done means markup no longer breaks parsing and the @code members appear in the graph. The requested support for directives and markup call edges extends the scope.
由索引模型根据 Issue 内容生成。
描述
Version: 0.12.1 (also 0.11.0), macOS arm64, index_repository mode full or fast.
Since #1824, .razor files are discovered and @page emits a Route node. However, the whole file appears to be handed to the C# grammar as it is. Razor markup (<h1>, @if (...) { <p>…</p> }, @onclick="...") and directives are not C#. Inside @code { }, members that are not valid as statements (properties, attributed members) produce errors too. The result:
- In a real Blazor app, 108 of ~150
.razorfiles come backparse_unusableand 43 moreparse_partial. - The component's methods, fields and properties are mostly missing from the graph, so
search_graph/trace_pathcan't see the C# that most Blazor apps keep in@code.
Repro
Pages/Items.razor:
@page "/items"
@implements IDisposable
@inject NavigationManager Nav
<h1>Items</h1>
@if (error is not null)
{
<p class="error">@error</p>
}
@foreach (var item in items)
{
<button @onclick="() => Select(item)">@item</button>
}
@code {
[Parameter, SupplyParameterFromQuery(Name = "q")] public string? Query { get; set; }
[Parameter] public int? Page { get; set; }
List<string> items = [];
string? error;
protected override async Task OnInitializedAsync()
{
items = await Load();
}
Task<List<string>> Load() => Task.FromResult(new List<string> { "a", "b" });
void Select(string item) => Nav.NavigateTo($"/items/{item}");
public void Dispose() { }
}
get_file_outline for Pages/Items.razor:
/items Route -
@inject Function 2-32
parse_partial error ranges: 1-1,3-3,5-6,6-6,8-8,9-9,10-10,11-11,12-12,12-27.
Control: the same @code body as public partial class Items { … } in Pages/Items.cs gives class Items, the fields Query, Page, items and error, and the methods OnInitializedAsync, Load, Select and Dispose. (The two properties are labelled Field there, but they are found.)
A component with only simple members (fields and methods, no markup, no properties) parses almost cleanly. Adding two properties in a row, or any markup before @code, is enough to lose members.
Expected
For a .razor file:
- Take the bodies of
@code { … }(and@functions { … }) and parse them as members of a class named after the file (Items, namespace from folder or@namespace), the same as a.razor.cscode-behind partial class. - Use
@inherits,@implements,@inject Type Nameand@attributeas the class's base type, interfaces, injected members and attributes. - Skip the markup, or at least don't let it break the
@codeparse. Calls from markup such as@onclick="() => Select(item)"or@Method()would be a bonus as CALLS edges from the component.
Related: #1667 / #1824 (discovery and @page routes), #2229.
- 主要语言
- C
- 星标
- 45.8k
- 派生
- 3.8k
- 平均合并
- 2 天 18 小时
- 30 天内合并 PR
- 108
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
DeusData/codebase-memory-mcp 的其他 Issue
-
bug ux/behavior
难度 2/5 1-3 小时 新手友好度 70/100
DeusData/codebase-memory-mcp#3191 ·
维护者通常 1 天内回复
-
documentation enhancement parsing/quality ux/behavior
难度 1/5 1-3 小时 新手友好度 82/100
DeusData/codebase-memory-mcp#3131 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
hook-augment: the five-row cap keeps the first five search_graph rows, so variables and modules displace function definitions (v0.12.1)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug editor/integration parsing/quality ux/behavior
难度 2/5 1-3 小时 新手友好度 75/100
DeusData/codebase-memory-mcp#3062 · 2 条评论 ·
维护者通常 1 天内回复
-
bug documentation editor/integration parsing/quality
难度 2/5 1-3 小时 新手友好度 75/100
DeusData/codebase-memory-mcp#3050 · 1 条评论 ·
维护者通常 1 天内回复
-
editor/integration parsing/quality
难度 2/5 1-3 小时 新手友好度 68/100
DeusData/codebase-memory-mcp#2286 ·
维护者通常 1 天内回复
查看 DeusData/codebase-memory-mcp 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
NVIDIA/open-gpu-kernel-modules#1635 ·
维护者通常 1 天内回复
-
iOS: the "Edit controls" button never hides, even with a controller connected, and covers the game未关闭game: 010065A014024000 ios
难度 2/5 1-3 小时 新手友好度 76/100
seedds/nxnative#3714 · 1 条评论 ·
维护者通常 2 天内回复