108 references to Labels
Microsoft.CodeAnalysis.CSharp (10)
Binder\ExpressionVariableFinder.cs (1)
139foreach (SwitchLabelSyntax label in node.Labels)
Binder\LocalBinderFactory.cs (1)
749foreach (SwitchLabelSyntax label in node.Labels)
Binder\SwitchBinder.cs (1)
183BuildSwitchLabels(section.Labels, GetBinder(section), labels, BindingDiagnosticBag.Discarded);
Binder\SwitchBinder_Patterns.cs (2)
187var boundLabelsBuilder = ArrayBuilder<BoundSwitchLabel>.GetInstance(node.Labels.Count); 192foreach (SwitchLabelSyntax labelSyntax in node.Labels)
FlowAnalysis\AbstractFlowPass_Switch.cs (1)
108foreach (var label in sectionSyntax.Labels)
Syntax.xml.Main.Generated.cs (1)
1924=> node.Update(VisitList(node.Labels), VisitList(node.Statements));
Syntax.xml.Syntax.Generated.cs (3)
8606if (labels != this.Labels || statements != this.Statements) 8617public SwitchSectionSyntax WithStatements(SyntaxList<StatementSyntax> statements) => Update(this.Labels, statements); 8619public SwitchSectionSyntax AddLabels(params SwitchLabelSyntax[] items) => WithLabels(this.Labels.AddRange(items));
Microsoft.CodeAnalysis.CSharp.CodeStyle (15)
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs (2)
117if (!sections.All(s => CanConvertLabelsToArms(s.Labels))) 179if (switchStatement.Sections.Any(section => section.Labels.Any(label => IsDefaultSwitchLabel(label))))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (2)
82if (section.Labels.Count == 0 && 115var lastTokenOfLabel = section.Labels.Last().GetLastToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (9)
186if (switchSection.Labels.Count < 2) 194for (var i = 0; i < switchSection.Labels.Count - 1; ++i) 196if (switchSection.Labels[i] != null) 198AddSuppressWrappingIfOnSingleLineOperation(list, switchSection.Labels[i].GetFirstToken(includeZeroWidth: true), switchSection.Labels[i].GetLastToken(includeZeroWidth: true)); 203if (switchSection.Labels[switchSection.Labels.Count - 1] != null) 205AddSuppressWrappingIfOnSingleLineOperation(list, switchSection.Labels[switchSection.Labels.Count - 1].GetFirstToken(includeZeroWidth: true), switchSection.GetLastToken(includeZeroWidth: true));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (2)
470var originalSwitchLabels = originalSwitchStatement.Sections.SelectMany(section => section.Labels).ToArray(); 471var newSwitchLabels = newSwitchStatement.Sections.SelectMany(section => section.Labels).ToArray();
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (5)
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (4)
125pattern: GetPattern(node.Labels, out var whenClauseOpt), 224.OrderBy(section => section.Labels.Any(label => IsDefaultSwitchLabel(label))) 226(tokensForLeadingTrivia: new[] { s.Labels[0].GetFirstToken(), s.Labels[0].GetLastToken() },
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (1)
2132if (switchStatement.Sections.SelectMany(ss => ss.Labels)
Microsoft.CodeAnalysis.CSharp.Features (15)
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (4)
852var hasDecitionTree = oldNode.Sections.Any(s => s.Labels.Any(l => l is CasePatternSwitchLabelSyntax)); 1805return ((SwitchSectionSyntax)node).Labels.Last().Span; 2913=> oldSection.Labels.SequenceEqual(newSection.Labels, AreLabelsEquivalent);
EditAndContinue\SyntaxComparer.cs (2)
766return SyntaxFactory.AreEquivalent(left.Labels, right.Labels, null)
Highlighting\KeywordHighlighters\SwitchStatementHighlighter.cs (1)
43foreach (var label in switchSection.Labels)
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs (2)
117if (!sections.All(s => CanConvertLabelsToArms(s.Labels))) 179if (switchStatement.Sections.Any(section => section.Labels.Any(label => IsDefaultSwitchLabel(label))))
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (4)
125pattern: GetPattern(node.Labels, out var whenClauseOpt), 224.OrderBy(section => section.Labels.Any(label => IsDefaultSwitchLabel(label))) 226(tokensForLeadingTrivia: new[] { s.Labels[0].GetFirstToken(), s.Labels[0].GetLastToken() },
Structure\Providers\SwitchStatementStructureProvider.cs (2)
30if (section.Labels.Count > 0 && section.Statements.Count > 0) 32var start = section.Labels.Last().ColonToken.Span.End;
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (4)
Compilation\SemanticModelAPITests.cs (2)
1912var switchLabel = switchStatement.Sections[0].Labels[0]; 2783var switchLabel = switchStatement.Sections[0].Labels[0] as CaseSwitchLabelSyntax;
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (2)
718SwitchLabelSyntax switchLabel = switchStmt.Sections[0].Labels[0]; 751SwitchLabelSyntax switchLabel = switchStmt.Sections[0].Labels[0];
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (31)
Generated\Syntax.Test.xml.Generated.cs (2)
12813Assert.Equal(default, node.Labels); 12815var newNode = node.WithLabels(node.Labels).WithStatements(node.Statements);
Parsing\StatementParsingTests.cs (29)
2161Assert.Equal(1, ss.Sections[0].Labels.Count); 2162Assert.NotEqual(default, ss.Sections[0].Labels[0].Keyword); 2163Assert.Equal(SyntaxKind.CaseKeyword, ss.Sections[0].Labels[0].Keyword.Kind()); 2164var caseLabelSyntax = ss.Sections[0].Labels[0] as CaseSwitchLabelSyntax; 2197Assert.Equal(1, ss.Sections[0].Labels.Count); 2198Assert.NotEqual(default, ss.Sections[0].Labels[0].Keyword); 2199Assert.Equal(SyntaxKind.CaseKeyword, ss.Sections[0].Labels[0].Keyword.Kind()); 2200var caseLabelSyntax = ss.Sections[0].Labels[0] as CaseSwitchLabelSyntax; 2208Assert.Equal(1, ss.Sections[1].Labels.Count); 2209Assert.NotEqual(default, ss.Sections[1].Labels[0].Keyword); 2210Assert.Equal(SyntaxKind.CaseKeyword, ss.Sections[1].Labels[0].Keyword.Kind()); 2211var caseLabelSyntax2 = ss.Sections[1].Labels[0] as CaseSwitchLabelSyntax; 2244Assert.Equal(1, ss.Sections[0].Labels.Count); 2245Assert.NotEqual(default, ss.Sections[0].Labels[0].Keyword); 2246Assert.Equal(SyntaxKind.DefaultKeyword, ss.Sections[0].Labels[0].Keyword.Kind()); 2247Assert.Equal(SyntaxKind.DefaultSwitchLabel, ss.Sections[0].Labels[0].Kind()); 2248Assert.NotEqual(default, ss.Sections[0].Labels[0].ColonToken); 2277Assert.Equal(2, ss.Sections[0].Labels.Count); 2278Assert.NotEqual(default, ss.Sections[0].Labels[0].Keyword); 2279Assert.Equal(SyntaxKind.CaseKeyword, ss.Sections[0].Labels[0].Keyword.Kind()); 2280var caseLabelSyntax = ss.Sections[0].Labels[0] as CaseSwitchLabelSyntax; 2284Assert.NotEqual(default, ss.Sections[0].Labels[1].Keyword); 2285Assert.Equal(SyntaxKind.CaseKeyword, ss.Sections[0].Labels[1].Keyword.Kind()); 2286var caseLabelSyntax2 = ss.Sections[0].Labels[1] as CaseSwitchLabelSyntax; 2290Assert.NotEqual(default, ss.Sections[0].Labels[0].ColonToken); 2319Assert.Equal(1, ss.Sections[0].Labels.Count); 2320Assert.NotEqual(default, ss.Sections[0].Labels[0].Keyword); 2321Assert.Equal(SyntaxKind.CaseKeyword, ss.Sections[0].Labels[0].Keyword.Kind()); 2322var caseLabelSyntax = ss.Sections[0].Labels[0] as CaseSwitchLabelSyntax;
Microsoft.CodeAnalysis.CSharp.Workspaces (14)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (2)
82if (section.Labels.Count == 0 && 115var lastTokenOfLabel = section.Labels.Last().GetLastToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (9)
186if (switchSection.Labels.Count < 2) 194for (var i = 0; i < switchSection.Labels.Count - 1; ++i) 196if (switchSection.Labels[i] != null) 198AddSuppressWrappingIfOnSingleLineOperation(list, switchSection.Labels[i].GetFirstToken(includeZeroWidth: true), switchSection.Labels[i].GetLastToken(includeZeroWidth: true)); 203if (switchSection.Labels[switchSection.Labels.Count - 1] != null) 205AddSuppressWrappingIfOnSingleLineOperation(list, switchSection.Labels[switchSection.Labels.Count - 1].GetFirstToken(includeZeroWidth: true), switchSection.GetLastToken(includeZeroWidth: true));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (2)
470var originalSwitchLabels = originalSwitchStatement.Sections.SelectMany(section => section.Labels).ToArray(); 471var newSwitchLabels = newSwitchStatement.Sections.SelectMany(section => section.Labels).ToArray();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (1)
2132if (switchStatement.Sections.SelectMany(ss => ss.Labels)
Roslyn.Diagnostics.CSharp.Analyzers (14)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (2)
82if (section.Labels.Count == 0 && 115var lastTokenOfLabel = section.Labels.Last().GetLastToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (9)
186if (switchSection.Labels.Count < 2) 194for (var i = 0; i < switchSection.Labels.Count - 1; ++i) 196if (switchSection.Labels[i] != null) 198AddSuppressWrappingIfOnSingleLineOperation(list, switchSection.Labels[i].GetFirstToken(includeZeroWidth: true), switchSection.Labels[i].GetLastToken(includeZeroWidth: true)); 203if (switchSection.Labels[switchSection.Labels.Count - 1] != null) 205AddSuppressWrappingIfOnSingleLineOperation(list, switchSection.Labels[switchSection.Labels.Count - 1].GetFirstToken(includeZeroWidth: true), switchSection.GetLastToken(includeZeroWidth: true));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (2)
470var originalSwitchLabels = originalSwitchStatement.Sections.SelectMany(section => section.Labels).ToArray(); 471var newSwitchLabels = newSwitchStatement.Sections.SelectMany(section => section.Labels).ToArray();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (1)
2132if (switchStatement.Sections.SelectMany(ss => ss.Labels)