Click here to Skip to main content
13,731,697 members
Click here to Skip to main content
Add your own
alternative version

Stats

7.6K views
6 bookmarked
Posted 12 Apr 2018
Licenced CPOL

Getting started with JetBrains Rider - A cross-platform IDE for .NET developers

, 12 Apr 2018
In this article, we'll look at JetBrains Rider, a cross-platform IDE for .NET developers - built by the same folks that build ReSharper.

Editorial Note

This article is in the Product Showcase section for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers.

Introduction

It almost feels like a renaissance of Microsoft's .NET platform happened in the past few years! It all started with ASP.NET Core, which later became .NET Core, and before we knew it we now have a framework that can be installed from a series of NuGet packages. We can run our .NET code on Windows, Linux ad macOS. Even on a RaspberryPi!

The obvious next question is: can we also develop our code on any of these platforms? Well yes! Along with .NET Core, an explosion of .NET IDE's happened! There's good old Visual Studio and a number of alternatives from Microsoft, but the ecosystem is much bigger than that. In this article, we'll look at JetBrains Rider, a cross-platform IDE for .NET developers - built by the same folks that build ReSharper.

What is JetBrains Rider?

JetBrains Rider (I will just call it Rider from here on) is a cross-platform .NET IDE that supports developing, running and debugging pretty much any .NET project type out there. It supports the full .NET Framework, Mono, as well as .NET Core. It lets us write code in C#, VB.NET, F#, JavaScript, TypeScript, HTML, CSS and so on. We can build console apps, libraries, ASP.NET MVC and other web application types, Unity games, Xamarin apps (even debug on an Android or iOS device), Angular, React, Vue.js and more. So when we say it is a .NET IDE, it really is a full-stack .NET IDE.

JetBrains Rider - Cross-platform IDE for full-stack .NET developers

Now that we got the buzzwords out of the way: why should we care about Rider? If you're familiar with IntelliJ IDEA or ReSharper, you may know that JetBrains (the author of these tools) is very well known and respected in productivity tooling for many programming languages and frameworks. Rider is building on top of both of these products that have been under active development for over 12 years - making Rider the most mature "new IDE on the block".

For all of the languages supported by Rider, it provides navigation, automatic code inspections and quick fixes, code generation, a large number of refactorings, and more. Of course, built-in tooling like a debugger, a unit test runner, a (fast!) NuGet client, database tooling, a WPF XAML preview window, version control and integration with tools like Docker and Unity Editor is there as well. A full-blown IDE with a heavy feature set, Rider is pretty fast and responsive.

As you can imagine, these are too many things to discuss in one article, so let's focus on a few things to help you get started. You can always download the latest version of Rider and test-drive for 30 days.

Keyboard shortcuts

Before we dive into any functionality, I want to highlight that while Rider can be used with the mouse, it also provides keyboard shortcuts to do pretty much anything.

No need to study all of them for this article! Except for these two that are good to learn from the start:

  • Show contextual actions (Alt+Enter in the Visual Studio keymap on Windows and macOS) - When invoking this in the editor, Rider will show a small pop-up that lets us perform actions that apply to the location of our text cursor. For example when our cursor is on a class name, Alt+Enter will let us rename the class, create a derived type, navigate to usages of that class, etc.
  • Search Everywhere (Ctrl+T in the Visual Studio keymap on Windows, or Double shift on macOS) - This shortcut will let us find elements in our codebase, files in our projects, actions we can perform, and even searches for settings.

Navigation and search

The first time we create a new solution or open an existing .sln file in Rider, the IDE indexes all file names, textual content, as well as the meaning of content (so it knows about the Person class in our codebase, and that it has a Name property of the type string).

When we invoke Search Everywhere (Ctrl+T / Double shift), we can search for things. For example when we search for the word "View", we can see that Rider finds results in recent files, classes, files, symbols, actions, settings, ...

Search Everywhere with Rider

