📜 ⬆️ ⬇️

10 of my favorite CodeRush features for .NET development in Visual Studio


In short, DevExpress CodeRush is a paid plug-in for Visual Studio, belonging to the productivity tools class, which allows a developer to write better code faster, debug it, run tests, detect defects and perform other useful functions.

In this article I tried to collect not just a list of my own preferences for its use, but also to carry out a small validation so that at the output most of the presented chips are used by other guys on my team. I believe that even despite the active development of Visual Studio (especially pleased with the 2012 version) and the transformation of some of the described functions into native ones, the need for third-party helpers such as CodeRush and ReSharper is still relevant for some developers, as it saves time and improves overall convenience. coding. Finally, do not forget that there are still enough developers sitting on Visual Studio 2010- (at least judging by many customers) due to the nature of the project, budget, or just habit.

So, who is interested to know that other .NET developers use to increase the efficiency of even a small, but no less fascinating part of the software design process, please welcome to the cat (attention, a lot of pictures and video, as well as a survey!)

')
I warn you in advance that my “hot ten” demonstrates only a small fraction of the product’s capabilities (I myself think I use less than 5%). For more convenience of the reader, in addition to the Russian functional names, I will give English names that are typical for a programmer’s ear, indicate keyboard shortcuts by default (if any), and also indicate here and there analogs among standard studio features.

1. Collapse the project tree in Solution Explorer for Visual Studio 2010- / Collapse To Projects


Often you have to work with large solutions consisting of dozens of projects, and therefore this function is simply indispensable to find the right place in the project:



I have been using it for several years in different versions of Visual Studio and so far I am very satisfied (before the appearance of this feature, I used the VB-shny macro, in the latest versions of the studio the macros were cut out, EMNIP). I hope that this small feature will also be useful to someone, since not all projects still use Visual Studio 2012+, where the built-in Collapse All button appeared right in Solution Explorer:



2. Quick file navigation in the solution / Quick File Navigation ( Control + Alt + F )


It is not uncommon for you to know the source file by name and you want to quickly get into it. To do this, simply use the Control + Alt + F command, which allows you to make the transition as quickly as possible:



Beginning with Visual Studio 2012, a similar feature is available in Solution Explorer:



3. Quick navigation on types and members in the solution / Quick Navigation ( Control + Shift + Q )


This option is very similar to the previous one, the only difference is that we no longer navigate through the files, but across all types and their members:



Frankly, if the solution is just huge, then calling this search dialog without any additional settings can be a noticeable lag for obvious reasons. To avoid this, I recommend to conduct a small tuning search (by types of types and members, access and areas), which will help get rid of junk results and also increase responsiveness. Of course, it would be even better if the list was not rebuilt with each call, but was cached before reassembly (you need to ask our IDE team to make this option).

As an alternative, I sometimes use the good old studio search, for example Control + Shift + F on the string “ss ClassName”, which in principle also works well. Also, the standard Navigate To (Control +,) chip is quite convenient for this purpose, but I use it much less often:



4. Navigating the type and member use locations / Tab To Next Reference ( Tab / Shift + Tab )


This is probably one of my favorite features! It allows you to quickly find out where and how a type or member is used: for example, where this method is called. To do this, simply place the cursor on the desired object in the code and press the Tab key (forward) or Shift + Tab (backward), which is very natural and understandable for any Windows user:



There are standard studio cuts (Control + Shift + Arrow Up / Down) for the same, but they cause me a little pain in my left hand, although, of course, you can reconfigure all this for yourself.

5. Optimization of namespaces / Optimize Namespace References ( Control + ~ )


I like to get rid of unnecessary using in files that I visit and make everything look beautiful and tidy. If you are the same using-nazi as me, then this feature is for you:



Although this feature appeared in Visual Studio 2008 (the Organize Usings command from the context menu), I still use the co-crash functionality, since it seems more convenient due to backlighting and a faster call.

It is worth noting that in the settings you can choose the default sorting, for example, I have the length, instead of the alphabetical one:



6. Code Analysis and Formatting / Code Analysis & Code Style ( Control + ~ )


In short, this studio-embedded tool, in essence, is FxCop + StyleCop in one steroid bottle, which is visually represented by the thin strip on the right in the Code Editor:



This bar unobtrusively shows multicolored serifs (the color signals the severity of the problem), indicating to the programmer any potential problems in the code. A complete list of diagnosed problems (including even duplicate code in the solution!) Can be found here .
As with other similar tools, this helper can be flexibly customized for you or company code rules so that only the necessary hints are displayed:



And finally, if you trust the analysis mechanism as your wife :-), then in the menu for the file in the Solution Explorer there is a magic Code Cleanup command that will automatically “clean” the problems found for you. But, to be honest, I never use this command, because I don’t like it when someone completely rules the code for me. I remember even making the guys a suggestion to add a confirmation dialog for this command, as it seems to me quite serious (to avoid accidental clicks in the context menu).

As for the search for duplicate code (Duplicate Code Detection and Consolidation) and formatting , I use these chips much less often and will not focus on them, just leave links for those who will be interested.

In general, this built-in code analysis is a fairly tolerable initial foolproof or with the watchful eye of a pair programming partner, if you wish. I think it will be especially useful for novice .NET developers.
In conclusion, it is worth noting that, in addition to the previously mentioned FxCop / StyleCop with Visual Studio 2012, a Code Analysis window appeared that performs similar functions:



