Formatting Object Initializers with K&R Braces

Can we play get ReSharper to respect formatting options for K&R braces and object initializers?  As it is, ReSharper 6 creates so much indenting that code is unreadable:

 
var viewModel = new ClientGridModel {
                                        GridModel = new GridModel {
                                                                        AjaxDataUrl =
                                                                            this.Url.Action(
                                                                                "ActiveClientsGridModel"),
                                                                        Caption = "Active Clients",
                                                                        ColumnSettings = {
                                                                                            new ColumnSetting {
                                                                                                                    Name = "Code",
                                                                                                                    SortIndex =
                                                                                                                        "Code",
                                                                                                                    Formatter =
                                                                                                                        Formatter
                                                                                                                        .ShowLink,
                                                                                                                    FormatOptions
                                                                                                                        =
                                                                                                                        new FormatOptions {
                                                                                                                                            BaseLinkUrl
                                                                                                                                                =
                                                                                                                                                this
                                                                                                                                                .
                                                                                                                                                Url
                                                                                                                                                .
                                                                                                                                                Action
                                                                                                                                                ("Detail")
                                                                                                                                        }
                                                                                                                },
                                                                                            new ColumnSetting {
                                                                                                                    Name =
                                                                                                                        "FullName",
                                                                                                                    SortIndex =
                                                                                                                        "FullName",
                                                                                                                    Width = 830
                                                                                                                }
                                                                                        },
                                                                        ShowAddButton = false,
                                                                        ShowEditButton = false,
                                                                        ShowDeleteButton = false
                                                                    }
                                    };

It should be formatted like this instead:



var viewModel = new ClientGridModel {
    GridModel = new GridModel {
        AjaxDataUrl = this.Url.Action("ActiveClientsGridModel"),
        Caption = "Active Clients",
        ColumnSettings = {
            new ColumnSetting {
                Name = "Code",
                SortIndex = "Code",
                Formatter = Formatter.ShowLink,
                FormatOptions = new FormatOptions {
                    BaseLinkUrl = this.Url.Action("Detail")
                }
            },
            new ColumnSetting {
                Name = "FullName",
                SortIndex = "FullName",
                Width = 830
            }
        },
        ShowAddButton = false,
        ShowEditButton = false,
        ShowDeleteButton = false
    }
};

4 comments
Comment actions Permalink

Hello Kevin
     Have you tried turning off 'Indent object/array/collection initializer' option under ReSharper | Options | Code Editing | C# | Formatting Style | Other | Other? Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

That works fine if you're using BSD braces, but with K&R style it has no effect.  You can even see this in the preview window as you toggle that option on / off.  The code block remains indented and unchanged.

For all that ReSharper does so very well, I really feel like us K&R guys are second-class citizens.

0
Comment actions Permalink

Hello Kevin
     I'm sorry, this is actually a known problem and you're welcome to vote for the following bug-report in our tracker: http://youtrack.jetbrains.com/issue/RSRP-187374. Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Thanks for having a look into this.  It's a shame this has been reported for nearly two years with no resolution yet.

Tell Evgeny I'll buy him a pizza and some kittens if he can knock it out for the next minor release. :D

0

Please sign in to leave a comment.