问题的Global.asax.cs文件了StyleCop规则SA1649 [英] Issue with Global.asax.cs file and StyleCop rule SA1649

查看:145
本文介绍了问题的Global.asax.cs文件了StyleCop规则SA1649的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在工作中的一个项目,我们期待从4.3.3版本升级我们的了StyleCop 4.5

Currently I'm working on a project at work and we're looking at upgrading our StyleCop from version 4.3.3 to 4.5

在所有的乐趣,我们已经遇到规则SA1649 - FileHeaderFileNameDocumentationMustMatchTypeName,这是所有好的,这一点,但造成问题的Global.asax.cs文件,在该文件

During the fun of all that, we've come across rule SA1649 - "FileHeaderFileNameDocumentationMustMatchTypeName" which is all nice and that, but causes issues with Global.asax.cs files, in that the file

// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Global.asax.cs" company="COMPANY">
//   Copyright (c) COMPANY. All rights are reserved.....
// </copyright>
// <summary>
//   Starting point for back office website.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Foo.Web
{
    /// <summary>
    /// Starting point for back office website.
    /// </summary>
    public class MvcApplication : HttpApplication
    {
        ....
    }
}

时被抱怨因为文件名'的Global.asax.cs和阶级MvcApplication不匹配。我们试图把苏preSS名单的Global.asax.cs在sylecop设置,但这似乎并没有工作。 (目前,我们的解决方法是完全禁用规则,但我们不希望保留的情况下,我们只希望例外的Global.asax.cs文件。)

Is being complained about because the file name 'Global.asax.cs' and the class 'MvcApplication' don't match. We've tried to put a supress list for 'Global.asax.cs' in the sylecop settings but this didn't seem to work. (Currently our work around is to disable the rule entirely but we don't want to keep that as the case, we only want the exception for Global.asax.cs files.)

推荐答案

发现用一点时间和操纵原始的工具生成的文件。

Found it out with a bit of time and manipulation of the original tool generated file.

<StyleCopSettings Version="105">
  <Analyzers>
  ... Removed for brevity ...
  </Analyzers>
  <SourceFileList>
        <SourceFile>Global.asax.cs</SourceFile>
        <Settings>
            <Analyzers>
                <Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
                    <Rules>
                        <Rule Name="FileHeaderFileNameDocumentationMustMatchTypeName">
                          <RuleSettings>
                            <BooleanProperty Name="Enabled">False</BooleanProperty>
                          </RuleSettings>
                        </Rule>
                    </Rules>
                </Analyzer>
            </Analyzers>
        </Settings>
    </SourceFileList>
</StyleCopSettings>

希望这有助于从别人这个问题。

Hope this helps out anyone else with this issue.

这篇关于问题的Global.asax.cs文件了StyleCop规则SA1649的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