# Roslyn analyzer support in Rider 2018.1 EAP

Posted on by

While writing code, Rider performs code analysis and helps us spot any errors, problems or potential improvements. With over 2.400 code inspections that come from ReSharper and WebStorm, Rider helps us improve code quality in every language it supports (C#, VB.NET, F#, HTML, JavaScript TypeScript, CSS, …).

The latest Rider 2018.1 EAP build goes one step further and adds Roslyn analyzer support as a new (experimental) feature! Let’s see!

## Why Roslyn support in Rider?

Many open source projects as well as development teams are writing their own analyzers to provide additional tooling for the frameworks they build. For example the xUnit.net folks have a set of Roslyn-based analyzers that help with things like making sure Fact methods do not have parameters – often combined with a code fix as well.

By adding Roslyn support to Rider, developers now get the best of all worlds! Not only will you get the 2.400+ inspections and quick fixes from ReSharper and WebStorm, you can now get community fixes from Roslyn analyzers!

## Enabling Roslyn analyzers in Rider

Roslyn analyzer support is disabled by default. We can enable it in the settings under Editor | Inspection Settings | Roslyn Analyzers.

Once enabled and settings are saved, Rider will scan for installed Roslyn analyzers.

## Installing and using Roslyn analyzers

Many Roslyn analyzers ship as NuGet packages, which means we can use Rider’s NuGet client to search for analyzers. Right now, installing analyzers via NuGet only works on .NET Core. Referencing analyzers in our .csproj using <Analyzer Include="path\to\analyzers.dll"> is supported for all frameworks and project types.

In a .NET Core web application, let’s install the DisableDateTimeNow analyzer, a simple analyzer which checks for usage of DateTime.Now and will suggest using DateTime.UtcNow instead.

After installation, Rider runs the analyzer on our code. It displays a hint, suggestion, warning or error in the editor. The “light bulb” in the left gutter is displayed when our cursor is on the code issue, and shows a Roslyn logo to differentiate between Rider’s own code analysis and code analysis provided by a custom analyzer. Using Alt+Enter, we can invoke the corresponding fix.

Analyzers may also run as part of the build in Rider. If an analyzer has a default severity of warning or error, it will show in the build output as such.

## Configuring analyzer severity

Hints and suggestions will show as light “squiggles” in our code, while for warnings and errors we will see clear yellow and red colors. For every analysis, we can configure its severity from the Alt+Enter popup.

Severity can also be configured in Rider’s settings, under Editor | Inspection Settings | Roslyn Analyzers. The full list of referenced Roslyn analyzers is displayed here, making it easier to change severity multiple analyzers at once.

## Solution-Wide Analysis

Like with any other code issue, Rider lets us find similar issues in the current file, project or solution and will run Roslyn analyzers for that scope.

We can also include Roslyn analyzers in Solution-Wide Analysis (enable/disable it from the settings). When opening the Errors in Solution tool window, we can inspect code analysis results powered by Rider as well as those coming from Roslyn. Note I enabled “Show Warnings” here as well.

## Current limitations

Roslyn analyzer support in Rider is still experimental and there are a number of things we’re still working on.

If you encounter any issues while using Roslyn analyzers in Rider, please open an issue in our tracker.

Give the latest Rider 2018.1 EAP build a try! We’d love to hear your feedback!

Comments below can no longer be edited.

1. #### Joseph Woodwardsays:

March 22, 2018

Great to see Roslyn Analysers are now supported in Rider. It’s one of the things I’ve missed since switching from Visual Studio, that and Peek Definition *hint, hint, wink, wink*

2. #### Blazor says:

March 23, 2018

Hi, did you start on Rider support for Blazor? Thanks!

https://github.com/aspnet/Blazor

3. #### Yacoub Massadsays:

March 23, 2018

Do you also support Rolsyn based code refactorings? Or just analyzers? Are you planning to support them?

• #### Maarten Balliauwsays:

March 23, 2018

They are supported indeed! Check the animations to see them in action.

• #### Yacoub Massadsays:

March 23, 2018

Which animation? The animation above shows the DisableDateTimeNow analyzer.

How can I install a Rolsyn code refactoring?

Thanks

• #### Maarten Balliauwsays:

March 23, 2018

…as well as the associated refactoring?

Any analyzer that has a corresponding quick-fix should work here.

• #### Yacoub Massadsays:

March 23, 2018

So, code fixes that come with the analyzer are supported.

I am specifically asking about code refactorings which are different.

For example, code refactorings are exported via the ExportCodeRefactoringProvider attribute, while code fixes (which are associated with analyzers) are exported via the ExportCodeFixProvider attribute.

• #### Nikolay Kuznetsov says:

March 23, 2018

Roslyn refactorings (known as Context Actions in ReSharper, and listed as such in Roslyn Analyzers settings page) should also be available after installation, same as analyzers and quick fixes.

I’ve tested it with RefactoringEssentials NuGet package, and it seemed to provide refactorings just fine.

Please note though, that availability of refactorings could be affected by some other factors. If you believe that we don’t support some refactorings that we should, please feel free to open a ticket on our issue tracker.

• #### Yacoub Massadsays:

March 23, 2018

Thanks. I have tested a custom refactoring and it worked!

I added <Analyzer Include… in the project file to make it work.

Is there a way to install a refactoring so that all projects can use it?

• #### Maarten Balliauwsays:

March 23, 2018

We have some ideas around that but haven’t done this yet. Would you mind creating an issue at https://youtrack.jetbrains.com/issues/RIDER#newIssue ?

• #### Yacoub Massadsays:

March 23, 2018

Done.

https://youtrack.jetbrains.com/issue/RIDER-14564

4. #### Rob says:

March 28, 2018

Oh wow!!! I am seriously impressed! I was thinking about this just the other day, as we use StyleCop Analyzers (which requires Roslyn Analyzers). This is why I pay you guys: nice job!

5. #### Joshua Light says:

May 13, 2018

Hi!

New feature is awesome!

One question: how can I inject included analyzer into build process so that every detected error will result in failed build?

6. #### Johannes Ebner says:

June 7, 2018

This is great! However, StyleCop.Analyzers and the quick fixes are not showing up for me or my team members. But they do in Visual Studio.

7. #### Chris Heselgrovesays:

November 23, 2018

Rider 2018.2.1
Roslyn is enabled by default, can this be changed in the registry or an install parameter please?

• #### Maarten Balliauwsays:

November 23, 2018

When you change this in the settings, it will be disabled for all projects you load afterwards.

• #### Chris Heselgrovesays:

November 24, 2018

Thank you, I’m looking more towards disabling for a whole site so an easier way that manually doing it for each workstation

• #### Maarten Balliauwsays:

November 24, 2018

I think you can disable it and save that to a team-shared settings file. Once checked in to source control, others on the team opening the same solution will get it disabled as well.

8. #### Deni35 says:

August 5, 2019

How can I disable default analizer? I want only StyleCop to work.
But I see many warnings like next (this is not StyleCop).
Using directive is not required by the code and can be safely removed
Property ‘***’ is never used

• #### Maarten Balliauwsays:

August 5, 2019

Hi, this series may be of help: https://blog.jetbrains.com/dotnet/2018/05/17/introduction-code-analysis-rider/

• #### Deni35 says:

August 5, 2019

Looks like there is no one checkbox to disable Rider’s analyzer?
https://d3nmt5vlzunoa1.cloudfront.net/dotnet/files/2018/03/configure-inspection-severity-settings.png

Do I need to disable each rule? If yes, then it’s badly.

• #### Maarten Balliauwsays:

August 6, 2019

Since it is what you are after, yes. However, I’d encourage you to make use of the built-in analyzers, as they do help in making code better over time.

• #### Deni35 says:

August 6, 2019

I wanted to disable this for the time of study. I spent a lot of time searching desired checkbox.
I’m sure every feature should be disabled. Ideally this should be a plugin.
Please provide this checkbox!
Also problem is that “Errors in Solution” Window doesn’t show the ID and the cause of error (Roslyn or IDE).

• #### Maarten Balliauwsays:

August 6, 2019

You could try with unchecking “Enable Code Analysis” under settings (Editor | Inspection Settings)

• #### Deni35 says:

August 6, 2019

I want to disable only Rider’s analyzer.
“Enable Code Analysis” is disabling all analysis.

• #### Maarten Balliauwsays:

August 6, 2019

Would you mind opening a feature request in that case? Via https://youtrack.jetbrains.com/issues/RIDER#newIssue

9. #### Vladimir Panchenko says:

October 18, 2019

Does Rider support Roslyn code fixes and refactorings as well? Many projects such as mentioned xUnit analyzers include them.
Also, does it support other Roslyn features such as custom IntelliSense providers?

• #### Maarten Balliauwsays:

October 18, 2019

Hi Vladimir, currently analyzers and their quick-fixes are fully supported. Other features (such as IntelliSense providers) are not. If you think those would be useful, feel free to create a new issue at https://youtrack.jetbrains.com/issues/RIDER#newIssue

Subscribe to .NET Tools updates