From dfbd0ed3e2e743e537be9a44375bcb17bcddb5b7 Mon Sep 17 00:00:00 2001 From: Jason Malinowski Date: Tue, 1 Feb 2022 19:05:04 -0800 Subject: [PATCH] Don't silently eat a certain class of analyzer-thrown exceptions If an analyzer threw an exception, we generate a message that tells you what diagnostic IDs the analzyer produces, so you know what to disable so you can work around the analyzer. If the analyzer then also were to throw exceptions while we ask it for it's SupportedDiagnostics, we were eating that exception. This includes that as well. --- .../Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs b/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs index e290776b3dfda..7f58b39152533 100644 --- a/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs +++ b/src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs @@ -1657,9 +1657,9 @@ private static string CreateDisablingMessage(DiagnosticAnalyzer analyzer) diagnosticIds = diagnosticIds.Add(diagnostic.Id); } } - catch (Exception) + catch (Exception ex) { - // Intentionally empty + return string.Format(CodeAnalysisResources.AnalyzerDriverThrowsDescription, ex.CreateDiagnosticDescription()) } if (diagnosticIds.IsEmpty)