Question about formatting collection and object initializers

Give this code as an example:

var distributors = new List<Distributor>
{
    new Distributor {Name = "KBC"},
    new Distributor {Name = "Dexia"},
    new Distributor {Name = "Fortis"},
};

I have tried all kinds of settings for the line breaks, wrapping and so on to be able to format the code as above during a code cleanup but I am not able to find the correct settings. What I want basically is to be able to put simple object initializers in a single line but when I do this, this is the result:

var distributors = new List<Distributor> {new Distributor {Name = "KBC"}, new Distributor {Name = "Dexia"}, new Distributor {Name = "Fortis"},};

This off course depends on what your interpretation of a simple object/collection initializer is? With "Chop Always" enabled this is the result:

var distributors = new List<Distributor> {
    new Distributor {
        Name = "KBC"
    },
    new Distributor {
        Name = "Dexia"
    },
    new Distributor {
        Name = "Fortis"
    },
};

Any ideas?

2 comments

+1

"Gabriel Lozano-Moran" <gabriel.lozanomoran@fluxys.net> wrote in message
news:29307369.74181255011747922.JavaMail.clearspace@app8.labs.intellij.net...

Give this code as an example:

>

var distributors = new List<Distributor>
{
new Distributor {Name = "KBC"},
new Distributor {Name = "Dexia"},
new Distributor {Name = "Fortis"},
};

>

I have tried all kinds of settings for the line breaks, wrapping and so on
to be able to format the code as above during a code cleanup but I am not
able to find the correct settings. What I want basically is to be able to
put simple object initializers in a single line but when I do this, this
is the result:

>

var distributors = new List<Distributor> {new Distributor {Name = "KBC"},
new Distributor {Name = "Dexia"}, new Distributor {Name = "Fortis"},};

>

This off course depends on what your interpretation of a simple
object/collection initializer is? With "Chop Always" enabled this is the
result:

>

var distributors = new List<Distributor> {
new Distributor {
Name = "KBC"
},
new Distributor {
Name = "Dexia"
},
new Distributor {
Name = "Fortis"
},
};

>

Any ideas?

>

---
Original message URL:
http://www.jetbrains.net/devnet/message/5246680#5246680


0

Hello Gabriel
     Could you please export your code style settings (through ReSharper > Options > Languages > Common > Code Style Sharing) into an xml file and send it to andrew dot serebryansky at jetbrains dot com?

Andrey Serebryansky

Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"
0

Please sign in to leave a comment.