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
Hello,
I have checked the fix from T403571 - see the attached screencast. It works on my side.
Would you share with me sample code where the issue is reproducible on your side. Also please export your CodeRush settings and paste them here.
I will try to reproduce the issue with your settings.
Hi
The settings are attached.
Please note:
Thanks,
Zvonko
Thank you for the settings and additional information. However, I still cannot reproduce the issue. I used different test projects, but all works as expected - see the attached screencast.
You shared your solution settings, but the
%AppData%…\Roaming\CodeRush\Settings
folder also contains settings. Would you please zip and share this folder with me? Also, please open the CodeRush->Options…->Editor->All Languages->Namespace References options page and check whether the Sort namespace references option is set to Alphabetically.
We are looking forward to hearing from you.
Hi
Please find the required settings folder attached in a ZIP file. It should not contain any notable settings.
Also the screenshot of namespace settings is attached.
Zvonko
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.
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:
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
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.