Skip to main content

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

  1. In the Visual Studio menu, choose the CodeRush | Code Analysis | Code Issues item to open the Code Issues window.

    CodeIssues_main

  2. In the invoked window, click Options to open the Code Issues Catalog page.

    Enable

  3. In this page, click Disable All and check the Enabled for CRR0026 to include only the Unused Member diagnostic in code analysis.

    Enable

  4. Click the Open options page button (Open Configure) for CRR0026 to open the Unused Code Analysis page.

    Open Options

  5. 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.

    Set

  6. Click OK to save these settings and close the Unused Code Analysis options page.

Run Unused Code Analysis

  1. Open a solution.

  2. Make sure the Mode Selector drop-down menu is set to Run CodeRush Diagnostics mode in the Code Issues window.

    CodeIssues_main

  3. Click Refresh to start unused code analysis.

    Refresh

CodeRush shows the unused members found in this solution:

Found

Export Code Issues Report

CodeRush can export a code issue report to plain text or XML file.

  1. In the Code Issues window, click the Export drop-down button and choose Export to XML… or Export to Text… item.

    Export

  2. In the Save As dialog, specify the file name and click Save.

    Save