From ced80acaf5220cea6b28b2810ca7fea8698e8e72 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Mon, 11 May 2020 15:41:57 -0700 Subject: [PATCH] Address feedback --- .../VisualStudioDiagnosticAnalyzerService.cs | 58 +++++++++++-------- .../Core/Def/ServicesVSResources.resx | 6 ++ .../Core/Def/xlf/ServicesVSResources.cs.xlf | 10 ++++ .../Core/Def/xlf/ServicesVSResources.de.xlf | 10 ++++ .../Core/Def/xlf/ServicesVSResources.es.xlf | 10 ++++ .../Core/Def/xlf/ServicesVSResources.fr.xlf | 10 ++++ .../Core/Def/xlf/ServicesVSResources.it.xlf | 10 ++++ .../Core/Def/xlf/ServicesVSResources.ja.xlf | 10 ++++ .../Core/Def/xlf/ServicesVSResources.ko.xlf | 10 ++++ .../Core/Def/xlf/ServicesVSResources.pl.xlf | 10 ++++ .../Def/xlf/ServicesVSResources.pt-BR.xlf | 10 ++++ .../Core/Def/xlf/ServicesVSResources.ru.xlf | 10 ++++ .../Core/Def/xlf/ServicesVSResources.tr.xlf | 10 ++++ .../Def/xlf/ServicesVSResources.zh-Hans.xlf | 10 ++++ .../Def/xlf/ServicesVSResources.zh-Hant.xlf | 10 ++++ 15 files changed, 171 insertions(+), 23 deletions(-) diff --git a/src/VisualStudio/Core/Def/Implementation/Diagnostics/VisualStudioDiagnosticAnalyzerService.cs b/src/VisualStudio/Core/Def/Implementation/Diagnostics/VisualStudioDiagnosticAnalyzerService.cs index d0a2cb3a454..073c30c9f47 100644 --- a/src/VisualStudio/Core/Def/Implementation/Diagnostics/VisualStudioDiagnosticAnalyzerService.cs +++ b/src/VisualStudio/Core/Def/Implementation/Diagnostics/VisualStudioDiagnosticAnalyzerService.cs @@ -209,15 +209,20 @@ public void RunAnalyzers(IVsHierarchy? hierarchy) var asyncToken = _listener.BeginAsyncOperation($"{nameof(VisualStudioDiagnosticAnalyzerService)}_{nameof(RunAnalyzers)}"); Task.Run(async () => { - var onProjectAnalyzed = statusBarUpdater != null ? statusBarUpdater.OnProjectAnalyzed : (Action)((Project _) => { }); - await _diagnosticService.ForceAnalyzeAsync(solution, onProjectAnalyzed, project?.Id, CancellationToken.None).ConfigureAwait(false); - - // If user has disabled live analyzer execution for any project(s), i.e. set RunAnalyzersDuringLiveAnalysis = false, - // then ForceAnalyzeAsync will not cause analyzers to execute. - // We explicitly fetch diagnostics for such projects and report these as "Host" diagnostics. - HandleProjectsWithDisabledAnalysis(); + try + { + var onProjectAnalyzed = statusBarUpdater != null ? statusBarUpdater.OnProjectAnalyzed : (Action)((Project _) => { }); + await _diagnosticService.ForceAnalyzeAsync(solution, onProjectAnalyzed, project?.Id, CancellationToken.None).ConfigureAwait(false); - statusBarUpdater?.Dispose(); + // If user has disabled live analyzer execution for any project(s), i.e. set RunAnalyzersDuringLiveAnalysis = false, + // then ForceAnalyzeAsync will not cause analyzers to execute. + // We explicitly fetch diagnostics for such projects and report these as "Host" diagnostics. + HandleProjectsWithDisabledAnalysis(); + } + finally + { + statusBarUpdater?.Dispose(); + } }).CompletesAsyncOperation(asyncToken); return; @@ -352,6 +357,7 @@ private sealed class StatusBarUpdater : IDisposable private readonly uint _totalProjectCount; private readonly string _statusMessageWhileRunning; private readonly string _statusMesageOnCompleted; + private readonly string _statusMesageOnTerminated; private readonly Timer _timer; private int _analyzedProjectCount; @@ -371,6 +377,9 @@ public StatusBarUpdater(IVsStatusbar statusBar, IThreadingContext threadingConte _statusMesageOnCompleted = projectOrSolutionName != null ? string.Format(ServicesVSResources.Code_analysis_completed_for_0, projectOrSolutionName) : ServicesVSResources.Code_analysis_completed_for_Solution; + _statusMesageOnTerminated = projectOrSolutionName != null + ? string.Format(ServicesVSResources.Code_analysis_terminated_before_completion_for_0, projectOrSolutionName) + : ServicesVSResources.Code_analysis_terminated_before_completion_for_Solution; // Set the initial status bar progress and text. _statusBar.Progress(ref _statusBarCookie, fInProgress: 1, _statusMessageWhileRunning, nComplete: 0, nTotal: totalProjectCount); @@ -383,45 +392,48 @@ public StatusBarUpdater(IVsStatusbar statusBar, IThreadingContext threadingConte internal void OnProjectAnalyzed(Project _) { - var analyzedProjectCount = Interlocked.Increment(ref _analyzedProjectCount); - UpdateStatus(isRunning: analyzedProjectCount < _totalProjectCount); + Interlocked.Increment(ref _analyzedProjectCount); + UpdateStatusCore(); } // Add a message to VS status bar that we are running code analysis. private void UpdateStatusOnTimer(object state) - => UpdateStatus(isRunning: true); + => UpdateStatusCore(); public void Dispose() { _timer.Dispose(); _disposed = true; - UpdateStatus(isRunning: false); + UpdateStatusCore(); } - private void UpdateStatus(bool isRunning) + private void UpdateStatusCore() { - Task.Run(async () => + _threadingContext.JoinableTaskFactory.RunAsync(async () => { await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(); string message; - uint analyzedCount; int fInProgress; - if (isRunning && !_disposed && _analyzedProjectCount != _totalProjectCount) + var analyzedProjectCount = (uint)_analyzedProjectCount; + if (analyzedProjectCount == _totalProjectCount) { - message = _statusMessageWhileRunning; - analyzedCount = (uint)_analyzedProjectCount; - fInProgress = 1; + message = _statusMesageOnCompleted; + fInProgress = 0; } - else + else if (_disposed) { - message = _statusMesageOnCompleted; - analyzedCount = _totalProjectCount; + message = _statusMesageOnTerminated; fInProgress = 0; } + else + { + message = _statusMessageWhileRunning; + fInProgress = 1; + } // Update the status bar progress and text. - _statusBar.Progress(ref _statusBarCookie, fInProgress, message, analyzedCount, _totalProjectCount); + _statusBar.Progress(ref _statusBarCookie, fInProgress, message, analyzedProjectCount, _totalProjectCount); _statusBar.SetText(message); }); } diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.resx b/src/VisualStudio/Core/Def/ServicesVSResources.resx index e32bb13a3b7..afcfbaf0f8e 100644 --- a/src/VisualStudio/Core/Def/ServicesVSResources.resx +++ b/src/VisualStudio/Core/Def/ServicesVSResources.resx @@ -1344,6 +1344,12 @@ I agree to all of the foregoing: Code analysis completed for Solution. + + Code analysis terminated before completion for '{0}'. + + + Code analysis terminated before completion for Solution. + Background analysis scope: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf index d199bed06b1..2b4e696a41d 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf @@ -122,6 +122,16 @@ Dokončila se analýza kódu pro řešení. + + Code analysis terminated before completion for '{0}'. + Code analysis terminated before completion for '{0}'. + + + + Code analysis terminated before completion for Solution. + Code analysis terminated before completion for Solution. + + Colorize regular expressions Obarvit regulární výrazy diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf index 4082320d477..9f40b40c57c 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf @@ -122,6 +122,16 @@ Die Codeanalyse für die Projektmappe wurde abgeschlossen. + + Code analysis terminated before completion for '{0}'. + Code analysis terminated before completion for '{0}'. + + + + Code analysis terminated before completion for Solution. + Code analysis terminated before completion for Solution. + + Colorize regular expressions Reguläre Ausdrücke farbig hervorheben diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf index 13ca1750ad6..078f8441351 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf @@ -122,6 +122,16 @@ El análisis de código se ha completado para la solución. + + Code analysis terminated before completion for '{0}'. + Code analysis terminated before completion for '{0}'. + + + + Code analysis terminated before completion for Solution. + Code analysis terminated before completion for Solution. + + Colorize regular expressions Colorear expresiones regulares diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf index f6a5ffa0869..cdf9da2a5c0 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf @@ -122,6 +122,16 @@ Analyse du code effectuée pour la solution. + + Code analysis terminated before completion for '{0}'. + Code analysis terminated before completion for '{0}'. + + + + Code analysis terminated before completion for Solution. + Code analysis terminated before completion for Solution. + + Colorize regular expressions Coloriser les expressions régulières diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf index 0a9c6ded5b5..d1a00cd67d2 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf @@ -122,6 +122,16 @@ Analisi codice completata per la soluzione. + + Code analysis terminated before completion for '{0}'. + Code analysis terminated before completion for '{0}'. + + + + Code analysis terminated before completion for Solution. + Code analysis terminated before completion for Solution. + + Colorize regular expressions Colora espressioni regolari diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf index f9fbc799b49..1490adfd2d5 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf @@ -122,6 +122,16 @@ ソリューションのコード分析が完了しました。 + + Code analysis terminated before completion for '{0}'. + Code analysis terminated before completion for '{0}'. + + + + Code analysis terminated before completion for Solution. + Code analysis terminated before completion for Solution. + + Colorize regular expressions 正規表現をカラー化 diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf index 59094860522..ee403020bad 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf @@ -122,6 +122,16 @@ 솔루션에 대한 코드 분석이 완료되었습니다. + + Code analysis terminated before completion for '{0}'. + Code analysis terminated before completion for '{0}'. + + + + Code analysis terminated before completion for Solution. + Code analysis terminated before completion for Solution. + + Colorize regular expressions 정규식 색 지정 diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf index fffa631f393..6f55c48766b 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf @@ -122,6 +122,16 @@ Ukończono analizę kodu dla rozwiązania. + + Code analysis terminated before completion for '{0}'. + Code analysis terminated before completion for '{0}'. + + + + Code analysis terminated before completion for Solution. + Code analysis terminated before completion for Solution. + + Colorize regular expressions Koloruj wyrażenia regularne diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf index 654e37c8656..42a71dc4e0f 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf @@ -122,6 +122,16 @@ Análise de código concluída para a Solução. + + Code analysis terminated before completion for '{0}'. + Code analysis terminated before completion for '{0}'. + + + + Code analysis terminated before completion for Solution. + Code analysis terminated before completion for Solution. + + Colorize regular expressions Colorir expressões regulares diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf index bee4ec9a687..c70b48ebe93 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf @@ -122,6 +122,16 @@ Анализ кода для решения выполнен. + + Code analysis terminated before completion for '{0}'. + Code analysis terminated before completion for '{0}'. + + + + Code analysis terminated before completion for Solution. + Code analysis terminated before completion for Solution. + + Colorize regular expressions Выделить регулярные выражения цветом diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf index a04fb04637f..9ccb0f8e228 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf @@ -122,6 +122,16 @@ Çözüm için kod analizi tamamlandı. + + Code analysis terminated before completion for '{0}'. + Code analysis terminated before completion for '{0}'. + + + + Code analysis terminated before completion for Solution. + Code analysis terminated before completion for Solution. + + Colorize regular expressions Normal ifadeleri renklendir diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf index d35b7079dc5..53a1ad5d94a 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf @@ -122,6 +122,16 @@ 解决方案的代码分析已完成。 + + Code analysis terminated before completion for '{0}'. + Code analysis terminated before completion for '{0}'. + + + + Code analysis terminated before completion for Solution. + Code analysis terminated before completion for Solution. + + Colorize regular expressions 为正规表达式着色 diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf index 460e875d4bf..a20376a6e8a 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf @@ -122,6 +122,16 @@ 解決方案的程式碼分析已完成。 + + Code analysis terminated before completion for '{0}'. + Code analysis terminated before completion for '{0}'. + + + + Code analysis terminated before completion for Solution. + Code analysis terminated before completion for Solution. + + Colorize regular expressions 為規則運算式添加色彩 -- GitLab