diff --git a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs index db272fed3e..9576a26f01 100644 --- a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs @@ -106,7 +106,8 @@ public void ShortCircuit([ValueSource("defaultOptions")] CSharpCompilerOptions c public void ExceptionHandling([ValueSource("defaultOptions")] CSharpCompilerOptions cscOptions) { RunForLibrary(cscOptions: cscOptions, decompilerSettings: new DecompilerSettings { - NullPropagation = false + NullPropagation = false, + RemoveDeadCode = !cscOptions.HasFlag(CSharpCompilerOptions.UseRoslyn) }); } @@ -161,7 +162,9 @@ public void Generics([ValueSource("defaultOptions")] CSharpCompilerOptions cscOp [Test] public void Loops([ValueSource("defaultOptionsWithMcs")] CSharpCompilerOptions cscOptions) { - RunForLibrary(cscOptions: cscOptions); + RunForLibrary(cscOptions: cscOptions, decompilerSettings: new DecompilerSettings { + RemoveDeadCode = !cscOptions.HasFlag(CSharpCompilerOptions.Optimize) + }); } [Test] diff --git a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs index a0401c950a..74892e4e72 100644 --- a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs @@ -87,6 +87,7 @@ public static List GetILTransforms() // is already collapsed into stloc(V, ...). new RemoveDeadVariableInit(), new SplitVariables(), // split variables once again, because the stobj(ldloca V, ...) may open up new replacements + new ControlFlowSimplification(), //split variables may enable new branch to leave inlining new DynamicCallSiteTransform(), new SwitchDetection(), new SwitchOnStringTransform(),