private async Task ResetStatesAsync()
                    {
                        try
                        {
                            var currentSolution = this.Processor.CurrentSolution;

                            if (currentSolution != _processingSolution)
                            {
                                ResetLogAggregatorIfNeeded(currentSolution);

                                // clear version tracking set we already reported.
                                _currentSnapshotVersionTrackingSet.Clear();

                                _processingSolution = currentSolution;

                                await RunAnalyzersAsync(this.Analyzers, currentSolution, (a, s, c) => a.NewSolutionSnapshotAsync(s, c), this.CancellationToken).ConfigureAwait(false);

                                foreach (var id in this.Processor.GetOpenDocumentIds())
                                {
                                    AddHigherPriorityDocument(id);
                                }

                                SolutionCrawlerLogger.LogResetStates(this.Processor._logAggregator);
                            }
                        }
                        catch (Exception e) when(FatalError.ReportUnlessCanceled(e))
                        {
                            throw ExceptionUtilities.Unreachable;
                        }
                    }
예제 #2
0
                    private async Task ResetStatesAsync()
                    {
                        try
                        {
                            var currentSolution = this.Processor.CurrentSolution;

                            if (currentSolution == _processingSolution)
                            {
                                return;
                            }

                            // solution has changed
                            ResetLogAggregatorIfNeeded(currentSolution);

                            _processingSolution = currentSolution;

                            // synchronize new solution to OOP
                            await currentSolution.Workspace.SynchronizePrimaryWorkspaceAsync(currentSolution, this.CancellationToken).ConfigureAwait(false);

                            await RunAnalyzersAsync(this.Analyzers, currentSolution, (a, s, c) => a.NewSolutionSnapshotAsync(s, c), this.CancellationToken).ConfigureAwait(false);

                            foreach (var id in this.Processor.GetOpenDocumentIds())
                            {
                                AddHigherPriorityDocument(id);
                            }

                            SolutionCrawlerLogger.LogResetStates(this.Processor._logAggregator);
                        }
                        catch (Exception e) when(FatalError.ReportUnlessCanceled(e))
                        {
                            throw ExceptionUtilities.Unreachable;
                        }
                    }
예제 #3
0
                    private async Task ResetStatesAsync()
                    {
                        try
                        {
                            if (!IsSolutionChanged())
                            {
                                return;
                            }

                            await Processor.RunAnalyzersAsync(Analyzers, Processor.CurrentSolution, workItem : new WorkItem(), (a, s, c) => a.NewSolutionSnapshotAsync(s, c), CancellationToken).ConfigureAwait(false);

                            foreach (var id in Processor.GetOpenDocumentIds())
                            {
                                AddHigherPriorityDocument(id);
                            }

                            SolutionCrawlerLogger.LogResetStates(Processor._logAggregator);
                        }
                        catch (Exception e) when(FatalError.ReportUnlessCanceled(e))
                        {
                            throw ExceptionUtilities.Unreachable;
                        }

                        bool IsSolutionChanged()
                        {
                            var currentSolution = Processor.CurrentSolution;
                            var oldSolution     = _lastSolution;

                            if (currentSolution == oldSolution)
                            {
                                return(false);
                            }

                            _lastSolution = currentSolution;

                            ResetLogAggregatorIfNeeded(currentSolution, oldSolution);

                            return(true);
                        }

                        void ResetLogAggregatorIfNeeded(Solution currentSolution, Solution oldSolution)
                        {
                            if (currentSolution == null || oldSolution == null ||
                                currentSolution.Id == oldSolution.Id)
                            {
                                // we log aggregated info when solution is changed such as
                                // new solution is opened or solution is closed
                                return;
                            }

                            // this log things like how many time we analyzed active files, how many times other files are analyzed,
                            // avg time to analyze files, how many solution snapshot got analyzed and etc.
                            // all accumultation is done in VS side and we only send statistics to VS telemetry otherwise, it is too much
                            // data to send
                            SolutionCrawlerLogger.LogIncrementalAnalyzerProcessorStatistics(
                                Processor._registration.CorrelationId, oldSolution, Processor._logAggregator, Analyzers);

                            Processor.ResetLogAggregator();
                        }
                    }