All docs
V21.1
21.1
20.2
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

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.

    CodeIssues_main

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

    Enable

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

    Enable

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

    Open Options

  • 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

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

    CodeIssues_main

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

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

    Export

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

    Save