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

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

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

mrmonday opened this issue Nov 19, 2019 · 2 comments
Assignees
Labels
VB -> C# Specific to VB -> C# conversion

Comments

@mrmonday
Copy link
Contributor

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 GrahamTheCoder added the VB -> C# Specific to VB -> C# conversion label Nov 19, 2019
@GrahamTheCoder
Copy link
Member

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

@mrmonday
Copy link
Contributor Author

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
Labels
VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

No branches or pull requests

2 participants