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

Extract Method on part of an expression generates invalid code #38087

Open
thetuvix opened this issue Aug 18, 2019 · 1 comment
Open

Extract Method on part of an expression generates invalid code #38087

thetuvix opened this issue Aug 18, 2019 · 1 comment
Labels
Area-IDE Bug Feature - Extract Method help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-CodeStyle Built-in analyzers, fixes, and refactorings
Projects
Milestone

Comments

@thetuvix
Copy link
Contributor

Version Used:
Visual Studio 2019 version 16.2.2

Steps to Reproduce:

  1. Add the following code to a class:
private void Repro()
{
    int i = 1, j = 2;
    int k = i + j + 1;
}
  1. Select i + j and perform an Extract Method refactoring.

Expected Behavior:
Extract Method generates NewMethod(int i, int j):

private void Repro()
{
    int i = 1, j = 2;
    int k = NewMethod(i, j) + 1;
}

private static int NewMethod(int i, int j)
{
    return i + j;
}

Actual Behavior:
Extract Method generates NewMethod() without parameters to pass in i and j:

private void Repro()
{
    int i = 1, j = 2;
    int k = NewMethod() + 1;
}

private static int NewMethod()
{
    return i + j;
}
@RikkiGibson RikkiGibson added Area-IDE Bug IDE-CodeStyle Built-in analyzers, fixes, and refactorings labels Aug 18, 2019
@RikkiGibson
Copy link
Contributor

This could be a problem in IDE code or in dataflow analysis. We'll see once we take a closer look at the bug.

@vatsalyaagrawal vatsalyaagrawal added this to the Backlog milestone Aug 20, 2019
@vatsalyaagrawal vatsalyaagrawal added the help wanted The issue is "up for grabs" - add a comment if you are interested in working on it label Aug 20, 2019
@vatsalyaagrawal vatsalyaagrawal added this to InQueue in Small Fixes via automation Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug Feature - Extract Method help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-CodeStyle Built-in analyzers, fixes, and refactorings
Projects
Small Fixes
  
InQueue
Development

No branches or pull requests

3 participants