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

Incorrect expansion of selection if followed by 'Else' #20088

Closed
sharwell opened this issue Jun 7, 2017 · 1 comment · Fixed by #76723
Closed

Incorrect expansion of selection if followed by 'Else' #20088

sharwell opened this issue Jun 7, 2017 · 1 comment · Fixed by #76723
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it Language-VB
Milestone

Comments

@sharwell
Copy link
Member

sharwell commented Jun 7, 2017

Version Used: 15.3 Preview 1

🔗 Originally reported by Kevin O'Donovan: https://developercommunity.visualstudio.com/content/problem/65499/extract-method-refactoring-ignores-selection.html

Steps to Reproduce:

  1. Use the following code

    Public Class Class1
    
        Private Function Method(arg As Integer?) As Boolean
            Dim something As Boolean
            If arg.HasValue Then
                something = True
            ElseIf arg.Value < 50 Then
                something = arg.Value > 15
            Else
                something = False
            End If
    
            Return something
        End Function
    
    End Class
  2. Click in the left margin to select the line something = arg.Value > 15

  3. Use the Extract Method refactoring

Expected Behavior:

Public Class Class1

    Private Function Method(arg As Integer?) As Boolean
        Dim something As Boolean
        If arg.HasValue Then
            something = True
        ElseIf arg.Value < 50 Then
            something = NewMethod(arg)
        Else
            something = False
        End If

        Return something
    End Function

    Private Shared Function NewMethod(arg As Integer?) As Boolean
        Return arg.Value > 15
    End Function
End Class

Actual Behavior:

Public Class Class1

    Private Function Method(arg As Integer?) As Boolean
        Dim something As Boolean
        something = NewMethod(arg)

        Return something
    End Function

    Private Shared Function NewMethod(arg As Integer?) As Boolean
        Dim something As Boolean

        If arg.HasValue Then
            something = True
        ElseIf arg.Value < 50 Then
            something = arg.Value > 15
        Else
            something = False
        End If

        Return something
    End Function
End Class
@sharwell sharwell added Area-IDE Bug Language-VB help wanted The issue is "up for grabs" - add a comment if you are interested in working on it labels Jun 7, 2017
@Pilchie Pilchie added this to the Unknown milestone Jun 8, 2017
@dmartensson

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it Language-VB
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

3 participants