4 Replies Last post: Feb 9, 2010 10:23 PM by Andrew Koryavchenko  
Greg Law Novice 157 posts since
May 2, 2005
Currently Being Moderated

Feb 19, 2009 11:41 PM

Object initializer format

Does anyone know the settings to use so that object initializers are left aligned with the declaration, like this?

Blah blah = new Blah
{
    Foo = foo,
    Bar = bar
};


I've experimented with the various options and the closest I can get is the braces aligned on the constructor:

Blah blah = new Blah
               {
                    Foo = foo,
                    Bar = bar,
               }

 
 

Guest
Currently Being Moderated
Feb 20, 2009 1:41 PM in response to: Greg Law
Re: Object initializer format

Options-> ... ->Formatting Style -> Other -> Indent array, object and collection initializer block

--
Sergey V. Coox
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Jetbrains" <lothan@newsguy.com> wrote in message news:gnkel1$tsj$1@is.intellij.net...
Does anyone know the settings to use so that object initializers are left aligned with the declaration, like this?

Blah blah = new Blah
{
    Foo = foo,
    Bar = bar
};


I've experimented with the various options and the closest I can get is the braces aligned on the constructor:

Blah blah = new Blah
               {
                    Foo = foo,
                    Bar = bar,
               }

 
 

andre carlucci Newbie 3 posts since
Feb 5, 2010
Currently Being Moderated
Feb 9, 2010 9:25 PM in response to: Greg Law
Re: Object initializer format

Whas this bug fixed?

 

I really would like to have my constructor like:

 

StudentName student = new StudentName {
     FirstName = "John",
     LastName = "Smith",
     ID = 116
};

Andrew Koryavchenko Newbie 7 posts since
Mar 30, 2006
Currently Being Moderated
Feb 9, 2010 10:23 PM in response to: andre carlucci
Re: Object initializer format

1) To format as in first topic message, go to Braces Layout -> Braces Layout -> Array and object initializer and set it to "At next line (BSD style)".

2) To format as in your sample, set the same parameter to "At end of line (K&R style)" and uncheck Others -> Align Multiline Constructs -> Array, object and collection initializer.

More Like This

  • Retrieving data ...