Esempio n. 1
0
        private void ClearProjectState(Project project, DiagnosticAnalyzer analyzer, DiagnosticState state)
        {
            // remove saved cache
            state.Remove(project.Id);

            // raise diagnostic updated event
            var solutionArgs = new SolutionArgument(project);

            RaiseDiagnosticsUpdated(StateType.Project, project.Id, analyzer, solutionArgs, ImmutableArray <DiagnosticData> .Empty);
        }
Esempio n. 2
0
        private static async Task PersistProjectData(Project project, DiagnosticState state, AnalysisData data)
        {
            // TODO: Cancellation is not allowed here to prevent data inconsistency. But there is still a possibility of data inconsistency due to
            //       things like exception. For now, I am letting it go and let v2 engine take care of it properly. If v2 doesnt come online soon enough
            //       more refactoring is required on project state.

            // clear all existing data
            state.Remove(project.Id);
            foreach (var document in project.Documents)
            {
                state.Remove(document.Id);
            }

            // quick bail out
            if (data.Items.Length == 0)
            {
                return;
            }

            // save new data
            var group = data.Items.GroupBy(d => d.DocumentId);

            foreach (var kv in group)
            {
                if (kv.Key == null)
                {
                    // save project scope diagnostics
                    await state.PersistAsync(project, new AnalysisData(data.TextVersion, data.DataVersion, kv.ToImmutableArrayOrEmpty()), CancellationToken.None).ConfigureAwait(false);

                    continue;
                }

                // save document scope diagnostics
                var document = project.GetDocument(kv.Key);
                if (document == null)
                {
                    continue;
                }

                await state.PersistAsync(document, new AnalysisData(data.TextVersion, data.DataVersion, kv.ToImmutableArrayOrEmpty()), CancellationToken.None).ConfigureAwait(false);
            }
        }
Esempio n. 3
0
        private void ClearDocumentState(Document document, DiagnosticAnalyzer analyzer, StateType type, DiagnosticState state)
        {
            // remove saved info
            state.Remove(document.Id);

            // raise diagnostic updated event
            var documentId   = document.Id;
            var solutionArgs = new SolutionArgument(document);

            RaiseDiagnosticsUpdated(type, document.Id, analyzer, solutionArgs, ImmutableArray <DiagnosticData> .Empty);
        }
Esempio n. 4
0
        private async Task RemoveCacheDataAsync(Project project, DiagnosticState state, ProviderId providerId, CancellationToken cancellationToken)
        {
            try
            {
                // remove memory cache
                state.Remove(project.Id);

                // remove persistent cache
                await state.PersistAsync(project, AnalysisData.Empty, cancellationToken).ConfigureAwait(false);

                // raise diagnostic updated event
                var solutionArgs = new SolutionArgument(project);
                RaiseDiagnosticsUpdated(StateType.Project, project.Id, providerId, solutionArgs, ImmutableArray <DiagnosticData> .Empty);
            }
            catch (Exception e) when(FatalError.ReportUnlessCanceled(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
Esempio n. 5
0
        private async Task RemoveCacheDataAsync(Document document, DiagnosticState state, ProviderId providerId, StateType type, CancellationToken cancellationToken)
        {
            try
            {
                // remove memory cache
                state.Remove(document.Id);

                // remove persistent cache
                await state.PersistAsync(document, AnalysisData.Empty, cancellationToken).ConfigureAwait(false);

                // raise diagnostic updated event
                var documentId   = type == StateType.Project ? null : document.Id;
                var projectId    = document.Project.Id;
                var key          = documentId ?? (object)projectId;
                var solutionArgs = new SolutionArgument(document.Project.Solution, projectId, documentId);

                RaiseDiagnosticsUpdated(type, key, providerId, solutionArgs, ImmutableArray <DiagnosticData> .Empty);
            }
            catch (Exception e) when(FatalError.ReportUnlessCanceled(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
        private static async Task PersistProjectData(Project project, DiagnosticState state, AnalysisData data)
        {
            // TODO: Cancellation is not allowed here to prevent data inconsistency. But there is still a possibility of data inconsistency due to
            //       things like exception. For now, I am letting it go and let v2 engine take care of it properly. If v2 doesnt come online soon enough
            //       more refactoring is required on project state.

            // clear all existing data
            state.Remove(project.Id);
            foreach (var document in project.Documents)
            {
                state.Remove(document.Id);
            }

            // quick bail out
            if (data.Items.Length == 0)
            {
                return;
            }

            // save new data
            var group = data.Items.GroupBy(d => d.DocumentId);
            foreach (var kv in group)
            {
                if (kv.Key == null)
                {
                    // save project scope diagnostics
                    await state.PersistAsync(project, new AnalysisData(data.TextVersion, data.DataVersion, kv.ToImmutableArrayOrEmpty()), CancellationToken.None).ConfigureAwait(false);
                    continue;
                }

                // save document scope diagnostics
                var document = project.GetDocument(kv.Key);
                if (document == null)
                {
                    continue;
                }

                await state.PersistAsync(document, new AnalysisData(data.TextVersion, data.DataVersion, kv.ToImmutableArrayOrEmpty()), CancellationToken.None).ConfigureAwait(false);
            }
        }
            private async Task RemoveCacheDataAsync(Project project, DiagnosticState state, ProviderId providerId, CancellationToken cancellationToken)
            {
                try
                {
                    // remove memory cache
                    state.Remove(project.Id);

                    // remove persistent cache
                    await state.PersistAsync(project, AnalysisData.Empty, cancellationToken).ConfigureAwait(false);

                    // raise diagnostic updated event
                    var solutionArgs = new SolutionArgument(project);
                    RaiseDiagnosticsUpdated(StateType.Project, project.Id, providerId, solutionArgs, ImmutableArray<DiagnosticData>.Empty);
                }
                catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
                {
                    throw ExceptionUtilities.Unreachable;
                }
            }
            private async Task RemoveCacheDataAsync(Document document, DiagnosticState state, ProviderId providerId, StateType type, CancellationToken cancellationToken)
            {
                try
                {
                    // remove memory cache
                    state.Remove(document.Id);

                    // remove persistent cache
                    await state.PersistAsync(document, AnalysisData.Empty, cancellationToken).ConfigureAwait(false);

                    // raise diagnostic updated event
                    var documentId = type == StateType.Project ? null : document.Id;
                    var projectId = document.Project.Id;
                    var key = documentId ?? (object)projectId;
                    var solutionArgs = new SolutionArgument(document.Project.Solution, projectId, documentId);

                    RaiseDiagnosticsUpdated(type, key, providerId, solutionArgs, ImmutableArray<DiagnosticData>.Empty);
                }
                catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
                {
                    throw ExceptionUtilities.Unreachable;
                }
            }