Through the Alt + F7 and CTRL + B I have introduced before, you can quicklyCodeFile. However, sometimes code files are very complex, and dozens of functions are in pediatrics, and even one constructor has n or more overloading. At this time, it is not that easy to understand the functions, attributes, fields, events, and so on in the file.
In Visual Studio, you can organize or examine your code in these ways:
Region is the most commonly used method. My favorite method is field, property, event, and eventhander. Then, according to the actual situation, constructors (if the constructor is overloaded ), helper (if there are many common processes) is a series of methods associated with a specific task.
After you use region to organize your code, it looks very simple. But the problem arises. When a colleague checks your code and prepares to modify it, he wants to clarify your ideas, so he starts to fight in your code, this calls that. Oh, this part can accept 0, 1, or 3 parameters ...... After an hour, he was able to write the part he was about to change. The defect of region is that it is hard for the writer to understand and read.
The Object Browser can display your method structure, but the fatal thing is that it is sorted by letter. for Chinese, it is really difficult to find a self-explanatory method like filterselectablelayerbyname. In fact, you put it into a "Layer Control" region, but your readers cannot fully understand your usage. (If you often download code from codeproject, you will know that this kind of thing is common .)
After talking about this, we actually want to combine the strengths of the Object Browser With region, so that we can clearly classify the browser and find the desired method at a glance. Resharper has helped you a lot. Press Ctrl + F12 to bring up a window like the one on the right.
Here, according to your region, people who read your code will also benefit. The parameters and return values of each method are listed in the same way as those of UML.
- To browse a method, double-click its name;
- If you want to add several methods to a new region, you can select a method and click the icon in the image box on the toolbar; click the cross button to delete the region and move the corresponding method out.
- If you want to adjust the position of a method, such as moving it to another region, you just need to drag this method here.
- What's more, you want to browse and find all the functions of use and refactoring here. Right-click a method and you will be able to start the operation.
This is definitely the coolest feature in resharper. Open Visual Studio and try it.