What is the best way to prevent ReSharper from wrapping certain lines of code. For example, an if
statement with one condition and a simple body should not be wrapped. ReSharper currently forces this line...
if (item == null) { return null; }
... to break like this:
if (item == null)
{
return null;
}
I don't want to blindly disable this feature necessarily... just make it a bit more intelligent.
(my version is 2021.1)
Since a picture is worth than a thousand words, you probably want to configure it like so. In this way it takes care of constructs such as using
too:
Check the ones that start with Keep existing arrangement [...]
if you want to instruct ReSharper to leave, say, single-line if
s alone if they are already written that way.
Took me longer to figure out than I wanted it to, hopefully it will help someone else.
You can change this in the R# Settings:
Edit: As mentioned by @Alexander it would be more suitable to use the option Break Line in a block with a single statement which I think is available since R# 8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With