Merge two versions of C# projects - c#

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"

Related

opening c# files with visual studio outside of project gives no suggestions

Im currently writing some very small c# exercises, for a algorithm course.
visual studio is my favourite IDE, and usually, when i create or clone a visual studio project, I get the full functionality of viusal studio including spellchecking and suggestions for fields and methods on objects and so on.
But right now I am just trying to open a single .csc file and write some code in it. The problem is that when i do that, i get no suggestions. So if I create a list I would usually be able to view all the methods and fields inside the list class simply be referencing an object. Syntaxm checking works fine.
How do I turn on intellisense suggestions in a file that is not in a project?
Thank you
The simplest way is simply to add that file to a project.
Open VisualStudio.
Create a new project (you can probably use Console project or Class library, depending on what you're doing).
Add your file in that project.
Make sure your file as the Build Action C# Compiler.
And that should work.

How to open / edit an exe in visual studio 2019

Hello i deleted my old project from repos but i want to edit it again but i don't know how to do.
I want to edit form and my codes please help.
My project:
enter image description here
You can try what is suggested here : How do I decompile a .NET EXE into readable C# source code?
The purpose is to deassemble the code to be able to edit it again. But you will have some work to do cause the code will probably be quite different from the one you wrote.
Do you have you .soln file anywhere with the source code? You can use visual studio to open that.
Did you delete the repo or did you just delete all your code and push that change up to your repo? if its the latter, i would look into how to revert your codebase to a previous revision
Otherwise, the only thing i can think of doing is running your exe and dlls through a de-compiler but the code will not be the same as when you wrote it.

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.

Changing Project Metadata in Visual Studio 2013 C#

I've got a Visual Studio 2013 package written in C# where I need to make some changes in the items and their attributes in a C++ project file while Visual Studio 2013 is running and has the project loaded. Actually, it could also be OK to save the project file at the point when the whole solution is being saved.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="Test">
<MyItemToChange Include = "TestItem">
<MyMetadata1ToChange>Value1</MyMetadata1ToChange>
<MyMetadata2ToChange>Value2</MyMetadata2ToChange>
</MyItemToChange>
</ItemGroup>
<!-- The rest of the file -->
</Project>
In previous Visual Studio versions I used the Microsoft.Build.Evaluation.Project class to change the items and the metadata of the project. When you have the reference to the project, you can either accessed the XML structure of the project directly through Project.Xml property or get a hold on different Microsoft.Build.Evaluation.ProjectItem and use the interfaces found there.
However, since Microsoft has changed the structure of Visual Studio in their 2013 release, though the Microsoft.Build.Evaluation.Project is not deprecated, you can't access the C++ projects any more through Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.LoadedProjects as the collection is empty. However it still works if you want to access C# projects. (As a matter of fact, browsing deep into the objects while debugging you can find that they still use the same Microsoft.Build.Evaluation namespace for inner representation.)
Since I can't access the Microsoft.Build.Evaluation.Project any more, I need an alternative to
access the project otherwise than using the
Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.LoadedProjects
write project items and metadata while Visual Studio 2013 is running.
Unless I've missed something, the following are not good for my purposes:
Microsoft.VisualStudio.Shell.Interop.IVsBuildPropertyStorage.SetItemAttribute sets only attributes to items that are displayed in the Solution Explorer. "MyItemToChange" is not displayed in the Solution Explorer
Opening the file and manually editing and saving it. Unless you know how to suppress Visual Studio's warning about a changed project and how to auto reload it, it is not a way to go.
Note: You can close the solution, open the project file manually, edit then save it and reopen the solution. It would work fine, the data is there, unless the files are under source control. Now it opens up a whole lot of new issues (why EnvDTE.DTE.SourceControl.CheckOutItem() doesn't work, etc.) So I still think I would be better off if Visual Studio would handle writing data to the project file.
Reflection. Yes, as I mentioned before, I could dig into internal classes to get a hold on the "original" Microsoft.Build.Evaluation.Project, and Microsoft.Build.Evaluation.ProjectItem, but first of all, it is quite unsafe for future uses and as far as I remember, you cannot be sure that if you modify these now internal classes, the project will know that it is dirty and has to be saved.
I'm glad to have any suggestions as I'm really running out of options.
Thanks.
Well, I have worked out a workaround, not a real solution for the problem.
What I do right now is the following:
Ask the user whether they're OK with closing the whole solution and saving everything. If not, I cancel the whole procedure: EnvDTE.DTE.ItemOperations.PromptToSave
Try to ask Visual Studio 2013 to check out the project file for me in source control using EnvDTE.DTE.SourceControl.CheckOutItem() method. If it throws an exception (NotImplementedException), I use a bodge to check out the project file. That is, I write a custom property into the project file using Microsoft.VisualStudio.Shell.Interop.IVsBuildPropertyStorage.SetProperty() method.
Close the whole solution. EnvDTE.DTE.Solution.Close()
Open the project file using the System.Xml.XmlDocument class. Edit. Save. Oh, and remove my silly property written in the 2. point (the one used to force Visual Studio 2013 to check out the file in source control.)
Reopen the solution. EnvDTE.DTE.Solution.Open() At this point the user might be asked again to confirm some source control options.
Why is it just a workaround not a proper solution?
It's ugly. :)
Methods are abused for things they are not meant to be used (writing a random property into a project just to force source control checkout)
It wouldn't work if closing the solution / project is not an option. E.g.: if you need to save something during build or while they are editing the solution / project / source files; or if you have to do it often not just once during the lifetime of a project.
I'm still looking for the proper solution for the problem. But until someone could tell me how it is done, I have to live with this current implementation.

Overwriting default Code Snippets

I have been making several improvements on code snippets that are typically built into VS2010. Is there any way to either "prefer" certain snippet directories over others, or to overwrite the defaults without manually removing the references from the Code Snippets window? I would like to keep the same shortcuts.
This is mostly nit-picking, since I could remove the .snippet files manually, or remove the folder references, but I'm wondering if there is an easier way, incase I end up replacing a large amount of the default snippets yet still want to keep others.
There are two issues that come up when having similar shortcuts on code snippets.
For some snippets, such as propdp, you will be prompted that there are multiple snippets, and be asked to choose which one is appropriate.
For other snippets, such as ctor, it just uses the default snippet and pretends my own doesn't exist. Browsing the snippets using Ctrl+K,Ctrl+X clearly shows the snippet works, and the shortcut is correct.
The second issue here is a larger concern than the first.
Edit: Further experimentation shows that ctor in particular uses the default snippet no matter what. I haven't tried overwriting the code in the original snippet file, but removing the reference to Visual C# snippets folder still uses the default and ignores my replacement.
Edit 2: Even replacing the original snippet, ctor uses the default and ignores the .snippet file. This is after restarting Visual Studio as well. Now I have no idea where it's even retrieving this code snippet from. As a test, you can rename the snippet ctors and it will display properly. ctor is no longer a suggestion at this point. If you rename it back to ctor, it will once again display the default snippet. Either this snippet is cached somewhere, or it's built in to VS2010.
Have you tried simply overwriting the original files, replacing the snippet with your own?
They're located here: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Visual C#
On my system, the C# snippets are stored in two places at least:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC#\Snippets\1033\Visual C#
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC#\Snippets\1033\Visual C#
I think you're right that Microsoft's snippets always "win" when you have snippets in other directories, so to use customized snippets, you end up having to overwrite the originals. But every couple of weeks when an update to Visual Studio is released, the update will obliterate your versions in favor of MS's. (Why did they bother to expose this functionality if they're going to disrespectfully ignore or obliterate your customizations?)
I ended up just writing a program that starts running at login time to watch these two directories. When something changes in one of them, it compares the snippets there to ones I have stored in a "snippet override" directory, and if they aren't the same, it restores my versions of the snippets.
Have you looked at the plug-in for Code Barrel? It has revision support, tagging, etc... Looks like that may be what you need. ~shrug~ it is free, so is the plugin, go to codebarrel.com to get it.

Categories