Visual studio 2012 使用VS2012 Express禁用StyleCop规则

Visual studio 2012 使用VS2012 Express禁用StyleCop规则,visual-studio-2012,msbuild,stylecop,rule,Visual Studio 2012,Msbuild,Stylecop,Rule,我使用的是Visual Studio 2012 Express,因此无法访问VS常规版本的集成。我使用了,规则显示为警告。我希望能够禁用规则。这篇文章表明这是可能的,但我无法理解建议编辑Settings.StyleCop文件的答案。但是,我不明白需要向该文件添加什么才能禁用规则 例如,如果我想禁用规则,我将如何更新以下文件 <StyleCopSettings Version="4.3"> <GlobalSettings> <CollectionPrope

我使用的是Visual Studio 2012 Express,因此无法访问VS常规版本的集成。我使用了,规则显示为警告。我希望能够禁用规则。这篇文章表明这是可能的,但我无法理解建议编辑Settings.StyleCop文件的答案。但是,我不明白需要向该文件添加什么才能禁用规则

例如,如果我想禁用规则,我将如何更新以下文件

<StyleCopSettings Version="4.3">
  <GlobalSettings>
    <CollectionProperty Name="DeprecatedWords">
      <Value>preprocessor,pre-processor</Value>
      <Value>shortlived,short-lived</Value>
    </CollectionProperty>
  </GlobalSettings>
  <Parsers>
    <Parser ParserId="StyleCop.CSharp.CsParser">
      <ParserSettings>
        <CollectionProperty Name="GeneratedFileFilters">
          <Value>\.g\.cs$</Value>
          <Value>\.generated\.cs$</Value>
          <Value>\.g\.i\.cs$</Value>
        </CollectionProperty>
      </ParserSettings>
    </Parser>
  </Parsers>
  <Analyzers>
    <Analyzer AnalyzerId="StyleCop.CSharp.NamingRules">
      <AnalyzerSettings>
        <CollectionProperty Name="Hungarian">
          <Value>as</Value>
          <Value>do</Value>
          <Value>id</Value>
          <Value>if</Value>
          <Value>in</Value>
          <Value>is</Value>
          <Value>my</Value>
          <Value>no</Value>
          <Value>on</Value>
          <Value>to</Value>
          <Value>ui</Value>
        </CollectionProperty>
      </AnalyzerSettings>
    </Analyzer>
  </Analyzers>
</StyleCopSettings>

注意:我使用的是4.7版,尽管默认设置文件显示为4.3,但我发现以下文档

下面是XML代码片段

<StyleCopSettings Version="4.3">
  <Analyzers>
    <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.LayoutRules">
      <Rules>
        <Rule Name="StatementMustNotBeOnSingleLine">
          <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
          </RuleSettings>
        </Rule>
        <Rule Name="ElementMustNotBeOnSingleLine">
          <RuleSettings>
            <BooleanProperty Name="Enabled">False</BooleanProperty>
          </RuleSettings>
        </Rule>
      </Rules>
      <AnalyzerSettings />
    </Analyzer>
  </Analyzers>
</StyleCopSettings>

此外,我还发现您可以将Settings.Sytlecop文件拖到StyleCopSettingsEditor.exe上,该文件提供了一个用于启用和禁用规则的GUI。

将下面的代码粘贴到记事本中,另存为Settings.StyleCop,并将其放置在解决方案文件夹和构建中

<StyleCopSettings Version="105">
  <GlobalSettings>
    <BooleanProperty Name="RulesEnabledByDefault">False</BooleanProperty>
  </GlobalSettings>
</StyleCopSettings>