We can click any item (or use the arrow keys and press enter) to navigate to a certain item. Navigation is not just search: from any location in the editor, we can Show contextual actions (Alt+Enter) and, for example, pick Navigate to to see where we can go from here.

Navigate from a symbol to its usages, derived types, etc.

We can navigate to the implementation of our interface, base symbols (if any), find where our interface is being used, jump to derived symbols, and so on.

Note that in any popup or menu entry, Rider will display corresponding keyboard shortcuts. As mentioned before, we can start with just the two base shortcuts and then learn a new one every day.

While reading through code, we may want to navigate to the declaration of a type (or a property or method). We can always do this by hovering over any symbol and pressing the Ctrl (or Cmd) key, which will transform it into a hyperlink. Rider then lets us click and navigate to that symbol. If the symbol is found in our own code, Rider will navigate to it. If it exists in a third party assembly, well... Rider will navigate to it as well, decompiling the third party code on the fly!

Navigate to decompiler

Code editing and code analysis

As one would expect from an IDE, Rider provides features like code completion and code templates, including the very useful postfix templates, as well as things like inserting matching braces and import directives, automatic referencing of project in our solution when needed, and so on. So expect those things are there, and let's look at some unique things instead!

Code generation

Using the information Rider gathers by continuously analyzing our project in the background, code completion and code templates can be contextual. Let's say we have a class Person, and want to add a constructor that populates its properties. Of course we can type it, but since Rider learns about our class, it will provide a smart code template ctorp - creating a constructor for all pubic properties.

Using smart templates in the editor

There is more! When we invoke this template, Rider not only generates the code for us, it generates it based on the C# version we are working with! So it could be a C# 6 constructor that looks like this:

public Person(int id, [NotNull] string name)
{
    if (name == null)
    {
        throw new ArgumentNullException("name");
    }

    this.Id = id;
    this.Name = name;
}

But if we're using C# 7 and up, we'll get code that makes use of throw expressions instead:

public Person(int id, [NotNull] string name)
{
    this.Id = id;
    this.Name = name ?? throw new ArgumentNullException("name");
}

Smart templates are one way of generating code, the other way is using the Alt+Insert keyboard shortcut. When invoked in the solution explorer tool window, it will let us generate new directories, files, and more. When invoked in the editor, it provides access to contextual code generation that, for example, lets us implement equality members and will add an Equals() and GetHashCode() method, and optionally also implements IEquatable<T> and adds operator overloads for == and !=.

Generate equality members

Code analysis

Because Rider analyzes our code all the time, it can help us ensure we have a consistent code style, and detect common code issues (such as a possible NullReferenceException going to be thrown), as well as the more tricky ones that would typically only surface at run time (think heavy LINQ usage and implicit capture of closures). Rider comes with over 2200 of these code inspections, and most of them provide automated quick-fixes to resolve detected issues - individually or in bulk.

Automatic code inspections in Rider

Note it is also possible to install third-party Roslyn analyzers.

Rider also comes with solution-wide analysis, where warnings and errors in our solution can be grouped and filtered to wish. Inspections come with their own (configurable) severity, so obviously a hint will not be as severe as a warning or an error.

One type of inspections I personally like a lot are language usage opportunities. These inspections help us in learning new C# features - something that is especially handy now that Microsoft started shipping minor releases like C# 7.1 and C# 7.2. We can see the available suggestions from the settings (under Editor | Inspection Settings | Inspection Severity | C#).

Language usage opportunities

Refactoring

Rider comes with a large number of refactorings that can help us restructure our code, without breaking anything. For example, we can rename a class or property, and Rider will update all of its usages across our project. Refactorings are all context-based, and available from either the Alt+Enter shortcut, or using the Refactor This popup (Ctrl+Shift+R):

Refactoring code with Rider

Next to these refactorings, Rider also comes with over 450 context actions that we can execute from the Alt+Enter menu. Some are simple, like changing metod accessibility from public to private, while some are more elaborate. For example when implementing a class that provides change notification (via the INotifyPropertyChanged interface), Rider can refactor an existing property into one that has change notification:

