dotnet / codeformatter

Tool that uses Roslyn to automatically rewrite the source to follow our coding styles
MIT License
1.24k stars 244 forks source link

Namespaces are no longer moved to top of file #168

Closed davkean closed 9 years ago

davkean commented 9 years ago

It appears in recent builds namespaces are no longer moved, whereas, https://github.com/dotnet/codeformatter/releases/tag/v1.0.0-alpha5 did move them:

Have this:

namespace Microsoft.VisualStudio.ProjectSystem
{
    using System;

    [...]
}

Expected:

using System;

namespace Microsoft.VisualStudio.ProjectSystem
{
    [...]
}

Actual:

namespace Microsoft.VisualStudio.ProjectSystem
{
    using System;    

    [...]
}
jaredpar commented 9 years ago

We deliberately decided to disable this rule by default because it's simply unsafe to run in it's current form. Moving a using around has a subtle but significant impact on name lookup in the compiler. It's possible for this to create compilation errors or even silent redirections to new types. That goes against the operating principles of code formatter and hence it was disabled by default.