Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Extract method does not work if class in namespace

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
SMaton 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
2   L A T E S T    R E P L I E S    (Newest First)
accord Posted - Oct 01 2008 : 3:11:00 PM
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.
accord Posted - Oct 01 2008 : 2:52:50 PM
I am seeing the same effect here. Thank you for the clear description.

case=20072

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000