Extend file renaming in VS 2010 - c#

I want to be able to rename classes with associated file in VS without loosing file history in Perforce.
I thought I could include an Perforce command (p4 move...) in file renaming of Visual Studio
or in class-renaming of ReSharper.
I see 3 options:
Wrap Visual Studio's file-renaming
I extend the file renaming (I mean with file renaming: right-clicking file in Solution Explorer and selecting Rename.) by an own VS add-in or a macro that wraps the existing Rename menu command and calls p4 move....
Extend Visual Studio's file-renaming
I extend the file renaming by any kind of hooking into existing Rename command.
Extend ReSharper's class-renaming
I extend ReSharper's class-rename action (Ctrl+R,R) (with enabled option: Synchronize file names accordingly to changes) by calling p4 move....
Which option is the best one to rename a class with associated file in VS without loosing file history in Perforce?
I have no experience with VS add-ins and ReSharper plug-ins. So if anybody knows that an option is not possible at all than a hint would help me very much.
Any idea?

You can extend file renaming in VS 2010 by using a macro for adding a "p4 move -k" action to the rename event.
See answer of "How to keep change history while renaming files in Visual Studio using Perforce".
This macro calls automatically a p4 rename/move when you do any rename or move action in Visual Studio. So you keep the file history in Perforce.

Git handles these types of changes pretty well. Could you move to using Git for your development and using Git-P4 to get the source into Perforce? I don't know Perforce so I'm unsure how well this solution works, but it is definitely something to look into.

Do you have the new P4VS plugin? I believe it supports renaming pretty well.

Related

How to Delete Additional build files from the Project Solution in visual studio

How to delete additional build files from the project solution in Visual Studio?
I am forced to clear this files everytime manually when I want to give my executable program to anyone
Any solution?
I am using C# and C++.
This is simple
Right click at the project
Go to build events. From there you can play with many things.
You can't.
These files are generated when the .exe is generated and you can't force VS to not make them.
Upload your build to github.
Give your friend the link to the build repository.
Make your friend delete the files when they download the repo.
To answer your question: No, there is no way to prevent VS from automatically generating these build files. But there are ways to circumvent you from having to do the work, as I've stated above.

Merge two versions of C# projects

I am working on documenting a winForms project that isn't completely done being written, meaning there is another programmer who write the code right now. So I've already wrote some importent comments in a copy of the project.
In addition I use sandcastle to bulid the help file.
My question: what is the best way (if there is one) to copy the comments from the old copy of the project to the new version of it?
Maybe sandcastle can do something like import a documentation to a project?
I know it wasn't so smart to do so, still I have to check if there is a way to save the documentation work.
Visual Studio has a built in file difference function you can use to see where the two files are different. It should be then a matter of copy and paste of the changes you have made over to the "gold" copy of the file your other programmer has changed.
This link shows how to Compare two files in Visual Studio 2012
"You can invoke devenv.exe /diff list1.txt list2.txt from the command prompt or, if a Visual Studio instance is already running, you can type Tools.DiffFiles in the Command window"

Visual Studio Intellisense not showing some classes

My Visual Studio is not showing a lot of the available classes in the IntelliSense auto-complete. For example, a project I'm working on has a reference to the Microsoft.Xna.Framework namespace, yet even after adding the using statement using Microsoft.Xna.Framework in a file, IntelliSense is unable to recognize classes like Texture2D and Rectangle. I can still type them in, however, without getting a compiler error. Any idea what's happening?
The IntelliSense detects standard libraries like System.Diagnostics but not any external ones.
It is not a NameSpace conflict issue because classes within the current namespace are also missing from the IntelliSense.
I have tried:
Restarting Visual Studio (With and without closing tabs)
Deleting the contents of %LocalAppData%\Microsoft\VisualStudio\14.0\ComponentCacheModel folder
Resetting import and export settings
What worked for me is unloading and reloading the project
If unloading/reloading the project doesn't work, try deleting the .suo file found in the SolutionName/.vs/ folder. The .vs folder is an auto-created, hidden folder so you will have to show hidden folders in order to see it.
I am using ReSharper. What worked for me:
Unload project.
ReSharper > Options > Environment > General > Clear caches
Close solution.
Exit Visual Studio.
Restart Visual Studio.
Reload project.
Do you have ReSharper or any other plugins installed? There sounds like a similar issue/solution here. It may be third-party plugins at play depending on what add-ons you have.
Try saving and reloading the files.
I don't know why it happens, but it happens to my work laptop occasionally, typically reopening the source file resolves it.
OK so probably not the best solution but it works. I reinstalled Visual Studio and the problem was fixed. Also, it hasn't shown up since (this happened about 3 months ago).
another dumb solution))) Determine which classes/namespaces are not showing up. Then go to that project where they are. In that project pick any .cs file copy its contents, then delete that file and create again))
Click on the class not showing and Change Build Action -> to Compile
it happens sometimes when you add class as content or other resources

