diff --git a/docs/code-quality/how-to-generate-code-metrics-data.md b/docs/code-quality/how-to-generate-code-metrics-data.md index f19122a8989..41e1101a497 100644 --- a/docs/code-quality/how-to-generate-code-metrics-data.md +++ b/docs/code-quality/how-to-generate-code-metrics-data.md @@ -19,7 +19,7 @@ You can generate code metrics data in three ways: - By enabling [.NET code-quality analyzers](#net-code-quality-analyzers-code-metrics-rules) and enabling the four code metrics (maintainability) rules it contains. -- By choosing the [**Analyze** > **Calculate Code Metrics**](#calculate-code-metrics-menu-command) menu command within Visual Studio. +- By choosing the command or button to analyze code metrics in Visual Studio. Results are displayed in the Code Metrics window. - From the [command line](#command-line-code-metrics) for C# and Visual Basic projects. @@ -60,10 +60,29 @@ You can configure the thresholds at which the code metrics rules fire. ``` -## Calculate Code Metrics menu command +## Calculate Code Metrics -Generate code metrics for one or all of your open projects in the IDE by using the **Analyze** > **Calculate Code Metrics** menu. +Generate code metrics for one or all of your open projects in the IDE by using the Code Metrics window. +::: moniker range="visualstudio" +### Generate code metrics for a solution or project + +You can generate code metrics results for an entire solution or project using the following method: + +1. In **Solution Explorer**, set the scope of results to either a solution or project by selecting either the solution or project. + +1. From the menu bar, select **View** > **Other Windows** > **Code Metrics**. + + The Code Metrics Results window opens. + +1. In the **Code Metrics Results** window, select the **Calculate Code Metrics for Solution** button. + + The results are generated. To view the results details, expand the tree in the **Hierarchy** column. + + ![Screenshot of the Code Metrics window.](../code-quality/media/visualstudio/code-metrics-window.png) +::: moniker-end + +::: moniker range="vs-2022" ### Generate code metrics results for an entire solution You can generate code metrics results for an entire solution in any of the following ways: @@ -83,6 +102,7 @@ The results are generated and the **Code Metrics Results** window is displayed. 1. From the menu bar, select **Analyze** > **Calculate Code Metrics** > **For Selected Project(s)**. The results are generated and the **Code Metrics Results** window is displayed. To view the results details, expand the tree in the **Hierarchy**. +::: moniker-end ## Command-line code metrics diff --git a/docs/code-quality/media/visualstudio/code-metrics-window.png b/docs/code-quality/media/visualstudio/code-metrics-window.png new file mode 100644 index 00000000000..fc5015a03d7 Binary files /dev/null and b/docs/code-quality/media/visualstudio/code-metrics-window.png differ diff --git a/docs/code-quality/working-with-code-metrics-data.md b/docs/code-quality/working-with-code-metrics-data.md index c41a8643455..951788d65c7 100644 --- a/docs/code-quality/working-with-code-metrics-data.md +++ b/docs/code-quality/working-with-code-metrics-data.md @@ -1,6 +1,6 @@ --- title: Code Metrics window -ms.date: 12/12/2017 +ms.date: 1/22/2025 description: Learn how to view, filter, rearrange, and export Visual Studio code metrics analysis data. See how to create work items based on code metric results. ms.topic: reference f1_keywords: @@ -15,8 +15,24 @@ manager: mijacobs ms.subservice: code-analysis --- -# Use the Code Metrics Results window +# Use the Code Metrics window +::: moniker range="visualstudio" +The **Code Metrics** window displays the data that is generated by the code metrics analysis. For more information about code metrics data values, see [Code metrics values](../code-quality/code-metrics-values.md). + +## Display code metrics results + +You can display the Code Metrics window using the following sequence: + +1. On the **View** menu, choose **Other Windows** > **Code Metrics**. + +1. Select the **Calculate Code Metrics button** to generate results. + + Results are scoped to the project or solution based on the current selection in Solution Explorer. Select either the project node or the solution node. + +::: moniker-end + +::: moniker range="vs-2022" The **Code Metrics Results** window displays the data that is generated by the code metrics analysis. For more information about code metrics data values, see [Code metrics values](../code-quality/code-metrics-values.md). ## Display code metrics results @@ -30,6 +46,7 @@ You can display the Code Metrics Results window using one of the following menu - On the **View** menu, choose **Other Windows** > **Code Metrics Results**. The **Code Metrics Results** window opens, even if it contains no results. +::: moniker-end ### To view code metrics details @@ -37,7 +54,13 @@ If code metrics results have been generated, expand the tree in the **Hierarchy* ## Filter code metrics results +::: moniker range="visualstudio" +You can filter the results that are displayed in the **Code Metrics** window by using the toolbar at the top. For example, you might want to see only the results that have a maintainability index below 65. +::: moniker-end + +::: moniker range="vs-2022" You can filter the results that are displayed in the **Code Metrics Results** window by using the toolbar at the top. For example, you might want to see only the results that have a maintainability index below 65. +::: moniker-end The **Filter** dropdown list box contains the names of the results columns. When a filter is defined, it is added to the bottom of the list together with an indentation. The list can contain the last 10 filters that were defined. @@ -55,7 +78,13 @@ The **Filter** dropdown list box contains the names of the results columns. When ## Add, remove, and rearrange data columns +::: moniker range="visualstudio" +You can add or remove results columns from the **Code Metrics** window. In addition, you can rearrange results columns so that they appear in the order that you want. +::: moniker-end + +::: moniker range="vs-2022" You can add or remove results columns from the **Code Metrics Results** window. In addition, you can rearrange results columns so that they appear in the order that you want. +::: moniker-end ### Add or remove a column