SA1208 with Visual Studio 2012 and "Organize Usings"

Jan 3, 2013 at 3:15 PM

The "Sort" or "Remove and Sort" options of Organize Usings do not put System.* refrences at the top any longer.  It sorts everything alphabetically.

If I have this perfectly StyleCop clean file, and then do a "Remove and Sort", it will put ClassLibrary1.Child above System.Diagnostics, which will then trigger a SA1208.  Visual Studio 2010 keeps all the System.* references sorted first.

I checked a couple of different machines to make sure - it did it on both machines.  It looks like either VS2012 has a bug or SA1208 is an obsolete rule.  I'll create a bug on Connect.Microsoft.Com and see if they think the Organize Usings behavior change is a bug or by design.

//---------------------------------------------------------------------------

// <copyright file="Class1.cs" company="Tom Ballard">

// Copyright (c) Tom Ballard 2013. All rights reserved.</copyright>

//---------------------------------------------------------------------------

namespace ClassLibrary1 { using System.Diagnostics; using ClassLibrary1.Child;
    /// 
    /// Class 1.
    /// 
    public class Class1
    {
        /// 
        /// The instance.
        /// 
        private Class2 instance;

        /// 
        /// Initializes a new instance of the  class.
        /// 
        public Class1()
        {
            this.instance = null;
            Debug.WriteLine(this.instance);
        }
    }
}
Jan 3, 2013 at 3:25 PM

Bug created to see if feature change is By Design:

https://connect.microsoft.com/VisualStudio/feedback/details/775702/organize-usings-no-longer-puts-system-references-first-bug-or-feature-change

Jan 6, 2013 at 2:03 AM

As you can see on the connect issue you can re-enable the Sort System.* usings to the top in Tools | Options.  I didn't know that!