Make R# 2016.1 cleanup to enforce curly braces in single-line "if"

Answered

R# 2016.1 stopped to add curly braces when cleaning code

Before it worked, if I had code like 

if (IsEmpty)
return null;

R# cleaned it to 

if (IsEmpty)
{
return null;
}

But after I've updated to 2016.1 it doesn't work anymore. I had specified all possible settings in Code Editing \ C# \ Code Style \ Braces and set everything to "REQUIRED" but it seems it doesn't give any effect.

3 comments
Comment actions Permalink
Official comment

Hello Evgeniy,

Please:
1) ReSharper | Options | Code Editing | C# | Code Style | Braces | select any severity instead of default "Do not show" one;
2) tick "C# | Code Styles | Add/Remove braces for single statements..." checkbox in Cleanup Code profile you use (ReSharper | Options | Code Editing | Code Cleanup).

Thanks! 

Comment actions Permalink

Ver* 2016.3.2

While exactly those settings mentioned by Alexander is in effect, it still clears braces when cleanup is running.

0
Comment actions Permalink

Hello Unsal

From ReSharper 2016.2 (https://youtrack.jetbrains.com/issue/RSRP-458911), selected severity does not affect applying code styles, so you need to select desired behavior for braces (e.g. "Enforce always").

Thanks!  

0

Please sign in to leave a comment.