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

Address feedback

上级 424efa48
......@@ -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>)((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>)((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);
});
}
......
......@@ -1344,6 +1344,12 @@ I agree to all of the foregoing:</value>
<data name="Code_analysis_completed_for_Solution" xml:space="preserve">
<value>Code analysis completed for Solution.</value>
</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">
<value>Background analysis scope:</value>
</data>
......
......@@ -122,6 +122,16 @@
<target state="translated">Dokončila se analýza kódu pro řešení.</target>
<note />
</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">
<source>Colorize regular expressions</source>
<target state="translated">Obarvit regulární výrazy</target>
......
......@@ -122,6 +122,16 @@
<target state="translated">Die Codeanalyse für die Projektmappe wurde abgeschlossen.</target>
<note />
</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">
<source>Colorize regular expressions</source>
<target state="translated">Reguläre Ausdrücke farbig hervorheben</target>
......
......@@ -122,6 +122,16 @@
<target state="translated">El análisis de código se ha completado para la solución.</target>
<note />
</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">
<source>Colorize regular expressions</source>
<target state="translated">Colorear expresiones regulares</target>
......
......@@ -122,6 +122,16 @@
<target state="translated">Analyse du code effectuée pour la solution.</target>
<note />
</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">
<source>Colorize regular expressions</source>
<target state="translated">Coloriser les expressions régulières</target>
......
......@@ -122,6 +122,16 @@
<target state="translated">Analisi codice completata per la soluzione.</target>
<note />
</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">
<source>Colorize regular expressions</source>
<target state="translated">Colora espressioni regolari</target>
......
......@@ -122,6 +122,16 @@
<target state="translated">ソリューションのコード分析が完了しました。</target>
<note />
</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">
<source>Colorize regular expressions</source>
<target state="translated">正規表現をカラー化</target>
......
......@@ -122,6 +122,16 @@
<target state="translated">솔루션에 대한 코드 분석이 완료되었습니다.</target>
<note />
</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">
<source>Colorize regular expressions</source>
<target state="translated">정규식 색 지정</target>
......
......@@ -122,6 +122,16 @@
<target state="translated">Ukończono analizę kodu dla rozwiązania.</target>
<note />
</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">
<source>Colorize regular expressions</source>
<target state="translated">Koloruj wyrażenia regularne</target>
......
......@@ -122,6 +122,16 @@
<target state="translated">Análise de código concluída para a Solução.</target>
<note />
</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">
<source>Colorize regular expressions</source>
<target state="translated">Colorir expressões regulares</target>
......
......@@ -122,6 +122,16 @@
<target state="translated">Анализ кода для решения выполнен.</target>
<note />
</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">
<source>Colorize regular expressions</source>
<target state="translated">Выделить регулярные выражения цветом</target>
......
......@@ -122,6 +122,16 @@
<target state="translated">Çözüm için kod analizi tamamlandı.</target>
<note />
</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">
<source>Colorize regular expressions</source>
<target state="translated">Normal ifadeleri renklendir</target>
......
......@@ -122,6 +122,16 @@
<target state="translated">解决方案的代码分析已完成。</target>
<note />
</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">
<source>Colorize regular expressions</source>
<target state="translated">为正规表达式着色</target>
......
......@@ -122,6 +122,16 @@
<target state="translated">解決方案的程式碼分析已完成。</target>
<note />
</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">
<source>Colorize regular expressions</source>
<target state="translated">為規則運算式添加色彩</target>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册