Bug Report T867822
Visible to All Users

Code Cleanup produces uncompilable code

created 5 years ago (modified 5 years ago)

Sometimes CodeRush does format code in a way that makes it no longer compile. The latest example is the following:

return sign + " " + $"{payment.Amount.ToString("C2", CultureHelper.CurrentCulture)}";

To:

return $"{sign} {payment.Amount.ToString(string.Empty;

Comments (1)
DevExpress Support Team 5 years ago

    Hello,

    Thank you for the sample code. I can reproduce this issue locally. Please give us some time to research it. We will get back to you.

    Answers approved by DevExpress Support

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

      Other Answers

      created 5 years ago

      Thanks for the feedback Alex.

      I have another example, which is a bit strange. I have a razor component in a Blazor WASM Project with a list of usings:

      C#
      using Localization; using Microsoft.AspNetCore.Components; using System.Threading.Tasks; using Toolbelt.Blazor.I18nText;

      When I now run the cleanup on the project, the first namespace is replaced by:

      C#
      using ApplySupportTool.Client.i18ntext.types;

      This namespaces doesn't exist in that form with the same result as above that the file is no longer able to compile.
      The file in question is from this library: https://github.com/jsakamoto/Toolbelt.Blazor.I18nText
      The namespace is:

      C#
      namespace ApplySupportTool.Client.i18ntext.@types

      And you can configure it with this setting in the csproj:

      C#
      <I18nTextNamespace>Localization</I18nTextNamespace>

      So I assume that the dynamic nature is the issue. But the very strange thing is, that the cleanup works correctly when executed in the open file. So it only occurs when you execute it over the whole project.

        Comments (2)
        DevExpress Support Team 5 years ago

          Hello,

          I've created a separate ticket on your behalf (T868004: Code cleanup uses wrong namespace in a blazor component). It has been placed in our processing queue and will be answered shortly.

            Alright, thanks for the feedback.

            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.