使用错误顺序排序的指令

问题描述:

我在Visual Studio 2012中使用了Power Commands扩展。我选中了删除和排序保存选项。问题是,System.Xxx指令正在最后的排序,这是造成风格分析错误:使用错误顺序排序的指令

SA1208: System using directives must be placed before all other using directives.

之前保存:

using System; 
using System.Diagnostics.CodeAnalysis; 
using Foo; 

后保存:

using Foo; 
using System; 
using System.Diagnostics.CodeAnalysis; 

这与VS 2010正常工作(System.Xxx第一次)。任何人都知道如何解决这个问题?

注意:即使它没有导致SA错误,我仍然首选系统指令。

+0

有PowerCommands的VS2012版本吗?这可能是一个需要注意的问题,因此值得报告。 –

+0

重新安装Powercommands 2010即使其安装也会将其应用于VS2012,但AFAIK没有2012版本的powercommands,对于VS2013,它现在似乎是pwoer工具的一部分。 – CloudyMarble

+0

在这里查看更多信息:http://*.com/questions/12156921/powercommands-for-visual-studio-2012 – CloudyMarble

转到“快速启动”(Ctrl + Q)并键入“使用”,然后按Enter

然后更改以下设置:

Using Sorting option

这是一个恼人的默认设置,我不知道为什么微软选择了,它违背了我所见过的所有以前的标准。

编辑: 感谢Oskar我们有一个reason

The reason for the change in default behavior is due to the fact that Windows App Store applications prefer to have 'Windows.' at the top of the file rather than 'System.'

+0

完美。谢谢! –

+7

我发现了一个答案,为什么微软会改变默认行为:“造成默认行为改变的原因是因为Windows App Store应用程序喜欢在文件顶部有'Windows。*'而不是'System。*'“(https://connect.microsoft.com/VisualStudio/feedback/details/775702/organize-usings-no-longer-puts-system-references-first-bug-or-feature-change) – Oskar

+2

@Oskar,他们解决了这个问题,而不是他们笨拙的... – MarioDS