Bug Report T609156
Visible to All Users

Formatting - Indentation taking into account nested levels

created 7 years ago

[DevExpress Support Team: CLONED FROM T609122: Object Initialization Formatting indentation rules not followed on subsequent format of document]

A missing thing I haven't been able to figure out how to handle is nesting of indentation rules. I can't find an option to specify that I want indentation by declaration based with respect to nesting level. So if I have a method call that has a nested object initializer, for instance, indentation for the nested items all end up being reset to the original declaration's level when indenting by declaration (as does nested Call Chaining).

Show previous comments (1)

    What I'd like:

    C#
    myObject.Initialize(new Request() { Property1 = mySimple, Name = "New", Property2 = activeUser.Id, PersistChanges = true }); myObject.Initialize(new Request() { Property1 = MoreComplex(new ComplexThinger() { ComplexProperty1 = thingy, ComplexProperty2 = thingy2, }, Name = "New", Property2 = activeUser.Id, PersistChanges = true }); var states = GetWorksheetStates(request) .Select(ws => { var worksheet = CreateWorksheetInstance(); worksheet.Initialize(new CreateWorksheetRequest() { CopyFromInvoiceId = ws.InvoiceId, Name = "New", PersistChanges = true, OwnerEmployeeId = _activeUser.EmployeeId, }); return worksheet; }) .ToArray();

    What I can get:

    C#
    myObject.Initialize(new Request() { Property1 = mySimple, Name = "New", Property2 = activeUser.Id, PersistChanges = true }); myObject.Initialize(new Request() { Property1 = MoreComplex(new ComplexThinger() { ComplexProperty1 = thingy, ComplexProperty2 = thingy2, }, Name = "New", Property2 = activeUser.Id, PersistChanges = true }); var states = GetWorksheetStates(request) .Select(ws => { var worksheet = CreateWorksheetInstance(); worksheet.Initialize(new CreateWorksheetRequest() { CopyFromInvoiceId = ws.InvoiceId, Name = "New", PersistChanges = true, OwnerEmployeeId = _invoiceProvider.ActiveUser.EmployeeId, }); return worksheet; }) .ToArray();

    It looks like the formatting for the Object Initialization falls back to Parameter formatting rules. It appears that nesting is working in some cases and not others because when I built this sample it wasn't falling back to the statement level, whereas when I tried something earlier all the braces had reset back to level 1 indent no matter how deeply nested. I'll see if I can figure out what I had to get that scenario. I'm using this formatter exclusively now, so I should be able to track down issues more quickly.

    DevExpress Support Team 7 years ago

      Hello Jason,

      Thank you for providing the code samples.
      Now I understand the behavior you want and I agree that we should support it.
      We need some additional time to research how we can do that, so we will notify you when we make any progress.

      DevExpress Support Team 7 years ago

        Hi Jason,
        I would like to inform you that in the latest CodeRush version (available at Visual Studio Market Place) you can adjust formatting options to format code exactly as you want.

        I have attached a screencast that illustrates how to do this.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.