Object Initializer Code Style

Thread is closed for posting
2 posts, 0 answers
  1. Ashot
    Ashot avatar
    1 posts
    Member since:
    Mar 2014

    Posted 21 Mar 2014 Link to this post

    I want JustCode formats object initializers in my code like below:
    var endpoint = new Endpoint { Address = address,
                              Port = port };

    ​How I can set up code style options for this?
  2. Rumen
    Rumen avatar
    6 posts

    Posted 27 Mar 2014 Link to this post


    Unfortunately your formatting is not supported by JustCode.
    ​Our formatter will not let the opening brace to be on the first line of a multiline block and the closing brace to be on the last line of a multiline block.

    However, I would like to suggest a formatting that JustCode supports and looks closest to your request:

    Endpoint endpoint = new Endpoint {
        Address = address,
        Port = port

    You can achieve this result with the following option:
    Code Style -> C# -> Brace Positions -> Array, object and collection initializer = Same Line

    We design our formatting settings according to the most widely used conventions.
    The community decides which are the most widely used conventions.
    Therefore, you can make us implement your feature by suggesting it in our feedback portal - http://feedback.telerik.com/Project/100/Feedback/List/All%20Feedback


    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

Back to Top