[235] Inline variable unexpected behaviour Follow
I have this class (Forget about the logic of the code):
public class Class1
{
private int _prop1 = 0;
private int _prop2 = 0;
public int Prop1
{
get
{
_prop2++;
return _prop1;
}
set { _prop1 = value; }
}
public void Method1()
{
string[] strings = { "a", "b" };
int dummyInt = Prop1;
for (int i = 0; i < strings.Length; i++)
{
string s = strings[ i ];
s = dummyInt.ToString();
}
}
}
Now if on the line "s = dummyInt.ToString();" I move the cursor on dummyInt, and I choose Inline Variable from Refactor menu, I get this as a result for Method1:
public void Method1()
{
string[] strings = {"a", "b"};
for (int i = 0; i < strings.Length; i++)
{
string s = strings[ i ];
s = Prop1.ToString();
}
}
Which I think is logically wrong and a bug, because in the get method of Prop1, I'm doing more than just returning the value of _prop1. I think I should at least get a warning that applying this change might have a side effect.
Ali Bolourian
http://www.bolourian.com
Please sign in to leave a comment.
Can someone from R# asnwer why this is happening please?
Thanks,
Ali Bolourian