8

Here you can see how ReSharper is suggesting a change

enter image description here

Now here you can see how Resharper is changing up the code but the result is not correct because it is newing up a class, assigning a value to a property on it and then returning a totally new instance of that class that doesn't have the value assigned to it.

enter image description here

I had cursor on the new keyword. Pressed Alt+Enter and chose the option called "use object initializer".

Is this a possible bug in ReSharper or am I just missing something here?

15
  • 1
    What is it suggesting? Commented Apr 15, 2015 at 19:42
  • 1
    Yeah, that definitely doesn't look right. Commented Apr 15, 2015 at 19:43
  • 6
    That's wrong - it should refactor it to return new FlightRetrievalResponse {test = "this is a test"}; - What is the exact version of R# is this? Commented Apr 15, 2015 at 19:44
  • 4
    You sure you didn't pick "inline variable"? Commented Apr 15, 2015 at 19:45
  • 1
    Not sure I was much of a help though, it sure looks like a bug, the end result is exactly what "inline variable" would produce, and if it appeared after you applied "Use object initializer" then something got crosswired in there. If I experienced this I would first upgrade, then I would try to create a reproducible and simple example, and then contact Jetbrains. They always answer rather promptly to support requests so I would definitely do that. Commented Apr 15, 2015 at 20:02

1 Answer 1

1

It seems that it is not looking correctly. It should look like:

return new FlightRetrievalResponese
{
   test = "this is a test"
};

What is your R# version?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.