Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Extract method does not work if class in namespace
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

SMaton
New Member

7 Posts

Posted - Oct 01 2008 :  06:02:47 AM  Show Profile  Reply with Quote
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

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Oct 01 2008 :  2:52:50 PM  Show Profile  Reply with Quote
I am seeing the same effect here. Thank you for the clear description.

case=20072
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Oct 01 2008 :  3:11:00 PM  Show Profile  Reply with Quote
About the second case: extracting b = a; twice in a row is working for me if I avoid the main problem. So, the second case will work after case=20072 will be fixed.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000