public void TestExceptionFromSupportedSuppressions()
        {
            string source = "class C { }";

            var compilation = CreateCompilation(source);

            compilation.VerifyDiagnostics();

            var expectedException = new NotImplementedException();
            var analyzer          = new CompilationAnalyzerWithSeverity(
                DiagnosticSeverity.Warning,
                configurable: true
                );
            var suppressor = new DiagnosticSuppressorThrowsExceptionFromSupportedSuppressions(
                expectedException
                );
            var exceptions = new List <Exception>();
            EventHandler <FirstChanceExceptionEventArgs> firstChanceException = (sender, e) =>
            {
                if (e.Exception == expectedException)
                {
                    exceptions.Add(e.Exception);
                }
            };

            try
            {
                AppDomain.CurrentDomain.FirstChanceException += firstChanceException;

                IFormattable context =
                    $@"{new LazyToString(() => exceptions[0])}
-----";
                var analyzersAndSuppresors = new DiagnosticAnalyzer[] { analyzer, suppressor };
                VerifyAnalyzerDiagnostics(
                    compilation,
                    analyzersAndSuppresors,
                    Diagnostic("AD0001")
                    .WithArguments(
                        suppressor.ToString(),
                        typeof(NotImplementedException).FullName,
                        new NotImplementedException().Message,
                        context
                        )
                    .WithLocation(1, 1),
                    Diagnostic("ID1000", "class C { }").WithLocation(1, 1)
                    );

                VerifySuppressedDiagnostics(compilation, analyzersAndSuppresors);
            }
            finally
            {
                AppDomain.CurrentDomain.FirstChanceException -= firstChanceException;
            }
        }
        public void TestExceptionFromSupportedSuppressions()
        {
            string source = "class C { }";

            var compilation = CreateCompilation(source);

            compilation.VerifyDiagnostics();

            var analyzer               = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true);
            var suppressor             = new DiagnosticSuppressorThrowsExceptionFromSupportedSuppressions();
            var analyzersAndSuppresors = new DiagnosticAnalyzer[] { analyzer, suppressor };

            VerifyAnalyzerDiagnostics(compilation, analyzersAndSuppresors,
                                      Diagnostic("AD0001").WithArguments(suppressor.ToString(), typeof(NotImplementedException).FullName, new NotImplementedException().Message).WithLocation(1, 1),
                                      Diagnostic("ID1000", "class C { }").WithLocation(1, 1));

            VerifySuppressedDiagnostics(compilation, analyzersAndSuppresors);
        }