ReSharper 2018.1 Help

Code Inspection and Quick-Fixes in ASP.NET

Most of ReSharper's code analysis features are also supported in JavaScript. You can find the detailed information on these features in the corresponding topics of the Code Analysis section. In the main topic of the section, you can also find the feature matrix and check what exactly is supported in JavaScript.

In this topic, you can find some examples of using code analysis features in JavaScript:

Code Inspection

Various code inspections are available for ASP.NET, including detecting unused import namespaces, unknown symbols and entities, etc. You can set a severity level for each inspection. For more information, see Configuring Code Inspection Settings.

Web Development Code Highlighting
To navigate between code issues that ReSharper discovers, use marker bar and status indicator.

If the locations of files in design time are different from the location where the application is deployed, you can use Path mapping to help ReSharper analyze your code.

Auto-importing namespaces

During code analysis ReSharper detects and highlights symbols that can't be resolved because the appropriate Import or Register directives are missing. Also, it offers an easy way to add such directives and fix the problem. ReSharper adds a necessary Import directive for .NET symbols:

Web Development Import namespaces
Or a necessary Register directive for ASP.NET controls:
Web Development Register user controls
For more information, see Importing Missing Namespaces.

Examples of quick-fixes

Import type
If the corresponding Import directive is missing, ReSharper suggests this quick-fix.

Web Development Quick Fixes import type 01
After applying the quick-fix, the necessary directive is added.
Web Development Quick Fixes import type 02

Create method
ReSharper informs you that the ChangePasswordPushButton_Click method doesn't exist...

Web Development Quick Fixes create method 01
...and offers to create one.
Web Development Quick Fixes create method 02
The method declaration is inserted into the code-behind file or into the current file depending on web page code model (single-file page model or code-behind page model).
Web Development Quick Fixes create method 03

Change signature
The signature of the ChangePasswordPushButton_Click method doesn't match the signature of the OnClick event.

Web Development Quick Fixes change signature 01
ReSharper offers a quick-fix to change the signature of the method:
Web Development Quick Fixes change signature 02

Remove unused directives in file
ReSharper detects unused import namespace directives.

Web Development Quick Fixes remove unused directives 01
As they are unnecessary ReSharper suggests a quick-fix that removes all of them from the current file.
Web Development Quick Fixes remove unused directives 02

Add Inherits attribute
This quick-fix is specific for ASP.NET directives. The CodeFile attribute is used together with the Inherits attribute to associate a code-behind source file with a user control or a page. When the latter is missing, ReSharper suggests a quick fix:

Web Development Quick Fixes add inherits attribute 01

Create ContentPlaceholder
If there is a Content control on a content page that is mapped to a missing ContentPlaceholder on the master page, ReSharper suggests creating the corresponding ContentPlaceholder control on the corresponding master page.

Web Development Quick Fixes create contentplaceholder 01
The ContentPlaceholder control with the corresponding ID attribute is added to the master page:
Web Development Quick Fixes create contentplaceholder 02

Last modified: 20 August 2018

See Also