Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

VB -> C#: Avoid creating code blocks for each case when converting Select Case #1244

Open
Labels
Good for coding agentCoding agent might get it in one - small change with repro enhancement

Description

When converting a Select Case statement, each outcome is wrapped in braces, creating a code block. This adds unnecessary indentation.

For example:

 Private Shared Function d1mach(i As Integer) As Double
 Select Case i
 Case 1
 Return 2.2250738585072014E-308 ' the smallest positive magnitude.
 Case 2
 Return Double.MaxValu ' the largest magnitude.
 End Select
 Return 0
 End Function

Is converted as:

 private static double d1mach(int i)
 {
 switch (i)
 {
 case 1:
 {
 return 2.2250738585072014E-308d; // the smallest positive magnitude.
 }
 case 2:
 {
 return double.MaxValue; // the largest magnitude.
 }
 }
 return 0d;
 }

Proposed solution
When no variable is created in the case branch, avoid creating a code block. The output code would be:

 private static double d1mach(int i)
 {
 switch (i)
 {
 case 1:
 return 2.2250738585072014E-308d; // the smallest positive magnitude.
 case 2:
 return double.MaxValue; // the largest magnitude.
 }
 return 0d;
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good for coding agentCoding agent might get it in one - small change with repro enhancement

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /