ReSharper Configuration and usage

Source: Internet
Author: User

Disclaimer: This article is reproduced, the specific source, please click

1: After installation, ReSharper will use his own English smart tips, replace vs2010 Smart hints, so we want to change back to vs2010 Smart tips

2: Shortcut key. Do you use vs2010 shortcut keys or use ReSharper shortcuts? I am a shortcut key for using RE

3:

Esharper after installation, will do a few things, these things for other than this user, more trouble, so summarized, for reference.

(1), will be the option--text editor--c#--general--Automatically list Members this selection box is removed. So when you use a method, it will not prompt the parameters, is a very depressing thing.

Can be manually hooked up.

(2), will be the option-text editor--c#--advanced-Display real-time semantic errors, in the edit with the underlined identification error two options removed. This would have been nothing, but if ReSharper had been uninstalled,

The VS Editor does not prompt for errors in real time. So after uninstalling the ReSharper, the two options need to be checked again.

4:use var

Use implicitly typed local variable declaration

5: Press Alt+enter can solve many problems. Here is the shortcut key Daquan.

6:alt+f7 all uses of the variable where your cursor is located are displayed in a list, and the form that displays the results can be docked like any other form.

Its advantages include:

    • You can choose to show only read usage or write usage from all uses, and sometimes we just want to know where a variable has been changed. The icon in front of the found location also tells you this.
    • Can be previewed below, even if we list all use, do not want to jump to each use it place, this time preview can help you a lot.
    • When you change some of the usage in the Code Editor, such as deleting a row, a strikethrough is used in the Find results form.
    • The default is to find all the use of the solution and organize it by namespace, which is very easy to choose.

I can't remember how I looked for it before I had alt+f7. Anyway, I'm pretty ctrl+f now, unless I forget the name of a variable. If so, most of the name needs to be refactor, and that's another big chunk of ReSharper's function. Some people may scoff at this feature, but those who have used the cab know that subscribing to and releasing a signature for an event is a string, and if you don't have to search to find it, you don't know how many handlers are going to work behind it. Alt+f7 is used to search for this string, which is equal to all callers behind the lookup.

However, when the cursor rests on a type, be careful to use alt+f7, suppose it is a string, you should be able to imagine how many use

7: The Mighty Alt+enter carriage return

The almighty Alt+enter can help you with a lot of dirty work in the process of writing code, which is probably summed up in the following:

    • A way to help you implement an interface or abstract base class;
    • Provide you with some suggestions for handling current warnings;
    • Provide you with some suggestions for dealing with the current error (not necessarily a true error);
    • Simplify the current bloated code for you;

8:ctrl + F11 When we look at someone else's code, or look at their own code, always feel that the code is too much, so we use the region to the code to encapsulate the comments, but then others look at the code is very depressed, ReSharper File Structure function, you can To show the region and your methods.

Said so much, in fact, the Object Browser and region of the advantages of combining, can be clearly categorized, but also at a glance to find the method needed. ReSharper is a great help to you at this time. With Ctrl+f11, it pops up a window like the one on the right.

In this case, according to your region, people who read your code also benefit. The parameters of each method, the return values are listed as UML.

    • If you need to browse to a method, simply double-click its name;
    • If you want to put some methods into a new region, you can select the method, click the icon on the toolbar, and the fork will delete the region and move the corresponding method outside.
    • If you want to adjust the position of a method, such as moving it to another region, just drag the method here.
    • What's even more gratifying is that the features you want to browse from here and find all the use and refactoring are also available here, and right-click on a method to start the operation.

9: Refactoring is the kingly Way (UP)

Refactoring is a spirit that proves that you are committed to providing efficient, refined, and robust code, rather than messy, obscure, and flawed code. In Visual Studio 2005, Microsoft provided the refactoring tool for the first time. But not enough, far from enough. The refactoring we need is very broad, and we want to make quick adjustments to the code, as soon as I think about what my tool can do. This is the pursuit of the reconstruction of the realm.  So in this sense, almost resharper provides you with tremendous productivity. The refactoring provided by Visual Studio 2005 includes the following:

    1. Encapsulate Fields
    2. Extraction method
    3. Extract Interface
    4. Promote local variables
    5. Remove Parameters
    6. Renaming
    7. Rearrange parameters

