Author |
Topic |
|
dewtell
Junior Member
18 Posts |
Posted - Jun 14 2011 : 2:36:08 PM
|
When doing a "move to source file" refactoring from foo.h, if there is no foo.cpp in the same directory, but there is a foo.cpp or Foo.cpp elsewhere in the solution, the code will probably be moved there. I ran into this with one file, and needed to restart Visual Studio (after creating foo.cpp in the correct directory) in order to break the link to the wrong file.
This is with Visual Assist X version 10.6.1850.0 and Visual Studio 2008, Professional Edition. |
|
feline
Whole Tomato Software
United Kingdom
19024 Posts |
Posted - Jun 14 2011 : 3:24:03 PM
|
I am not quite sure what to say here. If the correct destination file does not exist when you initially trigger Move Implementation to Source File then VA obviously cannot use this file, so VA did its best.
Once you have added the file to the solution, you have to save the solution before VA will learn about the new file, since we read the solution file from the hard drive, not from memory. Reloading the IDE will save the solution and let VA learn about the new, matching file, but doing a "File -> Save All" should also help. |
zen is the art of being at one with the two'ness |
|
|
dewtell
Junior Member
18 Posts |
Posted - Jun 14 2011 : 3:58:09 PM
|
Well, I'd like it to at least be able to warn me that (in this case) it's about to move the code to a potentially completely unrelated file (in this case, it took a core engine .h file and moved the code to a GUI file with the same name/different case). I suppose this warning should be configurable, for people who intend to keep their .h and .cpp files in different directories, but I think the default should be to warn.
In this case, I created the correct .cpp file by using cmake, which rebuilt the solution file on disk. So Visual Studio did re-read the updated solution file from disk, and Visual Assist still kept trying to move the code to the wrong file until I completely got out of Visual Studio and restarted it from scratch.
|
|
|
accord
Whole Tomato Software
United Kingdom
3287 Posts |
Posted - Jun 14 2011 : 8:10:19 PM
|
The problem is that how you define a "completely unrelated file". We have made several improvements on how alt+o works (switching between related files) and through this process I have seen a lot of "odd" variations about where people tend to keep their corresponding files. Not everyone keeps the corresponding files in the same directory to say the least. A warning that may be inappropriate, may break the flow and may cause more frustration / distraction than benefit.
Personally, I always create the corresponding files at the same time to avoid problems like this or others.
Anyway, VA usually does a very good job at catching up changes, including file creations. However, in this case VA "caches" the file location it found, for some reason. Normally this shouldn't cause any inconvenience. Is this a frequent problem you run into? |
Edited by - accord on Jun 14 2011 8:18:01 PM |
|
|
|
Topic |
|
|
|