Can't rename Visual Studio 2010 Project

I have a Visual Studio 2010 Solution, that is also under source control (TFS 2010). Usually, I have no problem renaming a sub-project; just right-click, rename, and life is good!
However, I now have one project that I'm trying to rename, but whenever i right-click, type in a new name, and then hit enter, it goes right back to the old name!
I must be losing my mind here!
You probably already have a file with the name you are trying to use on the filesystem though not as part of the solution/project.
Use the windows explorer to find and delete this file and you should be good to go.
In the end it seemed like a TFS issue. THere was a lingering shelveset that was mapped to the project that wouldn't allow me to modify it at all. Once I was able to get my TFS admin to make the necessary changes, all was well!
Just try to do Reset Settings
The command "devenv /resetsettings" will restore Visual Studio back to its original factory state. If you have previously saved your settings from option 1 above, you can pass them as a parameter: "devenv /resetsettings ".
Or else if you have saved any previous settings try to import by this path "Tools" > "Import and Export Settingsā€¦" and your problem get resolved.
If this is v1 sorry you can't rename it as it is mentioned here http://social.msdn.microsoft.com/forums/en-US/tfsgeneral/thread/9e50138e-46f2-4f7f-ba09-e5624d30250b/
I tried to go offline from TFS but it gave no results =(
So, then I tried to delete 'SolutionName.suo' file and it made the trick! I was able to rename my project. Buggy VS 2010 =(

Changing folder names in Visual Studio when using SVN

I am using VS2008/VS2010 with Resharper 5, TortoiseSVN 1.6.8.19260-x64, and AnkhSVN 2.1.8420.8. Most operations I do in Visual Studio are reflected fine in SVN, however, renaming folders in a project can cause problems when I try to submit my changes. Also all the namespaces in the C# source files under the renamed folder need to be updated to reflect the name change.
What is the best way to rename the main project folder or any sub folders and ensure there are no issues with SVN? Should it be done outside Visual Studio?
What is the best way to update all the namespace changes? Is search/replace the only way?
Are there any best practices regarding folder names and their contents?
Yes do your rename outside of Visual Studio.
Using TortoiseSVN in windows explorer, do your rename via the TortoiseSVN context menu on the folder in question. The project in Visual Studio will detect the changes on disk and ask you to reload.
You could also do an exclude from project in Visual Studio, then rename and then re-include the new path.
Edit: As per #Sander Rijken below, AnkhSVN tracks the rename and makes sure the rename is correctly registered in the svn working copy.
If you don't have AnkhSVN installed in addition to TortoiseSVN though this will not work and you have to do as I said above.
You should be able to rename folders inside Visual Studio when running AnkhSvn. Also when using refactoring tools like Resharper to change the namespace according to the new folder name, everything works as expected for me.
The Agent SVN plug-in implements the MS-SCCI interface which allows it to integrate with Visual Studio.
Since the MS-SCCI defines a file rename operation, that means Agent SVN can do file renames from within the IDE, as should any plug-in that also implements the MS-SCCI.
What I typically do when having to perform a folder renaming is first renaming the folder using tortoiseSVN, then Excluding/Including the folder in VS and finally renaming all the namespaces (with Resharper it's just a matter of going file by file and Alt+Enter(ing) on the namespace directive to rename as appropriate.

Categories