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
 C++ Refactor Rename Fails
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

CLight
Junior Member

United Kingdom
11 Posts

Posted - May 23 2012 :  05:17:29 AM  Show Profile  Reply with Quote
Whenever I try to use Refactor->Rename from the Header File, it shows me the list of all the items to be renamed but only renames the items in the Header file and ignores all the items in the correpsonding cpp file although they are clearly listed.

When I try to use Refactor->Rename from the CPP file, it throws the following error:

"Visual Assist failed to modify one or more files. The refactoring may not have completed successfully. Inspect your files to see if any changes need to be rolled back. Common causes for this error are read-only files and related source control problems."

None of my files are read-only and the project is currently not under any source control.

What do I need to do to get this to work?

feline
Whole Tomato Software

United Kingdom
19179 Posts

Posted - May 23 2012 :  09:41:02 AM  Show Profile  Reply with Quote
If you open this problem cpp file via VA's Open File dialog, Alt-Shift-O, and then type, is the file modified?

If you trigger a VA Snippet, is the snippet inserted correctly?

VA thinks it is having problems modifying the file, I am just looking for any clues that might help explain why.

Can you please go to:

VA Options -> System Info -> Copy Info

and paste the details (from the clipboard) into your reply. This will give us the basic information about your setup.

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

CLight
Junior Member

United Kingdom
11 Posts

Posted - May 24 2012 :  05:09:32 AM  Show Profile  Reply with Quote
Hi feline,

Opening the File using VA's Open File dialog opens fine and can be edited.
When I trigger a VA Snippet it seems to get inserted correctly.
But again, when I try to rename, it only renames the method in the Header File. It is strange that it throws an error if I do the rename from the Header file but silently ignores to rename the method in the CPP file when doing the rename from there.

VA_X.dll file version 10.7.1903.0 built 2012.04.03
Licensed to:
VA X: ***.co.uk (Non-renewable license) Support ends 2012.11.22
DevEnv.exe version 9.0.30729.1 Professional
msenv.dll version 9.0.30729.1
Font: Courier New 13(Pixels)
Comctl32.dll version 6.10.7601.17514
Windows 7 6.1 Build 7601 Service Pack 1
8 processors (x86-64;
WOW64)
Language info: 1252, 0x809

Platform: Win32
Stable Includes:
c:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\include;
c:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\atlmfc\\include;
C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\include;
C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\include;

Other Includes:

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



Edited by - CLight on May 24 2012 05:10:06 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19179 Posts

Posted - May 24 2012 :  1:35:32 PM  Show Profile  Reply with Quote
Can you please try triggering Add Include in one of these problem cpp files. What happens here?

Are the .h files and .cpp files stored in the same directory, or are they in different directories?
Are these files on a local hard drive, or some form of network share?
Have you used a mapped drive letter, even if it is mapped to a folder on the local hard drive?

If you look in Windows Explorer at the file permissions of the .h file and .cpp file are you seeing any difference?

Since the files are being edited normally most of the time it sounds like the problem lies with Rename checking for an editable file, so I am searching for anything that might explain why VA is getting the wrong information about these cpp files.

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

CLight
Junior Member

United Kingdom
11 Posts

Posted - May 25 2012 :  11:58:30 AM  Show Profile  Reply with Quote
I think I tracked down what causes the problems. After restarting the computer I could rename methods without problems. Then I opened Expression Blend to do some changes to the XAML and imported the changes into my project (Tools - Windows Embedded Silverlight Tools - Update Silverlight for Windows Embedded Project ...). Now using 'rename' fails throwing up the error message as before. It seems that the problem is linked with the Silverlight update.




Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19179 Posts

Posted - May 25 2012 :  2:51:11 PM  Show Profile  Reply with Quote
I have downloaded and installed a Blend version 4 trial, but I am not sure what to do with it.

In VS2008 I am not seeing the option to create a new Silverlight solution.
Can you tell me what I should be doing to set up a test for this situation? Its possible I am missing something very obvious, or need to install another component or tool.

