1 instantiation of SwitchSectionSyntax
Microsoft.CodeAnalysis.CSharp (1)
_generated\1\Syntax.xml.Internal.Generated.cs (1)
14061internal override SyntaxNode CreateRed(SyntaxNode? parent, int position) => new CSharp.Syntax.SwitchSectionSyntax(this, parent, position);
126 references to SwitchSectionSyntax
ILLink.CodeFixProvider (3)
RequiresUnsafeCodeFixProvider.cs (3)
97var switchSection = containingStatement.Parent as SwitchSectionSyntax; 365SwitchSectionSyntax _,
Microsoft.CodeAnalysis.CSharp (34)
_generated\0\Syntax.xml.Main.Generated.cs (7)
444public virtual TResult? VisitSwitchSection(SwitchSectionSyntax node) => this.DefaultVisit(node); 1200public virtual void VisitSwitchSection(SwitchSectionSyntax node) => this.DefaultVisit(node); 1955public override SyntaxNode? VisitSwitchSection(SwitchSectionSyntax node) 4633public static SwitchStatementSyntax SwitchStatement(SyntaxList<AttributeListSyntax> attributeLists, SyntaxToken switchKeyword, SyntaxToken openParenToken, ExpressionSyntax expression, SyntaxToken closeParenToken, SyntaxToken openBraceToken, SyntaxList<SwitchSectionSyntax> sections, SyntaxToken closeBraceToken) 4655public static SwitchSectionSyntax SwitchSection(SyntaxList<SwitchLabelSyntax> labels, SyntaxList<StatementSyntax> statements) 4657return (SwitchSectionSyntax)Syntax.InternalSyntax.SyntaxFactory.SwitchSection(labels.Node.ToGreenList<Syntax.InternalSyntax.SwitchLabelSyntax>(), statements.Node.ToGreenList<Syntax.InternalSyntax.StatementSyntax>()).CreateRed(); 4661public static SwitchSectionSyntax SwitchSection()
_generated\2\Syntax.xml.Syntax.Generated.cs (11)
8643public SyntaxList<SwitchSectionSyntax> Sections => new SyntaxList<SwitchSectionSyntax>(GetRed(ref this.sections, 6)); 8671public SwitchStatementSyntax Update(SyntaxList<AttributeListSyntax> attributeLists, SyntaxToken switchKeyword, SyntaxToken openParenToken, ExpressionSyntax expression, SyntaxToken closeParenToken, SyntaxToken openBraceToken, SyntaxList<SwitchSectionSyntax> sections, SyntaxToken closeBraceToken) 8690public SwitchStatementSyntax WithSections(SyntaxList<SwitchSectionSyntax> sections) => Update(this.AttributeLists, this.SwitchKeyword, this.OpenParenToken, this.Expression, this.CloseParenToken, this.OpenBraceToken, sections, this.CloseBraceToken); 8695public SwitchStatementSyntax AddSections(params SwitchSectionSyntax[] items) => WithSections(this.Sections.AddRange(items)); 8744public SwitchSectionSyntax Update(SyntaxList<SwitchLabelSyntax> labels, SyntaxList<StatementSyntax> statements) 8748var newNode = SyntaxFactory.SwitchSection(labels, statements); 8756public SwitchSectionSyntax WithLabels(SyntaxList<SwitchLabelSyntax> labels) => Update(labels, this.Statements); 8757public SwitchSectionSyntax WithStatements(SyntaxList<StatementSyntax> statements) => Update(this.Labels, statements); 8759public SwitchSectionSyntax AddLabels(params SwitchLabelSyntax[] items) => WithLabels(this.Labels.AddRange(items)); 8760public SwitchSectionSyntax AddStatements(params StatementSyntax[] items) => WithStatements(this.Statements.AddRange(items));
Binder\ExpressionVariableFinder.cs (1)
137public override void VisitSwitchSection(SwitchSectionSyntax node)
Binder\LocalBinderFactory.cs (2)
752foreach (SwitchSectionSyntax section in node.Sections) 758public override void VisitSwitchSection(SwitchSectionSyntax node)
Binder\SwitchBinder.cs (3)
141foreach (var section in SwitchSyntax.Sections) 153foreach (var section in SwitchSyntax.Sections) 180foreach (var section in SwitchSyntax.Sections)
Binder\SwitchBinder_Patterns.cs (2)
178foreach (SwitchSectionSyntax sectionSyntax in SwitchSyntax.Sections) 191SwitchSectionSyntax node,
Compilation\MemberSemanticModel.cs (1)
296if (LookupPosition.IsInSwitchSectionScope(position, (SwitchSectionSyntax)current))
FlowAnalysis\AbstractFlowPass_Switch.cs (1)
106foreach (var sectionSyntax in ((SwitchStatementSyntax)node.Syntax).Sections)
Syntax\LookupPosition.cs (1)
282internal static bool IsInSwitchSectionScope(int position, SwitchSectionSyntax section)
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) 2788return SyntaxFactory.SwitchStatement(expression, default(SyntaxList<SwitchSectionSyntax>));
Syntax\SyntaxNormalizer.cs (1)
1396node is SwitchSectionSyntax ||
Microsoft.CodeAnalysis.CSharp.CodeStyle (9)
src\roslyn\src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs (1)
218private SyntaxKind AnalyzeSwitchSection(SwitchSectionSyntax section)
src\roslyn\src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\RemoveUnreachableCodeHelpers.cs (1)
22case SwitchSectionSyntax switchSection:
src\roslyn\src\Analyzers\CSharp\Analyzers\RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (1)
70return statementAncestor is not (BlockSyntax or SwitchSectionSyntax);
src\roslyn\src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs (1)
113if (enclosingBlock is not BlockSyntax and not SwitchSectionSyntax)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (1)
72if (node is not SwitchSectionSyntax section)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (1)
184if (node is SwitchSectionSyntax switchSection)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\WrappingFormattingRule.cs (1)
82SwitchSectionSyntax switchSection => (switchSection.GetFirstToken(includeZeroWidth: true), switchSection.GetLastToken(includeZeroWidth: true)),
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpBlockFacts.cs (2)
31SwitchSectionSyntax switchSection => switchSection, 41SwitchSectionSyntax switchSection => switchSection.Statements,
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (15)
src\roslyn\src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AbstractAssignOutParametersCodeFixProvider.cs (1)
68|| location.Parent is SwitchSectionSyntax
src\roslyn\src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AssignOutParametersAboveReturnCodeFixProvider.cs (1)
65else if (parent is BlockSyntax or SwitchSectionSyntax)
src\roslyn\src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (1)
122private SwitchExpressionArmSyntax GetSwitchExpressionArm(SwitchSectionSyntax node)
src\roslyn\src\Analyzers\CSharp\CodeFixes\PopulateSwitch\CSharpPopulateSwitchStatementCodeFixProvider.cs (1)
19: AbstractPopulateSwitchStatementCodeFixProvider<SwitchStatementSyntax, SwitchSectionSyntax, MemberAccessExpressionSyntax>;
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (2)
30ForEachStatementSyntax, SwitchSectionSyntax, SwitchLabelSyntax, CatchClauseSyntax, CatchClauseSyntax> 168protected override void InsertAtStartOfSwitchCaseBlockForDeclarationInCaseLabelOrClause(SwitchSectionSyntax switchCaseBlock, SyntaxEditor editor, LocalDeclarationStatementSyntax declarationStatement)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseLabeledJumpStatements\CSharpUseLabeledJumpStatementsCodeFixProvider.cs (1)
231editor.ReplaceNode(loop, loop.Parent is BlockSyntax or SwitchSectionSyntax or GlobalStatementSyntax
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndNullCheckCodeFixProvider.cs (2)
64: ((SwitchSectionSyntax)newParentScope).Statements.First(); 74if (statement.Parent is BlockSyntax or SwitchSectionSyntax)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (2)
412var section = targetToken.GetAncestor<SwitchSectionSyntax>();
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (1)
1564if (node is CaseSwitchLabelSyntax { Parent: SwitchSectionSyntax })
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (1)
174if (node is not SwitchSectionSyntax { Statements: [var firstStatement, ..] and [.., var lastStatement] })
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpReplaceDiscardDeclarationsWithAssignmentsService.cs (1)
208if (_localDeclarationStatement.Parent is BlockSyntax or SwitchSectionSyntax)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (1)
2289var container = afterNode.AncestorsAndSelf().FirstOrDefault(a => a is BlockSyntax or SwitchSectionSyntax);
Microsoft.CodeAnalysis.CSharp.Features (39)
ConvertIfToSwitch\CSharpConvertIfToSwitchCodeRefactoringProvider.Rewriting.cs (1)
77[.. sectionList.Cast<SwitchSectionSyntax>()],
Debugging\CSharpProximityExpressionsService.Worker.cs (1)
272foreach (var section in switchStatement.Sections)
EditAndContinue\BreakpointSpans.cs (1)
556if (switchLabel.Parent is not SwitchSectionSyntax switchSection || switchSection.Statements.Count == 0)
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (3)
1805return ((SwitchSectionSyntax)node).Labels.Last().Span; 2912private static bool AreSwitchSectionsEquivalent(SwitchSectionSyntax oldSection, SwitchSectionSyntax newSection)
EditAndContinue\SyntaxComparer.cs (4)
742return Equal((SwitchSectionSyntax)left, (SwitchSectionSyntax)right); 764private bool Equal(SwitchSectionSyntax left, SwitchSectionSyntax right)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs (1)
134public override SyntaxNode VisitSwitchSection(SwitchSectionSyntax node)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.MultipleStatementsCodeGenerator.cs (1)
74SwitchSectionSyntax switchSectionNode => switchSectionNode.Statements,
ExtractMethod\Extensions.cs (1)
39=> node is BlockSyntax or SwitchSectionSyntax or GlobalStatementSyntax;
Highlighting\KeywordHighlighters\SwitchStatementHighlighter.cs (1)
43foreach (var switchSection in switchStatement.Sections)
IntroduceUsingStatement\CSharpIntroduceUsingStatementCodeRefactoringProvider.cs (4)
42=> parent is BlockSyntax or SwitchSectionSyntax || parent.IsEmbeddedStatementOwner(); 48SwitchSectionSyntax switchSection => switchSection.Statements, 56parentOfStatementsToSurround is SwitchSectionSyntax switchSection ? switchSection.WithStatements(statements) : 99if (declarationStatement.Parent is SwitchSectionSyntax ||
IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs (3)
530private static bool IsBlockLike(SyntaxNode node) => node is BlockSyntax or SwitchSectionSyntax; 536SwitchSectionSyntax switchSection => switchSection.Statements, 544SwitchSectionSyntax switchSection => switchSection.WithStatements(statements),
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (4)
78case SwitchSectionSyntax: 97SwitchSectionSyntax n => n.Statements, 104SwitchSectionSyntax 235SwitchSectionSyntax n => n.WithStatements([.. statements]),
src\roslyn\src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs (1)
218private SyntaxKind AnalyzeSwitchSection(SwitchSectionSyntax section)
src\roslyn\src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\RemoveUnreachableCodeHelpers.cs (1)
22case SwitchSectionSyntax switchSection:
src\roslyn\src\Analyzers\CSharp\Analyzers\RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (1)
70return statementAncestor is not (BlockSyntax or SwitchSectionSyntax);
src\roslyn\src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs (1)
113if (enclosingBlock is not BlockSyntax and not SwitchSectionSyntax)
src\roslyn\src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AbstractAssignOutParametersCodeFixProvider.cs (1)
68|| location.Parent is SwitchSectionSyntax
src\roslyn\src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AssignOutParametersAboveReturnCodeFixProvider.cs (1)
65else if (parent is BlockSyntax or SwitchSectionSyntax)
src\roslyn\src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (1)
122private SwitchExpressionArmSyntax GetSwitchExpressionArm(SwitchSectionSyntax node)
src\roslyn\src\Analyzers\CSharp\CodeFixes\PopulateSwitch\CSharpPopulateSwitchStatementCodeFixProvider.cs (1)
19: AbstractPopulateSwitchStatementCodeFixProvider<SwitchStatementSyntax, SwitchSectionSyntax, MemberAccessExpressionSyntax>;
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (2)
30ForEachStatementSyntax, SwitchSectionSyntax, SwitchLabelSyntax, CatchClauseSyntax, CatchClauseSyntax> 168protected override void InsertAtStartOfSwitchCaseBlockForDeclarationInCaseLabelOrClause(SwitchSectionSyntax switchCaseBlock, SyntaxEditor editor, LocalDeclarationStatementSyntax declarationStatement)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseLabeledJumpStatements\CSharpUseLabeledJumpStatementsCodeFixProvider.cs (1)
231editor.ReplaceNode(loop, loop.Parent is BlockSyntax or SwitchSectionSyntax or GlobalStatementSyntax
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndNullCheckCodeFixProvider.cs (2)
64: ((SwitchSectionSyntax)newParentScope).Statements.First(); 74if (statement.Parent is BlockSyntax or SwitchSectionSyntax)
Structure\Providers\SwitchStatementStructureProvider.cs (1)
28foreach (var section in node.Sections)
Microsoft.CodeAnalysis.CSharp.Workspaces (15)
CodeGeneration\CSharpSyntaxGenerator.cs (3)
2333var newSections = statement.Sections.InsertRange(index, switchSections.Cast<SwitchSectionSyntax>()); 3609[.. caseClauses.Cast<SwitchSectionSyntax>()]); 3619[.. caseClauses.Cast<SwitchSectionSyntax>()],
ReassignedVariable\CSharpReassignedVariableService.cs (1)
78if (current is BlockSyntax or SwitchSectionSyntax or ArrowExpressionClauseSyntax or AnonymousMethodExpressionSyntax or MemberDeclarationSyntax)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (1)
72if (node is not SwitchSectionSyntax section)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (1)
184if (node is SwitchSectionSyntax switchSection)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\WrappingFormattingRule.cs (1)
82SwitchSectionSyntax switchSection => (switchSection.GetFirstToken(includeZeroWidth: true), switchSection.GetLastToken(includeZeroWidth: true)),
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpBlockFacts.cs (2)
31SwitchSectionSyntax switchSection => switchSection, 41SwitchSectionSyntax switchSection => switchSection.Statements,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (2)
412var section = targetToken.GetAncestor<SwitchSectionSyntax>();
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (1)
1564if (node is CaseSwitchLabelSyntax { Parent: SwitchSectionSyntax })
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (1)
174if (node is not SwitchSectionSyntax { Statements: [var firstStatement, ..] and [.., var lastStatement] })
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpReplaceDiscardDeclarationsWithAssignmentsService.cs (1)
208if (_localDeclarationStatement.Parent is BlockSyntax or SwitchSectionSyntax)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (1)
2289var container = afterNode.AncestorsAndSelf().FirstOrDefault(a => a is BlockSyntax or SwitchSectionSyntax);
Roslyn.Diagnostics.CSharp.Analyzers (11)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (1)
72if (node is not SwitchSectionSyntax section)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (1)
184if (node is SwitchSectionSyntax switchSection)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\WrappingFormattingRule.cs (1)
82SwitchSectionSyntax switchSection => (switchSection.GetFirstToken(includeZeroWidth: true), switchSection.GetLastToken(includeZeroWidth: true)),
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpBlockFacts.cs (2)
31SwitchSectionSyntax switchSection => switchSection, 41SwitchSectionSyntax switchSection => switchSection.Statements,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (2)
412var section = targetToken.GetAncestor<SwitchSectionSyntax>();
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (1)
1564if (node is CaseSwitchLabelSyntax { Parent: SwitchSectionSyntax })
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (1)
174if (node is not SwitchSectionSyntax { Statements: [var firstStatement, ..] and [.., var lastStatement] })
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpReplaceDiscardDeclarationsWithAssignmentsService.cs (1)
208if (_localDeclarationStatement.Parent is BlockSyntax or SwitchSectionSyntax)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (1)
2289var container = afterNode.AncestorsAndSelf().FirstOrDefault(a => a is BlockSyntax or SwitchSectionSyntax);