mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
DebugInfoGenerator asserted that every local variable's decompiled type is equivalent to the metadata local-signature type at its slot. That holds at IL-read time but not afterwards: variable splitting gives one slot several typed variables, pinned-region locals are modeled as pointers (int* vs int& pinned), and generic-context type-parameter identity differs. The assertion therefore aborted PDB generation (Debug builds) for ordinary inputs such as any method with a fixed statement. The type is never written to the PDB - only the slot index and name are - so the mismatch cannot affect the debugging experience. The slot index, the only emitted value, is correct by construction: it is the IL ldloc/stloc operand, sourced from the signature slot when the variable is created and copied verbatim by SplitVariables; it is never reassigned. Keep only the index-bound check and document why the type is not verified. Assisted-by: Claude:claude-opus-4-8:Claude Codepull/3832/head
4 changed files with 66 additions and 1 deletions
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
// A simple pinned pointer (fixed statement). The metadata local signature types the slot as |
||||
// `int32& pinned`, but the decompiler models a pinned-region local as a pointer (`int*`). The two |
||||
// never match, yet the slot index is faithful to the IL ldloc/stloc operand, so PDB generation |
||||
// must not assert on the type difference. Regression fixture for that assertion. |
||||
.assembly extern System.Runtime { } |
||||
.assembly PinnedLocalSlot { } |
||||
.module PinnedLocalSlot.dll |
||||
|
||||
.class public auto ansi beforefieldinit C extends [System.Runtime]System.Object |
||||
{ |
||||
.method public hidebysig instance int32 M(int32[] a) cil managed |
||||
{ |
||||
.maxstack 2 |
||||
.locals ( [0] int32& pinned p ) |
||||
ldarg.1 |
||||
ldc.i4.0 |
||||
ldelema [System.Runtime]System.Int32 |
||||
stloc.0 |
||||
ldloc.0 |
||||
ldind.i4 |
||||
ldc.i4.0 |
||||
conv.u |
||||
stloc.0 |
||||
ret |
||||
} |
||||
|
||||
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed |
||||
{ |
||||
.maxstack 1 |
||||
ldarg.0 |
||||
call instance void [System.Runtime]System.Object::.ctor() |
||||
ret |
||||
} |
||||
} |
||||
Loading…
Reference in new issue