Bug Report T675126
Visible to All Users

Formatting - The "Chained Method Calls" formatting option works incorrectly

created 6 years ago

Hello,

I have this code :

C#
public int? GetId(string cnk, ArticleType articleType)
C#
{ DomainObjects.Article article = this.articleDal .ReadByCnk(cnk) .SingleOrDefault(x => x.ArticleType == articleType.ToString()); if (article != null) return article.Id; return null; }

When I format I get this mess :

C#
public int? GetId(string cnk, ArticleType articleType) { DomainObjects.Article article = this.articleDal .ReadByCnk(cnk) .SingleOrDefault(x => x.ArticleType == articleType.ToString()); if(article != null) return article.Id; return null; }
Comments (3)
DevExpress Support Team 6 years ago

    Hi Christian,

    Thank you for providing the settings and code snippets.

    I have reproduced the problem, we will try to fix it shortly. As a workaround, you can temporary disable two formatting options to avoid unexpected code formatting:

    1. CodeRush->Options->Editor->C#->Formatting->Wrapping->Chained Method Calls: disable the item check box
    2. CodeRush->Options->Editor->C#->Formatting->Wrapping->Lambda Expression: disable the item check box

    Also, could you please provide us with formatted code snippets which you would like to have after applying CodeRush formatting?
    Probably, we can help you configure your CodeRush formatting options more precisely, for expected result code?

    CI CI
    Christian Ista 6 years ago
      C#
      DomainObjects.Article article = this.articleDal .ReadByCnk(cnk) .SingleOrDefault(x => x.ArticleType == articleType.ToString());

      but the the expression body is set to have something like this :

      C#
      public string MyMethod() => "bla bla"
      DevExpress Support Team 6 years ago

        Christian, you are right; CodeRush has different settings for expression bodies and lambda expressions.
        In my previous message I suggested disabling the "Chained Method Calls" and "Lambda Expression" options only as a temporary workaround.
        For now, we have fixed the problem and prepared a special build with the fix for you.
        Could you please enable "Chained Method Calls" and "Lambda Expression", install the build with a fix, try to reproduce the problem and notify as of your results?

        Note: Christian, I amn't sure what result you want to have after formatting. Could you take the settings from the screenshot into account? Maybe it's exactly what you want to have as a result.

        Answers approved by DevExpress Support

        created 6 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.