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#: Duplicate break in switch statement with Exit Select #433

Open
mrmonday opened this issue Nov 19, 2019 · 2 comments
Open

VB -> C#: Duplicate break in switch statement with Exit Select #433

mrmonday opened this issue Nov 19, 2019 · 2 comments
Labels

Comments

@mrmonday
Copy link
Contributor

@mrmonday mrmonday commented Nov 19, 2019

When using Exit Select in VB, the converter generates duplicate break statements in C#.

Input code

Class A
    Public Function Add(ByVal x As Integer) As Integer
        Select Case x
            Case 1
                Exit Select
        End Select
        Return 3
    End Function
End Class

Erroneous output

class A
{
    public int Add(int x)
    {
        switch (x)
        {
            case 1:
                {
                    break;
                    break;
                }
        }
        return 3;
    }
}

Expected output

class A
{
    public int Add(int x)
    {
        switch (x)
        {
            case 1:
                {
                    break;
                }
        }
        return 3;
    }
}

Details

  • Version in use: 7.2.0
warning CS0162: Unreachable code detected
@GrahamTheCoder

This comment has been minimized.

Copy link
Member

@GrahamTheCoder GrahamTheCoder commented Nov 19, 2019

Yep I'm guessing it just always sticks a break at the end, just linking #432 for reference

@mrmonday

This comment has been minimized.

Copy link
Contributor Author

@mrmonday mrmonday commented Nov 19, 2019

Interestingly it doesn't - I had to add the if statement in #432 to trigger it - if you just have Select Case x Case 1 Return 3 the break isn't added.

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