AntiPlagiarism is a Visual Studio extension that can compare C# code from different sources and find similar methods in the compared code. You can use the tool to collect the data for refactoring by comparing the source code with itself or with the provided custom code.
AntiPlagiarism is intended to be used for the development and certification of third-party solutions for the Acumatica ERP application. However, it can be used with any C# code as an instrument to find code duplication in methods. The functionality is similar to the Code Clone Detection functionality, which is available in Visual Studio Enterprise. (For details about this functionality, see https://docs.microsoft.com/en-us/previous-versions/hh205279(v=vs.140) .)
To start working with AntiPlagiarism, you open in Visual Studio the solution you want to analyse and then open the AntiPlagiarism window from the Tools main menu of Visual Studio.
You can specify the parameters for analysis such as Threshold and Min. Method Size. You start the analysis by clicking the Run button.
You can work with the data grid as follows:
- In the table with the results, you can sort the results by clicking on the column headers.
- You can navigate to the code fragment locations by double clicking on the file names in the Source Location column (for the copied code) and Reference Location column (for the original code).
- You can view the code fragments for the selected row if, in the context menu, you click Show Code. To hide the code, you can click Hide Code in the context menu or change the selected row.
- You can copy the table rows. You can select a set of rows (the standard Shift/Ctrl functionality for selection is supported). You can also press Ctrl + A to select all rows in the grid. Press Ctrl + C to copy the selection to the clipboard. The copied data can be pasted to Excel or another place.
- You can filter the data in the table by using the Threshold parameter. The Similarity column shows how similar the source and reference methods are. The red information sign to the left of the value indicates that the similarity value exceeds the threshold. If you change the Threshold parameter value for the already completed analysis, the red information signs is updated. You can also use the Show only rows exceeding threshold settign for filtering, which is described in the Settings section.
AntiPlagiarism has the Settings panel. You can expand or collapse the panel by clicking on the button with a gear icon.
The panel contains the following elements.
Element | Description |
---|---|
Column Visibility (button) | You use this button to specify the columns visible in the data grid. |
Show only rows exceeding threshold (button) | You use this button to turn on the mode in which all rows with the value of Similarity that does not exceed Threshold are hidden. |
Source Origin | In this box, you can choose what will be used as the source code for the comparison. You can use one of the following values:
|
Work Mode | In this box, you can select the analysis work mode. You can use one of the following values:
|
To build the solution, do the following:
- Add your strong-name key file as src/Key.snk. If you don't have one, run Developer Command Prompt and generate the key by using the following command: sn.exe -k "src\Key.snk".
- Build AntiPlagiarism.sln.