Using code editing helpers

Writing code is not only about writing, but also about getting more information on your code and support editing it.

Enhanced IntelliSense

IntelliSense is a standard tool in Visual Studio. ReSharper extends it by adding a couple of very useful features.

One of the most useful extensions for IntelliSense is CamelHumps, which allows you to filter options from IntelliSense by writing only capital letters from prompted options. By typing just UM (or um), ReSharper displays UserManager(), UnmanagedMarshal, and so on, as shown in the following screenshot:

Enhanced IntelliSense

ReSharper also extends the available options by adding objects from namespaces that are not used in the current file. In the preceding screenshot, only the first option comes from a developed project and the others come from unused namespaces.

For comparison, the options available when you are not using ReSharper are shown in the following screenshot:

Enhanced IntelliSense

ReSharper provides smart mode too that, in a smart way, filters the available IntelliSense options. For example, if you are comparing enum values, it displays only enum members. If you are passing some parameters to a method, it will display only members with the correct type. Smart mode is made available using the Ctrl + Alt + Space bar shortcut.

The last extension that we would like to describe is providing IntelliSense for objects that don't exist. It sounds strange but the following screenshot explains what this means:

Enhanced IntelliSense

As you can see, we have created a MyProvider class and a new IsReady property. After this, ReSharper knows that MyProvider will contain the IsReady property and display it in the available options.

Extending the code selection

It is very common that you will need to select some code. Normally, you select code by using the mouse or by using the Shift + arrows shortcut. ReSharper allows you to extend your selection by pressing Ctrl + Alt + the right arrow. Move your cursor to a word in your code and press Ctrl + Alt + the right arrow, which will select the whole word. Pressing Ctrl + Alt + the right arrow will extend the selection as shown in the following screenshot:

Extending the code selection

You can continue extending your selection until you select the whole file.

Safe delete

The Safe delete option allows you to check whether deleting an object member would break your code or not. The Safe delete option is made available using the Alt + Delete shortcut.

If it is safe to delete a selected member, ReSharper will just delete it. If not, ReSharper will display a warning or error for the conflicts found.

Auto-importing namespaces

As we have described previously, ReSharper marks objects that do not exist in red. However, this does not always mean that we would like to create it, because it can exist, but in namespace, which is not included in our file.

Such a situation is shown in the following screenshot:

Auto-importing namespaces

In this case, you can just add the missed namespace by pressing Alt + Enter.

Quick documentation

ReSharper can provide you with more information about your code if you press Ctrl + Shift + F1. This will display a pop up similar to the following screenshot:

Quick documentation

The Summary and Parameters description comes from a comment related to the UpdateConnectionStringInWebConfig method.

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

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