-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SA1217 asks for incorrect sorting with System usings #2163
Comments
@RobinHood70 Do you have an example so we could add unit test for this and try to fix it? |
In one of my projects, I have the following mess of usings:
If you do a Remove and Sort Usings, this is the order they appear in. However, SA1217 triggers in the System.Net.HttpStatusCode because it's not in alphabetical order. This behaviour differs from the regular usings rule, which allows System usings to be sorted first (as they are above). |
Looks like this is still up for someone to update. I've also noticed that this rule (SA1217) conflicts with SA1208 in some cases. Visual Studio has a setting to do System first or alphabetical. This rule can also be realized in .editorconfig with the Personally, I find myself using the Remove and Sort Usings (CTRL+R, CTRL+G) shortcut a lot now, but I always end up having to manually fix the System Firstdotnet_sort_system_directives_first = true using System;
using System.IO;
using Microsoft.Security;
using static System.Math;
using static Microsoft.Security.IdentityType; All Alphabeticdotnet_sort_system_directives_first = false using Microsoft.Security;
using System;
using System.IO;
using static Microsoft.Security.IdentityType;
using static System.Math; |
Ran into the same issue as well. Given VS 2017 can automatically do code clean up upon save (sort using), this will cause more issues. The fix should be prioritized. |
This was discussed in pull #786, but it doesn't seem to have been addressed.
If you ask VS to sort usings (Edit, Intellisense, Organize Usings), assuming you have the option set in your preferences, it will sort them with "using static System.*" on top of other "using static"s. StyleCop, however, is asking for that to be alphabetical.
The text was updated successfully, but these errors were encountered: