官术网_书友最值得收藏!

  • ReSharper Essentials
  • ?ukasz G?sior
  • 542字
  • 2021-07-19 18:20:05

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.

主站蜘蛛池模板: 信丰县| 武安市| 新余市| 井冈山市| 会同县| 安泽县| 江源县| 清水河县| 隆化县| 延边| 金昌市| 平定县| 尼木县| 天全县| 神农架林区| 沂源县| 鹤庆县| 昌图县| 张家界市| 石景山区| 大竹县| 徐水县| 平果县| 泾川县| 无锡市| 桑植县| 抚宁县| 静乐县| 成武县| 疏附县| 天镇县| 温州市| 巩义市| 布尔津县| 盖州市| 交城县| 广平县| 灵石县| 大同市| 墨江| 祁门县|