From a4fb45bff5cd29dafe1debd1689b3a88a9dd87d1 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 27 Feb 2015 03:27:45 -0800 Subject: [PATCH] Couple of minor fixes. --- .../Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs | 7 ++++--- src/Test/Utilities/DiagnosticExtensions.cs | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs b/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs index 29997a1b344..1756a0bfa6d 100644 --- a/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs +++ b/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs @@ -197,20 +197,21 @@ private Task ExecuteSyntaxTreeActions(CancellationToken cancellationToken) var addDiagnostic = GetDiagnosticSinkWithSuppression(analyzerDriver.DiagnosticQueue.Enqueue, newCompilation); + Action 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); diff --git a/src/Test/Utilities/DiagnosticExtensions.cs b/src/Test/Utilities/DiagnosticExtensions.cs index 9af11b403c5..e6b63f94d48 100644 --- a/src/Test/Utilities/DiagnosticExtensions.cs +++ b/src/Test/Utilities/DiagnosticExtensions.cs @@ -148,9 +148,10 @@ public static TCompilation VerifyDiagnostics(this TCompilation c, var exceptionDiagnostics = new ConcurrentSet(); + Action 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(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); -- GitLab