1 instantiation of SwitchStatementSyntax
Microsoft.CodeAnalysis.CSharp (1)
Syntax.xml.Internal.Generated.cs (1)
13825internal override SyntaxNode CreateRed(SyntaxNode? parent, int position) => new CSharp.Syntax.SwitchStatementSyntax(this, parent, position);
241 references to SwitchStatementSyntax
Microsoft.CodeAnalysis.CSharp (45)
Binder\Binder_Statements.cs (5)
79result = BindSwitchStatement((SwitchStatementSyntax)node, diagnostics); 352var switchStatement = (SwitchStatementSyntax)node; 2787private BoundStatement BindSwitchStatement(SwitchStatementSyntax node, BindingDiagnosticBag diagnostics) 2794internal 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)
729public override void VisitSwitchStatement(SwitchStatementSyntax node) 1058var 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)
391var 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;
Syntax.xml.Main.Generated.cs (5)
436public virtual TResult? VisitSwitchStatement(SwitchStatementSyntax node) => this.DefaultVisit(node); 1183public virtual void VisitSwitchStatement(SwitchStatementSyntax node) => this.DefaultVisit(node); 1929public override SyntaxNode? VisitSwitchStatement(SwitchStatementSyntax node) 4578public static SwitchStatementSyntax SwitchStatement(SyntaxList<AttributeListSyntax> attributeLists, SyntaxToken switchKeyword, SyntaxToken openParenToken, ExpressionSyntax expression, SyntaxToken closeParenToken, SyntaxToken openBraceToken, SyntaxList<SwitchSectionSyntax> sections, SyntaxToken closeBraceToken) 4596return (SwitchStatementSyntax)Syntax.InternalSyntax.SyntaxFactory.SwitchStatement(attributeLists.Node.ToGreenList<Syntax.InternalSyntax.AttributeListSyntax>(), (Syntax.InternalSyntax.SyntaxToken)switchKeyword.Node!, (Syntax.InternalSyntax.SyntaxToken?)openParenToken.Node, (Syntax.InternalSyntax.ExpressionSyntax)expression.Green, (Syntax.InternalSyntax.SyntaxToken?)closeParenToken.Node, (Syntax.InternalSyntax.SyntaxToken)openBraceToken.Node!, sections.Node.ToGreenList<Syntax.InternalSyntax.SwitchSectionSyntax>(), (Syntax.InternalSyntax.SyntaxToken)closeBraceToken.Node!).CreateRed();
Syntax.xml.Syntax.Generated.cs (12)
8576public SwitchStatementSyntax Update(SyntaxList<AttributeListSyntax> attributeLists, SyntaxToken switchKeyword, SyntaxToken openParenToken, ExpressionSyntax expression, SyntaxToken closeParenToken, SyntaxToken openBraceToken, SyntaxList<SwitchSectionSyntax> sections, SyntaxToken closeBraceToken) 8580var newNode = SyntaxFactory.SwitchStatement(attributeLists, switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, sections, closeBraceToken); 8589public new SwitchStatementSyntax WithAttributeLists(SyntaxList<AttributeListSyntax> attributeLists) => Update(attributeLists, this.SwitchKeyword, this.OpenParenToken, this.Expression, this.CloseParenToken, this.OpenBraceToken, this.Sections, this.CloseBraceToken); 8590public SwitchStatementSyntax WithSwitchKeyword(SyntaxToken switchKeyword) => Update(this.AttributeLists, switchKeyword, this.OpenParenToken, this.Expression, this.CloseParenToken, this.OpenBraceToken, this.Sections, this.CloseBraceToken); 8591public SwitchStatementSyntax WithOpenParenToken(SyntaxToken openParenToken) => Update(this.AttributeLists, this.SwitchKeyword, openParenToken, this.Expression, this.CloseParenToken, this.OpenBraceToken, this.Sections, this.CloseBraceToken); 8592public SwitchStatementSyntax WithExpression(ExpressionSyntax expression) => Update(this.AttributeLists, this.SwitchKeyword, this.OpenParenToken, expression, this.CloseParenToken, this.OpenBraceToken, this.Sections, this.CloseBraceToken); 8593public SwitchStatementSyntax WithCloseParenToken(SyntaxToken closeParenToken) => Update(this.AttributeLists, this.SwitchKeyword, this.OpenParenToken, this.Expression, closeParenToken, this.OpenBraceToken, this.Sections, this.CloseBraceToken); 8594public SwitchStatementSyntax WithOpenBraceToken(SyntaxToken openBraceToken) => Update(this.AttributeLists, this.SwitchKeyword, this.OpenParenToken, this.Expression, this.CloseParenToken, openBraceToken, this.Sections, this.CloseBraceToken); 8595public SwitchStatementSyntax WithSections(SyntaxList<SwitchSectionSyntax> sections) => Update(this.AttributeLists, this.SwitchKeyword, this.OpenParenToken, this.Expression, this.CloseParenToken, this.OpenBraceToken, sections, this.CloseBraceToken); 8596public SwitchStatementSyntax WithCloseBraceToken(SyntaxToken closeBraceToken) => Update(this.AttributeLists, this.SwitchKeyword, this.OpenParenToken, this.Expression, this.CloseParenToken, this.OpenBraceToken, this.Sections, closeBraceToken); 8599public new SwitchStatementSyntax AddAttributeLists(params AttributeListSyntax[] items) => WithAttributeLists(this.AttributeLists.AddRange(items)); 8600public SwitchStatementSyntax AddSections(params SwitchSectionSyntax[] items) => WithSections(this.Sections.AddRange(items));
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)
2769public static SwitchStatementSyntax SwitchStatement(ExpressionSyntax expression, SyntaxList<SwitchSectionSyntax> sections) 2786public 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) 175private SyntaxKind AnalyzeNextStatement(SwitchStatementSyntax switchStatement, out bool shouldRemoveNextStatement)
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs (1)
55(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)
172(nodeParent is SwitchStatementSyntax switchStatement && switchStatement.Expression == node) ||
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (2)
106SwitchStatementSyntax switchStatementNode => (switchStatementNode.OpenBraceToken, switchStatementNode.CloseBraceToken), 717SwitchStatementSyntax n when n.OpenParenToken != default => (n.OpenParenToken, n.CloseParenToken),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (1)
295SwitchStatementSyntax switchStatement => switchStatement.CloseParenToken.Equals(token),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (3)
104var switchStatement = (SwitchStatementSyntax)node.Parent; 239if (node is SwitchStatementSyntax && !_options.Indentation.HasFlag(IndentationPlacement.SwitchSection))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
158if (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 (14)
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.cs (2)
74var 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)
183SwitchStatementSyntax switchStatement => InferTypeInSwitchStatement(switchStatement), 249SwitchStatementSyntax switchStatement => InferTypeInSwitchStatement(switchStatement, token), 2198var switchStatement = (SwitchStatementSyntax)switchLabel.Parent.Parent; 2203SwitchStatementSyntax switchStatement, SyntaxToken? previousToken = null)
Microsoft.CodeAnalysis.CSharp.EditorFeatures (3)
AutomaticCompletion\AutomaticLineEnderCommandHandler.cs (1)
584if (node is SwitchStatementSyntax switchStatementNode)
AutomaticCompletion\AutomaticLineEnderCommandHandler_Helpers.cs (2)
481SwitchStatementSyntax switchStatementNode => ShouldAddBraceForSwitchStatement(switchStatementNode), 646private static bool ShouldAddBraceForSwitchStatement(SwitchStatementSyntax switchStatementNode)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
Structure\SwitchStatementStructureTests.cs (1)
15public sealed class SwitchStatementStructureTests : AbstractCSharpSyntaxNodeStructureTests<SwitchStatementSyntax>
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (22)
FlowAnalysis\PatternsVsRegions.cs (2)
212var @switch = tree.GetRoot().DescendantNodes().OfType<SwitchStatementSyntax>().Single();
Semantics\OutVarTests.cs (2)
13733var statement = (SwitchStatementSyntax)SyntaxFactory.ParseStatement(@"
Semantics\PatternMatchingTestBase.cs (1)
463SwitchStatementSyntax n => ((BoundSwitchStatement)binder.BindStatement(n, BindingDiagnosticBag.Discarded)).ReachabilityDecisionDag,
Semantics\PatternMatchingTests_ListPatterns.cs (9)
6336VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 6374VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 6453VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 6503VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 6556VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 6628VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 6677VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 6937VerifyDecisionDagDump<SwitchStatementSyntax>(comp, 7246VerifyDecisionDagDump<SwitchStatementSyntax>(comp,
Semantics\PatternMatchingTests_Scope.cs (2)
5337var statement = (SwitchStatementSyntax)SyntaxFactory.ParseStatement(@"
Semantics\PatternMatchingTests4.cs (6)
4020var @switch = tree.GetRoot().DescendantNodes().OfType<SwitchStatementSyntax>().Single(); 4089var @switch = tree.GetRoot().DescendantNodes().OfType<SwitchStatementSyntax>().Single(); 4162var @switch = tree.GetRoot().DescendantNodes().OfType<SwitchStatementSyntax>().Single();
Microsoft.CodeAnalysis.CSharp.Features (40)
Completion\KeywordRecommenders\CaseKeywordRecommender.cs (1)
26token.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)
737var switchStatement = (SwitchStatementSyntax)statement;
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (11)
803return AreEquivalentActiveStatements((SwitchStatementSyntax)oldStatement, (SwitchStatementSyntax)newStatement); 843private static bool AreEquivalentActiveStatements(SwitchStatementSyntax oldNode, SwitchStatementSyntax newNode) 1800var switchStatement = (SwitchStatementSyntax)node; 2883if (oldActiveStatement.Parent!.Parent!.Parent is not SwitchStatementSyntax oldSwitch) 2889var newSwitch = (SwitchStatementSyntax)newActiveStatement.Parent!.Parent!.Parent!; 2909private static bool AreEquivalentSwitchStatementDecisionTrees(SwitchStatementSyntax oldSwitch, SwitchStatementSyntax newSwitch)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (1)
268SwitchStatementSyntax NoBreakSwitchStatement()
ExtractMethod\CSharpSelectionValidator.Validator.cs (1)
70SwitchStatementSyntax or
Highlighting\KeywordHighlighters\SwitchStatementHighlighter.cs (2)
24internal sealed class SwitchStatementHighlighter() : AbstractKeywordHighlighter<SwitchStatementSyntax>(findInsideTrivia: false) 37SwitchStatementSyntax 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) 175private SyntaxKind AnalyzeNextStatement(SwitchStatementSyntax switchStatement, out bool shouldRemoveNextStatement)
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs (1)
55(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 (2)
74var 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)
51builder.Add<SwitchStatementSyntax, SwitchStatementStructureProvider>();
Structure\Providers\SwitchStatementStructureProvider.cs (2)
13internal sealed 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)
10820private static SwitchStatementSyntax GenerateSwitchStatement() 12848var node = GenerateSwitchStatement(); 12858var 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); 17957var oldNode = GenerateSwitchStatement(); 17973var 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)
2314var statement = switchStatement as SwitchStatementSyntax; 2320if (switchStatement is not SwitchStatementSyntax statement)
Rename\LocalConflictVisitor.cs (1)
205public override void VisitSwitchStatement(SwitchStatementSyntax node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (1)
172(nodeParent is SwitchStatementSyntax switchStatement && switchStatement.Expression == node) ||
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (2)
106SwitchStatementSyntax switchStatementNode => (switchStatementNode.OpenBraceToken, switchStatementNode.CloseBraceToken), 717SwitchStatementSyntax n when n.OpenParenToken != default => (n.OpenParenToken, n.CloseParenToken),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (1)
295SwitchStatementSyntax switchStatement => switchStatement.CloseParenToken.Equals(token),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (3)
104var switchStatement = (SwitchStatementSyntax)node.Parent; 239if (node is SwitchStatementSyntax && !_options.Indentation.HasFlag(IndentationPlacement.SwitchSection))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
158if (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)
183SwitchStatementSyntax switchStatement => InferTypeInSwitchStatement(switchStatement), 249SwitchStatementSyntax switchStatement => InferTypeInSwitchStatement(switchStatement, token), 2198var switchStatement = (SwitchStatementSyntax)switchLabel.Parent.Parent; 2203SwitchStatementSyntax switchStatement, SyntaxToken? previousToken = null)
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (6)
CodeGeneration\SyntaxGeneratorTests.cs (6)
614VerifySyntax<SwitchStatementSyntax>( 620VerifySyntax<SwitchStatementSyntax>( 627VerifySyntax<SwitchStatementSyntax>( 635VerifySyntax<SwitchStatementSyntax>( 643VerifySyntax<SwitchStatementSyntax>( 649VerifySyntax<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)
Roslyn.Diagnostics.CSharp.Analyzers (20)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (1)
172(nodeParent is SwitchStatementSyntax switchStatement && switchStatement.Expression == node) ||
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (2)
106SwitchStatementSyntax switchStatementNode => (switchStatementNode.OpenBraceToken, switchStatementNode.CloseBraceToken), 717SwitchStatementSyntax n when n.OpenParenToken != default => (n.OpenParenToken, n.CloseParenToken),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (1)
295SwitchStatementSyntax switchStatement => switchStatement.CloseParenToken.Equals(token),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (3)
104var switchStatement = (SwitchStatementSyntax)node.Parent; 239if (node is SwitchStatementSyntax && !_options.Indentation.HasFlag(IndentationPlacement.SwitchSection))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
158if (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)
183SwitchStatementSyntax switchStatement => InferTypeInSwitchStatement(switchStatement), 249SwitchStatementSyntax switchStatement => InferTypeInSwitchStatement(switchStatement, token), 2198var switchStatement = (SwitchStatementSyntax)switchLabel.Parent.Parent; 2203SwitchStatementSyntax switchStatement, SyntaxToken? previousToken = null)