How to compare and merge source code in Visual Studio 2019
Tags: codecompare, git, visualstudio2019, с
Published: 2019-09-12 15:05:25

---
title: How to compare and merge source code in Visual Studio 2019
published: true
description: 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
tags: code compare, GIT, Visual Studio 2019, С#
---
**Summary:** In this article, you will learn how to easily compare and merge source code using [Code Compare](https://www.devart.com/codecompare/) 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](https://www.devart.com/codecompare/lexicalcomparison.html) from major programming languages
■ Similar lines detection

You can use Code Compare as a standalone code diff tool and a [Visual Studio extension](https://www.devart.com/codecompare/visual-studio-integration.html). It effortlessly integrates with multiple [version control](https://www.devart.com/codecompare/integration.html) 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](https://docs.devart.com/code-compare/file-comparison/structural-code-comparison.html).

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 and modified read-only property](https://blog.devart.com/wp-content/uploads/2019/08/lambda.png)

**Moved using static statement**

![Moved using static statement](https://blog.devart.com/wp-content/uploads/2019/08/using_static.png)

**Moved and modified dictionary being initialized**

![Moved using static statement](https://blog.devart.com/wp-content/uploads/2019/08/new_dictionary_initializers.png)

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.

![Moved using static statement](https://blog.devart.com/wp-content/uploads/2019/08/tfs_integration.png)

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

![Moved using static statement](https://blog.devart.com/wp-content/uploads/2019/08/code_compare_tfs.png)

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](https://www.devart.com/codecompare/integration_git.html) page.

#Conclusion

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](https://www.devart.com/codecompare/download.html), evaluate and [order](https://www.devart.com/codecompare/ordering.html) Code Compare Pro today to discover the best way of managing your source code changes!