At a guess it sounds like the .sln or .vcproj file in VS2008 is being changed in a way that confuses VA's Rename command, but that does not explain why the effect goes away after rebooting the computer.

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

feline
Whole Tomato Software

United Kingdom
19179 Posts

Posted - May 25 2012 :  4:52:10 PM  Show Profile  Reply with Quote
It occurred to me that since you mentioned Silverlight, I had better install the Silverlight SDK, which I have just done on a winXP test machine. But I am still not seeing any sign of an option to create a Silverlight project in VS2008, either in make a new project or a new website.

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

CLight
Junior Member

United Kingdom
11 Posts

Posted - May 25 2012 :  10:16:26 PM  Show Profile  Reply with Quote
Embedded Silverlight only works with VS2008 SP1 and Expression Blend 3. If you really want to install it you need to go to the following Microsoft Site and download Compact 7:

http://www.microsoft.com/windowsembedded/en-us/campaigns/compact7/default.aspx

However, I have a feeling that installing Compact 7 won't help much to identify the problem. I just copied a smaller project to my machine at home where I also have Compact 7 installed, and I don't seem to have any of the problems with rename here.

Since the problem at work is only with 'Rename' and not with any of the other features like 'Create Implementation' I can only assume that 'Rename' is doing something additional to what the other features are doing when they modify or add code to files.




Go to Top of Page

CLight
Junior Member

United Kingdom
11 Posts

Posted - May 28 2012 :  09:26:58 AM  Show Profile  Reply with Quote
Update to my last post on Friday. Coming back to work I wanted to try out a few things.

I copied the project I'm working on into another folder and the rename appeared at first to be working. However, I then created a new method and 'Rename' only renamed the Header file again. I then wrote a call from another file to this method and tried 'Rename' again. It now renamed the method in the header file and the calling file but again, ignored the rename in the implementation file.

Say I have Test.h, Test.cpp and MainPage.cpp. Methods declared in Test.h are only renamed in Test.h and MainPage.cpp but ignored in Test.cpp.

I then renamed a method in MainPage.h and it was correctly renamed also in MainPage.cpp.

I then renamed the same method in MainPage.cpp and this time it did not rename it in MainPage.h. The Header file didn't even show up in the list of items that would be changed.

I then renamed both methods back to how they were originally and now tried to rename it again in Mainpage.cpp and this time the rename worked correctly.

I then renamed the method again in the MainPage.h file. The method was not changed in the MainPage.h but it was now changed in MainPage.cpp.

I repeated the last step by undoing the change, and it happened again.

I changed it then first in MainPage.cpp and it ignored MainPage.h


Now, after that I changed another method, again in MainPage.cpp, and this time it renamed it correctly in both the files.

Renaming it back also worked correctly.


Clearly, this is very irratic behaviour and has nothing to do with file permissions. It seems to me that 'Rename' might be building up a lookup tree that somehow gets out of sync with the real code.


Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19179 Posts

Posted - May 28 2012 :  4:12:52 PM  Show Profile  Reply with Quote
Just to make sure I am clear, when Rename is failing, is the Rename dialog listing all of the references? Or is the problem (not updated) file not listed in the Rename dialog?

If the file is listed in the Rename dialog, are you getting the error message about being unable to modify files, or is this just silently failing?

Assuming all of the files / references are listed, can you please try the following test please. In the IDE close all open files except one, so for example you only have "MainPage.cpp" open. Then trigger Rename. Does VA open all of the files that should be updated? If VA is not even opening the files then that will be an interesting piece of news.

Some logs of VA trying to run the Rename might help. Can you please download and run Process Monitor:

http://technet.microsoft.com/en-us/sysinternals/bb896645

and add 3 filters, "Path ends with MainPage.cpp then Include", "Path ends with MainPage.h then Include", etc, for the three test files. Doing this, Process Monitor should only report activity for these test files.

Can you also please turn on VA logging, and then trigger this problem Rename. Screen shots showing the state of the Rename dialog, and any error messages would also help. If you can then please send me the VA log files, the Process Monitor log, and the screen shots, hopefully some of this will offer some clues.

