StateMachineHoistedLocalScopes rows are not aligned with the hoisted slots
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从第 330 行的 PortablePdbWriter.BuildStateMachineHoistedLocalScopes 开始,然后检查第 186-192 行附近的调用方,以及调试器如何从状态机字段名称中解析 slot 编号。重现 MixedAsync 示例,并将生成的行与最高 slot 进行比较;完成的标准是行按 slot 对齐,在需要时包含占位符,并且超出当前行数的 hoisted locals 仍然可见。
由索引模型根据 Issue 内容生成。
描述
Summary
StateMachineHoistedLocalScopes is indexed by slot number: a debugger parses N out of a state machine field name (<name>5__N, <>8__N) and reads row N-1 of the blob. PortablePdbWriter.BuildStateMachineHoistedLocalScopes (line 330) instead emits one row per surviving ILVariable that has a StateMachineField, ordered by field token, and gives every row the extent (0, CodeSize). That sequence has no relation to the slot numbering, so rows are misaligned, and where it is shorter than the highest slot the hoisted locals above the row count are dropped by the expression evaluator.
Reproduction
public static async Task<int> MixedAsync(IEnumerable<int> source)
{
List<int> chunks = new List<int>();
foreach (int value in source)
chunks.Add(value);
await Task.Yield();
int total = 0;
try
{
foreach (int chunk in chunks)
{
total += chunk;
await Task.Yield();
}
}
catch (InvalidOperationException e)
{
Console.WriteLine(e.Message);
}
return total;
}
State machine fields of <MixedAsync>d__0 (slots 1-7):
<>1__state, <>t__builder, source, <chunks>5__1, <total>5__2, <>s__3,
<value>5__4, <>s__5, <chunk>5__6, <e>5__7, <>u__1
Blob rows for <MixedAsync>d__0.MoveNext, start+length:
compiler: 0+24e, 0+24e, 0+0, 3c+25, 0+0, 124+8c, 1e8+1f
ILSpy: 0+24e, 0+24e, 0+24e, 0+24e, 0+24e, 0+24e, 0+24e
The compiler emits exactly one row per slot, in slot order, with an empty 0+0 placeholder for the synthesized <>s__N slots and the real live range for each user local. ILSpy's rows happen to number seven here, but they enumerate a different set (the hoisted parameter source is included, the <>s__N slots are not), so row N-1 does not describe slot N.
The counts diverge on real code: checking the PDB ILSpy generates against the highest user-visible slot in the binary reports a shortfall in 227 state machines of Newtonsoft.Json 13.0.4 and 2 of Microsoft.Extensions.Http 10.0.11. A shortfall means the hoisted locals whose slot exceeds the row count disappear from the Locals window entirely.
Note
#1230 lists StateMachineHoistedLocalScopes as unimplemented. It is emitted (PortablePdbWriter.cs lines 186-192), just not in the shape a consumer reads.
Posted by an AI agent (Claude) on Siegfried's behalf.
- 主要语言
- C#
- 星标
- 27.1k
- 派生
- 3.8k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 44
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
icsharpcode/ILSpy 的其他 Issue
-
External UI
难度 1/5 1-3 小时 新手友好度 75/100
icsharpcode/ILSpy#4284 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
icsharpcode/ILSpy#4357 ·
维护者通常 1 天内回复
-
Misdecompilation of a lazy initialization pattern可能已有人在做 @siegfriedpammer 于 5 天前认领。 未关闭Bug Decompiler
难度 4/5 3-5 天 新手友好度 20/100
icsharpcode/ILSpy#4349 ·
维护者通常 1 天内回复
-
Bug
难度 4/5 3-5 天 新手友好度 45/100
icsharpcode/ILSpy#4343 ·
维护者通常 1 天内回复
-
AI
难度 4/5 1-2 天 新手友好度 55/100
icsharpcode/ILSpy#4300 ·
维护者通常 1 天内回复
查看 icsharpcode/ILSpy 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
umbraco/Umbraco.Automate#612 ·
维护者通常 1 天内回复
-
崩溃日志只按 CRLF 分行未关闭
难度 2/5 1-3 小时 新手友好度 72/100
PCL-Community/PCL-CE#3872 ·
维护者通常 1 天内回复
-
type:task ux
难度 2/5 1-3 小时 新手友好度 72/100
elsa-workflows/elsa-foundation#5253 ·
维护者通常 1 天内回复