These methods are all supported in ReSharper (but the ReSharper refactoring is much more than these), and they correspond to:

    1. Encapsulate Fields--introduce Field
    2. Extraction Methods--extract Method
    3. Extract Interface--extract Interface (additional Extract superclass extracted as base class)
    4. Promote local variables--introduce Variable
    5. Remove Parameters--Move to change Signature (changing method signature)
    6. Rename--rename (ReSharper will provide you with a few optional best names based on the type name of the object)
    7. Rearranging parameters--moving to change Signature (changing method signature)

I know a lot of people claim that e-text is not good, but it is really a very simple word, difficult to pour anyone. These refactoring functions are well known, the following tells you some ReSharper unique, first, the refactoring of the shortcut is Ctrl+shift+r:1, for the class, in addition to the extraction interface, the base class, you can also move it to other namespaces and move to other files, this is a practical function, Perhaps you do not believe, but I really have a person, all business entity is written in a DataObject.cs inside.  You can't imagine how big my mouth was when I opened it. 2, for the field, provides:

    • Safe Delete, detects all the places used, and asks how to delete them;
    • Pull Member up and push Member down, you can move this field in the base class and the inheritance class;
    • Use base type where possible, as much as possible using the base class, because the ArcGIS platform is based on COM components, many times we need to be igeometry, ipointcollection such an interface exposes properties or methods, So you don't need to save a polygon object, but you can use the base type;
    • Encapsulate field, encapsulates the fields, but this feature is far less useful than another operation that provides the same functionality. I can talk about it later in the article.

3, for the method, provides:

    • Functions similar to fields, in addition;
    • Change Signature, changing function signatures, including changing names, returning value types, parameters of various information, adding and removing parameters, is quite practical. If you are working on an override method, you will be prompted whether to change in the base class.
    • Make Static, if ReSharper detects that this method is not associated with a non-static member, it will often automatically prompt you (in the form of a yellow bar) to be static, and if you take the liberty of modifying some methods there is nothing wrong, but the consequences are at your own risk.
    • Extract class from parameter, if you have seven parameters eight, then whether to consider a class to encapsulate these parameters, so this function came into being.
    • Method to property, as the name implies, if you are still using GetField () or SetField (..) , you must have come from a non-. NET star.

4, inside the method body: Extract methods, do not introduce it.  Introduce Variable/parameter/field, depending on which object you have the cursor on, provides the ability to convert. Inline Variable: Just put:

IPoint point = new Pointclass (); Point. Putcoords (_point. X, _point. Y);

To become this way:

New Pointclass (). Putcoords (_point. X, _point. Y); This is a bad example.

5. Renaming: Why renaming is worth picking out, because ReSharper provides the gold-like function of naming recommendations. So, want to change the name of easy-to-read strong names, not so much the brain of things. ReSharper will provide you with several alternative names based on the type of the variable, the name list is listed at the cursor position (the method renaming will pop up the dialog box), you only need to use the arrow keys to select and hit Enter, which is the type of first name to lowercase, or even root planing to the base class type name , you can also improve on this basis.  If you are still using the obscure name of I,j, please quickly change them to Outindex, pointcount such as the readable name.  ReSharper actually provides a more advanced function, when you name a variable, there are shortcut keys for you to provide alternative names, but Ctrl+space is our valuable input method toggle key, so, I hammered on the variable name, often first started a rotten, and then renamed. There are some more generalized, to help you to adjust the function of the code, I write another one, or too long.

Refactoring is the kingly way (next)

The Alt+insert shortcut key for inserting code ReSharper provides you with the ability to insert code. Because these two keys very difficult to press (this is my feeling), really in use, I use is alt-r-c-g, means to open resharper menu--code--generate, all only need your left hand, so you can hand gestures, while still writing code, how cool AH.

    Constructors and properties are most commonly used in the code generated by
    • , and when you do not have a private field, only an empty default constructor is generated, and there is no capability to generate properties. In the case where you have a private field, it is extremely convenient to write overloads that let you choose which private fields are required as arguments to the constructor and generate the initialized code. The build properties are similar. Another common use of
    • is to override the method of a base class or interface. Select implement Interface Member or override Inheritate Member,resharper to find the base class or interface for the current class, and then list them by inheritance hierarchy, overriding or implementing these methods according to your choice.
    • is not too common to generate the Equals and GetHashCode methods, which are rarely rewritten in my scenario. But according to the. NET design specification, both value types and equals of reference types are recommended overrides, and the Gethasecode method should be overridden because they depend on each other. If you have this requirement, then generating these three functions will certainly do you a big favor.

