Viewing a diff of your file in Visual Studio
When submitting a code review, you can look at a diff of the file(s) to see what changes have been made since your last commit. To see the diff, you must first configure the Klocwork plug-in to use your preferred diff tool.
Prerequisites:
- The Klocwork Server must be running
- As of 2019.2, Code Review must be enabled in Visual Studio manually
- Your SCM must be integrated and you must have a cloned SCM repository on local storage
- An external diff tool must be installed on your local machine
To configure your diff tool with Visual Studio:
- First, you'll need to enable Code Review in Visual Studio to access the Diff Viewer. Go to Klocwork > Options and click on the Code Review tab. Under Code Review State, select the Enable Code Review check box.
- Next, go to Klocwork > Options > Klocwork > General.
- Click the Code Review tab.
- In the Command field, browse to the path of your diff tool. For example, C:\Program Files (x86)\WinMerge\WinMergeU.exe.
- OPTIONAL: If your diff tool requires additional macros for the original file and modified file, add them to the Arguments field. If no arguments are provided, it uses "$(BasePath)" "$(ItemPath)" as the defaults.
Tip: The file path may contain spaces, so it's good practice to include quotes around the macros when defining the arguments.
Viewing the diff from Visual Studio
To view the diff for your code review, right-click the file and open the Create Code Review dialog. In the Changes field, click on a node and select Diff.
If the node you are trying to view has any associated children nodes, all of them will be diffed.
Tip: You can also right-click and select Diff file or double-click on a node to view the diff. The diff tool you configured with Visual Studio will open showing you the original file and the modified file.