Friday, July 12, 2024
HomeHow ToHow to Compare and Merge Source Code in Visual Studio 2019

How to Compare and Merge Source Code in Visual Studio 2019

Summary: In this article, you will learn how to easily compare and merge source code using Code Compare in Visual Studio 2019.  In this post, we will provide examples demonstrating the basic capabilities of Code Compare and tasks it helps you effectively solve.

Comparing two revisions of a heavily refactored code can be a quite challenging task for those who are involved in programming. Finding differences between two objects and detecting source code changes have to be performed line-by-line and it takes a while.

Code Compare is an easy-to-use solution for comparing and merging two source code files. It allows developers to reduce the number of bugs when coding and enhances source code editing with advanced code comparison features, e.g.:

  • Structural comparison mode
  • Lexical comparison from major programming languages
  • Similar lines detection

You can use Code Compare as a standalone code diff tool and a Visual Studio extension. It effortlessly integrates with multiple version control systems and supports different programming languages.

Integration with Visual Studio 2019

We continue to support integration with modern code editors of Visual Studio 2019 making code comparison process more productive and faster. This due to the fact that all new editor capabilities like commands, IntelliSence, syntax highlighting are fully operational, including third-party extensions.

Asynchronous loading of our add-on is possible due to removing deprecated API from the Code Compare extension for Visual Studio 2019, thus, making Code Compare load faster on Visual Studio run.

Moreover, the list of available languages in Code Compare for Visual Studio features such popular languages as JavaScript and TypeScript. When opening comparison, the programming language in use is defined automatically depending on the file extension. We have also considered reports from our users on the incorrect opening of the JSON files and strange blinking of the pop-up windows. Now JavaScript will be used for them.

Structural Source Code Comparison

Code Compare provides a wide range of possibilities for locating changes in source code with regard to its structure, e.g., matching methods and similar code lines, detecting moved blocks of code, and much more.

We’ve significantly improved structural comparison for the latest versions of the С# and VB languages. Having considered a number of comments on the structural comparison, we decided to switch to the Roslyn compiler that is the best choice when it comes to code analysis for C# and VB.  Also, we improved the binding of comments and processor directives to the structural elements in the code.

Now, Code Compare supports structural identification of all new C# and VB.NET statements, which are important for structural comparison. Below you will find the examples of basic ones.

Moved and modified read-only property as an expression-bodied member

Moved using static statement

Moved and modified dictionary being initialized

When comparing source code, we recommend you to enable the Ignore Line Break and Ignore Whitespaces options to omit nonexistent changes, and the Symbol to Symbol option to efficiently check for differences in lines of code.

Quick Integration with TFS and GIT

Code Compare can be automatically integrated into TFS. You need just to check Integrate with TFS Version Control during the product installation.

In this case, Code Compare is set as the default compare and merge tool for TFS.

If you use Git as a source code repository, you need to make just one change in the .gitconfig file. You can learn more about this by visiting the Code Compare Integration with GIT page.


Code Compare is a convenient Visual Studio add-in, which lets you forget about any issues when comparing and merging source code. No matter what programming language you use, Code Compare takes into account specific features of each of them. Moreover, the tool allows you to track and control your source code changes using popular version control systems. So, download, evaluate and order Code Compare Pro today to discover the best way of managing your source code changes!