Devart Code Compare is a really awesome tool for developers to use. It integrates seamlessly into Android Studio, Eclipse, IntelliJ IDEA and naturally, Visual Studio. It has also built-in support for the following popular source control systems: TFS, SVN, Git, Mercurial, and Perforce. Today I’m going to look at the standalone tool.
Devart Code Compare
Code Compare comes in two editions, Free and Pro. Don’t let the free version put you off, it is by no means watered down. Devart have done a great job with making Code Compare an extremely easy to use tool to use. Below are some features of the standalone tool.
Devart Code Compare will compare two files you choose and essentially highlight missing, inserted and modified blocks of code in your files.
- Missing blocks (default highlight red) – meaning that the piece code is not presented in the target pane
- Modified blocks (default highlight blue) – meaning that the piece of code was modified the previous time
- Inserted blocks (default highlight green) – meaning that the piece of code is not presented in the source pane
As you can see from the image below, it has identified a missing line of code in the target file.
The next example below, Code Compare identifies that a section of code has expanded into a for loop. It dutifully highlights the code correctly.
Devart Code Compare will then also highlight modified code blocks in blue. In the example below, Code Compare has identified that a standard Work center code value differs between the two files. It’s these little foxes in code that cause bugs to creep in.
When it comes to inserted code, it looks at the code in the source file and highlights changes in the target file. This indicates that the target file contains some code that the source file doesn’t.
The process of merging files is also very easy. You can simply right click the merge button in the center divider and choose an action.
The merge action can be performed from source to target or from target to source. Code Compare also highlights the issues with each file in the margin via color coded heat zones. These correspond to the type of difference, Missing, Modified or Inserted.
Similar Lines Detection (Pro Feature)
The detection of similar lines is also a great feature. Other comparison tools might miss this because they search for strictly equal strings in the code file. Devart Code Compare on the other hand detects approximately equal strings. This results in a better match. The option to enable or disable similar lines detection can also be toggled in the Options menu under Tools.
Code Compare also allows you to modify the code directly in the code window. Let’s use the previous example above for the missing code block. To merge it with the target file, I click on the ‘Replace to Right’ option from the context menu.
Now that I have my code merged, I want to comment the change in the target file. Code Compare allows me to add in any bit of text I need to.
If you are like me and was wondering… yes, Code Compare also supports Intellisense. This feature is available in both the free and pro editions of Devart Code Compare.
Difference Explorer (Pro Feature)
Difference Explorer allows us to identify changes in class structures between revisions. To enable it, you need to expand the Comparison menu and select the ‘Structural Code Comparison’ option. Then in the View menu, select the ‘Difference Explorer’ menu.
Difference Explorer will now show you a color coded list of classes that differ.
You can further filter these results in the Difference Explorer by clicking on the ‘Sort by Member Type and Alphabetically’ button.
To neaten things up a bit more, you can also elect to hide the classes that are identical. To do this, just click on the ‘Hide Identical Members’ button.
Moved Blocks Detection (Pro Feature)
Another pro feature is the detection of code blocks that have moved. Code Compare compares code using signatures and will detect a moved block of code, even if it is located at the beginning of the source file and at the end of the target file. You can see from the example below that Code Compare has also identified that the UpdateScheduledNotifications() method is missing the call to the correct controller. The method in the source and target files exist in different sections of the file, but it still shoes it as a single unmodified block of code that only differs in it’s implementation.
Folder Comparison And Merge
The last feature I want to highlight is the Folder Comparison and Merge. Code Compare allows us to compare whole folders and easily inspect the files if necessary.
When the comparison window is displayed, it will show you the Size and Modified Date column. If these columns are not visible, ensure that they are checked under the View menu. As you can see, Code Compare displays the Modified Date of newer files in the target window in red.
You can now also drill down even more and right click on a file and select to launch the Code Compare tool for the specific file. As you can see, you can also merge the files from the context menu.
If doing this one-by-one isn’t feasible, you can select to Synchronize the files from the Changes menu. Code Compare will display a confirmation screen along with the number of files that are going to be affected by this Synchronization.
Devart Code Compare is an awesome developer tool. If you want to try it out, you can download the powerful free edition from Devart’s website. To view and compare the Free and Pro edition, have a look at the following page. I have to say that since I have been using Devart Code Compare, merging files have been such an easy task. For me, the fact that Code Compare actually recognizes the code structure when when comparing, makes for better comparisons and a better tool overall.