Bug Report T609122
Visible to All Users

Formatting - CodeRush reformats code after it is applied for the second time and does not respect formatting options for object initializers

created 7 years ago

Getting so close, and I'm so excited! There are still several bugs and missing features, but it's close enough that I'm willing to deal with it right now and stop using Recrasher's formatter.

When I format my document using my object initializer format settings, the first time I format the document it functions correctly:

C#
var request = new Request() { Id = info.MyId, RateId = voucherInfo.RateId, };

The next time I run the document format, it reformats this section so that it ends up not following the original rules, namely removing the initial indentation:

C#
var request = new Request() { Id = info.MyId, RateId = voucherInfo.RateId, };

This happens whether I have wrapping by Declaration or by Declaration Name.

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).

Indenting by declaration name is typically too deep of an indentation in the case of nesting (but at least right now it's closer to what I want more often than not, so I'll see if I can get used to it).

I could get used to splitting things out more, but I would certainly love to see the Smart Copy / Paste automatically introduce a local variable for me as in CodeRush Classic -- otherwise splitting things out interrupts my flow too much.

Comments (3)
DevExpress Support Team 7 years ago

    Hello Jason,

    Thank you for contacting us and providing the code sample.

    I tried to reproduce the issue with formatting an object initializer, but without success.
    To help us research this issue, please provide additional information:
    - CodeRush settings (they can be obtained here: %AppData%\CodeRush\Settings.xml);
    - CodeRush log files (they can be obtained here: %LocalAppData%\CodeRush\Log);
    - a screencast that illustrates the issue in action (you can capture it using a free Jing tool from TechSmith).

    Regarding the questions about indentation and the Smart Copy / Paste feature, I have created separate tickets: Formatting - Indentation taking into account nested levels and Smart Copy / Paste should automatically introduce a local variable like in CodeRush Classic, which will be answered shortly.

    We are looking forward to your response.

      I don't recall how to turn on the heavy logging for CodeRush, but I've attached the latest log after closing VS, restarting it, making the problem happen, then closing it again.

      I took a screencast of the formatting working properly on pass one, then formatting again right after, which breaks it.

      I have attached both the exported settings and a manual zip of my settings.

      DevExpress Support Team 7 years ago

        Hello Jason,

        Thank you for collecting and providing additional information.
        I managed to reproduce the issue with your settings.
        So we will research it and let you know as soon as we have any results.

        Answers approved by DevExpress Support

        created 7 years ago

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

          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.