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#: String comparison doesn't follow VB's special logic after conversion #105

Closed
GrahamTheCoder opened this issue Apr 19, 2018 · 1 comment
Assignees
Labels
output logic error A bug where the converted output behaves differently to the input code VB -> C# Specific to VB -> C# conversion

Comments

@GrahamTheCoder
Copy link
Member

GrahamTheCoder commented Apr 19, 2018

Input code

    Dim x = ""
    Dim y = Nothing
    Dim z = x = y

Erroneous output

    var x = "";
    var y = null;
    var z = x == y;

Expected output

    var x = "";
    var y = null;
    var z = (x ?? "") == (y ?? "");

Details

Product in use: both

Version in use: 5.6.3

String operators = and <> should be converted to things that treat null and "" as equal.

  • x = y -> Microsoft.VisualBasic.CompilerServices.Operators.CompareString(string, string, bool) == 0
    *x <> y -> Microsoft.VisualBasic.CompilerServices.Operators.CompareString(string, string, bool) != 0
  • Comparison with empty string literal -> string.IsNullOrEmpty

<Fact(Skip := "https://github.com/icsharpcode/CodeConverter/issues/105")>
Public Sub EmptyStringEqualityToNull()
Dim s As String = ""
Dim areEqual As Boolean = s = Nothing
Assert.True(areEqual)
End Sub
should be enabled when this issue is resolved

@GrahamTheCoder GrahamTheCoder added output logic error A bug where the converted output behaves differently to the input code VB -> C# Specific to VB -> C# conversion labels Apr 19, 2018
@GrahamTheCoder GrahamTheCoder self-assigned this Mar 6, 2019
@GrahamTheCoder
Copy link
Member Author

#317 covered this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
output logic error A bug where the converted output behaves differently to the input code VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

No branches or pull requests

1 participant