diff --git a/src/VisualStudio/Core/Def/Implementation/Diagnostics/VisualStudioDiagnosticAnalyzerService.cs b/src/VisualStudio/Core/Def/Implementation/Diagnostics/VisualStudioDiagnosticAnalyzerService.cs index d0a2cb3a4541b42c031e9486d8342264b800555a..073c30c9f4765f1f17ecdad5f46521e550397a61 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 e32bb13a3b71b8c717dbe7655bfe437f9652ab2e..afcfbaf0f8e8c532e873a2d093a0814f8bfedb65 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 d199bed06b19e34e8bb69b6efd168e275776d4f4..2b4e696a41de138f76180fcbdca2fa658b777762 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 4082320d477cf2b57172a4b3aac2ecd52ee2e907..9f40b40c57c90738b2d967f9db88d666474cde3b 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 13ca1750ad6def8566e1618282ff4e7a254501d2..078f8441351222e2ee5bde40d5447d6afbdb7113 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 f6a5ffa0869d6307f53a7401660d77cc282823f2..cdf9da2a5c04797d64b3fb5e7f718e3e48789f91 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 0a9c6ded5b5ba3cb5a11c3ba7b1dac81846e6fea..d1a00cd67d2eab7a2105d870661d0851688f82f1 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 f9fbc799b498ab1cb6824c3fc0a19d7952bc4e02..1490adfd2d5f2c8436621c92714441af2a20e386 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 590948605229bcfedb7713b4e628654bdd6241cd..ee403020bad5ba04b37d13652127c4c4b1e46273 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 fffa631f393509498db9b25e511a5adfac04aa19..6f55c48766b980ac1d79091ed049ba0e3266a5c9 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 654e37c865692ad1187d2b319f2592d296280f81..42a71dc4e0f4fec9521047ea739a44849fb5d98e 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 bee4ec9a687567f0bce90f202fccfed3e37ceb1d..c70b48ebe93796a4bfa0f278b58920113e2c38b2 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 a04fb04637fb1ba962c62cd1508ff43e4245d958..9ccb0f8e2284f30337927b7982528acf21cc3530 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 d35b7079dc55b53bd9b946d30b113ac32c80cc24..53a1ad5d94ab5d9a17c3e099d21f1968ac5bbc01 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 460e875d4bf90f445e7fd13a03ec0f906aec1e45..a20376a6e8a39c39b33cecf88c916f6c089b86ce 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 為規則運算式添加色彩