SMaton
New Member
7 Posts |
Posted - Oct 01 2008 : 06:02:47 AM
|
Hi,
I remarked this since the last couple of releases but didn't report it (shame on me):
Imagine you have a header file with a class declaration embedded within a namespace:
namespace TEST { class A { public: int test(); };
}
Imagine further you have a source file in which you have stated "using namespace TEST;". You implement your function like this (note: code only for demonstration purposes and does not mirror my skill :) ):
int A::test() { int i = 0; int b, a; for ( ;i<10; i++) { b = a; }
return 1; }
You select "b=a;" and then extract method... you give the method a name, ok...
The method will not be part of the class a but put as a global function:
int MyMethod( int b, int a ) { b = a; return b; }
Even worse, the function is not declared before the first usage (in the same file) resulting in C3861
Ok... don't change anything in your code and go to the created "b = MyMethod(b, a);" line. Change it back (by hand) to "b=a;" and refactor again...
Result:
int MyMethod( int b, int a ) { b = a; return b;
int MyMethod( int b, int a ) { b = a; return b; } }
The function that got created is created INSIDE the first extracted method
I hope you can reproduce it.
BTW: VS2005 and Version 10.4.1649.0 built 2008.09.09
Have fun, Stefan
|
|