From c1ac461c267d1b7da38c1ad1b52d707b055d063b Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 7 Jul 2019 11:51:51 +0200 Subject: [PATCH] Enable MCS yield return pretty tests. --- ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs | 2 +- .../IL/Transforms/RemoveDeadVariableInit.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs index a8b4b980b..6c66f55c3 100644 --- a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs @@ -420,7 +420,7 @@ namespace ICSharpCode.Decompiler.Tests } [Test] - public void YieldReturn([ValueSource(nameof(defaultOptions))] CompilerOptions cscOptions) + public void YieldReturn([ValueSource(nameof(defaultOptionsWithMcs))] CompilerOptions cscOptions) { RunForLibrary(cscOptions: cscOptions); } diff --git a/ICSharpCode.Decompiler/IL/Transforms/RemoveDeadVariableInit.cs b/ICSharpCode.Decompiler/IL/Transforms/RemoveDeadVariableInit.cs index ff8f08ac4..a6dab356b 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/RemoveDeadVariableInit.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/RemoveDeadVariableInit.cs @@ -53,6 +53,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms var v = variableQueue.Dequeue(); if (v.Kind != VariableKind.Local && v.Kind != VariableKind.StackSlot) continue; + // Skip variables that are captured in a mcs yield state-machine + // loads of these will only be visible after DelegateConstruction step. + if (function.StateMachineCompiledWithMono && v.StateMachineField != null) + continue; if (v.LoadCount != 0 || v.AddressCount != 0) continue; foreach (var stloc in v.StoreInstructions.OfType().ToArray()) {