How to put braces for object initializer on next line?
Hello
How can I make sure that ReSharper's Code Cleanup puts the braces of object
initializers on the next line like this:
var plant = new Plant
{
Name = "BCN",
Description = "Barcelona plant"
};
I tried playing with the options but i can't seem to be able to do this?
Cheers
Gabriel Lozano-Moran
Please sign in to leave a comment.
Hello Gabriel Lozano-Moran,
Do you mean setting found here: Options / Languages / C# / Formatting Style
/ Other, Other subsection, "Indent array, object and collection initializer
block"?
Sincerely,
Ilya Ryzhenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
G> Hello
G>
G> How can I make sure that ReSharper's Code Cleanup puts the braces of
G> object initializers on the next line like this:
G>
G> var plant = new Plant
G> {
G> Name = "BCN",
G> Description = "Barcelona plant"
G> };
G> I tried playing with the options but i can't seem to be able to do
G> this?
G>
G> Cheers
G>
G> Gabriel Lozano-Moran
G>
Hello Ilya
It still does not work correctly. I have enabled the option "Wrap object and
collection initializer" otherwise it would be on a single line but this is
what I get:
var p = new Dimension {
Name = "A"
};
I have also tried different settings for the option in the Braces Layout for
object and collection initializers but that does not make any difference. I
want it to be like this:
var p = new Dimension
{
Name = "A"
};
Cheers
Gabriel Lozano-Moran
"Ilya Ryzhenkov" <orangy@jetbrains.com> wrote in message
news:76a2bd0b15ad698caa36559bc9e84@news.intellij.net...
>
>
>
>
I can confirm the issue. Object/collection initializers are always indented, no matter whether the option for this has been enabled or disabled. BTW: if you change the option ("Indent array, object and colleciton initializer") in the options, the preview does not change. It always shows the indented version.
Regards,
Andre
Edit: it seems that this is not quite the same issue, sorry.
I have:
List list = new List { 1, 2, 3, 3, 4, 5 }; I want: List list = new List { 1, 2, 3, 3, 4, 5 }; Edit 2: @Original poster: If I set the brace layout for "Array and object initializer" to "At next line (BSD style)" and disable "Indent array, object and colleciton initializer" I get List list = new List]]>
{
1,
2,
3,
3,
4,
5
};
Which is what you want, isn't it?
Edited by: Andre Loker on Jun 28, 2008 12:23 PM
Hmmm... I cannot reproduce this problem.
Please could you uncheck that option ("Indent array, object and colleciton
initializer") and try to reformat sample code.
If the code is still indented, then please could you copy entire code format
options (they could be found at
c:\document ans settings\\Application Data\Jetbrains\.....) and post them here for analysis? -- Eugene Pasynkov Developer JetBrains, Inc http://www.jetbrains.com "Develop with pleasure!" "Andre Loker" wrote in message news:9823289.57111214641276706.JavaMail.jive@app4.labs.intellij.net... >I can confirm the issue. Object/collection initializers are always >indented, no matter whether the option for this has been enabled or >disabled. BTW: if you change the option ("Indent array, object and >colleciton initializer") in the options, the preview does not change. It >always shows the indented version. >]]>
Hello Eugene
The "problem" is caused when I the option "Place simple array, object and
collection on single line" in "Line Breaks and Wrapping" is checked.
Cheers
Gabriel Lozano-Moran
"Eugene Pasynkov (JetBrains)" <Eugene.Pasynkov@jetbrains.com> wrote in
message news:g4a4me$g38$1@is.intellij.net...
>
>>I can confirm the issue. Object/collection initializers are always
>>indented, no matter whether the option for this has been enabled or
>>disabled. BTW: if you change the option ("Indent array, object and
>>colleciton initializer") in the options, the preview does not change. It
>>always shows the indented version.
>>
>> Regards,
>> ANdre
>