Пример #1
0
        protected override ImmutableArray <ParameterSyntax> FindUnusedSyntax(
            MethodDeclarationSyntax node,
            ParameterListSyntax list,
            SeparatedSyntaxList <ParameterSyntax> separatedList,
            SemanticModel semanticModel,
            CancellationToken cancellationToken)
        {
            if (!node.IsParentKind(SyntaxKind.InterfaceDeclaration) &&
                !GetModifiers(node).ContainsAny(SyntaxKind.AbstractKeyword, SyntaxKind.VirtualKeyword, SyntaxKind.OverrideKeyword))
            {
                CSharpSyntaxNode bodyOrExpressionBody = GetBody(node);

                if (bodyOrExpressionBody != null &&
                    !UnusedSyntaxHelper.ContainsOnlyThrowNewException(bodyOrExpressionBody, semanticModel, cancellationToken))
                {
                    IMethodSymbol methodSymbol = semanticModel.GetDeclaredSymbol(node, cancellationToken);

                    if (methodSymbol?.IsEventHandler(semanticModel) == false &&
                        methodSymbol.ExplicitInterfaceImplementations.IsDefaultOrEmpty &&
                        !methodSymbol.ImplementsInterfaceMember())
                    {
                        return(base.FindUnusedSyntax(node, list, separatedList, semanticModel, cancellationToken));
                    }
                }
            }

            return(ImmutableArray <ParameterSyntax> .Empty);
        }
Пример #2
0
 protected override ImmutableArray <ParameterSyntax> FindUnusedSyntax(
     ConstructorDeclarationSyntax node,
     ParameterListSyntax list,
     SeparatedSyntaxList <ParameterSyntax> separatedList,
     SemanticModel semanticModel,
     CancellationToken cancellationToken)
 {
     if (GetBody(node) != null &&
         !UnusedSyntaxHelper.ContainsOnlyThrowNewException(node.BodyOrExpressionBody(), semanticModel, cancellationToken))
     {
         return(base.FindUnusedSyntax(node, list, separatedList, semanticModel, cancellationToken));
     }
     else
     {
         return(ImmutableArray <ParameterSyntax> .Empty);
     }
 }
        protected override ImmutableArray <ParameterSyntax> FindUnusedSyntax(
            IndexerDeclarationSyntax node,
            BracketedParameterListSyntax list,
            SeparatedSyntaxList <ParameterSyntax> separatedList,
            SemanticModel semanticModel,
            CancellationToken cancellationToken)
        {
            if (!node.IsParentKind(SyntaxKind.InterfaceDeclaration) &&
                !GetModifiers(node).ContainsAny(SyntaxKind.AbstractKeyword, SyntaxKind.VirtualKeyword, SyntaxKind.OverrideKeyword) &&
                GetBody(node) != null &&
                !UnusedSyntaxHelper.ContainsOnlyThrowNewException(node, semanticModel, cancellationToken))
            {
                IPropertySymbol propertySymbol = semanticModel.GetDeclaredSymbol(node, cancellationToken);

                if (propertySymbol?.ExplicitInterfaceImplementations.IsDefaultOrEmpty == true &&
                    !propertySymbol.ImplementsInterfaceMember())
                {
                    return(base.FindUnusedSyntax(node, list, separatedList, semanticModel, cancellationToken));
                }
            }

            return(ImmutableArray <ParameterSyntax> .Empty);
        }