T O P I C R E V I E W |
vishnu |
Posted - Oct 07 2008 : 09:18:45 AM In the latest release 1649, the problem with extract method is not fixed. To reproduce the problem:
----Form1.cpp file------ 13. void Form1::AddItem(TreeNode^ node) 14. { 15. this->treeView1->Nodes->Add(gcnew TreeNode("Test1")); 16. 17. for each (TreeNode^ node in treeView1->Nodes) 18. { 19. System::Console::WriteLine(node->Text); 20. } 21. }
1. Select the lines (17-20). Right click and select "Refactor (VA X)"->"Extract Method..." 2. Type in a name and click OK (without the option "Extract to source" enabled) 3. It will extract and create a new method like below
13. void Form1::AddItem(TreeNode^ node) 14. { 15. this->treeView1->Nodes->Add(gcnew TreeNode("Test1")); 16. 17. MyMethod(); 18. } 19. 20. void MyMethod() 21. { 22. for each (TreeNode^ node in treeView1->Nodes) 23. { 24. System::Console::WriteLine(node->Text); 25. } 26. }
As you can see there is no namesapce added to the new method, and no declaration added to the header file.
Now if you add the namespace and declaration manually. And select again few lines (from above snippet select 15-17) and call the extract method it will create the new method but inside the last created method, in this case it will be MyMethod and looks something like this:
void Form1::MyMethod() { for each (TreeNode^ node in treeView1->Nodes) { System::Console::WriteLine(node->Text); }
void MyMethodNew() { this->treeView1->Nodes->Add(gcnew TreeNode("Test1"));
MyMethod(); } }
This problem persists even if you reparse the file.
Yes, if you enable the option "Extract to source" in the dialog box, then it will create the function with the namespace but does not add any declaration to the header file.
Any tips or tricks or any options to enable/disable to make this work correctly??
regards Vishnu |
1 L A T E S T R E P L I E S (Newest First) |
accord |
Posted - Oct 07 2008 : 2:41:23 PM Probably you have a "using namespace ..." before your example function.
For example when I created a default test project with the name "windows_forms" and I have added your example functions to the header, I got this after a create implementation:
void windows_forms::Form1::AddItem(TreeNode^ node);
Because Form1 is in a namespace by default. I think you have added a using before this function, like this:
using windows_forms;
void Form1::AddItem(TreeNode^ node);
so you can leave the "windows_forms" now.
In this case this is
case=20072
The second bug will not appear after case=20072 will be fixed. |
|
|