Working on a large solution with a team of developers can sometimes lead into code duplication or cloned code. Luckily, Visual Studio 2013 has a handy feature of finding cloned codes within a solution. Here are two ways to use the feature:

1. From the Visual Studio 2013 menu, select “ANALYZE” and then choose “Analyze Solution for Code Clones.” This will analyze the entire solution and will find all cloned codes within solution.

codeclone1

2. Highlight a block of code from the code editor, right click and choose “Find Matching Clones in Solution.” This will analyze the entire solution and will find all cloned codes based on the selected code block.

codeclone2

Once analyzed, the feature will display the results in the “Code Clone Analysis Results” window. From the results window, you can:

  • Hover over a line to get a preview.
  • Double click a line to open the file.
  • Do a side by side comparison.

codeclone3

Analyze your results and refactor as necessary. This will help tidy up and increase maintainability of your solution.

Like this post? Share it!