Static Code Analysis

  • 3 min to read

CodeRush provides a powerful static analysis tool. It detects possible issues in your code and helps you correct them. The list of supported issue types is available in the Analyzers Library article.

You can analyze your code using these two approaches:

Code Issues window

The Code Issues window is designed to simplify the static analysis process. Open the CodeRush | Code Analysis menu and choose the Code Issues menu item to invoke the Code Issues window.


The Code Issues window supports two operation modes:

  • CodeRush Diagnostics — performs analysis using the Analyzers Library
  • Visual Studio Diagnostics — performs the Visual Studio built-in code analysis

The Analyzer Set Selector on the toolbar allows you to switch between these modes. To analyze a current solution using the specified set of analyzers, use the Refresh button. You can export a report to plain text or an XML file using the Export toolbar button.


If your solution is very large, the analyzing process may take significant time. In this case, consider running Static Code Analysis for the active project or file only. Use the CodeRush | Code Analysis | Analyze Active Project or Analyze Active Document menu items for this.

Background Analysis

The CodeRush Diagnostics can be integrated into Visual Studio, which enables you to analyze your code on the fly.

You can instantly see code issues in the Error List window by checking the required analyzers' Register in VS checkbox on the Editor | <Language> | Code Analysis | Code Issues Catalog options page. This options page can be accessed using the CodeRush | Code Analysis | Configure... Visual Studio menu item.



Background Analysis is a resource-demanding feature. Use it with caution on large solutions.

Analyzer Suppression

You can suppress certain Analyzers using the Code Actions Menu invoked on a line of code with a Code Issue.


There are two types of suppression:

  • In Source — Suppresses a single issue locally using the #pragma warning disable directive.
  • In Suppression File — Creates or supplements the GlobalSuppressions.cs file with the SuppressMessage attribute. This type of suppression works only for members and broader scopes. Refer to the In Source Suppression Overview article to learn more.

The analyzer set for Visual Studio's Error List window can be configured for the entire project. You can disable some analyzers permanently or change their severity. Right-click <Your project> | References | Analyzers in the Solution Explorer to configure the project's analyzer set.


See Also