Code analysis
ReSharper helps you analyze code on various levels, starting from a single statement in the editor and all the way through to the architecture of your entire solution.
Find code issues
ReSharper provides static code analysis (also known as code inspection) by applying over 2500 code inspections in C#, VB.NET, XAML, XML, ASP.NET, ASP.NET MVC, Razor, JavaScript, TypeScript, HTML, CSS, ResX, and build script code, detecting compiler and runtime errors, suggesting corrections and improvements before you even compile.
By default, ReSharper starts analyzing a code file as soon as you open it in the editor, all the way you edit it, until it is closed. This design time inspection is performed silently by continuously applying all code inspections to your code. Not only ReSharper highlights code issues right in the editor according to their severity levels, it also adds its own marker bar to the right of the editor window, where you can see instantly the status of the file and jump to specific code issues, and provides commands for navigation between code issues.
If necessary, you can run code inspection for a specific project or the entire solution and check the list of issues found in the specified scope.
Also, you can enable the Solution-wide analysis that will detect all errors in your entire solution and extend the list of code inspections in the current file (for example it will find unused public members).
If needed, you can use code annotations to customize the way ReSharper inspects your code.
Another good thing is that you can define you own custom code inspections based on structural search and replace patterns, and specify severity level for them.
Quick-fixes for code issues
ReSharper helps you resolve most of the discovered code issues automatically. All you need is to press Alt+Enter when the caret is on a code issue highlighted in the editor and check the suggested quick-fixes.
Code exploration
ReSharper also provides features that do not detect code issues automatically, but rather allow you to find potential problems yourself by deeper investigation of the code. For instance, you can study call chains and find origin and destinations of a specific value. For more information on these features, see the Code exploration section.
Type dependency analysis
ReSharper allows you to visually study how types depend on each other in your solution. In the type dependency diagram, you can add any number of types from different projects or compiled assemblies and visualize different kinds of dependencies between them. For more information, see Explore type dependency diagram
Project dependency analysis
Some code issues may be discovered by analyzing the solution architecture. ReSharper can help you here with the project dependency analysis that allows you to visually explore project dependency diagram, find and optimize unused references, and detect possible architecture problems.
Code analysis from command line
If you need to integrate automatic code quality analysis into your CI, version control or any other server, you can use ReSharper command line tools, which are free of charge and do not require ReSharper or Visual Studio to be running. The Command Line Tools package includes two tools for analysing code:
InspectCode, which executes hundreds of ReSharper code inspections
dupFinder, which detects duplicated code in the whole solution or narrower scope
Code analysis in supported languages
Most of ReSharper's code analysis features are available in C# and Visual Basic .NET, some are available in several languages, others are language-specific. The table below lists all code analysis features and languages/technologies where they are supported.
The instructions and examples given in the topics within this section address the use of code analysis features in C#. For more information on code analysis features available for specific languages, see the corresponding topics in the ReSharper by language section.
Feature | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
| |||||||||||||
| |||||||||||||||
| |||||||||||||||
|
|
|
|
|
|
|
|
|
| ||||||
|
|
|
|
|
|
|
| ||||||||
|
|
|
|
|
|
|
|
| |||||||
|
|
|
|
|
|
|
|
|
|
| |||||
|
|
|
|
|
|
| |||||||||
|
|
|
|
|
|
|
|
|
|
|
|
| |||
|
|
|
|
|
|
|
|
|
|
|
|
|
| ||
|
|
|
|
|
|
|
|
|
|
|
| ||||
|
|
|
|
|
|
|
|
|
|
|
|
|
| ||
|
|
|
|
|
|
|
|
|
|
|
|
| |||
|
|
|
|
|
|
|
|
|
| ||||||
|
|
|
|
|
|
|
|
|
|
|
|
| |||
|
|
|
|
|
|
|
|
|
| ||||||
|
| ||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|