Search code examples
resharperstylecop

ReSharper conflict with Stylecop over using directive order SA1210 SA1211


StyleCop 4.7 rules SA1210 and SA1211 require the using directives to be sorted alphabetically. I've run into a conflict between StyleCop's rule and Resharper's applied sort: case-sensitivity.

Resharper 8.2 performs a case insensitive sort of the directives, while StyleCop's rule requires a case sensitive sort. So, I ran into an odd case with the following directives because of poor namespace choices (not my own):

using AB.Common;
using ab.Utility;

Pressing ctrl-E-F sorts common first; but the rule requires utility to be first because of the difference between AB and ab. I've gotten past it by removing the StyleCop rule and just letting Resharper's reformat reign. Of course the namespace itself should be refactored, but I don't have that option.

Any other opinions about how to deal with this other than turning off the StyleCop rule?


Solution

  • Turning the StyleCop rule off seems like the best answer, there is no need for both ReSharper and StyleCop to check the ordering.

    But if you want to have them both on, you could alias the namespaces to something like:

    using Common=AB.Common;
    using Utility=ab.Utility;