asp.net-mvc - 将 App_Start 更改为 AppStart

标签 asp.net-mvc asp.net-mvc-4 fxcop stylecop

我已经设置了一个新的 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/

相关文章:

jquery - MVC 4 WebGrid 和 Jquery 会产生两个错误。 JQuery 未定义,ajax 模型更改后出现排序错误

asp.net - 如何在powershell中执行具有[[FromForm]]参数的API PUT方法

c# - 在 Razor 组件 (Blazor) 中渲染 Razor 局部 View

c# - 如何获取 ASP.NET 应用程序路径?

css - MVC 4 在验证不成功后将自定义类添加到 html

c# mvc4 Html.DropDownListFor调用 Controller

visual-studio - 在源代码中排除代码分析规则

fxcop - 如何让 FxCop 规则 CA1726 忽略首选术语?

c# - 基于不适用于 System.Web.UI.Control 对象的 CA2000 "Dispose Objects Before Losing Scope"创建自定义 FXCop 规则

c# - mysql-c# 连接未完成