How to: Get a List of Unused Members in a Solution
- 2 minutes to read
The CRR0026 - Unused Member diagnostic can detect unused members based on a specified accessibility level. This example shows how to customize this diagnostic, run unused code analysis for a solution, and export the code issues report using the Code Issues Window.
Follow the steps below to get the code issues report with unused members:
Customize the Unused Member Diagnostic
In the Visual Studio menu, choose the CodeRush | Code Analysis | Code Issues item to open the Code Issues window.
In the invoked window, click Options to open the Code Issues Catalog page.
In this page, click Disable All and check the Enabled for CRR0026 to include only the Unused Member diagnostic in code analysis.
Click the Open options page button () for CRR0026 to open the Unused Code Analysis page.
Specify the accessibility levels for unused members. For this example, enable all options in the members accessibility section to allow this diagnostic to detect unused members with different accessibility levels.
Click OK to save these settings and close the Unused Code Analysis options page.
Run Unused Code Analysis
Open a solution.
Make sure the Mode Selector drop-down menu is set to Run CodeRush Diagnostics mode in the Code Issues window.
Click Refresh to start unused code analysis.
CodeRush shows the unused members found in this solution:
Export Code Issues Report
CodeRush can export a code issue report to plain text or XML file.
In the Code Issues window, click the Export drop-down button and choose Export to XML… or Export to Text… item.
In the Save As dialog, specify the file name and click Save.