How to stop ReSharper removing spaces in object initializer

ε祈祈猫儿з 提交于 2019-11-30 07:51:49

For R# 7, I can get this to vary by going to1

ReSharper | Options | Code Editing | C# | Formatting Style | Spaces

and toggling

Other | Within single-line initializer braces

the example for which is

int[] x = new int[] {0, 1, 2};

versus

int[] x = new int[] { 0, 1, 2 };

Although the example is of array initialization, it also appears to control object initialization.


1In R# 5, "Code Editing" was "Languages".

On Resharper 2019.1

ReSharper | Options | Code Editing | C# | Formatting Style | Spaces

And adjust this to your liking:

Preserve Existing Formatting | Extra spaces inside

Also, be sure to use this command shortcut:

ReSharper.ReSharper_ReformatCode, not this Edit.FormatDocument

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!