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(); } }
public override void Shutdown() { base.Shutdown(); SolutionCrawlerLogger.LogIncrementalAnalyzerProcessorStatistics(Processor._registration.CorrelationId, Processor.CurrentSolution, Processor._logAggregator, Analyzers); _workItemQueue.Dispose(); _projectCache?.Dispose(); _projectCache = null; }
private void ResetLogAggregatorIfNeeded(Solution currentSolution) { if (currentSolution == null || _processingSolution == null || currentSolution.Id == _processingSolution.Id) { return; } SolutionCrawlerLogger.LogIncrementalAnalyzerProcessorStatistics( this.Processor._registration.CorrelationId, _processingSolution, this.Processor._logAggregator, this.Analyzers); this.Processor.ResetLogAggregator(); }
public override void Shutdown() { base.Shutdown(); SolutionCrawlerLogger.LogIncrementalAnalyzerProcessorStatistics(this.Processor._registration.CorrelationId, _processingSolution, this.Processor._logAggregator, this.Analyzers); _workItemQueue.Dispose(); if (_projectCache != null) { _projectCache.Dispose(); _projectCache = null; } }