rider

Rider automatically formats List initializer to not contain spaces causing compilation errors


When I write following code in Rider:

new List<Guid> { Guid.NewGuid() } and I type ; at the end, Rider automatically formats this into new List<Guid> {Guid.NewGuid()};

Note that spaces were removed before and after both braces.

Compiler doesn't like it and reports [SA1012] Opening brace should be followed by a space. and [SA1013] Closing brace should be preceded by a space.

How can I turn off such behavior in Rider?


Solution

  • I don't know which version of Rider you're using but in 2022.2.3 I had to enable the following property under File | Settings | Editor | Code Style | C#: enter image description here

    I hope it helps you as well!