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 modifies wrong .h file
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dewtell
Junior Member

18 Posts

Posted - Feb 14 2020 :  7:23:39 PM  Show Profile  Reply with Quote
I have a Microsoft Project & directory with 2 .h files and one .cpp file: FindShiftRegBits.h, StubFindShiftRegBits.h, and FindShiftRegBits.cpp. FindShiftRegBits.h has the real definition of a class that is implemented in the .cpp file; StubFindShiftRegBits.h has a very stripped-down non-functional definition of the same class that is used for including in unit tests that need to link to the class and refer to a few of its public methods without needing it to work.

I've tried to Extract Method on some code in the FindShiftRegBits.cpp file. However, it extracts the method to the StubFindShiftRegBits.h file instead of the real .h file, and produces a popup: "Move implementation to Source File failed to identify a suitable target source file. Would you like to run Create File?" There is no corresponding .cpp file for the StubFindShiftRegBits.h file, and there shouldn't be, because we don't want to have to link from this project when building the unit tests. Is it possible to force Extract Method to modify the .h file that has the same root name as the .cpp file the code is being extracted from?

Dave Wallace

VAX Info:
License: Standard (******) Support ends 2022.07.17
VA_X.dll file version 10.9.2358.0 built 2019.12.19
DevEnv.exe version 12.0.40629.0 Professional
msenv.dll version 12.0.40629.0
Comctl32.dll version 6.10.18362.657
Windows 8.1 6.3 Build 9600
12 processors (x86-64, WOW64)
Language info: 1252, 0x409

Platform: Project defined
Stable Includes:
C:\Program Files (x86)\Windows Kits\8.1\Include\winrt;
C:\Program Files (x86)\Windows Kits\8.1\Include\shared;
C:\Program Files (x86)\Windows Kits\8.1\Include\um;
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include;
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include;

Other Includes:

Stable Source Directories:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\crt\src;
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\src\atl;
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\src\mfcm;
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\src\mfc;


*removed license email, no need to make it public*

Edited by - feline on Feb 15 2020 09:03:17 AM

feline
Whole Tomato Software

United Kingdom
16896 Posts

Posted - Feb 15 2020 :  09:31:39 AM  Show Profile  Reply with Quote
This is an interesting problem. Is editing the stub header file an option? Or is it being automatically generated from the main .h file in some manor?

Since VA is parsing all files in your solution, by design, it is seeing two different versions of the same class, at the same time, in the same namespace. This is going to effect more than just Extract Method. The easiest solution is to "hide" one of the two classes from VA's parser, without effecting anything else.

Adding this to the top of the stub file will get VA to ignore everything that follows it, but since it is also removed by the pre-processor, it won't effect how your code compiles:

// this code hides the rest of the file from VA's parser
// so only one instance of the class is found and worked with
#if 1 == 0
_asm {
#endif

zen is the art of being at one with the two'ness
Go to Top of Page

dewtell
Junior Member

18 Posts

Posted - Feb 18 2020 :  3:17:20 PM  Show Profile  Reply with Quote
The file is manually generated to meet the needs of the unit tests that include it, so it is easy to add your prefix. Thanks!

Dave W.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2019 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000