Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VB -> C#: Missing parenthesis when converting string concatenation #262

mrmonday opened this Issue Apr 5, 2019 · 1 comment


None yet
2 participants
Copy link

mrmonday commented Apr 5, 2019

Input code

Public Class Class1
    Sub Foo()
        Dim x = "x " & 5 - 4 & " y"
    End Sub
End Class

Erroneous output

public class Class1
    public void Foo()
        var x = "x " + 5 - 4 + " y";

Expected output

public class Class1
    public void Foo()
        var x = "x " + (5 - 4) + " y";


Product in use: e.g. VS extension

Version in use: e.g. 6.6.0

The converted code gives this error:

CS0019	Operator '-' cannot be applied to operands of type 'string' and 'int'

Adding parenthesis fixes the error.


This comment has been minimized.

Copy link

GrahamTheCoder commented Apr 8, 2019

Hopefully just a case of calling

private static CSharpSyntaxNode ParenthesizeIfPrecedenceCouldChange(VBasic.VisualBasicSyntaxNode node, ExpressionSyntax expression)
public override CSharpSyntaxNode VisitBinaryExpression(VBSyntax.BinaryExpressionSyntax node)

mrmonday added a commit to mrmonday/CodeConverter that referenced this issue Apr 19, 2019

@mrmonday mrmonday referenced a pull request that will close this issue Apr 19, 2019


Add parenthesis if necessary for binary expressions #290

2 of 2 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.