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

Couple of minor fixes.

上级 bb599add
......@@ -197,20 +197,21 @@ private Task ExecuteSyntaxTreeActions(CancellationToken cancellationToken)
var addDiagnostic = GetDiagnosticSinkWithSuppression(analyzerDriver.DiagnosticQueue.Enqueue, newCompilation);
Action<Exception, DiagnosticAnalyzer, Diagnostic> newOnAnalyzerException;
if (onAnalyzerException != null)
{
// Wrap onAnalyzerException to pass in filtered diagnostic.
var comp = newCompilation;
onAnalyzerException = (ex, analyzer, diagnostic) =>
newOnAnalyzerException = (ex, analyzer, diagnostic) =>
onAnalyzerException(ex, analyzer, GetFilteredDiagnostic(diagnostic, comp));
}
else
{
// Add exception diagnostic to regular diagnostic bag.
onAnalyzerException = (ex, analyzer, diagnostic) => addDiagnostic(diagnostic);
newOnAnalyzerException = (ex, analyzer, diagnostic) => addDiagnostic(diagnostic);
}
var analyzerExecutor = AnalyzerExecutor.Create(newCompilation, options, addDiagnostic, onAnalyzerException, cancellationToken);
var analyzerExecutor = AnalyzerExecutor.Create(newCompilation, options, addDiagnostic, newOnAnalyzerException, cancellationToken);
analyzerDriver.Initialize(newCompilation, analyzerExecutor, cancellationToken);
......
......@@ -148,9 +148,10 @@ public static TCompilation VerifyDiagnostics<TCompilation>(this TCompilation c,
var exceptionDiagnostics = new ConcurrentSet<Diagnostic>();
Action<Exception, DiagnosticAnalyzer, Diagnostic> newOnAnalyzerException;
if (onAnalyzerException != null)
{
onAnalyzerException = (ex, analyzer, diagnostic) =>
newOnAnalyzerException = (ex, analyzer, diagnostic) =>
{
exceptionDiagnostics.Add(diagnostic);
onAnalyzerException(ex, analyzer, diagnostic);
......@@ -159,11 +160,11 @@ public static TCompilation VerifyDiagnostics<TCompilation>(this TCompilation c,
else
{
// We want unit tests to throw if any analyzer OR the driver throws, unless the test explicitly provides a delegate.
onAnalyzerException = RethrowAnalyzerException;
newOnAnalyzerException = RethrowAnalyzerException;
}
Compilation newCompilation;
var driver = AnalyzerDriver.Create(c, analyzersArray, options, AnalyzerManager.Instance, onAnalyzerException, out newCompilation, CancellationToken.None);
var driver = AnalyzerDriver.Create(c, analyzersArray, options, AnalyzerManager.Instance, newOnAnalyzerException, out newCompilation, CancellationToken.None);
var discarded = newCompilation.GetDiagnostics();
diagnostics = driver.GetDiagnosticsAsync().Result.AddRange(exceptionDiagnostics);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册