Table of Contents

Class ReduceNestingTransform

Namespace
ICSharpCode.Decompiler.IL
Assembly
ICSharpCode.Decompiler.dll

Improves code quality by duplicating keyword exits to reduce nesting and restoring IL order.

public class ReduceNestingTransform : IILTransform
Inheritance
ReduceNestingTransform
Implements
Inherited Members

Remarks

ConditionDetection and DetectSwitchBody both have aggressive inlining policies for else blocks and default cases respectively. This can lead to excessive indentation when the entire rest of the method/loop is included in the else block/default case. When an If/SwitchInstruction is followed immediately by a keyword exit, the exit can be moved into the child blocks allowing the else block or default case to be moved after the if/switch as all prior cases exit. Most importantly, this transformation does not change the IL order of any code.

ConditionDetection also has a block exit priority system to assist exit point reduction which in some cases ignores IL order. After HighLevelLoopTransform has run, all structures have been detected and preference can be returned to maintaining IL ordering.

Constructors

ReduceNestingTransform()

public ReduceNestingTransform()

Methods

Run(ILFunction, ILTransformContext)

public void Run(ILFunction function, ILTransformContext context)

Parameters

function ILFunction
context ILTransformContext