コード例 #1
0
        protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
        {
            if (properties.VisitorName == nameof(CollectionShouldNotContainPropertyAnalyzer.AnyShouldBeFalseSyntaxVisitor))
            {
                var remove        = new NodeReplacement.RemoveAndExtractArgumentsNodeReplacement("Any");
                var newExpression = GetNewExpression(expression, remove);

                return(GetNewExpression(newExpression, NodeReplacement.RenameAndPrependArguments("BeFalse", "NotContain", remove.Arguments)));
            }
            else if (properties.VisitorName == nameof(CollectionShouldNotContainPropertyAnalyzer.WhereShouldBeEmptySyntaxVisitor))
            {
                var remove        = new NodeReplacement.RemoveAndExtractArgumentsNodeReplacement("Where");
                var newExpression = GetNewExpression(expression, remove);

                return(GetNewExpression(newExpression, NodeReplacement.RenameAndPrependArguments("BeEmpty", "NotContain", remove.Arguments)));
            }
            else if (properties.VisitorName == nameof(CollectionShouldNotContainPropertyAnalyzer.ShouldOnlyContainNotSyntaxVisitor))
            {
                return(GetNewExpression(expression, NodeReplacement.RenameAndNegateLambda("OnlyContain", "NotContain")));
            }
            throw new System.InvalidOperationException($"Invalid visitor name - {properties.VisitorName}");
        }