6

Is there a way to tell ReSharper to allow same-line brackets for empty methods and constructors?

For example:

MyConstructor(int x) : BaseConstructor(x) { }

protected virtual void Foo() { }

Should not be converted to:

MyConstructor(int x) : BaseConstructor(x)
{
}

protected virtual void Foo()
{
}

In the first case, I don't need a method body, I simply supply the parent constructor with its arguments.

In the second case, I define an "optional abstract" method by making it virtual that therefore doesn't require a body.

Lazlo
  • 8,518
  • 14
  • 77
  • 116

1 Answers1

11

Go to ReSharper -> Options... -> Code Editing -> C# -> Formatting Style -> Braces Layout.
Find Empty braces formatting and set it to Together on the same line.

Here's a screenshot that shows you how to find the setting.

enter image description here

Dmytro Shevchenko
  • 33,431
  • 6
  • 51
  • 67
  • 1
    For some reason, I managed to spend an hour in the settings and still missed it. Thanks a bunch! – Lazlo Oct 02 '15 at 16:48