7. Moving a type to a file, renaming a type or a file / Move Type To File, Rename, Rename File to Match Type ( Control + ~ )


Many consider it a good form to have only one public class in one source file, and if this is not the case, then the Move Type To File command will help fix this as quickly as possible. The related command Rename File to Match Type allows you to rename a file by the name of the type that is in it, if suddenly their names do not match. And finally, you can rename any type or member through the intuitive pressing of F2, after placing the cursor on the desired item:



8. Adding Base Type / Add Missing Constructors ( Control + ~ )


Often, during inheritance, you need to implement base type constructors with a bunch of parameters that you would prefer not to type yourself, but rather copy from somewhere or load it automatically. This command allows you to do all the routine work in one mouse click or a couple of keystrokes on the keyboard:


Before that, I usually moved to the declaration of the base type through F12 and copied the signature of its constructors.

9. Take-out method or variable / Extract Method, Widen Scope ( Control + ~ )


It is often necessary to simplify a method or make the variable's scope wider. I prefer CodeRush features for these tasks:



, although it is probably worth mentioning that the same thing, but a little less convenient, can be done through the built-in refactor:



10. Templates for quick code generation / Code Generation Templates


Here I would like to list the abbreviations I use most often, which will probably come in handy in almost any program:


The video shows all the above combinations in action:



With these abbreviations, the first letter is intuitively simple and understandable, except for the only exception, which usually makes me smile: if you use the pdt template, which in my world should produce a property of type DateTime, then we will get a property of type DataTable as output - not very similar to the most commonly used type by developers all over the world :-). For the very same DateTime used "thin" pd8 (from the similar sound of the date c "d" + "eight" in English). Fortunately, all this can again be flexibly configured through the settings dialog, in which you can also create your own templates:



Of course, these are not all templates or abbreviations, and who are interested, you can see the full list here or call directly in Visual Studio via the combination Control + Alt + / (although I honestly doubt that in the world someone uses 20% of the total these abbreviations).

In terms of abbreviations, I can say a little bit of non-standard orientation, because I manage to use both standard studio tools (Insert Code Snipped, which is Control + K + X) and Koderashevsky at the same time, although they almost do not overlap:



eleven.
  <irony> Unload CodeRush for certain projects </ irony> 


It's probably no secret for anyone that any extensions for Visual Studio, however good they are, do not speed up the work of the IDE itself. What can we say when it comes to manipulating just huge solutions, for example, from 80 or more projects - in such cases the “clean” studio itself is barely moving, not like plug-ins ... At such times even the most loyal users have the thought will creep in as soon as possible to turn off all additional whistles, well, or somehow to minimize their impact:



In particular, it would be very useful for me to be able to include the CodeRush functions only for the necessary projects with which, for example, you work most often. Now there is no such thing, but if it were, then it would definitely be on my list of favorites, which is why it occupies the eleventh place of honor, albeit virtual :-)

Of course, these are not all the chips that I use and there are a lot of small and nice buns that do not deserve separate points ( structural backlight code , spell checking , color choice in the code , smart brackets , deep debugging visualization and 100500 others opportunities ).

Finally


I remember a couple of years ago I really liked it when the guys from our IDE team made Friction Free a mode of operation that allows you to flexibly configure CodeRush exactly for your coding style. This was done specifically to minimize the impact of the artificial intelligence assistant, namely, that he did not think that he knows better than you, that you love and dislike, and did not add incomprehensible pieces of code in response to random keystrokes on the keyboard. Specifically, this “silent mode” shows confirmation if during the dialing process you have executed some CodeRush command:



Those. if you like what happened, then you can let him do it further. So over time, just by doing your usual work, you can teach CodeRush to do only what you need, and not to interfere in the coding process at all (a few years ago he really sinned about it), while not breaking your habits, As you know, is one of the signs of software, which is pleasant to use. I remember when this opportunity only appeared, I deliberately set up this mode and was able to get rid of a few annoying chips of this “smart guy”, which were sometimes caused by chance, but which I lacked the spirit and time to find in the settings and chop off.

It may also be interesting:


CodeRush for Visual Studio (product page with a description of the full features and a link to download the trial version)
Search and Navigation Tips / Tricks with Visual Studio (article about standard IDE features from Scott Guthrie blog)
Beware of productivity tools (hot discussion on Habré)
DevExpress CodeRush Tips & Tricks (private blog on tool application)
Articles about CodeRush on Habré

Respectfully,
Denis

PS


  1. I am not a member of the IDE team that develops this product, although I am now sitting on the same floor with them. Therefore, I ask you to consider this post only as a personal opinion of an ordinary CodeRush user. The official position of the IDE team or statistics on TOP capabilities may not coincide with mine. This post arose spontaneously as a result of loyalty to this product and the presence of a couple of free days during the New Year holidays.
  2. If one of the readers also uses CodeRush, then I ask, so to speak, to share experiences, and share your favorite lists of product chips (or even its analogs) in the comments. It so happened that after the 3rd course of the institute (where, by the way, I indulged in Visual Assist), I immediately got into DevExpress, where I became very attached to CodeRush, and as a result I didn’t look deeply at any other similar tools. I would be glad to learn another experience and maybe even learn something for myself, although they say that the choice of IDE productivity tools is done only once in a lifetime ...

Source: https://habr.com/ru/post/211805/


All Articles