Chapter 5. Extended Support for Web Developers

ReSharper has been focused on supporting backend languages such as C# or VB.NET from the beginning. Fortunately, with almost every release, there are more and more languages that are supported.

Currently, ReSharper provides you with many features that can be used by almost every .NET developer. Most of these features are dedicated to web developers.

In this chapter, we will explain how ReSharper supports the following:

  • ASP.NET and ASP.NET MVC
  • JavaScript
  • TypeScript
  • HTML/CSS

As we have described most of these features, here we will only quickly describe how they support web development without a detailed description.

Note

Some of the presented features already exist in newer versions of Visual Studio, but ReSharper adds these features to all supported versions.

ASP.NET Web Forms and ASP.NET MVC tools

In terms of web development in Visual Studio, ASP.NET was the first area that was supported by ReSharper. Currently, almost every ReSharper feature supports ASP.NET in some way—both Web Forms and MVC.

Writing ASP.NET smartly

In the same way as in C#, ReSharper helps you write ASP.NET by extending IntelliSense, generating code, and providing you with some refactoring methods.

IntelliSense provides you with prompts for web-related things, such as ASP.NET controls, ASP.NET MVC helpers, resources, JavaScript symbols, and so on.

While working with ASP.NET, ReSharper helps you in importing required namespaces and removing unused directives (same as with using statements in C#).

As with C#, ReSharper allows you to generate members based on the implemented interface; in ASP.NET, you can generate Content tags based on ContentPlaceHolders from your Master Page and the required event handlers.

Templates

When you are working with the ASP.NET project, ReSharper allows you to use file templates that are specific to ASP.NET. You can find templates to add web pages, controls, and Razor views, as shown in the following screenshot:

Templates

Note

Quick reminder: creating a new file from a template can be done by pressing Ctrl + Alt + Insert from the code editor or by pressing Alt + Insert in Solution Explorer.

And of course, you can define your own templates.

Enhanced navigation

In case of navigation, you can find well-known features such as displaying the File Structure or navigation through file using the Go to File Member option by pressing Alt + . Using the Go to File Member option, you can search by HTML tags, IDs, CSS classes, and any other object used in your view. A sample search by HTML tag and element ID is shown in the following screenshot:

Enhanced navigation

A very useful feature in web applications is Go to Related Files. You can access this option by pressing Ctrl + Alt + F7. It is also available in C# but is most useful in ASP.NET or HTML code. It allows you to quickly navigate to related files, such as JavaScript, CSS, Master Page, Controls, and any related code.

The following screenshot presents you with a list of related files for a sample ASP.NET MVC view:

Enhanced navigation

As you can see, it contains the controller that is related to this view, the JavaScript files declared in this file, the master layout, and CSS files declared in this layout.

ASP.NET MVC specific support

In case of support for ASP.NET MVC, the most important feature is IntelliSense, which prompts you the controllers and controller's methods every time you need to specify them. A sample usage is shown in the following screenshot:

ASP.NET MVC specific support

ReSharper also improves navigation between controllers and views, and detects non-existent views, as you can see in the following screenshot:

ASP.NET MVC specific support

The preceding screenshot presents the return statement from the Process method.

Tip

In Visual Studio, there's a very useful shortcut, Ctrl + G, M, which allows you to easily switch between View and Controller. Just put your cursor somewhere in the controller method or in the view method and use this shortcut.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.123.189