提交 ced80aca 编写于 作者: M Manish Vasani

Address feedback

上级 424efa48
...@@ -209,15 +209,20 @@ public void RunAnalyzers(IVsHierarchy? hierarchy) ...@@ -209,15 +209,20 @@ public void RunAnalyzers(IVsHierarchy? hierarchy)
var asyncToken = _listener.BeginAsyncOperation($"{nameof(VisualStudioDiagnosticAnalyzerService)}_{nameof(RunAnalyzers)}"); var asyncToken = _listener.BeginAsyncOperation($"{nameof(VisualStudioDiagnosticAnalyzerService)}_{nameof(RunAnalyzers)}");
Task.Run(async () => Task.Run(async () =>
{ {
var onProjectAnalyzed = statusBarUpdater != null ? statusBarUpdater.OnProjectAnalyzed : (Action<Project>)((Project _) => { }); try
await _diagnosticService.ForceAnalyzeAsync(solution, onProjectAnalyzed, project?.Id, CancellationToken.None).ConfigureAwait(false); {
var onProjectAnalyzed = statusBarUpdater != null ? statusBarUpdater.OnProjectAnalyzed : (Action<Project>)((Project _) => { });
// If user has disabled live analyzer execution for any project(s), i.e. set RunAnalyzersDuringLiveAnalysis = false, await _diagnosticService.ForceAnalyzeAsync(solution, onProjectAnalyzed, project?.Id, CancellationToken.None).ConfigureAwait(false);
// then ForceAnalyzeAsync will not cause analyzers to execute.
// We explicitly fetch diagnostics for such projects and report these as "Host" diagnostics.
HandleProjectsWithDisabledAnalysis();
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); }).CompletesAsyncOperation(asyncToken);
return; return;
...@@ -352,6 +357,7 @@ private sealed class StatusBarUpdater : IDisposable ...@@ -352,6 +357,7 @@ private sealed class StatusBarUpdater : IDisposable
private readonly uint _totalProjectCount; private readonly uint _totalProjectCount;
private readonly string _statusMessageWhileRunning; private readonly string _statusMessageWhileRunning;
private readonly string _statusMesageOnCompleted; private readonly string _statusMesageOnCompleted;
private readonly string _statusMesageOnTerminated;
private readonly Timer _timer; private readonly Timer _timer;
private int _analyzedProjectCount; private int _analyzedProjectCount;
...@@ -371,6 +377,9 @@ public StatusBarUpdater(IVsStatusbar statusBar, IThreadingContext threadingConte ...@@ -371,6 +377,9 @@ public StatusBarUpdater(IVsStatusbar statusBar, IThreadingContext threadingConte
_statusMesageOnCompleted = projectOrSolutionName != null _statusMesageOnCompleted = projectOrSolutionName != null
? string.Format(ServicesVSResources.Code_analysis_completed_for_0, projectOrSolutionName) ? string.Format(ServicesVSResources.Code_analysis_completed_for_0, projectOrSolutionName)
: ServicesVSResources.Code_analysis_completed_for_Solution; : 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. // Set the initial status bar progress and text.
_statusBar.Progress(ref _statusBarCookie, fInProgress: 1, _statusMessageWhileRunning, nComplete: 0, nTotal: totalProjectCount); _statusBar.Progress(ref _statusBarCookie, fInProgress: 1, _statusMessageWhileRunning, nComplete: 0, nTotal: totalProjectCount);
...@@ -383,45 +392,48 @@ public StatusBarUpdater(IVsStatusbar statusBar, IThreadingContext threadingConte ...@@ -383,45 +392,48 @@ public StatusBarUpdater(IVsStatusbar statusBar, IThreadingContext threadingConte
internal void OnProjectAnalyzed(Project _) internal void OnProjectAnalyzed(Project _)
{ {
var analyzedProjectCount = Interlocked.Increment(ref _analyzedProjectCount); Interlocked.Increment(ref _analyzedProjectCount);
UpdateStatus(isRunning: analyzedProjectCount < _totalProjectCount); UpdateStatusCore();
} }
// Add a message to VS status bar that we are running code analysis. // Add a message to VS status bar that we are running code analysis.
private void UpdateStatusOnTimer(object state) private void UpdateStatusOnTimer(object state)
=> UpdateStatus(isRunning: true); => UpdateStatusCore();
public void Dispose() public void Dispose()
{ {
_timer.Dispose(); _timer.Dispose();
_disposed = true; _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(); await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync();
string message; string message;
uint analyzedCount;
int fInProgress; int fInProgress;
if (isRunning && !_disposed && _analyzedProjectCount != _totalProjectCount) var analyzedProjectCount = (uint)_analyzedProjectCount;
if (analyzedProjectCount == _totalProjectCount)
{ {
message = _statusMessageWhileRunning; message = _statusMesageOnCompleted;
analyzedCount = (uint)_analyzedProjectCount; fInProgress = 0;
fInProgress = 1;
} }
else else if (_disposed)
{ {
message = _statusMesageOnCompleted; message = _statusMesageOnTerminated;
analyzedCount = _totalProjectCount;
fInProgress = 0; fInProgress = 0;
} }
else
{
message = _statusMessageWhileRunning;
fInProgress = 1;
}
// Update the status bar progress and text. // 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); _statusBar.SetText(message);
}); });
} }
......
...@@ -1344,6 +1344,12 @@ I agree to all of the foregoing:</value> ...@@ -1344,6 +1344,12 @@ I agree to all of the foregoing:</value>
<data name="Code_analysis_completed_for_Solution" xml:space="preserve"> <data name="Code_analysis_completed_for_Solution" xml:space="preserve">
<value>Code analysis completed for Solution.</value> <value>Code analysis completed for Solution.</value>
</data> </data>
<data name="Code_analysis_terminated_before_completion_for_0" xml:space="preserve">
<value>Code analysis terminated before completion for '{0}'.</value>
</data>
<data name="Code_analysis_terminated_before_completion_for_Solution" xml:space="preserve">
<value>Code analysis terminated before completion for Solution.</value>
</data>
<data name="Background_analysis_scope_colon" xml:space="preserve"> <data name="Background_analysis_scope_colon" xml:space="preserve">
<value>Background analysis scope:</value> <value>Background analysis scope:</value>
</data> </data>
......
...@@ -122,6 +122,16 @@ ...@@ -122,6 +122,16 @@
<target state="translated">Dokončila se analýza kódu pro řešení.</target> <target state="translated">Dokončila se analýza kódu pro řešení.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions"> <trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source> <source>Colorize regular expressions</source>
<target state="translated">Obarvit regulární výrazy</target> <target state="translated">Obarvit regulární výrazy</target>
......
...@@ -122,6 +122,16 @@ ...@@ -122,6 +122,16 @@
<target state="translated">Die Codeanalyse für die Projektmappe wurde abgeschlossen.</target> <target state="translated">Die Codeanalyse für die Projektmappe wurde abgeschlossen.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions"> <trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source> <source>Colorize regular expressions</source>
<target state="translated">Reguläre Ausdrücke farbig hervorheben</target> <target state="translated">Reguläre Ausdrücke farbig hervorheben</target>
......
...@@ -122,6 +122,16 @@ ...@@ -122,6 +122,16 @@
<target state="translated">El análisis de código se ha completado para la solución.</target> <target state="translated">El análisis de código se ha completado para la solución.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions"> <trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source> <source>Colorize regular expressions</source>
<target state="translated">Colorear expresiones regulares</target> <target state="translated">Colorear expresiones regulares</target>
......
...@@ -122,6 +122,16 @@ ...@@ -122,6 +122,16 @@
<target state="translated">Analyse du code effectuée pour la solution.</target> <target state="translated">Analyse du code effectuée pour la solution.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions"> <trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source> <source>Colorize regular expressions</source>
<target state="translated">Coloriser les expressions régulières</target> <target state="translated">Coloriser les expressions régulières</target>
......
...@@ -122,6 +122,16 @@ ...@@ -122,6 +122,16 @@
<target state="translated">Analisi codice completata per la soluzione.</target> <target state="translated">Analisi codice completata per la soluzione.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions"> <trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source> <source>Colorize regular expressions</source>
<target state="translated">Colora espressioni regolari</target> <target state="translated">Colora espressioni regolari</target>
......
...@@ -122,6 +122,16 @@ ...@@ -122,6 +122,16 @@
<target state="translated">ソリューションのコード分析が完了しました。</target> <target state="translated">ソリューションのコード分析が完了しました。</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions"> <trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source> <source>Colorize regular expressions</source>
<target state="translated">正規表現をカラー化</target> <target state="translated">正規表現をカラー化</target>
......
...@@ -122,6 +122,16 @@ ...@@ -122,6 +122,16 @@
<target state="translated">솔루션에 대한 코드 분석이 완료되었습니다.</target> <target state="translated">솔루션에 대한 코드 분석이 완료되었습니다.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions"> <trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source> <source>Colorize regular expressions</source>
<target state="translated">정규식 색 지정</target> <target state="translated">정규식 색 지정</target>
......
...@@ -122,6 +122,16 @@ ...@@ -122,6 +122,16 @@
<target state="translated">Ukończono analizę kodu dla rozwiązania.</target> <target state="translated">Ukończono analizę kodu dla rozwiązania.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions"> <trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source> <source>Colorize regular expressions</source>
<target state="translated">Koloruj wyrażenia regularne</target> <target state="translated">Koloruj wyrażenia regularne</target>
......
...@@ -122,6 +122,16 @@ ...@@ -122,6 +122,16 @@
<target state="translated">Análise de código concluída para a Solução.</target> <target state="translated">Análise de código concluída para a Solução.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions"> <trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source> <source>Colorize regular expressions</source>
<target state="translated">Colorir expressões regulares</target> <target state="translated">Colorir expressões regulares</target>
......
...@@ -122,6 +122,16 @@ ...@@ -122,6 +122,16 @@
<target state="translated">Анализ кода для решения выполнен.</target> <target state="translated">Анализ кода для решения выполнен.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions"> <trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source> <source>Colorize regular expressions</source>
<target state="translated">Выделить регулярные выражения цветом</target> <target state="translated">Выделить регулярные выражения цветом</target>
......
...@@ -122,6 +122,16 @@ ...@@ -122,6 +122,16 @@
<target state="translated">Çözüm için kod analizi tamamlandı.</target> <target state="translated">Çözüm için kod analizi tamamlandı.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions"> <trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source> <source>Colorize regular expressions</source>
<target state="translated">Normal ifadeleri renklendir</target> <target state="translated">Normal ifadeleri renklendir</target>
......
...@@ -122,6 +122,16 @@ ...@@ -122,6 +122,16 @@
<target state="translated">解决方案的代码分析已完成。</target> <target state="translated">解决方案的代码分析已完成。</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions"> <trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source> <source>Colorize regular expressions</source>
<target state="translated">为正规表达式着色</target> <target state="translated">为正规表达式着色</target>
......
...@@ -122,6 +122,16 @@ ...@@ -122,6 +122,16 @@
<target state="translated">解決方案的程式碼分析已完成。</target> <target state="translated">解決方案的程式碼分析已完成。</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_0">
<source>Code analysis terminated before completion for '{0}'.</source>
<target state="new">Code analysis terminated before completion for '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="Code_analysis_terminated_before_completion_for_Solution">
<source>Code analysis terminated before completion for Solution.</source>
<target state="new">Code analysis terminated before completion for Solution.</target>
<note />
</trans-unit>
<trans-unit id="Colorize_regular_expressions"> <trans-unit id="Colorize_regular_expressions">
<source>Colorize regular expressions</source> <source>Colorize regular expressions</source>
<target state="translated">為規則運算式添加色彩</target> <target state="translated">為規則運算式添加色彩</target>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册