From a323210346fa09627ac2725388b92e46c6de5b19 Mon Sep 17 00:00:00 2001 From: mohe2015 Date: Mon, 9 Oct 2017 09:53:48 +0200 Subject: [PATCH] Clean up the check a little bit. --- .../IL/Transforms/ProxyCallReplacer.cs | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/ICSharpCode.Decompiler/IL/Transforms/ProxyCallReplacer.cs b/ICSharpCode.Decompiler/IL/Transforms/ProxyCallReplacer.cs index e095aa916..4e2c0eb68 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/ProxyCallReplacer.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/ProxyCallReplacer.cs @@ -31,28 +31,16 @@ namespace ICSharpCode.Decompiler.IL.Transforms } } - - if (proxyFunction.Children.Count != 1) - return; - var blockContainer = proxyFunction.Children[0]; - if (blockContainer.OpCode != OpCode.BlockContainer) - return; - if (blockContainer.Children.Count != 1) - return; - var block = blockContainer.Children[0]; - if (block.OpCode != OpCode.Block) - return; - if (block.Children.Count > 2) + if (!(proxyFunction.Body is BlockContainer blockContainer)) return; - if (block.Children.Count == 2 && block.Children[1].OpCode != OpCode.Nop) + if (blockContainer.Blocks.Count != 1) return; - var leave = block.Children[0]; - if (leave.OpCode != OpCode.Leave) + var block = blockContainer.Blocks[0]; + if (block.Instructions.Count != 1) return; - if (leave.Children.Count != 1) + if (!block.Instructions[0].MatchLeave(blockContainer, out ILInstruction returnValue)) return; - Call call = leave.Children[0] as Call; - if (call == null) + if (!(returnValue is Call call)) return; // check if original arguments are only correct ldloc calls for (int i = 0; i < call.Arguments.Count; i++) {