Different brace behaviour for single line if
Greetings, I'm attempting to make my resharper do the following when formatting C# code:
if(something) return true;
if(somethingelse) {
// do things
} else {
// do other things
// more than one line
}
However under Formatting Style -> Braces Layout there's only an option for Braces in "if-else" statement. If i set this too add braces I get this:
if(something) {
return true;
}
if(somethingelse) {
// do things
} else {
// do other things
// more than one line
}
And when set to use braces for multiline this is the result:
if(something) return true;
if(somethingelse) // do things
else {
// do other things
// more than one line
}
Is there an option that makes resharper not add braces only when it is a single line if statement without an else/else if?
Please sign in to leave a comment.
Yes, in R# 2016.
Look under Code Style > Braces > In "if" statement > Enforce if statement is multi-line.
Other choices include:
Note: result is also affected by Formatting Style > Line Breaks and Wrapping > Preserve Existing Formatting > Break line in single embedded statement, and Break line in a block with a single statement.