private bool CanBranchAtInstruction(ILInstruction instruction) { { var opCode = instruction.OpCode; if (opCode.Type == OpCodeType.Branch || opCode.Type == OpCodeType.CondBranch || opCode.Type == OpCodeType.Reserved) { return(false); } } // Check previous var previousNode = instruction.FindPreviousSibling(n => n.NodeType != ILNodeType.Label); if (previousNode == null) { return(false); } var previousInstruction = previousNode as ILInstruction; if (previousInstruction != null) { var opCode = previousInstruction.OpCode; if (opCode.Type == OpCodeType.Branch || opCode.Type == OpCodeType.CondBranch || opCode.Type == OpCodeType.Prefix || opCode.Type == OpCodeType.Reserved) { return(false); } } // Check next var nextNode = instruction.FindNextSibling(n => n.NodeType != ILNodeType.Label); if (nextNode == null) { return(false); } var nextInstruction = nextNode as ILInstruction; if (nextInstruction != null) { var opCode = nextInstruction.OpCode; if (opCode.Type == OpCodeType.Branch || opCode.Type == OpCodeType.CondBranch || opCode.Type == OpCodeType.Reserved) { return(false); } } return(true); }