Any errors in the Process Monitor log would be of real interest, since if devenv.exe, which covers VA, was having problems accessing the files this might explain the problem, and perhaps point towards a cause.

Since VA is capable of renaming all of the files its not a simple permissions problem, I agree. It would make more sense if the Rename dialog was missing some of the references, so VA was not even attempting to rename in the problem files, but then we would need to work out why that was happening.

Please see this FAQ for details of turning on VA's logging, and sending us the log files

http://docs.wholetomato.com?W305

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

CLight
Junior Member

United Kingdom
11 Posts

Posted - May 29 2012 :  06:21:49 AM  Show Profile  Reply with Quote
I just closed all files but one, renamed a method. It reopened the other cpp file and renamed them correctly. I then tried to rename them back to how they were before but this time the rename only worked on the header files and silently ignored the ones in the cpp file.

I then undid the change in the header and saved both files and tried again, cpp was ignored again.

I then closed the cpp file and tried the rename again, and it didn't open this time. I also noticed that it didn't appear again in the list of files to be changed.

Interesting however is the next thing that happened.

I changed the name back in the header (manually) to how it was originally. Now when I try to rename it, it lists the cpp file and shows all the other methods to be renamed. However, the cpp file is still in a changed state. In the list it showed all the places where it found the method but as if they never had been renamed in the first place.

I then renamed everything back manually to how they were originally. I tried 'Rename' again but this time it only changed the names in the cpp file and ignored it in the header.


I switched on logging and set the filters in Process Monitor.

1. I created two test methods in TestScreen that use MainPage. I renamed the method in MainPage.h and it showed all the files in the dialog. Clicking ok it did not change the name in MainPage.h, but in all the other files (MainPage.cpp and TestScreen.cpp);


2. I undid all changes and closed all files except MainPage.h. Tried the rename again, it opened MainPage.cpp and TestScreen.cpp and did the changes in there but MainPage.h remained unchanged. (MainPage.h was also not listed in the dialog)

3. I closed MainPage.h and MainPage.cpp and only kept TestScreen.cpp open. I renamed the method here and it opened and renamed in Mainpage.cpp but not MainPage.h

I could not repeat the error message lately, it simply ignores renames at the moment. This is all I had time to do just now. I sent the log files via the Request Assist form.







Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19179 Posts

Posted - May 29 2012 :  11:56:49 AM  Show Profile  Reply with Quote
I have the files, thank you for these. While I am looking at these, a couple more questions. Do you have:

VA Options -> Performance -> Parse all files when opening a project

turned On or Off?

If you run Find References, rather than Rename, is this any more reliable? Find References is just going to check if our parser can find the references, without trying to do any updates. Some of this sounds like a problem with VA knowing files have been changed, and should be reparsed, but there seems to be some other problems at work as well.

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

CLight
Junior Member

United Kingdom
11 Posts

Posted - May 29 2012 :  12:22:08 PM  Show Profile  Reply with Quote
Parse all files is turned on.

Using 'Find References' is not always reliable. At times I have to use a crude Search to find the references I'm looking for.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19179 Posts

Posted - May 30 2012 :  10:07:14 AM  Show Profile  Reply with Quote
Problems with Find References make sense, since Rename uses Find References to build the list of references to update.

When Find References is having a problem, do you get some references in a file, or are some files just entirely missing from the results list?

If files are entirely missing then VA may be having problems understanding the solution or project files, so missing some of your code files under some conditions. This would make sense given this is a solution specific problem, if I understand correctly.

If the files are found, but some references within the files are missed then this sounds like a parser problem, there is something inside the code files that is confusing our parser, and code after these problem points is being missed.

Do you have a sense of which of these might be going on?

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

CLight
Junior Member

United Kingdom
11 Posts

