207 references to SwitchStatementSyntax
Microsoft.CodeAnalysis.CSharp (29)
Binder\Binder_Statements.cs (5)
79result = BindSwitchStatement((SwitchStatementSyntax)node, diagnostics); 352var switchStatement = (SwitchStatementSyntax)node; 2738private BoundStatement BindSwitchStatement(SwitchStatementSyntax node, BindingDiagnosticBag diagnostics) 2745internal virtual BoundStatement BindSwitchStatementCore(SwitchStatementSyntax node, Binder originalBinder, BindingDiagnosticBag diagnostics)
Binder\BuckStopsHereBinder.cs (1)
186internal override BoundStatement BindSwitchStatementCore(SwitchStatementSyntax node, Binder originalBinder, BindingDiagnosticBag diagnostics)
Binder\ExpressionVariableFinder.cs (1)
208public override void VisitSwitchStatement(SwitchStatementSyntax node)
Binder\LocalBinderFactory.cs (3)
730public override void VisitSwitchStatement(SwitchStatementSyntax node) 1059var switchStatement = (SwitchStatementSyntax)statement;
Binder\LocalScopeBinder.cs (2)
270var switchStatement = (SwitchStatementSyntax)innerStatement;
Binder\SwitchBinder.cs (2)
21protected readonly SwitchStatementSyntax SwitchSyntax; 28private SwitchBinder(Binder next, SwitchStatementSyntax switchSyntax)
Binder\SwitchBinder_Patterns.cs (2)
21internal static SwitchBinder Create(Binder next, SwitchStatementSyntax switchSyntax) 29internal override BoundStatement BindSwitchStatementCore(SwitchStatementSyntax node, Binder originalBinder, BindingDiagnosticBag diagnostics)
Compilation\MemberSemanticModel.cs (2)
390var switchStmt = (SwitchStatementSyntax)stmt;
FlowAnalysis\AbstractFlowPass_Switch.cs (1)
106foreach (var sectionSyntax in ((SwitchStatementSyntax)node.Syntax).Sections)
Lowering\Instrumentation\DebugInfoInjector.cs (2)
425SwitchStatementSyntax switchSyntax = (SwitchStatementSyntax)original.Syntax;
Parser\LanguageParser.cs (1)
9713private SwitchStatementSyntax ParseSwitchStatement(SyntaxList<AttributeListSyntax> attributes)
Syntax\LookupPosition.cs (2)
351return ((SwitchStatementSyntax)statement).Expression.GetFirstToken(); 414return ((SwitchStatementSyntax)statement).CloseBraceToken;
Syntax\SwitchStatementSyntax.cs (2)
11public SwitchStatementSyntax Update(SyntaxToken switchKeyword, SyntaxToken openParenToken, ExpressionSyntax expression, SyntaxToken closeParenToken, SyntaxToken openBraceToken, SyntaxList<SwitchSectionSyntax> sections, SyntaxToken closeBraceToken) 20public static SwitchStatementSyntax SwitchStatement(SyntaxToken switchKeyword, SyntaxToken openParenToken, ExpressionSyntax expression, SyntaxToken closeParenToken, SyntaxToken openBraceToken, SyntaxList<SwitchSectionSyntax> sections, SyntaxToken closeBraceToken)
Syntax\SyntaxFactory.cs (2)
2721public static SwitchStatementSyntax SwitchStatement(ExpressionSyntax expression, SyntaxList<SwitchSectionSyntax> sections) 2738public static SwitchStatementSyntax SwitchStatement(ExpressionSyntax expression)
Syntax\SyntaxNodeExtensions.cs (1)
124return ((SwitchStatementSyntax)parent).Expression == expression;
Microsoft.CodeAnalysis.CSharp.CodeStyle (22)
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs (4)
32SwitchStatementSyntax node, 104public override SyntaxKind VisitSwitchStatement(SwitchStatementSyntax node) 107private SyntaxKind AnalyzeSwitchStatement(SwitchStatementSyntax switchStatement, out bool shouldRemoveNextStatement) 176private SyntaxKind AnalyzeNextStatement(SwitchStatementSyntax switchStatement, out bool shouldRemoveNextStatement)
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs (1)
57(SwitchStatementSyntax)switchStatement,
src\Analyzers\CSharp\Analyzers\NewLines\ConsecutiveStatementPlacement\CSharpConsecutiveStatementPlacementDiagnosticAnalyzer.cs (1)
41=> node is BlockSyntax or SwitchStatementSyntax;
src\Analyzers\CSharp\Analyzers\PopulateSwitch\CSharpPopulateSwitchStatementDiagnosticAnalyzer.cs (1)
13AbstractPopulateSwitchStatementDiagnosticAnalyzer<SwitchStatementSyntax>
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (1)
144(nodeParent is SwitchStatementSyntax switchStatement && switchStatement.Expression == node) ||
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (2)
104SwitchStatementSyntax switchStatementNode => (switchStatementNode.OpenBraceToken, switchStatementNode.CloseBraceToken), 715SwitchStatementSyntax n when n.OpenParenToken != default => (n.OpenParenToken, n.CloseParenToken),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (1)
292SwitchStatementSyntax switchStatement => switchStatement.CloseParenToken.Equals(token),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (3)
109var switchStatement = (SwitchStatementSyntax)node.Parent; 244if (node is SwitchStatementSyntax && !_options.Indentation.HasFlag(IndentationPlacement.SwitchSection))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
178if (parent is MemberDeclarationSyntax or SwitchStatementSyntax or SwitchExpressionSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (7)
441var oldSwitchStatement = (SwitchStatementSyntax)originalCaseSwitchLabel.Parent.Parent; 442var newSwitchStatement = (SwitchStatementSyntax)newCaseSwitchLabel.Parent.Parent; 457else if (currentOriginalNode is SwitchStatementSyntax originalSwitchStatement && 463var newSwitchStatement = (SwitchStatementSyntax)currentReplacedNode;
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (16)
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.cs (4)
40var switchStatement = (SwitchStatementSyntax)switchLocation.FindNode(getInnermostNodeForTie: true, context.CancellationToken); 85var switchStatement = (SwitchStatementSyntax)switchLocation.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (6)
38SwitchStatementSyntax switchStatement, 214public override ExpressionSyntax VisitSwitchStatement(SwitchStatementSyntax node) 218SwitchStatementSyntax node, 246var switchStatement = topLevel ? AddCastIfNecessary(node) : node; 258private SwitchStatementSyntax AddCastIfNecessary(SwitchStatementSyntax node)
src\Analyzers\CSharp\CodeFixes\PopulateSwitch\CSharpPopulateSwitchStatementCodeFixProvider.cs (1)
19: AbstractPopulateSwitchStatementCodeFixProvider<SwitchStatementSyntax, SwitchSectionSyntax, MemberAccessExpressionSyntax>;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (5)
179SwitchStatementSyntax switchStatement => InferTypeInSwitchStatement(switchStatement), 245SwitchStatementSyntax switchStatement => InferTypeInSwitchStatement(switchStatement, token), 2120var switchStatement = (SwitchStatementSyntax)switchLabel.Parent.Parent; 2125SwitchStatementSyntax switchStatement, SyntaxToken? previousToken = null)
Microsoft.CodeAnalysis.CSharp.EditorFeatures (3)
AutomaticCompletion\AutomaticLineEnderCommandHandler.cs (1)
590if (node is SwitchStatementSyntax switchStatementNode)
AutomaticCompletion\AutomaticLineEnderCommandHandler_Helpers.cs (2)
472SwitchStatementSyntax switchStatementNode => ShouldAddBraceForSwitchStatement(switchStatementNode), 637private static bool ShouldAddBraceForSwitchStatement(SwitchStatementSyntax switchStatementNode)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
Structure\SwitchStatementStructureTests.cs (1)
14public class SwitchStatementStructureTests : AbstractCSharpSyntaxNodeStructureTests<SwitchStatementSyntax>
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (20)
Semantics\OutVarTests.cs (2)
13735var statement = (SwitchStatementSyntax)SyntaxFactory.ParseStatement(@"
Semantics\PatternMatchingTestBase.cs (1)
464SwitchStatementSyntax n => ((BoundSwitchStatement)binder.BindStatement(n, BindingDiagnosticBag.Discarded)).ReachabilityDecisionDag,
Semantics\PatternMatchingTests_ListPatterns.cs (9)
6211VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 6252VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 6340VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 6395VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 6448VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 6520VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 6570VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 6838VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 7154VerifyDecisionDagDump<SwitchStatementSyntax>(comp,
Semantics\PatternMatchingTests_Scope.cs (2)
5337var statement = (SwitchStatementSyntax)SyntaxFactory.ParseStatement(@"
Semantics\PatternMatchingTests4.cs (6)
4017var @switch = tree.GetRoot().DescendantNodes().OfType<SwitchStatementSyntax>().Single(); 4086var @switch = tree.GetRoot().DescendantNodes().OfType<SwitchStatementSyntax>().Single(); 4159var @switch = tree.GetRoot().DescendantNodes().OfType<SwitchStatementSyntax>().Single();
Microsoft.CodeAnalysis.CSharp.Features (42)
Completion\KeywordRecommenders\CaseKeywordRecommender.cs (1)
31token.GetAncestor<SwitchStatementSyntax>() != null)
Debugging\CSharpProximityExpressionsService.RelevantExpressionsCollector.cs (1)
84public override void VisitSwitchStatement(SwitchStatementSyntax node)
Debugging\CSharpProximityExpressionsService.Worker.cs (2)
271var switchStatement = statement as SwitchStatementSyntax;
EditAndContinue\BreakpointSpans.cs (2)
736var switchStatement = (SwitchStatementSyntax)statement;
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (11)
827return AreEquivalentActiveStatements((SwitchStatementSyntax)oldStatement, (SwitchStatementSyntax)newStatement); 867private static bool AreEquivalentActiveStatements(SwitchStatementSyntax oldNode, SwitchStatementSyntax newNode) 1805var switchStatement = (SwitchStatementSyntax)node; 2875if (oldActiveStatement.Parent!.Parent!.Parent is not SwitchStatementSyntax oldSwitch) 2881var newSwitch = (SwitchStatementSyntax)newActiveStatement.Parent!.Parent!.Parent!; 2901private static bool AreEquivalentSwitchStatementDecisionTrees(SwitchStatementSyntax oldSwitch, SwitchStatementSyntax newSwitch)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (1)
269SwitchStatementSyntax NoBreakSwitchStatement()
ExtractMethod\CSharpSelectionValidator.Validator.cs (1)
70SwitchStatementSyntax or
Highlighting\KeywordHighlighters\SwitchStatementHighlighter.cs (2)
23internal sealed class SwitchStatementHighlighter() : AbstractKeywordHighlighter<SwitchStatementSyntax>(findInsideTrivia: false) 36SwitchStatementSyntax switchStatement, List<TextSpan> spans, CancellationToken cancellationToken)
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs (4)
32SwitchStatementSyntax node, 104public override SyntaxKind VisitSwitchStatement(SwitchStatementSyntax node) 107private SyntaxKind AnalyzeSwitchStatement(SwitchStatementSyntax switchStatement, out bool shouldRemoveNextStatement) 176private SyntaxKind AnalyzeNextStatement(SwitchStatementSyntax switchStatement, out bool shouldRemoveNextStatement)
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs (1)
57(SwitchStatementSyntax)switchStatement,
src\Analyzers\CSharp\Analyzers\NewLines\ConsecutiveStatementPlacement\CSharpConsecutiveStatementPlacementDiagnosticAnalyzer.cs (1)
41=> node is BlockSyntax or SwitchStatementSyntax;
src\Analyzers\CSharp\Analyzers\PopulateSwitch\CSharpPopulateSwitchStatementDiagnosticAnalyzer.cs (1)
13AbstractPopulateSwitchStatementDiagnosticAnalyzer<SwitchStatementSyntax>
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.cs (4)
40var switchStatement = (SwitchStatementSyntax)switchLocation.FindNode(getInnermostNodeForTie: true, context.CancellationToken); 85var switchStatement = (SwitchStatementSyntax)switchLocation.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (6)
38SwitchStatementSyntax switchStatement, 214public override ExpressionSyntax VisitSwitchStatement(SwitchStatementSyntax node) 218SwitchStatementSyntax node, 246var switchStatement = topLevel ? AddCastIfNecessary(node) : node; 258private SwitchStatementSyntax AddCastIfNecessary(SwitchStatementSyntax node)
src\Analyzers\CSharp\CodeFixes\PopulateSwitch\CSharpPopulateSwitchStatementCodeFixProvider.cs (1)
19: AbstractPopulateSwitchStatementCodeFixProvider<SwitchStatementSyntax, SwitchSectionSyntax, MemberAccessExpressionSyntax>;
Structure\CSharpBlockStructureProvider.cs (1)
50builder.Add<SwitchStatementSyntax, SwitchStatementStructureProvider>();
Structure\Providers\SwitchStatementStructureProvider.cs (2)
13internal class SwitchStatementStructureProvider : AbstractSyntaxNodeStructureProvider<SwitchStatementSyntax> 17SwitchStatementSyntax node,
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (12)
IOperation\IOperationTests_IBranchOperation.Extensions.cs (2)
344var (expected, actual) = GetOuterOperationAndCorrespondingInnerOperation<SwitchStatementSyntax, BreakStatementSyntax>(@" 368var (expected, actual) = GetOuterOperationAndCorrespondingInnerOperation<SwitchStatementSyntax, BreakStatementSyntax>(source);
IOperation\IOperationTests_InvalidStatement.cs (2)
117VerifyOperationTreeAndDiagnosticsForTest<SwitchStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 165VerifyOperationTreeAndDiagnosticsForTest<SwitchStatementSyntax>(source, expectedOperationTree, expectedDiagnostics);
IOperation\IOperationTests_IPatternSwitchCase.cs (1)
699VerifyOperationTreeAndDiagnosticsForTest<SwitchStatementSyntax>(source, expectedOperationTree, expectedDiagnostics);
IOperation\IOperationTests_ISwitchOperation.cs (7)
51VerifyOperationTreeAndDiagnosticsForTest<SwitchStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 107VerifyOperationTreeAndDiagnosticsForTest<SwitchStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 150VerifyOperationTreeAndDiagnosticsForTest<SwitchStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 214VerifyOperationTreeAndDiagnosticsForTest<SwitchStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 260VerifyOperationTreeAndDiagnosticsForTest<SwitchStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 304VerifyOperationTreeAndDiagnosticsForTest<SwitchStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 2057VerifyOperationTreeAndDiagnosticsForTest<SwitchStatementSyntax>(source, expectedOperationTree, expectedDiagnostics);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (6)
Compilation\SemanticModelAPITests.cs (4)
1905var switchStatement = (SwitchStatementSyntax)SyntaxFactory.ParseStatement(@" 2776var switchStatement = (SwitchStatementSyntax)blockStatement.Statements[0];
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (2)
717SwitchStatementSyntax switchStmt = methodDecl.Body.Statements[1]; 750SwitchStatementSyntax switchStmt = methodDecl.Body.Statements[1];
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (23)
Generated\Syntax.Test.xml.Generated.cs (5)
10643private static SwitchStatementSyntax GenerateSwitchStatement() 12651var node = GenerateSwitchStatement(); 12661var newNode = node.WithAttributeLists(node.AttributeLists).WithSwitchKeyword(node.SwitchKeyword).WithOpenParenToken(node.OpenParenToken).WithExpression(node.Expression).WithCloseParenToken(node.CloseParenToken).WithOpenBraceToken(node.OpenBraceToken).WithSections(node.Sections).WithCloseBraceToken(node.CloseBraceToken); 17687var oldNode = GenerateSwitchStatement(); 17703var oldNode = GenerateSwitchStatement();
Parsing\StatementParsingTests.cs (12)
2128var ss = (SwitchStatementSyntax)statement; 2151var ss = (SwitchStatementSyntax)statement; 2186var ss = (SwitchStatementSyntax)statement; 2233var ss = (SwitchStatementSyntax)statement; 2266var ss = (SwitchStatementSyntax)statement; 2308var ss = (SwitchStatementSyntax)statement;
Syntax\GreenNodeTests.cs (6)
45var sw1 = SyntaxFactory.SwitchStatement(expression); 48var sw2 = SyntaxFactory.SwitchStatement(expression, default); 57var sw1 = SyntaxFactory.SwitchStatement(expression); 60var sw2 = SyntaxFactory.SwitchStatement(expression, default); 69var sw1 = SyntaxFactory.SwitchStatement(expression); 72var sw2 = SyntaxFactory.SwitchStatement(expression, default);
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
LocalVariableDeclaratorsCollector.cs (1)
54public override void VisitSwitchStatement(SwitchStatementSyntax node)
Microsoft.CodeAnalysis.CSharp.Workspaces (24)
CodeGeneration\CSharpSyntaxGenerator.cs (3)
2146var statement = switchStatement as SwitchStatementSyntax; 2152if (switchStatement is not SwitchStatementSyntax statement)
Rename\LocalConflictVisitor.cs (1)
184public override void VisitSwitchStatement(SwitchStatementSyntax node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (1)
144(nodeParent is SwitchStatementSyntax switchStatement && switchStatement.Expression == node) ||
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (2)
104SwitchStatementSyntax switchStatementNode => (switchStatementNode.OpenBraceToken, switchStatementNode.CloseBraceToken), 715SwitchStatementSyntax n when n.OpenParenToken != default => (n.OpenParenToken, n.CloseParenToken),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (1)
292SwitchStatementSyntax switchStatement => switchStatement.CloseParenToken.Equals(token),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (3)
109var switchStatement = (SwitchStatementSyntax)node.Parent; 244if (node is SwitchStatementSyntax && !_options.Indentation.HasFlag(IndentationPlacement.SwitchSection))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
178if (parent is MemberDeclarationSyntax or SwitchStatementSyntax or SwitchExpressionSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (7)
441var oldSwitchStatement = (SwitchStatementSyntax)originalCaseSwitchLabel.Parent.Parent; 442var newSwitchStatement = (SwitchStatementSyntax)newCaseSwitchLabel.Parent.Parent; 457else if (currentOriginalNode is SwitchStatementSyntax originalSwitchStatement && 463var newSwitchStatement = (SwitchStatementSyntax)currentReplacedNode;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (5)
179SwitchStatementSyntax switchStatement => InferTypeInSwitchStatement(switchStatement), 245SwitchStatementSyntax switchStatement => InferTypeInSwitchStatement(switchStatement, token), 2120var switchStatement = (SwitchStatementSyntax)switchLabel.Parent.Parent; 2125SwitchStatementSyntax switchStatement, SyntaxToken? previousToken = null)
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (6)
CodeGeneration\SyntaxGeneratorTests.cs (6)
594VerifySyntax<SwitchStatementSyntax>( 600VerifySyntax<SwitchStatementSyntax>( 607VerifySyntax<SwitchStatementSyntax>( 615VerifySyntax<SwitchStatementSyntax>( 623VerifySyntax<SwitchStatementSyntax>( 629VerifySyntax<SwitchStatementSyntax>(
Microsoft.CodeAnalysis.Test.Utilities (2)
Compilation\ControlFlowGraphVerifier.cs (2)
611if (syntax.Parent is CSharp.Syntax.SwitchStatementSyntax switchStmt && switchStmt.Expression == syntax) 1171if (((CSharp.Syntax.SwitchStatementSyntax)parent).Expression == syntax)