Dev of things

Dev of things

Improving Productivity with Rider IDE

Improving Productivity with Rider IDE

How much do you need from your IDE to feel comfortable? There are lots of factors affecting this such as technical stack, user interface, extensibility, price, etc. Fortunately, we have enough tools to choose from. Today, I will show how efficient you can be using the proper tools such as Rider IDE JetBrains.

There are several perfect code editors you would rather for some reason. I worked with Microsoft Visual Studio for years and it was a great experience. I also like Visual Studio Code and how easily it can be extended.

There are no tools comparisons here but I will show you why Rider is the best one for me.

Rider

Rider is a cross-platform code editor which helps you develop .NET, ASP .NET, .NET Core, Xamarin, or Unity applications on Windows, macOS, or Linux. It contains tons of smart code editing features, navigation and search features, code analysis tools, and much more. You can also extend the feature set by installing suitable plugins for cloud development, Kubernetes, specific framework, etc.

If you are a .NET developer you probably know a Visual Studio plugin ReSharper which provides a huge number of features to have a better coding experience. Here you can find the features comparison between Rider, ReSharper, and Visual Studio.

Keymap Settings

It is worth mentioning that I use Visual Studio Keymap. You can configure your preferences by choosing IntelliJ, ReSharper, VSCode, or any other keymap you got used to.

Keymap.gif

As programmers, we spend most of the time reading and analyzing code. It is important to navigate fast between different app parts, see the dependencies, search for usages. You can always use Text Search but it is a bit messy. The features below help you to see the whole picture and find any part of the project.

Most of the features described are applicable for the front-end code as well! That fact makes me even happier cause I have had a lot to do with Angular and React in the last couple of years.

Search Everywhere

The feature name is descriptive enough. Press Ctr + T or Shift + Shift and type the name and you will get all associated items in the list below:

Shortcut_Ctrl+T.gif

Go to Implementation

If you have an interface and searching for the implementations you can press Ctrl + F12. If there is a list of items - you can choose the suitable one. If there is the only class - you will be navigated instantly.

Shortcut_Ctrl + F12.gif

Find Usages

Find usages is really important when you need to navigate through the project with lots of files. It is way more efficient than searching via text search or in Explorer. You can find usages pressing Shift + F12 on the object you need.

Shortcut_Shift + F12.gif

TODO Window

Personally, I would rather avoid using TODO in your code. But if you prefer there is an amazing and simple option in the Rider - TODO window. You will also find all System.NotImplementedException() supposed to be implemented later.

To open the window go to the menu View -> Tool Windows -> TODO or use a shortcut. It is Alt + 6 configured for me.

Window_TODO.gif

Structure Window

If you want to walk through the file and see its members you had better try Structure Window. It can be opened with the shortcut Ctrl + Alt + F or menu View -> Tool Windows -> Structure.

Window_Structure.gif

Recent Window

