Bug Report T959749
Visible to All Users

Code Cleanup - The “Sort Namespace References” cleanup rule should sort namespace aliases alphabetically

created 4 years ago

Hi

Namespaces which contain using-alias directives, are sorted by the namespace being aliased rather than the alias name itself. This results is violation of SA1211 StyleCopAnalyzer rule.

This is a duplicate of T403571 that was fixed in version 16.1.7, yet it is still present in 20.2.6.

Thanks,
Zvonko

Show previous comments (4)
DevExpress Support Team 4 years ago

    Thank you for the info, but, unfortunately, it did not help. I still can't reproduce the problem on my side.
    I attached an archive with a sample solution. Would you please check whether the issue is reproducible on your side in this solution. Just open it, navigate to
    …\WpfApp2\WpfApp2\Class1.cs, make some changes, and save the file. If the issue is not reproducible in this project, it would be great if you can share with us a small project where it is reproducible on your side.
    Also, please share with us your CodeRush logs. You can find them in the CodeRush->Support->CodeRush logs… folder.

    ZB ZB
    Zvonko Boštjančič 4 years ago

      Hi

      I took your project and duplicated the issue. It occurs if you combine aliases with System and non-System namespaces. Here is the modified code of Class1.cs which reproduces the issue:

      C#
      using System.Collections.Generic; using System.Linq; using C = System.Diagnostics.BooleanSwitch; using D = System.AccessViolationException; using A = Serilog.Core.Constants; using B = Serilog.Formatting.Display.OutputProperties; namespace WpfApp2 { public class Class1 { #region Methods - private private void m() { var t = typeof(A); var t2 = typeof(B); var t3 = typeof(C); var t4 = typeof(D); } #endregion } }

      Thanks,
      Zvonko

      AE AE
      Alex Eg (DevExpress) 4 years ago

        Hi Zvonko,
        Thank you for the code snippet. Now, I can see the issue too. Our sorting engine applies the 'Place System references first' logic to both using statements and alias declarations. We will change the existing behavior so that it will be in accordance with the SA1211 rule.

        Answers approved by DevExpress Support

        created 4 years ago

        We have addressed the issue described in this ticket and will include a fix in our next maintenance update. Should you need to apply our fix prior to official release, you can request a hotfix here.

        Note: Hotfixes may be unavailable for betas/updates set for release within a week.

          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.