ReSharper 2024.1 Help

Use StyleCop styles

In C#, ReSharper can apply its code formatting and code syntax styles according to StyleCop rules. Below are several ways in which ReSharper supports StyleCop.

To apply StyleCop rules, ReSharper relies on its own features and settings, which do not always map directly onto StyleCop rules:

  • ReSharper supports most of StyleCop naming, maintainability, readability, and layout rules.

  • Some StyleCop rules may not be supported in a specific version of ReSharper. However we will try to support more rules in coming versions.

Inspections for StyleCop rules

ReSharper provides a number of code inspections for formatting and syntax style rules. These inspections do not find all code style problems that StyleCop finds, but they also can find some other problems that StyleCop cannot find, such as indenting problems.

As of version 2018.1, formatter inspections are disabled by default, but they will be automatically activated as soon as you enable StyleCop settings, and will offer you quick-fixes for code issues to automatically correct detected problems.

ReSharper: Code inspections and quick-fixes for violations of the code formatting style

Apply settings from StyleCop files

By default, ReSharper does not read settings from StyleCop files (RuleSet and Settings.StyleCop). To start taking these settings into account, select the Read code style from StyleCop files checkbox on the Code Editing | General Formatter Style page of ReSharper options Alt+R, O and choose which StyleCop file format should be used. Make sure that Read settings from editorconfig and project settings on the Code Inspection | Settings page of ReSharper options is selected.

When StyleCop integration is enabled, settings from StyleCop files (RuleSet and Settings.StyleCop) will override ReSharper code formatting and code syntax styles, and enable corresponding code inspections.

If you use EditorConfig and StyleCop configuration files simultaneously, the EditorConfig settings will always take precedence over both StyleCop and ReSharper settings. This means that if settings from StyleCop files (RuleSet and Settings.StyleCop) do not give desired results, you can always override specific settings using EditorConfig properties.

Last modified: 26 May 2024