Posted - May 30 2012 :  4:22:58 PM  Show Profile  Reply with Quote
I think I do remember that sometimes files were missing altogether from the returned list. What does puzzle me though is why the behaviour is so erratic. One time it's working, another it misses out some files, and at other times it misses out the very file the call was made from (like I mentioned above when I tried to rename files from the header file and it renamed all methods in all other files but not the header itself, here it should have at least found the file from where 'Rename' was called from).

Often 'Rename' also failed to rename variables declared and used within a single method. Here was no requirement to find the methods in other files, just within the same method.



Go to Top of Page

CLight
Junior Member

United Kingdom
11 Posts

Posted - Jun 01 2012 :  10:16:51 AM  Show Profile  Reply with Quote
I had a completely unrelated problem which was caused by the Silverlight Project Update tool. For some reason it added header files to the MainPage.h that already existed there. At one time there were nearly fifty redeclarations of two of the header files includes. After fixing this I had done some 'Rename' since and they worked fine so far. It's too early to say if removing those additional declarations fixed the issue but so far everything is fine.

However, I'm still concerned that 'Rename' does not have a policy to make sure that all files have been modified correctly or fail completely. I don't mind it throwing an error when it fails but the fact that it often fails silently and leaves the project in an inconsistent state makes me worried now each time I use it.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19179 Posts

Posted - Jun 12 2012 :  4:25:24 PM  Show Profile  Reply with Quote
Apologies for the slow reply on this.

Rename should never silently fail, it would be good to find out what is going wrong here, and try to fix it.

I have been looking at the logs you generated, thank you for these. In the process monitor logs, there are multiple entries that are marked "FILE LOCKED WITH ONLY READERS", which sounds a lot like the code file has become read only, but it was not obvious why this might be happening.

What are you using for anti-virus?
Are you able to exclude the folder tree where your solution is, and see if this makes any difference?

In the IDE, do you have:

IDE tools menu -> Options -> Environment -> Documents -> Allow editing of read-only files; warn when attempt to save

turned On or Off?

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

CLight
Junior Member

United Kingdom
11 Posts

Posted - Jun 13 2012 :  09:32:28 AM  Show Profile  Reply with Quote
Allow editing of read-only files is switched on. I still had some rename problems recently. For example I declared a variable within a method and used it several times. Trying to rename it failed each time.

A rename like this only requires to rename variables within the same file and function, how could this be down to file access issues? It doesn't have to open or safe a file just edit what is visible on the screen already.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19179 Posts

Posted - Jun 13 2012 :  1:25:42 PM  Show Profile  Reply with Quote
To be honest I have no idea why renaming in the current file failed, but I am going to help you to find out, if at all possible.

Firstly can you please turn Off allow editing of read-only files. This should not make any difference, but it removes one possible variable. VA is designed to detect read-only files when doing Rename, and not try to update them, but you should always be warned when this is happening.

When you renamed in the current file, did VA give you any error message? Any warning? In the rename dialog did VA actually list the references to be updated? Did it list any references at all?

Is this problem file on your local hard drive, or some form of network share? I am just looking for anything to give us a clue, any difference, anything that marks this file as unusual.

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

CLight
Junior Member

United Kingdom
11 Posts

Posted - Jun 13 2012 :  2:36:28 PM  Show Profile  Reply with Quote
There are sometimes warnings saying something like the update failed but often there are no warnings whatsoever. I can't see why the Rename wants to check if files are read-only since it's not saving the files only changing the content. I still would have to save the file if I want to apply the changes myself. Anyway, have to rush and will try to switch off Allow editing read-only files tomorrow.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19179 Posts

Posted - Jun 13 2012 :  10:41:34 PM  Show Profile  Reply with Quote
Rename checks for read only files since if editing of read only files is disabled you can get a lot of message boxes stacked up, as the IDE complains about VA trying to edit a read only file.

Perhaps not the perfect solution, but it is simple and easy to describe.

However if there are no warnings at all, then something else is going on. Are you able to exclude your solution directory tree from being monitored by your anti-virus? Anti-virus problems with VA are very rare, but they do happen occasionally. Again, I am just trying to remove possible factors, to try and see what is happening here.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000