mirror of https://github.com/icsharpcode/ILSpy.git
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							27 lines
						
					
					
						
							751 B
						
					
					
				
			
		
		
	
	
							27 lines
						
					
					
						
							751 B
						
					
					
				using System; | 
						|
using System.Collections.Generic; | 
						|
using System.Linq; | 
						|
using System.Text; | 
						|
using ICSharpCode.Decompiler.CSharp.Syntax; | 
						|
 | 
						|
namespace ICSharpCode.Decompiler.CSharp.Transforms | 
						|
{ | 
						|
	class FlattenSwitchBlocks : IAstTransform | 
						|
	{ | 
						|
		public void Run(AstNode rootNode, TransformContext context) | 
						|
		{ | 
						|
			foreach (var switchSection in rootNode.Descendants.OfType<SwitchSection>()) | 
						|
			{ | 
						|
				if (switchSection.Statements.Count != 1) | 
						|
					continue; | 
						|
 | 
						|
				var blockStatement = switchSection.Statements.First() as BlockStatement; | 
						|
				if (blockStatement == null || blockStatement.Statements.Any(st => st is VariableDeclarationStatement)) | 
						|
					continue; | 
						|
 | 
						|
				blockStatement.Remove(); | 
						|
				blockStatement.Statements.MoveTo(switchSection.Statements); | 
						|
			} | 
						|
		} | 
						|
	} | 
						|
}
 | 
						|
 |