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

  • 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.

主站蜘蛛池模板: 廉江市| 乐安县| 封开县| 芜湖县| 潼南县| 衡水市| 双流县| 朝阳区| 泗水县| 汉寿县| 新疆| 吴堡县| 文登市| 治县。| 三亚市| 长沙县| 昭平县| 长沙县| 湖北省| 普宁市| 谷城县| 黎川县| 额尔古纳市| 桑植县| 岳西县| 晋城| 屏东县| 米易县| 北海市| 玉环县| 茶陵县| 盱眙县| 昌吉市| 开封市| 乌苏市| 灌南县| 伽师县| 东山县| 永靖县| 瑞金市| 武安市|