Browse Source

Record candidates for the C# step that hits the step limit

When the step limit falls on a C# transform step, Stepper.Step records the node
as LimitReachedStep but throws before TransformContext can attach the node's
highlight candidates, so the 'show state before' view had only the bare modified
node to resolve against -- and nothing if that node renders no text of its own.
The IL path already records its candidates before the throw; mirror that on the
C# side by attaching the candidates to the limit-reached node in the catch, then
re-throwing so the pipeline still halts.

Assisted-by: Claude:claude-opus-4-8:Claude Code
pull/3847/head
Siegfried Pammer 7 days ago committed by Siegfried Pammer
parent
commit
e43dab7e11
  1. 17
      ICSharpCode.Decompiler/CSharp/Transforms/TransformContext.cs

17
ICSharpCode.Decompiler/CSharp/Transforms/TransformContext.cs

@ -81,7 +81,22 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
[DebuggerStepThrough] [DebuggerStepThrough]
internal void Step(string description, AstNode? near = null) internal void Step(string description, AstNode? near = null)
{ {
TrackModifiedNode(Stepper.Step(description, modifiedNode: near), near); Stepper.Node stepNode;
try
{
stepNode = Stepper.Step(description, modifiedNode: near);
}
catch (StepLimitReachedException)
{
// The limit fell on this step: Stepper recorded it as LimitReachedStep but threw
// before we could attach the node candidates. Attach them to the limit-reached node
// (the tree is still in its pre-mutation state) so the "show state before" view can
// locate the change, mirroring how the IL path records candidates before its throw.
if (Stepper.LimitReachedStep is { } limitStep)
TrackModifiedNode(limitStep, near);
throw;
}
TrackModifiedNode(stepNode, near);
} }
[Conditional("STEP")] [Conditional("STEP")]

Loading…
Cancel
Save