Resharper 8.2: Adding blank lines before and after if statement.

Hiya,

We're currently trying to set up a standard team format that can be applied via resharper, but I'm having a little trouble setting up if statement formatting.

Currently, it always seems to remove new lines around if statements:

var sausage = someVariable;

if (true) {
    return "yay";
}

if (false) {
    return "woo";
}

var pie = sausage;


becomes

var sausage = someVariable;
if (true) {
    return "yay";
}
if (false) {
    return "woo";
}
var pie = sausage;


Is there any way to stop this happening? I can't find any option for this.

2 comments
Comment actions Permalink

Please check you have at least "1" in ReSharper | Options | Code Editing | C# | Formatting Style | Blank Lines | Preserve Existing Formatting | Keep max blank lines in code.

0
Comment actions Permalink

Thanks for the reply! Unfortunately that setting has a few drawbacks (appologies for not being clearer in my op). It keeps some spacing where we don't actually want spacing which is why its turned off. It also won't fix any if's which have been added without the space to start with.

This also seems to affect other statements such as switch, for etc.

0

Please sign in to leave a comment.