Author |
Topic |
|
Tomasz Kleczek
New Member
Poland
4 Posts |
Posted - Jun 13 2016 : 04:21:49 AM
|
I have a .h / .cpp file pair, they look like this
// .h
namespace ns { class VATest { public: void foo(); }; }
// .cpp
using namespace ns;
void VATest::foo() { }
I am trying to change the signature of foo() to add an 'int i' parameter. The Change Signature windows opens and both instances of foo (in h and cpp files) are identified correctly. However, when I click 'OK' the operation fails with the message (leaving .h updated, but .cpp file not):
'Visual Assist failed to modify one or more files. The refactoring may not have completed successfully. Inspect you files to see if any changes need to be rolled back. Common causes for this error are read-only files and realted source control problems.'
I investigated the problem and noticed that the issue does not occur when changing the .cpp file to
// .cpp
void ns::VATest::foo() { }
Of course, I am working on a huge project and introducing such change to all files is not an option. Hence, my question: is it a valid bahaviour or a bug and what are some possible other workarounds?
System info:
VA_X.dll file version 10.9.2102.0 built 2016.06.02 DevEnv.exe version 12.0.40629.0 Ultimate msenv.dll version 12.0.40629.0 Comctl32.dll version 6.10.7601.18837 Windows 7 6.1 Build 7601 Service Pack 1 8 processors (x86-64, WOW64) Language info: 1250, 0x415
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; C:\Program Files (x86)\Windows Kits\8.1\include; E:\clientsdk6\deps\qwave\windows\include; E:\clientsdk6\deps\ldap\windows\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;
IDE:
Microsoft Visual Studio Ultimate 2013 Version 12.0.40629.00 Update 5 Microsoft .NET Framework Version 4.6.01055
|
|
feline
Whole Tomato Software
United Kingdom
19024 Posts |
Posted - Jun 13 2016 : 3:26:34 PM
|
Are you triggering Change Signature in the header or the cpp file? Does this even make any difference?
So far I cannot reproduce this here. Is it possible that the cpp file is marked as read only? If you are working with source control, and the file is checked out when you edit it, this could be a factor.
Since VA is finding both references to the function, I would expect both to be updated. The error message suggests a problem updating the file, but sadly its not providing any real clues. |
zen is the art of being at one with the two'ness |
|
|
Tomasz Kleczek
New Member
Poland
4 Posts |
Posted - Jun 13 2016 : 5:35:53 PM
|
I am triggering in the header. Will try to trigger from cpp file tomorrow.
I don't think that cpp file is marked read-only. E.g. the 'Rename' works perfectly fine. I use git, so no checking out is taking place.
I really think that this issue is somehow related to the namespaces. Please note, that adding 'ns::' qualified in front of the method in cpp allowed VA to complete the 'Change Signature' successfully. Is there any more input I can provide? |
|
|
feline
Whole Tomato Software
United Kingdom
19024 Posts |
Posted - Jun 14 2016 : 2:32:10 PM
|
The fact that Rename works perfectly is helpful, and disturbing. It proves that VA is not having any problems, in principle, updating both files. So it looks like we can eliminate any theories about read only files, or related problems.
I agree, the namespace is obviously what is triggering the problem for you, but if it was as simple as the test code on its own, then I should be seeing the same problem here.
Lets try this. Can you please add the following test code to your solution, and see if you still get this error when triggering Change Signature from the .h file:
// header file code
namespace felineSpaceOneChangeSig
{
class felineTestUpdateWithUsing
{
public:
void felineMemberWithUsing();
};
}
namespace felineSpaceTwoChangeSig
{
class felineTestUpdateFullName
{
public:
void felineMemberFullName();
};
}
// cpp file code
using namespace felineSpaceOneChangeSig;
void felineTestUpdateWithUsing::felineMemberWithUsing()
{
}
void felineSpaceTwoChangeSig::felineTestUpdateFullName::felineMemberFullName()
{
}
there are two tests, the two forms of your test. The code is the same, but I have hopefully made sure we have unique symbol names. I am wondering if "ns" is a widely used namespace in your main solution, if this is somehow a factor. If so, Change Signature on this test code should work.
If you still get the error, would you have time to make a new, default solution and try this test code there, to see if this error is somehow solution specific? |
zen is the art of being at one with the two'ness |
|
|
Tomasz Kleczek
New Member
Poland
4 Posts |
Posted - Jun 15 2016 : 01:47:46 AM
|
I purposefully used the not-used-in-our-project 'ns' namespace to see if the problem is related to it.. and I somehow did miss that with this new name the Change Signature actually works... Bottom line:
All your cases work fine in our project solution. In fact, my original case also work. The problem occurs when in case of 'ns' I use our project-wide namespace (let's call it project_ns). In that case I observe the failure as described in the first post.
Also: when I am trying to Change Signature from the cpp file, It fails with the same error (updates .h file, but fails to update .cpp file)
|
|
|
feline
Whole Tomato Software
United Kingdom
19024 Posts |
Posted - Jun 15 2016 : 3:20:59 PM
|
Thank you for the update. At least this explains why I was not able to reproduce this here, which is something.
Just to double check, if you use Find References on the function, both references are found correctly, and the Change Signature dialog is listing both references correctly as well?
In the problem case, if you sit in the header file and use alt-g on the function declaration, are you taken to the implementation?
The reason I am asking is that normally when things break, VA cannot find all of the references to update. Finding them, but failing to update them is quite puzzling.
Do you have the time to add a couple of new, empty files to your main solution, a matching .h and .cpp file? If so, could you add a copy of the failing code to these two files. Renaming the class to something unique will hopefully still make for a valid test. I am wondering if VA is able to update the .cpp file in this case.
I am wondering if there is something else in the files in your main solution that is somehow a factor. No idea what that might be, but the pattern suggests there is something.
Do you have:
IDE tools menu -> Options -> Environment -> Documents -> Check for consistent line endings on load
turned On or Off? If this is turned Off, can you please try turning it On, and reload the .cpp file where you see this problem? |
zen is the art of being at one with the two'ness |
|
|
Tomasz Kleczek
New Member
Poland
4 Posts |
Posted - Jun 15 2016 : 3:43:55 PM
|
Hello I am on vacation till Tuesday,�so I don't have access to the project at the moment.
However, there are some questions I already know the answer to:
1. References are correctly found and listed in the dialog window (one in .h and one in .cpp) 2. When writing the original post, I first added a pair of fresh new files to the solution project and gave the class a unique name. Also, there was no code in the files (except for header guard in .h and include of header in .cpp). When declaring class in the ns_project namespace, VA fails to change signature. If the namespace is arbitrary, there is no problem.
I will post an update with the remaining answers on Tuesday.
I love VA so far, so I am happy to spend some time getting to the root cause of this issue and potentially help improve it :)
|
|
|
feline
Whole Tomato Software
United Kingdom
19024 Posts |
Posted - Jun 15 2016 : 7:34:32 PM
|
Thank you for the updates. Since you are not seeing this in new, clean files it really is just down to the namespace. I just don't see why.
One last question for when you get back to the code, is the namespace declared directly, or via macros? |
zen is the art of being at one with the two'ness |
|
|
feline
Whole Tomato Software
United Kingdom
19024 Posts |
Posted - Jun 17 2016 : 12:34:41 PM
|
I don't know if it means anything or not, but I can reproduce the same error message, and a very similar problem, with the code in this thread:
http://forums.wholetomato.com/forum/topic.asp?TOPIC_ID=12681
Of course, I would still like to reproduce what you are seeing, but I have not given up on this yet. |
zen is the art of being at one with the two'ness |
|
|
|
Topic |
|
|
|