public void AnalyzeCodeBlock(CodeBlockEndAnalysisContext context)
 {
     if (IsEmptyFinalizer(context.CodeBlock, context.SemanticModel))
     {
         context.ReportDiagnostic(context.OwningSymbol.CreateDiagnostic(CA1821DiagnosticAnalyzerRule.Rule));
     }
 }
 public void AnalyzeCodeBlock(CodeBlockEndAnalysisContext context)
 {
     if (!suppress)
     {
         context.ReportDiagnostic(GetDiagnosticLocation(context.CodeBlock).CreateDiagnostic(Rule, context.OwningSymbol.Name));
     }
 }
        private static void AnalyzeBlock(CodeBlockEndAnalysisContext context)
        {
            SyntaxNode node = context.CodeBlock;

            //If the node isn't a Method Declaration - exit
            if (node.Kind() != SyntaxKind.MethodDeclaration)
            {
                return;
            }

            var block = node.ChildNodes().OfType <BlockSyntax>().FirstOrDefault();

            if (block == null)
            {
                return;
            }

            //If there are less than 10 statements - exit
            if (block.Statements.Count <= 10)
            {
                return;
            }

            //Get the identifier name
            var methodName = node.ChildTokens().FirstOrDefault(k => k.Kind() == SyntaxKind.IdentifierToken).Text;

            var diagnostic = Diagnostic.Create(Rule, block.GetLocation(), methodName);

            context.ReportDiagnostic(diagnostic);
        }
        private static void AnalyzeBlock(CodeBlockEndAnalysisContext context)
        {
            SyntaxNode node = context.CodeBlock;

            //If the node isn't a Method Declaration - exit
            if (node.Kind() != SyntaxKind.MethodDeclaration) return;

            var block = node.ChildNodes().OfType<BlockSyntax>().FirstOrDefault();
            if (block == null) return;

            //If there are less than 10 statements - exit
            if (block.Statements.Count <= 10) return;

            //Get the identifier name
            var methodName = node.ChildTokens().FirstOrDefault(k => k.Kind() == SyntaxKind.IdentifierToken).Text;

            var diagnostic = Diagnostic.Create(Rule, block.GetLocation(), methodName);
            context.ReportDiagnostic(diagnostic);
        }
Exemple #5
0
 public void AnalyzeCodeBlock(CodeBlockEndAnalysisContext context)
 {
 }
 private void AnalyzeCodeBlock(CodeBlockEndAnalysisContext context)
 {
     OnAbstractMember("CodeBlock", context.CodeBlock, context.OwningSymbol);
     OnOptions(context.Options);
 }
 public static void OnCodeBlockEnded(CodeBlockEndAnalysisContext context)
 {
     context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Desciptor1, Location.None));
 }
 public static void OnCodeBlockEnded(CodeBlockEndAnalysisContext context)
 {
     context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(Desciptor1, Location.None));
 }