There are three windows to search for the recent locations:

  • Ctrl + comma to see the latest files you have opened
  • Ctrl + Shift + comma to see the latest files you have changed
  • `Ctrl + Shift + E' to see the latest locations you have visited.

Alternatively, you can go to the menu View -> Recent files / Recent Changed Files / Recent Locations.

I don't use them so much mostly because of the integrated Git client which allows me to observe the changes but I found it useful to navigate in the scope.

Window_Recent.gif

Errors in Solution Window

Working with the Visual Studio I used to run the Build/Rebuild command when refactoring or new feature implementing to see whether some warnings or errors appear. I don't need to do it with Rider at all because of the Errors In Solution window.

To open the window go to menu View -> Tool Windows -> Errors in Solution or press Ctrl + Alt + 2.

Window_Errors.gif

Generate and Refactor Commands

Inplace Refactorings

The most useful command in my opinion. You can press Alt + Enter and see the actions list. Let's create a nested type using all the power Inline Refactorings).

In the beginning, we create a derived type of an existing Interface:

Refactorings_Alt + Enter_CreateType.gif

Then we initialize members via the constructor:

Refactorings_Alt + Enter_InitMembers.gif

Finally, we move implementation into a separate file:

Refactorings_Alt + Enter_MoveToFile.gif

There are way more refactorings provided by the Alt + Enter combination. You definitely can rely on it while automating the routine codings tasks.

Refactor this

Another powerful command is Refactor this. I am just getting used to it but already find some cases.

You can extract the interface from the class:

Refactorings_ExtractInterface.gif

Move class to another file:

Refactirongs_MoveToFile.gif

Rename the object:

Refactorings_Rename.gif

There is a Ctrl + R + R shortcut that allows you to rename the class (and *.cs file as well). It will definitely be one of your most popular.

You can also apply this command to any object in the Explorer to Adjust Namespaces, Move to Folder, Rename, etc.

Refactorings_Explorer.gif

Code cleanup

After writing some code sometimes we need to adjust the formatting. There is the Code Cleanup command that makes it incredibly simple. Just press Ctrl + E + C and see the available options.

Code_cleanUp.gif

In C#, Rider can apply its code formatting and code syntax styles according to StyleCop rules. You can read more details here

Services Window

For me personally, Services Window is a killer feature. It saves a lot of time for me when debugging, analyzing the output, dealing with containers, etc. There is a configuration guideline you can follow but I'll just show you my common cases.

The feature looks very simple but it combines usage experience in a single place. I don't need some terminals opened or separate UI for the Docker containers or K8S cluster. I can read back-end and front-end logs in the same window. I can easily switch from start to debug mode for specific projects. I would really recommend playing with it.

.NET

You can edit, debug, run or analyze your .NET projects via Services Window. It doesn't matter Console Application, Worker Service, ASP .NET Core Web Application, and so on.

Services_Net_1.gif

If you create the Compound configuration combining multiple applications - you can add it to the list.

Services_Compound_1.gif

Docker and K8S

After setting up the connection just add the Docker configuration type and get access to Docker Desktop resources.

Images:

Services_DockerImages_1.gif

Containers:

Services_Containers.gif

Switch a context, choose namespaces, observe and modify workloads of the K8S cluster:

Services_K8S_1.gif

NPM

For sure, the NPM configuration exists. There are some tasks you can specify: install, start, build, lint, e2e, etc. You can also configure JavaScript Debug with the browser you wish.

Services_NPM.gif

Python

I like Python as a scripting tool and fortunately, the Services Window has an option to run the scripts:

Services_Python_1.gif

Speeding Up Routine

Any time I need to search for a place on the screen and click the mouse makes me thinking about the keyboard shortcut alternative. That's why I am trying to use a keyboard as much as possible.

I have no special recommendations to avoid using a mouse. It is just my experience and feelings. Avoiding mouse makes me more productive and helps keep the context in IDE.

Most Useful Shortcuts

TabsNavigation.gif

  • Ctrl + Shift + S - open Rider settings

OpenSettings.gif

  • Ctrl + M + O and Ctrl + M + X - collapse/expand class methods

CollapseExpand.gif

  • Alt + Up and Alt + Down - go to next/previous class member

GoToNextMember.gif

  • Alt + Insert - create new item

InsertNewItem.gif

  • Ctrl + Alt + L or Alt + 1 - show/hide explorer

Explorer.gif

  • Ctrl + Alt + 1 - show/hide terminal

Terminal.gif

  • Ctrl + Alt + K (git commit) and Ctrl + Shift + K (git push)

GitCommitPush.gif

Custom Shortcuts

In addition to existing shortcuts, I configured the custom ones to cover repeated cases. To set up keys go to Settings -> Keymap and choose the action.

Add_Shortcut.gif

  • Alt + F (git fetch) and Alt + P (git pull)

GitFetchPull.gif

  • Alt + C (close all tabs) and Alt + A (close other tabs)

ServicesOpen.gif

  • Alt + S - show/hide Services Window

ServicesOpen.gif

CamelHumps

There is a perfect feature called CamelHumps that identifies parts of compound names according to CamelCase:

CamelHumps.gif

Conclusion

Working with Rider I can delegate code writing and refactoring tasks to IDE and concentrate more on the architecture and the feature design. I believe the environment you prefer exposes a ton of amazing opportunities to make you even more productive and creative. Investigate your tools, search for useful plugins and share your experience!

I hope you find it useful. Thanks for reading!

 
Share this