private static void AnalyzeRedundantDefaultSwitchSection(SyntaxNodeAnalysisContext context, SwitchSectionSyntax switchSection)
 {
     if (switchSection.Labels.Any(SyntaxKind.DefaultSwitchLabel) &&
         ContainsOnlyBreakStatement(switchSection) &&
         switchSection
         .DescendantTrivia(switchSection.Span)
         .All(f => f.IsWhitespaceOrEndOfLineTrivia()))
     {
         context.ReportDiagnostic(
             DiagnosticDescriptors.RemoveRedundantDefaultSwitchSection,
             switchSection.GetLocation());
     }
 }
Beispiel #2
0
 public override void VisitSwitchSection(SwitchSectionSyntax node)
 {
     if (entryNode is AnonymousFunctionExpressionSyntax && embeddedNode is AnonymousFunctionExpressionSyntax)
     {
         return;
     }
     if (_weComeFromMethod && _weInAnonymousMethod)
     {
         return;
     }
     InsertLLOCMap(node.GetLocation());
     foreach (var statement in node.Statements)
     {
         InsertLLOCMap(statement.GetLocation());
     }
     foreach (var label in node.Labels)
     {
         InsertLLOCMap(label.GetLocation());
     }
     base.VisitSwitchSection(node);
 }