Skip to content

VB -> C#: Select Case involving a range needs cast #780

@docfresh

Description

@docfresh

VB.Net input code

    Select Case u.userlevel
        Case userlevel.City_Staff To userlevel.Fixity_ROOT
            Return True
            Exit Function
    End Select

Erroneous output

        switch (u.userlevel)
        {
            case var @case when userlevel.City_Staff <= @case && @case <= userlevel.Fixity_ROOT:
                {
                    return true;
                    return default;
                }
        }

Expected output

adding a cast here seems to fix the problem.

        switch (u.userlevel)
        {
            case var @case when (int) userlevel.City_Staff <= @case && @case <= (int) userlevel.Fixity_ROOT:
                {
                    return true;
                    return default;
                }
        }

details

extension version 8.4.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good for coding agentCoding agent might get it in one - small change with reproVB -> C#Specific to VB -> C# conversioncompilation errorA bug where the converted output won't compile

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions