【问题标题】:changing App_Start to AppStart将 App_Start 更改为 AppStart
【发布时间】:2012-11-27 21:13:23
【问题描述】:

我已经设置了一个新的 MVC 4 Web 应用程序。我目前正在对项目运行源代码分析并收到以下错误:

CA1707  Identifiers should not contain underscores

这是因为命名空间“App_Start”由于 App_Start 文件夹名称所致。将文件夹重命名为“AppStart”是否有任何问题?这意味着我的所有规则都通过了。

【问题讨论】:

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


    【解决方案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")]
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-16
    • 2013-06-13
    • 2019-10-19
    • 2010-12-30
    相关资源
    最近更新 更多