2012-10-03 99 views
57

我在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://stackoverflow.com/questions/12156921/powercommands-for-visual-studio-2012 – CloudyMarble

回答

121

轉到「快速啓動」(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