From e43dab7e1161995ae37279bbe36ff7efa755b434 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 1 Jul 2026 12:15:36 +0200 Subject: [PATCH] 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 --- .../CSharp/Transforms/TransformContext.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/TransformContext.cs b/ICSharpCode.Decompiler/CSharp/Transforms/TransformContext.cs index 5e6ee99c6..31dd4f263 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/TransformContext.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/TransformContext.cs @@ -81,7 +81,22 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms [DebuggerStepThrough] 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")]