public static async Task ComputeRefactoringAsync(RefactoringContext context, ThrowStatementSyntax throwStatement) { ExpressionSyntax expression = throwStatement.Expression; if (expression?.IsMissing == false && context.Span.IsContainedInSpanOrBetweenSpans(throwStatement)) { SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); ITypeSymbol typeSymbol = semanticModel.GetTypeSymbol(expression, context.CancellationToken); if (typeSymbol?.IsErrorType() == false && SyntaxAnalyzer.IsException(typeSymbol, semanticModel)) { MemberDeclarationSyntax member = GetContainingMember(throwStatement); if (member != null) { SyntaxTrivia trivia = member.GetSingleLineDocumentationComment(); if (trivia.IsSingleLineDocumentationCommentTrivia()) { var comment = trivia.GetStructure() as DocumentationCommentTriviaSyntax; if (comment?.IsKind(SyntaxKind.SingleLineDocumentationCommentTrivia) == true) { string exceptionName = typeSymbol .ToMinimalDisplayString(semanticModel, trivia.FullSpan.End) .Replace('<', '{') .Replace('>', '}'); if (!ContainsException(comment, typeSymbol, semanticModel, context.CancellationToken)) { context.RegisterRefactoring( "Add exception to documentation comment", cancellationToken => RefactorAsync(context.Document, trivia, exceptionName, cancellationToken)); } } } } } } }