Inline Variable - Nor working on simple assignments?

Hello

I am unable to inline a variable with Resharper.

Here is some example code where it is not working...

int i;
i=5;
int b;
b = i;

Here is some code where it works....

int i=5;
int b;
b = i;

Inline seems to be only accepting the variable assignment on creation in order to function....

I would expect Resharper to be able to detect the last asignment and then inline it for me...

1 comment
Comment actions Permalink

Hello Rdrunner,

Inline variable eliminates variable by inserting initialization expression
whenever variable is used. To be able to do this, variable shouldn't have
write usages except its initialization expression. I agree, that simple cases
like "declare and immediately assign" should be recognized by ReSharper,
but you can easily apply Context Action to merge declaration and assignment
and then issue Inline Variable.

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


IR> Hello
IR>
IR> I am unable to inline a variable with Resharper.
IR>
IR> Here is some example code where it is not working...
IR>
IR> int i;
IR> i=5;
IR> int b;
IR> b = i;
IR> Here is some code where it works....
IR>
IR> int i=5;
IR> int b;
IR> b = i;
IR> Inline seems to be only accepting the variable assignment on
IR> creation in order to function....
IR>
IR> I would expect Resharper to be able to detect the last asignment and
IR> then inline it for me...
IR>


0

Please sign in to leave a comment.