private static ThrowInfo GetUndocumentedExceptionInfo( SyntaxNode node, ExpressionSyntax expression, MemberDeclarationSyntax declaration, ISymbol declarationSymbol, SemanticModel semanticModel, CancellationToken cancellationToken) { if (expression != null) { ITypeSymbol typeSymbol = semanticModel.GetTypeSymbol(expression, cancellationToken); if (typeSymbol?.IsErrorType() == false && SymbolUtility.IsException(typeSymbol, semanticModel)) { DocumentationCommentTriviaSyntax comment = declaration.GetSingleLineDocumentationComment(); if (comment != null && !ContainsException(comment, typeSymbol, semanticModel, cancellationToken)) { return(ThrowInfo.Create(node, typeSymbol, declarationSymbol)); } } } return(null); }
private static AddExceptionToDocumentationCommentAnalysis Analyze( SyntaxNode node, ExpressionSyntax expression, SemanticModel semanticModel, CancellationToken cancellationToken) { ITypeSymbol exceptionSymbol = semanticModel.GetTypeSymbol(expression, cancellationToken); if (exceptionSymbol?.IsErrorType() == false && SymbolUtility.IsException(exceptionSymbol, semanticModel)) { ISymbol declarationSymbol = GetDeclarationSymbol(node.SpanStart, semanticModel, cancellationToken); if (declarationSymbol != null) { var containingMember = declarationSymbol .DeclaringSyntaxReferences[0] .GetSyntax(cancellationToken) as MemberDeclarationSyntax; if (containingMember != null) { SyntaxTrivia trivia = containingMember.GetSingleLineDocumentationComment(); if (trivia.IsKind(SyntaxKind.SingleLineDocumentationCommentTrivia)) { var comment = trivia.GetStructure() as DocumentationCommentTriviaSyntax; if (comment?.IsKind(SyntaxKind.SingleLineDocumentationCommentTrivia) == true && !ContainsException(comment, exceptionSymbol, semanticModel, cancellationToken)) { ThrowInfo throwInfo = ThrowInfo.Create(node, exceptionSymbol, declarationSymbol); return(new AddExceptionToDocumentationCommentAnalysis(throwInfo, trivia)); } } } } } return(AddExceptionToDocumentationCommentAnalysis.NoSuccess); }