Example #1
0
        private static ImmutableArray <DiagnosticData> GetResult(DiagnosticAnalysisResult result, AnalysisKind kind, DocumentId id)
        {
            if (result.IsEmpty || !result.DocumentIds.Contains(id) || result.IsAggregatedForm)
            {
                return(ImmutableArray <DiagnosticData> .Empty);
            }

            return(kind switch
            {
                AnalysisKind.Syntax => result.GetResultOrEmpty(result.SyntaxLocals, id),
                AnalysisKind.Semantic => result.GetResultOrEmpty(result.SemanticLocals, id),
                AnalysisKind.NonLocal => result.GetResultOrEmpty(result.NonLocals, id),
                _ => Contract.FailWithReturn <ImmutableArray <DiagnosticData> >("shouldn't reach here"),
            });
        private static ImmutableArray <DiagnosticData> GetResult(DiagnosticAnalysisResult result, AnalysisKind kind, DocumentId id)
        {
            if (result.IsEmpty || !result.DocumentIds.Contains(id) || result.IsAggregatedForm)
            {
                return(ImmutableArray <DiagnosticData> .Empty);
            }

            switch (kind)
            {
            case AnalysisKind.Syntax:
                return(result.GetResultOrEmpty(result.SyntaxLocals, id));

            case AnalysisKind.Semantic:
                return(result.GetResultOrEmpty(result.SemanticLocals, id));

            case AnalysisKind.NonLocal:
                return(result.GetResultOrEmpty(result.NonLocals, id));

            default:
                return(Contract.FailWithReturn <ImmutableArray <DiagnosticData> >("shouldn't reach here"));
            }
        }
Example #3
0
        public static void LogProjectDiagnostics(Project project, DiagnosticAnalysisResult result)
        {
            if (!s_reportErrors || !s_reported.TryAdd(project.Id, null))
            {
                // doesn't meet the bar to report the issue.
                return;
            }

            // logs count of errors for this project. this won't log anything if FSA off since
            // we don't collect any diagnostics for a project if FSA is off.
            var map = new Dictionary <string, int>();

            foreach (var documentId in result.DocumentIdsOrEmpty)
            {
                CountErrors(map, result.GetResultOrEmpty(result.SyntaxLocals, documentId));
                CountErrors(map, result.GetResultOrEmpty(result.SemanticLocals, documentId));
                CountErrors(map, result.GetResultOrEmpty(result.NonLocals, documentId));
            }

            CountErrors(map, result.Others);

            LogErrors(project, "ProjectDignostics", project.Id.Id, map);
        }
        private static ImmutableArray<DiagnosticData> GetResult(DiagnosticAnalysisResult result, AnalysisKind kind, DocumentId id)
        {
            if (result.IsEmpty || !result.DocumentIds.Contains(id) || result.IsAggregatedForm)
            {
                return ImmutableArray<DiagnosticData>.Empty;
            }

            switch (kind)
            {
                case AnalysisKind.Syntax:
                    return result.GetResultOrEmpty(result.SyntaxLocals, id);
                case AnalysisKind.Semantic:
                    return result.GetResultOrEmpty(result.SemanticLocals, id);
                case AnalysisKind.NonLocal:
                    return result.GetResultOrEmpty(result.NonLocals, id);
                default:
                    return Contract.FailWithReturn<ImmutableArray<DiagnosticData>>("shouldn't reach here");
            }
        }