private void AnalyseSyntax(SyntaxNodeAnalysisContext context)
        {
            var whileStatement = context.Node as WhileStatementSyntax;

            if (whileStatement is null)
            {
                if (!Debugger.IsAttached)
                {
                    Debugger.Launch();
                }

                return;
            }

            var problematicCatch = ThreadAbortSyntaxHelper.FindProblematicCatchClause(whileStatement, context.SemanticModel);

            if (problematicCatch is null)
            {
                // no issues
                return;
            }

            // For all such symbols, produce a diagnostic.
            var diagnostic = Diagnostic.Create(Rule, problematicCatch.GetLocation());

            context.ReportDiagnostic(diagnostic);
        }
        private async Task <Document> AddThrowStatement(Document document, WhileStatementSyntax whileStatement, CancellationToken cancellationToken)
        {
            var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);

            var catchBlock = ThreadAbortSyntaxHelper.FindProblematicCatchClause(whileStatement, semanticModel);

            // This messes with the whitespace, but it's a PITA to get that right
            var throwStatement = SyntaxFactory.ThrowStatement();
            var statements     = catchBlock.Block.Statements.Add(throwStatement);
            var newCatchBlock  = catchBlock.Block.WithStatements(statements);

            // replace the syntax and return updated document
            var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            root = root.ReplaceNode(catchBlock.Block, newCatchBlock);
            return(document.WithSyntaxRoot(root));
        }