Example #1
0
        private async Task <ExpressionSyntax> ConvertToObjectComparisonOperatorAsync(VBSyntax.BinaryExpressionSyntax node, KnownMethod member)
        {
            var(lhs, rhs) = await AcceptSidesAsync(node);

            member = (member.Import, member.TypeName, "Conditional" + member.MethodName); //The VB compiler would late bind, but this should provide identical results in most cases I think
            var optionaCompareTextBoolLiteralExpression = _visualBasicEqualityComparison.OptionCompareTextCaseInsensitiveBoolExpression;

            return(member.Invoke(_visualBasicEqualityComparison.ExtraUsingDirectives, lhs, rhs, optionaCompareTextBoolLiteralExpression));
        }
Example #2
0
        private async Task <ExpressionSyntax> ConvertToLikeOperatorAsync(VBSyntax.BinaryExpressionSyntax node, KnownMethod member)
        {
            var(lhs, rhs) = await AcceptSidesAsync(node);

            var compareText = ValidSyntaxFactory.MemberAccess("CompareMethod", _visualBasicEqualityComparison.OptionCompareTextCaseInsensitive ? "Text" : "Binary");

            _visualBasicEqualityComparison.ExtraUsingDirectives.Add("Microsoft.VisualBasic");
            return(member.Invoke(_visualBasicEqualityComparison.ExtraUsingDirectives, lhs, rhs, compareText));
        }
Example #3
0
        private async Task <ExpressionSyntax> ConvertToStringComparisonOperatorAsync(VBSyntax.BinaryExpressionSyntax node, SyntaxKind expressionKind)
        {
            var(lhs, rhs) = await AcceptSidesAsync(node);

            lhs = VisualBasicEqualityComparison.VbCoerceToString(lhs, _semanticModel.GetTypeInfo(node.Left));
            rhs = VisualBasicEqualityComparison.VbCoerceToString(rhs, _semanticModel.GetTypeInfo(node.Right));
            var member = new KnownMethod(_compilerServices, _operators, "CompareString");
            var optionaCompareTextBoolLiteralExpression = _visualBasicEqualityComparison.OptionCompareTextCaseInsensitiveBoolExpression;
            var comparedLhs = member.Invoke(_visualBasicEqualityComparison.ExtraUsingDirectives, lhs, rhs, optionaCompareTextBoolLiteralExpression);

            return(SyntaxFactory.BinaryExpression(expressionKind, comparedLhs, LiteralConversions.GetLiteralExpression(0)));
        }
Example #4
0
        private async Task <ExpressionSyntax> ConvertToMethodAsync(VBSyntax.BinaryExpressionSyntax node, KnownMethod member)
        {
            var(lhs, rhs) = await AcceptSidesAsync(node);

            return(member.Invoke(_visualBasicEqualityComparison.ExtraUsingDirectives, lhs, rhs));
        }