surround code   Visual Studio also provides this feature of the external code, you can press Ctrl+k,ctrl+s to activate this function, While I didn't mean to despise Visual Studio, ReSharper's shortcuts were really more reasonable (I really had a hard time pressing s when I pressed the CTRL key) and the entries were clearer. The shortcut key for this feature in ReSharper is Ctrl+alt+j, and you can then choose to surround the current line's code with the Try-catch block or the using. This is a very efficient approach, and we tend to avoid catching exceptions in the early stages of development and adding exception handling mechanisms in the middle and late stages. So you have a lot of work in a certain period is to extend them into the Try-catch block. When you want to use a support Dispose object, the best way is to use a using block. (The cake, when I know my code is not the best time, I always sleep at ease), here naturally there is the code to expand the function of the block, is also one of the common functions.   position of the adjustment method   as I said earlier, if you want to adjust the location of the method, you can drag and drop the operation in the Code structure window. If you think that just moving a method to the front, but have to open the Code structure window is too heavy, then there is a lightweight method: When the cursor is on the name of the method, you can move the position of the method with ctrl+shift+, including the method's XML comment, but if you are not using a three/ XML comment Instead of two/, then I'm sorry.   Other trivial features   you must often copy the code that pastes the current line, For example, when using Stringbuilder.append, Ctrl+d can simplify the work you ctrl+c,ctrl+v.   Once had a key combination to comment out the current line, and another to uncomment it, but I've forgotten it because ctrl+/should be the one that really belongs to it, and you can cancel the comment again by pressing it again.   about ReSharper The refactoring function is that, I might naively put a lot of extra functionality into refactoring, but it does help you quickly tweak and optimize your code. So, please do not delve into my understanding of the concept of refactoring is not chaotic.

Enhanced browsing Capabilities

We have become accustomed to the parameter hints provided by the IDE to the way the parameters are entered, which greatly facilitates our choice of overloaded methods. In an environment without ReSharper, Visual Studio has done it. So why ReSharper to enhance this feature and be highly praised. Ask, is there any hint of a narrow line of Visual studio parameters that makes you feel stuck? We have a 19-inch big screen, 1600 resolution, but have to stare at the narrow strips, carefully press the up and down keys to find the overload we need.  At the very least, the guy who developed the ReSharper couldn't stand this kind of buckling, so the parameter list of the big open version appeared, and the long parameter overloading was shown in the form of a list, and when you saw the huge parameter overloading using the Gdt+ method, you would make an exclamation from the bottom of your heart: Sell the cake. At the same time, ReSharper display parameters of the shortcut keys to become ctrl+p, if you think the printed shortcuts are just kidding, then ask yourself how many times you have printed your own code. Browse open documents   I thought you already knew how to switch documents in Visual Studio, including:  ctrl+alt+ Up and DOWN ARROW keys, you can switch;  Ctrl+tab in the open document, not only can switch before the document, and can switch to the solution folder, the Properties view to go, need to press the left and right key.   But how do I open a file that was closed after the recent edits, and Visual Studio did not provide this functionality, so it was left to ReSharper. In my case, this shortcut is Ctrl+e,ctrl+e, yes, press two times. If you are not, then look under the Resharper-view-recent files menu to see what it is. Because you will always use it. Open a list of files, select with the arrow keys, and enter will open in the editor.   Many people say ReSharper's performance problem, I think, one possible reason is that there are too many open documents, if you have the habit of turning off unwanted documents at all times, performance may not be so bad, and you can always open those documents that you have closed, just like switching between documents that are already open.   My team didn't use agile to develop those high-level stuff, but we kept the good habit of only two or three files per change, and frequently commite to the source code server. So, every time I really want to edit a few files, performance is not a problem.   and we share a lot of resharper use of skills, little drops have been integrated into my daily development work. Of course, it is not comprehensive, such as integration with NUnit, because we are not test-driven, so there is no experience, nature also dare not boast, but also very subjective, I think it is good, you may think it is bad, radish greens each their own. Besides, it's not a place without idiots, right-click on the document to add a close all feature, you can close all open documents, shut down what to do, staring at a blank screen? I think the original "close all" is enough. There is also a positioning function (Locate in Solution Explorer), which is useless if you set up in the VS option and track the active item in the solution Manager, then vs automatically gives you the location.   Anyway, it brings me a faster and more convenient development experience, freeing me from trivial, impersonal functions. From this point on, I hope more and more people like it, start using it, and help it develop better.

Software:

Registration Code: Username: User Registration code: D9d09dsyjel9iyudu4btaqwzcbluguad

ReSharper Configuration and usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.