精华内容
下载资源
问答
  • 适用于.NET编译器平台的StyleCop分析器 该存储库包含使用.NET Compiler Platform的StyleCop规则的实现。 在可能的情况下,还提供代码修复程序,以简化纠正违规的过程。 使用StyleCop.Analyzers 使用分析器的首选...
  • ReSharper的StyleCop StyleCop分析C#源代码以强制执行一组样式和一致性规则。 StyleCop for ReSharper是ReSharper的扩展,它将在您键入时运行StyleCop分析,在编辑器中内联显示违规并为某些违规提供快速修复。 它...
  • StyleCop vs2017扩展插件

    2019-04-25 09:48:43
    最新StyleCop插件,适用于VS2017,代码格式检查利器。
  • StyleCop for vs 2017 以及所有规则的翻译,并且简单介绍了StyleCop的使用方法。
  • StyleCop.exe

    2020-07-27 08:20:15
    stylecop microsoft 工具
  • StyleCop CLI-开源

    2021-04-17 20:31:56
    该项目已移至GitHub:https://github.com/bbadjari/stylecopcli StyleCop源代码分析器的命令行界面。
  • StyleCop-4.7.55.0最新版

    2017-11-06 16:31:47
    StyleCop-4.7.55.0,最新代码检测工具,适用于java,C#等语言
  • visual studio C#代码审查工具StyleCop-4.7.51.0。StyleCop是微软的一个开源的静态代码分析工具,检查c#代码一致性和编码风格。
  • StyleCop 4.7 StyleCop.dll

    2014-02-25 14:47:18
    “未能从程序集 C:\Program Files (x86)\MSBuild\..\StyleCop 4.7\StyleCop.dll 加载任务“StyleCopTask”。 Could not load file or assembly 'file:///C:\Program Files (x86)\StyleCop 4.7\StyleCop.dll' or one ...
  • StyleCop.rar

    2019-10-09 10:48:07
    VS2017 代码规范检查工具stylecop安装包加简单说明文档
  • .NET代码检查工具StyleCop-4.7.54;包含安装包和中文提示包
  • styleCop

    2019-09-29 08:23:45
    1styleCop安装 安装参考 2和VS集成 要和vs集成一定要在安装时把MSBuild files那个选项选中的,否则安装后是不会和VS集成集成的。 3styleCop使用 User Guide 4在项目中使用stylecop和把警告改为错误 在后缀...

    1styleCop安装

    安装参考

    2和VS集成

    要和vs集成一定要在安装时把MSBuild files那个选项选中的,否则安装后是不会和VS集成集成的。

    3styleCop使用

    User Guide

    4在项目中使用stylecop和把警告改为错误

     

    在后缀为.csproj的文件添加如下一行,就可以使用styleCop主动检测项目了,但默认不符合规则的都是警告,注意需要在安装styleCop时选择与VS集成的那一部分,此部分默认是不安装的,否则这个项目用VS打开就会有问题,会提示不能识别某一节,不能打开。

     

    [csharp]  view plain copy
     
    1. <ImportProject="$(ProgramFiles)\MSBuild\Microsoft\StyleCop\v4.3\Microsoft.StyleCop.targets"/>    

     

    styleCop把检测出来的问题默认设置为警告,如果要改为错误需要使用记事本之类的工具打开项目文件,也就是后缀为.csproj的文件,添加如下代码。请参考如下,


     

    [csharp]  view plain copy
     
    1. <PropertyGroup>    
    2. <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>   
    3.  <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>    
    4. <ProductVersion>8.0.50727</ProductVersion>    
    5. <SchemaVersion>2.0</SchemaVersion>    
    6. <ProjectGuid>{4B4DB6AA-A021-4F95-92B7-B88B5B360228}</ProjectGuid>    
    7. <OutputType>WinExe</OutputType>    
    8. <AppDesignerFolder>Properties</AppDesignerFolder>    
    9. <RootNamespace>SampleProject</RootNamespace>    
    10. <AssemblyName>SampleProject</AssemblyName>    
    11. <StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>    
    12. </PropertyGroup>    

     

          目前发现RootNamespace,AssemblyName 两节的值,没理解到底应该替换为什么,只是参考其他的PropertyGroup的节改写了一下就可以了 。

    或者使用更简单的方法,在文件中的第一个 PropertyGroup节中添加如下代码  ,其实和上边的方法基本一样,只是没有添加PropertyGroup,而是在已有的第一个PropertyGroup节中添加如下一行代码罢了。

    [csharp]  view plain copy
     
    1. <StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>    

     

    注意:如果需要把警告改为错误,则必须添加如下一行,否则以上两种方法都没作用。


    [csharp]  view plain copy
     
    1. <Import Project="$(ProgramFiles)\MSBuild\Microsoft\StyleCop\v4.3\Microsoft.StyleCop.targets" />  


     

    5规则的应用顺序

     

    据说是首先是项目下的规则文件,然后是styleCop安装目录下的规则文件,还有一个MSBuild\Microsoft\StyleCop\下的规则文件不知道什么顺序,我个人也不是很清楚,也没有找到相关文档,希望知道的朋友告诉一声。

    规则应用顺序参考

    转载于:https://www.cnblogs.com/zhiji6/p/4047863.html

    展开全文
  • StyleCop修正工具

    2013-05-29 11:50:15
    此工具可自动修正一些StyleCop产生的代码不规范问题,如去除空格,空白行等
  • Microsoft.StyleCop

    2010-01-20 23:48:27
    StyleCop的终极目标是让所有人都能写出优雅和一致的代码,因此这些代码具有很高的可读性。 早就听说了微软内部的静态代码检查和代码强制格式美化工具 StyleCop StyleCop不是代码格式化(代码美化)工具,而是代码...
  • StyleCop自定义规则

    2016-01-14 14:25:34
    主要是自己写的自定义规则,相对较为详细,里面包含规则文档 ,项目原代码由于特殊原因不方面上传,这边只放出DLL 自己去反编译,具体使用方法 除了自定义的DLL需要放置到使用的项目中 和stylecop 安装目录,其他的...
  • stylecop 4.7 (c#代码静态扫描工具)
  • StyleCop社区规则 StyleCop社区规则包含其他规则。 规则 可以使用以下规则: LinesMustNotEndWithWhitespace (CO1000):检查尾随空格 LinesMustNotBeLongerThanNumCharacters (CO1001):检查行长不超过配置的...
  • Cake.StyleCop 这是围绕标准StyleCop库的精简包装,该库以Cake构建脚本可以使用的方式公开StyleCop。 包含的.dll可直接从 注意:误将某些C#6语法报告为违规-这是由于可用的dll版本所致。 一旦stylecop 4.7.55完全...
  • StyleCop只是一个代码格式的检查工具,它会根据预定义的C#代码格式的最佳实践,对我们的源代码进行检查,并给出不符合编码风格的错误提示
  • StyleCop 最新 4.7.50 版 中文规则,在VS中显示的规则提示是中文的。 将下载的文件覆盖到4.7.50版本的StyleCop安装后的MSBuild下的tools文件夹下即可
  • StyleCop的终极目标是让所有人都能写出优雅和一致的代码,因此这些代码具有很高的可读性。 早就听说了微软内部的静态代码检查和代码强制格式美化工具 StyleCop StyleCop不是代码格式化(代码美化)工具,而是代码...
  • stylecop.zip

    2020-07-24 10:24:13
    StyleCop analyzes C# source code to enforce a set of style and consistency rules. It can be run from inside of Visual Studio or integrated into an MSBuild project. StyleCop has also been integrated ...
  • StyleCop 配置 审查代码

    2020-12-28 09:59:30
    第一步:安装 StyleCop 插件 第二步:配置规则 本人配置的规则如下,可以根据自己团队开发情况进行自定义配置:https://blog.csdn.net/csethcrm/article/details/111681484 Settings.StyleCop 内容如下: <...

    第一步:安装 StyleCop 插件

    第二步:配置规则

    本人配置的规则如下,可以根据自己团队开发情况进行自定义配置: https://blog.csdn.net/csethcrm/article/details/111681484
    Settings.StyleCop 内容如下:

     

    <StyleCopSettings Version="105">
      <Analyzers>
        <Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
          <Rules>
            <Rule Name="DocumentationMustContainValidXml">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ElementDocumentationMustNotHaveDefaultSummary">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ElementParameterDocumentationMustDeclareParameterName">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="VoidReturnValueMustNotBeDocumented">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="GenericTypeParametersMustBeDocumented">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="GenericTypeParametersMustBeDocumentedPartialClass">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="GenericTypeParameterDocumentationMustMatchTypeParameters">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="GenericTypeParameterDocumentationMustDeclareParameterName">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="GenericTypeParameterDocumentationMustHaveText">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="PropertySummaryDocumentationMustMatchAccessors">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="PropertySummaryDocumentationMustOmitSetAccessorWithRestrictedAccess">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="SingleLineCommentsMustNotUseDocumentationStyleSlashes">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="DocumentationTextMustContainWhitespace">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="DocumentationMustMeetCharacterPercentage">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ConstructorSummaryDocumentationMustBeginWithStandardText">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="DestructorSummaryDocumentationMustBeginWithStandardText">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="DocumentationHeadersMustNotContainBlankLines">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="IncludedDocumentationXPathDoesNotExist">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="IncludeNodeDoesNotContainValidFileAndPath">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="InheritDocMustBeUsedWithInheritingClass">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ElementDocumentationMustBeSpelledCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="FileMustHaveHeader">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="FileHeaderMustShowCopyright">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="FileHeaderMustHaveCopyrightText">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="FileHeaderMustContainFileName">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="FileHeaderFileNameDocumentationMustMatchFileName">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="FileHeaderMustHaveValidCompanyText">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="FileHeaderFileNameDocumentationMustMatchTypeName">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
          </Rules>
          <AnalyzerSettings />
        </Analyzer>
        <Analyzer AnalyzerId="StyleCop.CSharp.LayoutRules">
          <Rules>
            <Rule Name="CurlyBracketsForMultiLineStatementsMustNotShareLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="StatementMustNotBeOnSingleLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ElementMustNotBeOnSingleLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="CurlyBracketsMustNotBeOmitted">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="AllAccessorsMustBeMultiLineOrSingleLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="OpeningCurlyBracketsMustNotBeFollowedByBlankLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ElementDocumentationHeadersMustNotBeFollowedByBlankLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ChainedStatementBlocksMustNotBePrecededByBlankLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="WhileDoFooterMustNotBePrecededByBlankLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="SingleLineCommentsMustNotBeFollowedByBlankLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ClosingCurlyBracketMustBeFollowedByBlankLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ElementDocumentationHeaderMustBePrecededByBlankLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="SingleLineCommentMustBePrecededByBlankLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ElementsMustBeSeparatedByBlankLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="CodeMustNotContainBlankLinesAtStartOfFile">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="CodeMustNotContainBlankLinesAtEndOfFile">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ClosingCurlyBracketsMustNotBePrecededByBlankLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="CodeMustNotContainMultipleBlankLinesInARow">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
          </Rules>
          <AnalyzerSettings />
        </Analyzer>
        <Analyzer AnalyzerId="StyleCop.CSharp.MaintainabilityRules">
          <Rules>
            <Rule Name="AccessModifierMustBeDeclared">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="FieldsMustBePrivate">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="CodeAnalysisSuppressionMustHaveJustification">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="DebugAssertMustProvideMessageText">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="DebugFailMustProvideMessageText">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="FileMayOnlyContainASingleClass">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="FileMayOnlyContainASingleNamespace">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="StatementMustNotUseUnnecessaryParenthesis">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ArithmeticExpressionsMustDeclarePrecedence">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ConditionalExpressionsMustDeclarePrecedence">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="RemoveDelegateParenthesisWhenPossible">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="AttributeConstructorMustNotUseUnnecessaryParenthesis">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="RemoveUnnecessaryCode">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
          </Rules>
          <AnalyzerSettings />
        </Analyzer>
        <Analyzer AnalyzerId="StyleCop.CSharp.NamingRules">
          <Rules>
            <Rule Name="ElementMustBeginWithLowerCaseLetter">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="FieldNamesMustNotUseHungarianNotation">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="FieldNamesMustBeginWithLowerCaseLetter">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="AccessibleFieldsMustBeginWithUpperCaseLetter">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="VariableNamesMustNotBePrefixed">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="FieldNamesMustNotBeginWithUnderscore">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="FieldNamesMustNotContainUnderscore">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="StaticReadonlyFieldsMustBeginWithUpperCaseLetter">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
          </Rules>
          <AnalyzerSettings />
        </Analyzer>
        <Analyzer AnalyzerId="StyleCop.CSharp.OrderingRules">
          <Rules>
            <Rule Name="UsingDirectivesMustBePlacedWithinNamespace">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ElementsMustAppearInTheCorrectOrder">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ElementsMustBeOrderedByAccess">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ConstantsMustAppearBeforeFields">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="StaticElementsMustAppearBeforeInstanceElements">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="DeclarationKeywordsMustFollowOrder">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ProtectedMustComeBeforeInternal">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="PropertyAccessorsMustFollowOrder">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="EventAccessorsMustFollowOrder">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="StaticReadonlyElementsMustAppearBeforeStaticNonReadonlyElements">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="InstanceReadonlyElementsMustAppearBeforeInstanceNonReadonlyElements">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="SystemUsingDirectivesMustBePlacedBeforeOtherUsingDirectives">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="UsingAliasDirectivesMustBePlacedAfterOtherUsingDirectives">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="UsingDirectivesMustBeOrderedAlphabeticallyByNamespace">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="UsingAliasDirectivesMustBeOrderedAlphabeticallyByAliasName">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="UsingStaticDirectivesMustBePlacedAtTheCorrectLocation">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
          </Rules>
          <AnalyzerSettings />
        </Analyzer>
        <Analyzer AnalyzerId="StyleCop.CSharp.ReadabilityRules">
          <Rules>
            <Rule Name="CommentsMustContainText">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="DoNotPrefixCallsWithBaseUnlessLocalImplementationExists">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="PrefixLocalCallsWithThis">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="PrefixCallsCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="OpeningParenthesisMustBeOnDeclarationLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ClosingParenthesisMustBeOnLineOfLastParameter">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ClosingParenthesisMustBeOnLineOfOpeningParenthesis">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="CommaMustBeOnSameLineAsPreviousParameter">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ParameterListMustFollowDeclaration">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ParameterMustFollowComma">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ParametersMustBeOnSameLineOrSeparateLines">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ParameterMustNotSpanMultipleLines">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="QueryClauseMustFollowPreviousClause">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="QueryClausesMustBeOnSeparateLinesOrAllOnOneLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="QueryClauseMustBeginOnNewLineWhenPreviousClauseSpansMultipleLines">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="QueryClausesSpanningMultipleLinesMustBeginOnOwnLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="DoNotPlaceRegionsWithinElements">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="CodeMustNotContainEmptyStatements">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="CodeMustNotContainMultipleStatementsOnOneLine">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="BlockStatementsMustNotContainEmbeddedComments">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="BlockStatementsMustNotContainEmbeddedRegions">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="UseReadableConditions">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="UseStringEmptyForEmptyStrings">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="UseBuiltInTypeAlias">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="UseShorthandForNullableTypes">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
          </Rules>
          <AnalyzerSettings />
        </Analyzer>
        <Analyzer AnalyzerId="StyleCop.CSharp.SpacingRules">
          <Rules>
            <Rule Name="KeywordsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="CommasMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="SemicolonsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="SymbolsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="DocumentationLinesMustBeginWithSingleSpace">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="SingleLineCommentsMustBeginWithSingleSpace">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="PreprocessorKeywordsMustNotBePrecededBySpace">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="OperatorKeywordMustBeFollowedBySpace">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="OpeningParenthesisMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ClosingParenthesisMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="OpeningSquareBracketsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ClosingSquareBracketsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="OpeningCurlyBracketsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ClosingCurlyBracketsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="OpeningGenericBracketsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ClosingGenericBracketsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="OpeningAttributeBracketsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ClosingAttributeBracketsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="NullableTypeSymbolsMustNotBePrecededBySpace">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="MemberAccessSymbolsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="IncrementDecrementSymbolsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="NegativeSignsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="PositiveSignsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="DereferenceAndAccessOfSymbolsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="ColonsMustBeSpacedCorrectly">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="CodeMustNotContainMultipleWhitespaceInARow">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="CodeMustNotContainSpaceAfterNewKeywordInImplicitlyTypedArrayAllocation">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="TabsMustNotBeUsed">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
            <Rule Name="DoNotSplitNullConditionalOperators">
              <RuleSettings>
                <BooleanProperty Name="Enabled">False</BooleanProperty>
              </RuleSettings>
            </Rule>
          </Rules>
          <AnalyzerSettings />
        </Analyzer>
      </Analyzers>
    </StyleCopSettings>

     

    第三步: Run StyleCop ( 右键项目 - Run StyleCop ) 提示如下(类 和 函数 需要添加注释):




    第四步:添加注释 ,再次 Run StyleCop , 让 代码审查 可以 通过


    看到 StyleCop completed  ,  恭喜, 代码审查 大功告成 。
     

    展开全文
  • $ npm install grunt-stylecop-runner --save-dev 接下来将此行添加到项目的 Gruntfile 中: grunt . loadNpmTasks ( 'grunt-stylecop-runner' ) ; 配置 您将在此处找到 StyleCop.Console 应用程序: : 将此...
  • StyleCop4.7

    2012-12-21 14:31:58
    微软开发的代码格式审查工具,支持与VS2010集成
  • StyleCop

    2015-11-05 16:49:00
    1. Install StyleCop-4.7.49.0.msi https://stylecop.codeplex.com/ 2. Run StyleCop/Run StyleCop (Rescan All) 3. Warnings CSharp.Ordering: All using directives must be placed inside of the nam.....
    1. Install StyleCop-4.7.49.0.msi
     
    2. Run StyleCop/Run StyleCop (Rescan All)
     
    3. Warnings
    CSharp.Ordering: All using directives must be placed inside of the namespace. > Can be turned off in the StyleCop Settings
     
    4. How do I integrate StyleCop 4.7 with Visual Studio MSBuild?
     
    The above command will download the latest stable required dlls and files and integrate style cop with your project. Build your project and any stylecop errors will be shown in the warnings section.
     
    If you want your build to succeed only if all stylecop errors are fixed, you will need to make some changes to the project file to set a boolean to not treat stylecop errors as warnings.
    Open the .csproj file for your project in notepad, and find the first PropertyGroup section within the file. Add a new tag to set the StyleCopTreatErrorsAsWarnings flag to false.

    For example:

     
    <StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings> is shown above.
     
    Issues:
    1. C# - StyleCop - SA1121: UseBuiltInTypeAlias - Readability Rules

    The code uses one of the basic C# types, but does not use the built-in alias for the type.

    Rather than using the type name or the fully-qualified type name, the built-in aliases for these types should always be used: bool, byte, char, decimal, double, short, int, long, object, sbyte, float, string, ushort, uint, ulong.

    so String.Empty is wrong (depend on above rules) and string.Empty is good.

    I do not agree :)

    <Rule Name="UseBuiltInTypeAlias">
        <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
        </RuleSettings>
    </Rule>

    2. How to exclude private members from StyleCop rule SA1600

    I am not very interesting with write documents for private members :)

    <AnalyzerSettings>
        <BooleanProperty Name="IncludeFields">False</BooleanProperty>
    </AnalyzerSettings>

    3. A field name in C# must not begins with an underscore.

    I do not agree :)

    <Rule Name="FieldNamesMustNotBeginWithUnderscore">
        <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
        </RuleSettings>
    </Rule>

    4. By default, StyleCop does not allow variable or field names to include Hungarian notation

    How can I allow nh (NHibernate)

    <Analyzers>
        <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.NamingRules">
            <AnalyzerSettings>
                <CollectionProperty Name="Hungarian">
                    <Value>nh</Value>
                </CollectionProperty>
            </AnalyzerSettings>
        </Analyzer>
    </Analyzers>

    5. The comment must start with a single space. To ignore this error when commenting out a line of code, begin the comment with '' rather than '//'

    <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.SpacingRules">
        <Rules>
            <Rule Name="SingleLineCommentsMustBeginWithSingleSpace">
                <RuleSettings>
                    <BooleanProperty Name="Enabled">False</BooleanProperty>
                </RuleSettings>
            </Rule>
        </Rules>
    </Analyzer>

    6. The comment is empty. Add text to the comment or remove it.

    <Analyzer AnalyzerId="StyleCop.CSharp.ReadabilityRules">
        <Rules>
            <Rule Name="CommentsMustContainText">
                <RuleSettings>
                    <BooleanProperty Name="Enabled">False</BooleanProperty>
                </RuleSettings>
            </Rule>
        </Rules>
        <AnalyzerSettings />
    </Analyzer>

    7. More rules you can found in the below url:

    http://www.stylecop.com/docs/StyleCop%20Rules.html

    转载于:https://www.cnblogs.com/zhangpengc/p/4940060.html

    展开全文
  • StyleCop全套资料下载

    热门讨论 2013-04-05 22:13:25
    SourceAnalysis (StyleCop)的终极目标是让所有人都能写出优雅和一致的代码,因此这些代码具有很高的可读性。 是微软内部的静态代码检查和代码强制格式美化工具 StyleCop
  • StyleCop sample code

    2014-05-08 15:49:43
    StyleCop sample code
  • StyleCop 代码规范

    2011-04-01 15:52:50
    现在,微软发布了StyleCop,这是他们在内部使用的一个编码风格强制工具,微软的这一举措无疑将起到推波助澜的作用。 StyleCop,也即所谓的微软C#源代码分析器(Microsoft Source Analysis for C#),用途和FxCop...
  • 本篇文章介绍如何通过StyleCop这个工具,来自动分析代码格式,在不增加开发人员负担的前提下,让团队的程序代码产出趋于一致、大幅提高程序代码的生产质量。 一、安装 安装完成后重启vs。 二、使...

    前言

    但是在项目开发的过程中,如果只是验证命名规则、而没有统一程序排版,不同开发人员将产出不同的文件格式。这样的产出,虽然能够正常地提供项目功能 ,但缺会大幅降低了这份程序代码的可维护性与可读性。

    本篇文章介绍如何通过StyleCop这个工具,来自动分析代码格式,在不增加开发人员负担的前提下,让团队的程序代码产出趋于一致、大幅提高程序代码的生产质量。

    一、安装

    在这里插入图片描述安装完成后重启vs。

    二、使用

    1. 右键菜单项目
      在这里插入图片描述

    Run StyleCop执行代码分析。
    StyleCop Settings 设置规则,如下图:

    在这里插入图片描述

    三、不建议采纳的代码规范

    一、文档规则

    29. SA1628:DocumentationTextMustBeginWithACapitalLetter  注释节点内部的文本必须以大写字母开头
    30. SA1629:DocumentationTextMustEndWithAPeriod  注释节点内部的文本必须英文的句号结束
    31. SA1630:DocumentationTextMustContainWhitespace  注释节点内部的文本必须包含空格
    32. SA1631:DocumentationMustMeetCharacterPercentage 注释节点内部的文本中不能包含过多的字符(举例:包含’---------------------------------------’是不允许的) //不一定,类似这种不需要的可以自己手动删除这个规范
    33.  SA1632:DocumentationTextMustMeetMinimumCharacterLength  已经作废的规则,不允许有太短的字符串(如’A name’ 中的A字母)
    34.  SA1633:FileMustHaveHeader   代码文件头部必须有说明,一般放置版权信息
    35. SA1634:FileHeaderMustShowCopyright  代码文件头部注解中必须包含版权关键字
    36. SA1635:FileHeaderMustHaveCopyrightText代码文件头部注解中必须包含版权信息内同
    37. SA1636:FileHeaderCopyrightTextMustMatch  代码文件头部注解中版权信息必须与设置画面设置的内容相匹配,在”style seting”画面的” CompanyInformation tab”进行设置
    38. SA1637:FileHeaderMustContainFileName 代码文件头部注解中必须包含文件名称
    39. SA1638:FileHeaderFileNameDocumentationMustMatchFileName  代码文件头部注解中必须包含文件名称必须与实际的名称匹配
    41. SA1640:FileHeaderMustHaveValidCompanyText代码文件头部注解中版权信息必须含有合理的公司名字
    42. SA1641:FileHeaderCompanyNameTextMustMatch  代码文件头部注解中的公司名字必须与设置画面设置的内容相匹配,在”style seting”画面的” CompanyInformation tab”进行设置
    43. SA1642:ConstructorSummaryDocumentationMustBeginWithStandardText  构造函数注释标准:“Initializes a new instance of the <see cref="Customer{T}"/>class.”
    44. SA1643:DestructorSummaryDocumentationMustBeginWithStandardText  析构函数注释标准:“Finalizes an instance of the <see cref="Customer"/>class.”
    45. SA1644:DocumentationHeadersMustNotContainBlankLines   注释中不能出现空白行
    46. SA1645:IncludedDocumentationFileDoesNotExist   如果注释中包含文件,要确定这个文件存在,举例:“      
    /// <include file="IncludedDocumentation.xml" path="root/EnabledMethodDocs" />”这一项过于复杂不建议用,
    但是如果将来想规范化相同共性东西的注释的时候倒是可以考虑引入。
    48. SA1646:IncludedDocumentationXPathDoesNotExist  如果注释中包含文件,路径不存在。
    49. SA1647:IncludeNodeDoesNotContainValidFileAndPath  如果注释中包含文件文件与路径都要合法
    50. SA1648:InheritDocMustBeUsedWithInheritingClass   这项不明白是什么意思,还请知道的分享给我,谢谢。
    51. SA1649:FileHeaderFileNameDocumentationMustMatchTypeName  文件头注释必须匹配类型
    52. SA1650:ElementDocumentationMustBeSpelledCorrectly注释不能有拼写错误(对中文支持不好,不建议使用该项)
    

    二、布局规则

    4.  SA1503:CurlyBracketsMustNotBeOmitted  花括弧即使在单行代码的情况下也不能省略。
    5.  SA1504:AllAccessorsMustBeSingleLineOrMultiLine  读写属性,要么在同一行业要么在分多行写,不可规则不统一(个人建议分多行写)。
    7.  SA1506:ElementDocumentationHeadersMustNotBeFollowedByBlankLine元素头部注释跟元素之间不能有空白行
    8.  SA1507:CodeMustNotContainMultipleBlankLinesInARow不允许有多行空白行紧挨着(个人建议写一个空白行即可)
    9.  SA1508:ClosingCurlyBracketsMustNotBePrecededByBlankLine结尾的花括弧不能再一个空白行之前
    10.  SA1509:OpeningCurlyBracketsMustNotBePrecededByBlankLine  开始的花括弧不能再一个空白行之前
    13.  SA1512:SingleLineCommentsMustNotBeFollowedByBlankLine单行注释不能后跟空白行
    17.  SA1516:ElementsMustBeSeparatedByBlankLine邻近的元素之间要有一个空白行
    18.  SA1517:CodeMustNotContainBlankLinesAtStartOfFile代码文件头部字符之前不能出现空白行
    19.  SA1518:CodeMustNotContainBlankLinesAtEndOfFile代码文件尾部字符之后不能出现空白行
    

    三. 可维护规则

    6.  SA1404:CodeAnalysisSuppressionMustHaveJustification   Suppression特性(取消报告特定的静态分析工具规则冲突,允许一个代码项目上应用多个取消报告设置)必须要有合理理由
    7.  SA1405:DebugAssertMustProvideMessageText 参见代码:“Debug.Assert(value != true,"The value must always be true.");”
    8.  SA1406:DebugFailMustProvideMessageText   参见代码:“Debug.Fail("The code should never reach this point.");”
    12.  SA1410:RemoveDelegateParenthesisWhenPossible  调用一个c#匿名方法不包含任何方法参数,必须要包括一个空括号(本人不建议使用匿名方法.  匿名委托的语法,具体原因后续做分享)
    13.  SA1411:AttributeConstructorMustNotUseUnnecessaryParenthesis特性构造函数如果是空参的形式,不要包括那个空括号
    

    四. 命名规则

    2. SA1301: ElementMustBeginWithLowerCaseLetter  不会出现的情况
    6. SA1305:FieldNamesMustNotUseHungarianNotation除了列表外的字符不可以出现匈牙利命名规则,在”StyleSetting”里的” Hungarian”Tab里设置
    

    五. 排序规则

    1.  SA1200:UsingDirectivesMustBePlacedWithinNamespace  using部分必须在Namespace内部(个人不建议用这个规则)
    2.  SA1201:ElementsMustAppearInTheCorrectOrder所有的元素必须出现在正确的位置上(个人不建议使用该规则,用region把一个类文件里的元素分好组即可,字段.  属性.  对外公布的接口.  私有方法等组)
    3.  SA1202:ElementsMustBeOrderedByAccess  元素的修饰符有一个固定的顺序(个人不建议使用该规则,用region把一个类文件里的元素分好组即可,字段.  属性.  对外公布的接口.  私有方法等组)
    5.  SA1204:StaticElementsMustAppearBeforeInstanceElementsStatic  元素摆放在前面
    9.  SA1208:SystemUsingDirectivesMustBePlacedBeforeOtherUsingDirectives  系统级的引用在其他引用之前(格式化代码就会自动按照这个规则编排using部分)
    10.  SA1209:UsingAliasDirectivesMustBePlacedAfterOtherUsingDirectives  using部分起别名的在最后排布
    11.  SA1210:UsingDirectivesMustBeOrderedAlphabeticallyByNamespace  using部分按照字母顺序编排
    12.  SA1211:UsingAliasDirectivesMustBeOrderedAlphabeticallyByAliasName别名的按照别名的字母编排
    

    六. 可读性规则

    1. SA1100:DoNotPrefixCallsWithBaseUnlessLocalImplementationExists change the ‘base.’ prefix to ‘this.’
    2. SA1101:PrefixLocalCallsWithThis ‘this.’前缀不能省略
    4. SA1103:QueryClausesMustBeOnSeparateLinesOrAllOnOneLine 不是很理
    5. SA1104:QueryClauseMustBeginOnNewLineWhenPreviousClauseSpansMultipleLines不是很理
    6.  SA1105:QueryClausesSpanningMultipleLinesMustBeginOnOwnLine不是很理解
    9.  SA1108:BlockStatementsMustNotContainEmbeddedComments  非法用例:
    12.  SA1110:OpeningParenthesisMustBeOnDeclarationLine方法开始的括弧要在声明的那一行
    13.  SA1111:ClosingParenthesisMustBeOnLineOfLastParameter  方法结束括弧与最后一个参数同行
    14.  SA1112:ClosingParenthesisMustBeOnLineOfOpeningParenthesis  如果是空参的情况,开始于结束括弧在同一行
    15.  SA1113:CommaMustBeOnSameLineAsPreviousParameter  逗号必须与前一个参数同行
    16.  SA1114:ParameterListMustFollowDeclaration确保参数列表与开始括号同行,或者另起一行 参数整体要在同一行
    18.  SA1116:SplitParametersMustStartOnLineAfterDeclaration  所有参数在同一行或者如下示例:
    19.  SA1117:ParametersMustBeOnSameLineOrSeparateLines   同上
    20.  SA1118:ParameterMustNotSpanMultipleLines实际调用是参数要在同一行
    21.  SA1119
    22.  SA1121:UseBuiltInTypeAlias  使用内嵌的类型别名 
    23.  SA1123:DoNotPlaceRegionsWithinElements  不使用region(个人较反对这条,个人倾向于用region规整类里的元素)
    24.  SA1124:DoNotUseRegions  不使用region(个人较反对这条,个人倾向于用region规整类里的元素)
    25.  SA1125:UseShorthandForNullableTypes  使用简写版的可空类型 如”int?”
    26.  SA1126:PrefixCallsCorrectly  调用类成员的时候要带上“this”前缀
    

    七. 拼写规则

    2.  SA1001:CommasMustBeSpacedCorrectly 逗号前面摆放一个空格
    3.  SA1002:SemicolonsMustBeSpacedCorrectly  分号前面摆放一个空格
    6.  SA1005:SingleLineCommentsMustBeginWithSingleSpace  单行注释以一个空格开头
    7.  SA1006:PreprocessorKeywordsMustNotBePrecededBySpace  预处理关键字内部不允许出现空格如“# if Debug”是不允许的
    9.  SA1008:OpeningParenthesisMustBeSpacedCorrectly  开始括弧放置合理的空格
    10.  SA1009:ClosingParenthesisMustBeSpacedCorrectly  结尾括弧放置合理的空格
    11.  SA1010:OpeningSquareBracketsMustBeSpacedCorrectly开始方括号放置合理的空格
    12.  SA1011:ClosingSquareBracketsMustBeSpacedCorrectly   结束方括号放置合理的空格
    13.  SA1012:OpeningCurlyBracketsMustBeSpacedCorrectly  开始花括号放置合理的空格
    14.  SA1013:ClosingCurlyBracketsMustBeSpacedCorrectly结束花括号放置合理的空格
    15.  SA1014:OpeningGenericBracketsMustBeSpacedCorrectly同上
    16.  SA1015:ClosingGenericBracketsMustBeSpacedCorrectly  同上
    17.  SA1016:OpeningAttributeBracketsMustBeSpacedCorrectly  特性开始括号同上
    18.  SA1017:ClosingAttributeBracketsMustBeSpacedCorrectly  特性结尾括号同上
    19.  SA1018:NullableTypeSymbolsMustNotBePrecededBySpace空类型前不放置空格
    20.  SA1019:MemberAccessSymbolsMustBeSpacedCorrectly  成员访问关键字前后有空格
    21.  SA1020:IncrementDecrementSymbolsMustBeSpacedCorrectly自增.  自减关键字要有空格
    22.  SA1021:NegativeSignsMustBeSpacedCorrectly  负号要有空格
    23.  SA1022:PositiveSignsMustBeSpacedCorrectly   正号要有空格
    24.  SA1023:DereferenceAndAccessOfMustBeSpacedCorrectly
    25.  SA1024:ColonsMustBeSpacedCorrectly  冒号运算符要有空格
    26.  SA1025:CodeMustNotContainMultipleWhitespaceInARow 同一行不允许出现多个空格
    27.  SA1026:CodeMustNotContainSpaceAfterNewKeywordInImplicitlyTypedArrayAllocation  new关键字之后不允许出现空格
    28.   SA1027:TabsMustNotBeUsed  不用tab字符(个人不建议采用这条)
    

    refference [1]: https://blog.csdn.net/zzh920625/article/details/51637793

    展开全文

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 1,175
精华内容 470
关键字:

StyleCop