Search code examples
c#resharperwhitespacevisual-studio-2022

How to prevent Resharper of removing whitespace for new ()


Resharper removes whitespace after runinng Code cleanup. What I mean is:

Person person = new (); // there is a whitespace between `new` and `()`:

However the above code after running Code cleanup becomes without whitespace between new and ():

Person person = new(); // no whitespace between `new` and `()`

Is it possbile to keep whitespace between new and () after running Code cleanup of Resharper. We are using:

  • Visual Studio 2022
  • JetBrains ReSharper 2022.2.3

Solution

  • This is controlled by the Resharper option:

    Code editing > C# > Formatting Style > Spaces > Before other parentheses > 'new' parentheses