Compare (and merge) two VS C # projects

I have two VS C # projects (in particular, for the Outlook plugin) that I find are very similar, with the possible exception of 100 lines of code. I am a little worried that there may be other configuration options for the project that are different from each other, so I would like to compare these two.

What is the best way to see the differences between the two codes?

I tried to put two projects in parallel directories and use diff, but since the projects are named differently, some of the files do not match. I'm just wondering if there is an easier way to do this?

+6
source share
4 answers

It sounds like you need something like WinMerge to see the differences between the two projects. It's free, and I know that you can compare the contents of a folder with WinMerge, so this is probably a good place to start. Launch WinMerge in the project folders and it should generate a detailed comparison that describes the differences between the files.

See this folder comparison guide:
http://manual.winmerge.org/CompareDirs.html

enter image description here

+3
source

One way: Make copies of both projects, rename files and folders in one so that they match the files and folders in the other, and then use your favorite folder comparison tool to compare them.

This will not help you if there is no true copy and paste relationship between the two projects.

The best way is to use refactoring. After creating unit tests for both projects and achieving an adequate level of code coverage, navigate the class by class and method using the refactoring method to try to make the pairs of methods the same. Then you can define the methods that you need to pull into base classes or move to other classes.

In the end, you can find pairs of classes that are identical. Move these classes to a shared library, and then rename all uses of one of the classes to use the other. Then delete the one that is no longer in use.

Repeat until there is no more duplication.

+2
source

I highly recommend Code Compare (not being an affiliate, just a happy user) for this kind of work - there is a free version and a more advanced commercial version.

It combines perfectly with VS and has syntax highlighting for C #, C / C ++, etc.

+1
source

If you have changes, such as renaming or partial code moves, importing both versions into one git repository (like two different commits of the same directory) can help. Git tracks the contents of files, not the files themselves, so you can find out, for example. function moved from one file to another.

+1
source

Source: https://habr.com/ru/post/900155/


All Articles