在開始創建自定義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
運行的任何跡象。
有什麼我錯過了?