2012-11-27 28 views
4

我已經設置了一個新的MVC 4 Web應用程序。我目前正在運行鍼對項目的源代碼anaylsis並得到以下錯誤:將App_Start更改爲AppStart

CA1707 Identifiers should not contain underscores 

這樣做的原因是因爲命名空間「App_Start」由於App_Start文件夾名稱。將文件夾重命名爲「AppStart」有什麼問題嗎?這將意味着我所有的規則都通過了。

回答

1

我會禁止該特定命名空間的規則,而不是重命名它。在您的Web項目根目錄創建一個GlobalSuppressions.cs文件,並添加以下內容:

using System.Diagnostics.CodeAnalysis; 

[assembly: SuppressMessage("Microsoft.Naming", 
          "CA1707:IdentifiersShouldNotContainUnderscores", 
          Scope = "namespace", 
          Target = "<namespace>.App_Start", 
          Justification = "This is an infrastructure namespace")] 
+3

我更喜歡將其重命名爲AppStart。愚蠢的微軟工程師。 –

+0

似乎'App_Start'約定主要由'NuGet'使用。看到這個:http://weblogs.asp.net/pjohnson/mvc-4-and-the-app-start-folder –