Bug Report T579515
Visible to All Users

Code CleanUp - CodeRush wraps arguments inside an interpolated string

created 7 years ago

Hi

Having just upgraded to the latest version and cleaned up a large document I got a load of errors, I've tracked the error down to the following line of code:

C#
string sortCodeFormat = $"{(sortCode.Substring(0, 2))}-{(sortCode.Substring(2, 2))}-{(sortCode.Substring(4, 2))}";

As you can see I use the $"xxxx" command to place code within the string rather than use the older string.format() command. However this has caused an issue.

I currently have C#>Formatting>Wrapping > Arguments turned on to wrap the lines if it goes over 120 characters, the above line was wrapped to look like this:

C#
string sortCodeFormat = $"{(sortCode.Substring(0, 2))}-{(sortCode.Substring(2, 2))}-{(sortCode.Substring(4, 2))} ";

Due to the bad formatting of this line, the whole of the documents then threw various errors, took me a while to fine this issue in a c# file with over 7000 lines of code.

I think you need to remove the wrapping of arguments within the string $"" command.

Many thanks
Alan

Show previous comments (4)
AM AM
Alan Middleton 7 years ago

    Excellent, glad you could replicate it - Not sure what the default "order" is of the options, but I think I changed mine quite a bit to put them in a "logical" order (for me anyway). I understand it's important to have them in a certain order, but not sure if you need to put some rules around what needs to be above what, or if you need to add more rules to the code.

    DevExpress Support Team 7 years ago

      Hello Alan,

      Thank you for the clarification.
      We believe that code cleanup rules should work correctly regardless of their order.
      So we are trying to fix this issue even if the "Format Document" cleanup rule is above "Convert to string interpolation".

      AM AM
      Alan Middleton 7 years ago

        Excellent!  :)

        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.