我已经设置了一个新的 MVC 4 Web 应用程序。我当前正在针对该项目运行源代码分析并收到以下错误:
CA1707 Identifiers should not contain underscores
出现这种情况的原因是由于 App_Start 文件夹名称的 namespace “App_Start”所致。将文件夹重命名为“AppStart”是否有任何问题?这将意味着我的所有规则都已通过。
最佳答案
我会抑制该特定命名空间的规则,而不是重命名它。在您的 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")]
关于asp.net-mvc - 将 App_Start 更改为 AppStart,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13593164/