How to Prevent ReSharper from Wrapping One-Line Statements?
Update for newer versions of ReSharper
(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:
- Open the menu Resharper -> Options
- Go to Code Editing -> C# -> Formatting Style -> Line Breaks and Wrapping
- Change to option Break line in single embedded statement to Put on a single line or Do not change
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