From bcaf6db31338903353632996e10b21ba162dde93 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 22 Aug 2017 21:33:11 +0200 Subject: [PATCH] Fix use of Clone in NullCoalescingTransform --- .../IL/Instructions/NullCoalescingInstruction.cs | 2 +- .../IL/Transforms/NullCoalescingTransform.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ICSharpCode.Decompiler/IL/Instructions/NullCoalescingInstruction.cs b/ICSharpCode.Decompiler/IL/Instructions/NullCoalescingInstruction.cs index 415c8c7dd..4b42a9eba 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/NullCoalescingInstruction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/NullCoalescingInstruction.cs @@ -58,7 +58,7 @@ namespace ICSharpCode.Decompiler.IL public override void WriteTo(ITextOutput output) { output.Write(OpCode); - output.Write(" ("); + output.Write("("); valueInst.WriteTo(output); output.Write(", "); fallbackInst.WriteTo(output); diff --git a/ICSharpCode.Decompiler/IL/Transforms/NullCoalescingTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/NullCoalescingTransform.cs index 097945580..08ac23a2c 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/NullCoalescingTransform.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/NullCoalescingTransform.cs @@ -45,7 +45,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms /// stloc s(fallbackInst) /// } /// => - /// stloc s(if.notnull(valueInst, fallbackInst) + /// stloc s(if.notnull(valueInst, fallbackInst)) /// bool TransformNullCoalescing(Block block, int i) { @@ -57,7 +57,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms if (!ifInstruction.FalseInst.MatchNop() || !(ifInstruction.TrueInst is Block b) || b.Instructions.Count != 1 || !(b.Instructions[0] is StLoc fallbackStore) || fallbackStore.Variable != stloc.Variable) return false; context.Step("TransformNullCoalescing", stloc); - stloc.Value.ReplaceWith(new NullCoalescingInstruction(stloc.Value.Clone(), fallbackStore.Value.Clone())); + stloc.Value = new NullCoalescingInstruction(stloc.Value, fallbackStore.Value); return true; } }