Every time I type an object initializer as a parameter, like this:
SomeFunc(new { Id = id })
and type the semicolon afterwards, ReSharper formats what I just typed, as configured. However, I cannot find an option in ReSharper to make it not turn my code into this:
SomeFunc(new {
Id = id
});
I did confirm it actually is ReSharper doing the formatting.
If you want to keep ReSharper from formatting your object initializers (so you can decide how you want to format them yourself), I think a combination of these settings will do the job.
Keep existing line breaks : [Checked]
Place simple array, object and collection on single line : [Checked]
Wrap object and collection initializer : 'Simple wrap'
Wrap long lines : [Unchecked]
Of course, these settings might not fit everyone's situation, but I'm sure you can adapt them to your needs.
It looks like you need to set Wrap object and collection initializer option to Chop if long in Code Editing -> C# -> Formatting Style -> Line Breaks and Wrapping section.
来源:https://stackoverflow.com/questions/12428402/is-there-an-option-in-resharper-to-not-put-an-object-initializer-on-multiple-lin