Пример #1
0
        private bool ShouldRunForFullProject(DiagnosticAnalyzer analyzer, Project project)
        {
            // PERF: Don't query descriptors for compiler analyzer, always execute it.
            if (HostAnalyzerManager.IsCompilerDiagnosticAnalyzer(project.Language, analyzer))
            {
                return(true);
            }

            return(Owner.ShouldRunForFullProject(analyzer, project));
        }
        private bool ShouldRunForFullProject(DiagnosticAnalyzer analyzer, Project project)
        {
            // PERF: Don't query descriptors for compiler analyzer, always execute it.
            if (HostAnalyzerManager.IsCompilerDiagnosticAnalyzer(project.Language, analyzer))
            {
                return(true);
            }

            // most of analyzers, number of descriptor is quite small, so this should be cheap.
            return(Owner.GetDiagnosticDescriptors(analyzer).Any(d => GetEffectiveSeverity(d, project.CompilationOptions) != ReportDiagnostic.Hidden));
        }
        private bool SupportAnalysisKind(DiagnosticAnalyzer analyzer, string language, AnalysisKind kind)
        {
            // compiler diagnostic analyzer always support all kinds
            if (HostAnalyzerManager.IsCompilerDiagnosticAnalyzer(language, analyzer))
            {
                return(true);
            }

            switch (kind)
            {
            case AnalysisKind.Syntax:
                return(analyzer.SupportsSyntaxDiagnosticAnalysis());

            case AnalysisKind.Semantic:
                return(analyzer.SupportsSemanticDiagnosticAnalysis());

            default:
                return(Contract.FailWithReturn <bool>("shouldn't reach here"));
            }
        }
        private bool IsCandidateForFullSolutionAnalysis(DiagnosticAnalyzer analyzer, Project project)
        {
            // PERF: Don't query descriptors for compiler analyzer, always execute it.
            if (HostAnalyzerManager.IsCompilerDiagnosticAnalyzer(project.Language, analyzer))
            {
                return(true);
            }

            if (analyzer.IsBuiltInAnalyzer())
            {
                // always return true for builtin analyzer. we can't use
                // descriptor check since many builtin analyzer always return
                // hidden descriptor regardless what descriptor it actually
                // return on runtime. they do this so that they can control
                // severity through option page rather than rule set editor.
                // this is special behavior only ide analyzer can do. we hope
                // once we support editorconfig fully, third party can use this
                // ability as well and we can remove this kind special treatment on builtin
                // analyzer.
                return(true);
            }

            return(Owner.HasNonHiddenDescriptor(analyzer, project));
        }