在开始创建自定义StyleCop规则时,我遵循了Visual StyleCop Github上的说明。安装自定义StyleCop规则
•我创建了一个类,MyStyleCopRules.cs
:
[SourceAnalyzer(typeof(CsParser))]
public class MyStyleCopRules : SourceAnalyzer
{
public override void AnalyzeDocument(CodeDocument document)
{
...
•增加了一个XML文档,设置为EmbeddedResource生成操作,称为MyStyleCopRules.xml
:
<?xml version="1.0" encoding="utf-8" ?>
<SourceAnalyzer Name="My StyleCop Rules">
<Rules>
<Rule Name="Fully Qualified Using Statements" CheckId="IS0001">
<Context>Using statements must be fully qualifed.</Context>
<Description>Fires when using statements are not fully qualifed.</Description>
</Rule>
</Rules>
</SourceAnalyzer>
其他可能相关事实:
该库正在Framework 3.5的发行版中构建。
我在同一个目录中了StyleCop
掉了这个库的发布版本我用
StyleCop.MSBuild
(50年4月7日版)的集成了StyleCop,所以我将其复制到\packages\StyleCop.MSBuild.{version}\tools
。库中引用的StyleCop版本与我在旁边复制的版本相同。 (我已经检查使用ILSpy版本。)
我使用Visual Studio 2015年,但我不使用分析仪
我不明白规则,当我打开Settings.StyleCop
文件,我也没有看到他们使用Visual Studio
运行的任何迹象。
有什么我错过了?