0

我有一个(公司提供的)stylecop 设置文件,其中包含一些规则。

我将其放入项目的父文件夹中(测试项目,本地,无源代码控制 - stylecop 设置仍然显示“与父文件夹中的设置文件合并”)。

运行 Stylecop (4.7.42, Rescan All) 时,我收到几个警告,如 SA1400、SA1200 等,我没有定义。

另一方面,我有

<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.MaintainabilityRules">
  <Rules>
    <Rule Name="ArithmeticExpressionsMustDeclarePrecedence">
      <RuleSettings>
        <BooleanProperty Name="Enabled">True</BooleanProperty>
      </RuleSettings>
    </Rule>
  </Rules>
  <AnalyzerSettings />
</Analyzer>

i = i * 2 + 3 * 6;

并且没有得到任何警告。(规则说明:http ://stylecop.soyuz5.com/SA1407.html 。实际上,此处设置 True 或 False 会导致没有消息。)

此外,当打开设置编辑器时,会检查所有设置,尽管我只在我的设置文件中指定了一些设置。

我假设我的设置文件与 Stylecop 报告的内容无关?!

怎么修?

4

1 回答 1

1

I think you're looking for this: https://stackoverflow.com/a/13434198/1505426


Copied from linked answer:

By default your settings files are merged into parent settings, and this could be causing you some issues. Try stopping the merging at the solution root by adding the following setting:

<GlobalSettings>
    <StringProperty Name="MergeSettingsFiles">NoMerge</StringProperty>
</GlobalSettings>

This will ensure that StyleCop acts the same on all development and build machines, regardless of the settings configured higher up the hierarchy (such as the one in the StyleCop application folder). However if you do this, make sure you copy all the required settings from the files no longer being merged.

于 2012-12-03T20:29:19.550 回答