public RequiredType GetObjectEqualityType(VBSyntax.BinaryExpressionSyntax node, TypeInfo leftType, TypeInfo rightType)
        {
            var typeInfos = new[] { leftType, rightType };

            if (!node.IsKind(VBasic.SyntaxKind.EqualsExpression, VBasic.SyntaxKind.NotEqualsExpression))
            {
                return(RequiredType.None);
            }
            return(GetObjectEqualityType(typeInfos));
        }
        public RequiredType GetObjectEqualityType(VBSyntax.BinaryExpressionSyntax node, TypeInfo leftType, TypeInfo rightType)
        {
            var typeInfos = new[] { leftType, rightType };

            if (!node.IsKind(VBasic.SyntaxKind.EqualsExpression, VBasic.SyntaxKind.NotEqualsExpression))
            {
                return(RequiredType.None);
            }

            bool requiresVbEqualityCheck = typeInfos.Any(t => t.Type?.SpecialType == SpecialType.System_Object);

            if (typeInfos.All(t => t.Type != null) && typeInfos.All(
                    t => t.Type.SpecialType == SpecialType.System_String ||
                    t.Type.IsArrayOf(SpecialType.System_Char)))
            {
                return(RequiredType.StringOnly);
            }
            ;

            return(requiresVbEqualityCheck ? RequiredType.Object : RequiredType.None);
        }
 private static ExpressionSyntax NegateIfNeeded(VBSyntax.BinaryExpressionSyntax node, InvocationExpressionSyntax positiveExpression)
 {
     return(node.IsKind(VBasic.SyntaxKind.EqualsExpression)
         ? (ExpressionSyntax)positiveExpression
         : SyntaxFactory.PrefixUnaryExpression(SyntaxKind.LogicalNotExpression, positiveExpression));
 }
 private static ExpressionSyntax NegateIfNeeded(VBSyntax.BinaryExpressionSyntax node, InvocationExpressionSyntax positiveExpression)
 {
     return(node.IsKind(VBasic.SyntaxKind.NotEqualsExpression)
        ? Negate(positiveExpression)
        : (ExpressionSyntax)positiveExpression);
 }