StyleCop code style settings and inspections

In our previous post, we looked at how we can specify ReSharper’s inspection severities inside our EditorConfig file. In this post, we will see how ReSharper and Rider integrate with StyleCop configurations.

In this series:

Integration of StyleCop configurations

In the same way as ReSharper handles Roslyn coding conventions, it will also handle StyleCop rules. First, let’s make sure that we have enabled Read settings from editorconfig and project settings under Options | Code Inspection | Settings (in Rider, this is under Editor | Inspection Settings). After we’ve also enabled StyleCop support under Options | Code Editing | General Formatter Style (in Rider, this is under Editor | Code Style), all StyleCop configuration files will be evaluated and the ReSharper code style settings will be adapted accordingly:

Enable reading code formatting and inspection settings from StyleCop configurations

ReSharper 2018.1 EAP adds support for most of the naming, maintainability, readability and layout rules. For the next releases, we plan to expand the amount of supported rules. At the same time, in many cases ReSharper and Rider already allow to specify much more fine-grained settings. For instance, the StyleCop rule SA1002 (semicolon must be spaced correctly) maps to the following ReSharper formatter settings:

Overriding formatter settings via StyleCop configuration

At the same time, it activates the inspection for C# | Formatting | Incorrect spacing | Around semicolon.

One last thing to note, is that when using EditorConfig files and StyleCop configuration files simultaneously, the EditorConfig files will always take precedence over StyleCop configuration files (and ReSharper DotSettings).

We hope that you’ll enjoy our recent ReSharper and Rider improvements, like formatting inspections, extended EditorConfig support and integration of Roslyn conventions and StyleCop configurations.

Download ReSharper 2018.1 EAP now! Or give Rider 2018.1 EAP a try. We’d love to hear your feedback!

This entry was posted in How-To's and tagged , , , , , . Bookmark the permalink.

One Response to StyleCop code style settings and inspections

  1. Pingback: ReSharper Ultimate 2018.1 リリース! | JetBrains ブログ

Leave a Reply

Your email address will not be published. Required fields are marked *