diff --git a/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs b/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs index 0f08bc092..ccf459757 100644 --- a/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs @@ -112,7 +112,6 @@ namespace ICSharpCode.Decompiler.CSharp SwitchStatement TranslateSwitch(BlockContainer switchContainer, SwitchInstruction inst) { - Debug.Assert(switchContainer.EntryPoint.IncomingEdgeCount == 1); var oldBreakTarget = breakTarget; breakTarget = switchContainer; // 'break' within a switch would only leave the switch var oldCaseLabelMapping = caseLabelMapping; @@ -159,7 +158,7 @@ namespace ICSharpCode.Decompiler.CSharp switch (section.Body) { case Branch br: // we can only inline the block, if all branches are in the switchContainer. - if (br.TargetBlock.Parent == switchContainer && switchContainer.Descendants.OfType().Where(b => b.TargetBlock == br.TargetBlock).All(b => BlockContainer.FindClosestSwitchContainer(b) == switchContainer)) + if (br.TargetContainer == switchContainer && switchContainer.Descendants.OfType().Where(b => b.TargetBlock == br.TargetBlock).All(b => BlockContainer.FindClosestSwitchContainer(b) == switchContainer)) caseLabelMapping.Add(br.TargetBlock, firstValueResolveResult); break; default: @@ -173,7 +172,7 @@ namespace ICSharpCode.Decompiler.CSharp switch (section.Body) { case Branch br: // we can only inline the block, if all branches are in the switchContainer. - if (br.TargetBlock.Parent == switchContainer && switchContainer.Descendants.OfType().Where(b => b.TargetBlock == br.TargetBlock).All(b => BlockContainer.FindClosestSwitchContainer(b) == switchContainer)) + if (br.TargetContainer == switchContainer && switchContainer.Descendants.OfType().Where(b => b.TargetBlock == br.TargetBlock).All(b => BlockContainer.FindClosestSwitchContainer(b) == switchContainer)) ConvertSwitchSectionBody(astSection, br.TargetBlock); else ConvertSwitchSectionBody(astSection, section.Body); diff --git a/ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs b/ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs index a726c0e8f..d5420dc0f 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs @@ -193,6 +193,7 @@ namespace ICSharpCode.Decompiler.IL case ContainerKind.Switch: Debug.Assert(EntryPoint.Instructions.Count == 1); Debug.Assert(EntryPoint.Instructions[0] is SwitchInstruction); + Debug.Assert(EntryPoint.IncomingEdgeCount == 1); break; case ContainerKind.While: Debug.Assert(EntryPoint.IncomingEdgeCount > 1);