Refactor to property with change notification

This will update our class, adding a backing field and updating our property signature to notify observers that its value has been updated.

private string name;

public string Name
{
    get { return this.name; }
    set
    {
        if (value == this.name)
            return;

        this.name = value;
        this.OnPropertyChanged();
    }
}

Debugger

As developers, we spend much time debugging the software we are writing. Not only to track down bugs, but also to help us understand what a piece of code is doing when it's being executed.

Rider comes with a great debugger that allows attaching to a new or existing process and lets us place breakpoints to pause the application and inspect variables, the current call stack, current objects in .NET managed memory, and so on.

Rider debugger in action

The debugger in Rider works for .NET code, as well as JavaScript, TypeScript, and many other languages. Even simultaneously, which is really handy for debugging front-end JavaScript that talks to a .NET web API.

If you're interested, there's a series about debugging available on the JetBrains blog:

Earlier in this article we saw that we can navigate to third-party code using Rider's built-in decompiler. A nice touch is that it is also possible to debug third-party, decompiled code.

Unit test runner

Rider recognizes unit tests based on NUnit, xUnit.net, or MSTest, and marks test classes and methods with a gutter icon in the editor. By clicking it or using Alt+Enter, we can run and debug our tests or manage test sessions.

Unit testing in Rider

As we can see in the test tool window, we can explore test results, apply grouping, see test output, and so on. From the test results, we can also navigate back to our test (double-click or press F4), and when a test fails we can click symbols in the stack trace to jump there at once.

What else is there?

There are many more tools, tips and tricks to discover in Rider. For example, there's a WPF XAML preview tool window to help us visualize XAML markup.

WPF XAML preview in Rider

There are the database tools for connecting to a variety of database servers, including Oracle, SQL Server, PostgreSQL and more. Just like with code, Rider comes with similar functionality for databases: navigation, code assistance, refactorings, inspections, and so on. For example, Rider learns about the different foreign keys in our database and will provide smart completion when writing JOIN statements:

Working with the database tools

Of course, there is version control integration as well, with Git, GitHub, Mercurial, Visual Studio Team Services and Team Foundation Server, and more. It lets us commit, revert, merge, rebase and look at history.

One great tool is local history - which I tend to nickname "undo/redo on steroids". Version control is great, but what do you do between commits? Local history keeps a real-time, local version control that keeps track of changes we make to our code base.

Version control and local history

And then there's all of the WebStorm's tooling as well! JavaScript, TypeScript, CSS, HTML, React, Angular, Vue.js, Node, and npm. As I develop mostly web API's, the built-in REST client is a really invaluable tool to quickly test some calls against an API.

Conclusion

As we've seen in this article, JetBrains Rider is a cross-platform, full-stack .NET IDE that we can use to develop, run and debug almost any .NET project type. It is pretty light and fast, yet comes with very powerful features to help us be more productive.

If you would like to learn more, I'm maintaining a curated list of Rider content, bundling many tutorials and tips & tricks.

Download Rider now and give it a try!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Maarten_Balliauw
United States United States
Maarten Balliauw loves building web and cloud apps. His main interests are in ASP.NET MVC, C#, Microsoft Azure, PHP and application performance. He co-founded MyGet and is a Developer Advocate at JetBrains. He's an ASP Insider and MVP for Microsoft Azure. Maarten is a frequent speaker at various national and international events and organizes Azure User Group events in Belgium. In his free time, he brews his own beer. Maarten's blog can be found at http://blog.maartenballiauw.be.

You may also be interested in...

Pro
Pro

Comments and Discussions

 
QuestionWhich IDE Should I Keep? Pin
Stringda16-Apr-18 17:04
memberStringda16-Apr-18 17:04 
PraiseLooks Cool and all but... Pin
DumpsterJuice13-Apr-18 6:01
memberDumpsterJuice13-Apr-18 6:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06-2016 | 2.8.180920.1 | Last Updated 12 Apr 2018
Article Copyright 2018 by Maarten_Balliauw
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid