2009-11-16 63 views
1

我正在嘗試爲fxcop開發自定義規則。使用fxcop無法看到我的自定義規則

我有這樣的代碼:

namespace TestCustomRuleFxCop 
{ 
    public class DoTheRightThingRule : BaseIntrospectionRule 
    { 
     public DoTheRightThingRule() 
      : base("DoTheRightThing", "TestCustomRuleFxCop.Rules", 
        typeof(DoTheRightThingRule).Assembly) 
     { 
     } 

     public override ProblemCollection Check(Member member) 
     { 
      return null; // todo 
     } 
    } 
} 

我有這個XML(文件名爲rules.xml並設置生成操作嵌入的ressource)

<?xml version="1.0" encoding="utf-8" ?> 
<Rules FriendlyName="My rules"> 
    <Rule TypeName="DoTheRightThingRule" Category="MyCategory" CheckId="MyId"> 
    <Name>My rule name</Name> 
    <Description>My description</Description> 
    <Resolution>Add Resolution</Resolution> 
    <Email></Email> 
    <MessageLevel Certainty="100">Warning</MessageLevel> 
    <FixCategories>Breaking</FixCategories> 
    </Rule> 
</Rules> 

我編譯,運行的FxCop並添加規則與此DLL。

我可以看到「我的規則」的文件夾,但它沒有規則......

我在想什麼?

感謝您的幫助, 最好的問候

回答

1

http://msmvps.com/blogs/calinoiu/archive/2007/04/21/no-rules-in-your-fxcop-rule-assembly.aspx對於一些導致缺少規則的最常見的問題。從你提供的細節中,我猜你的問題在於你的資源名稱,或者(如果你已經粘貼了你的確切代碼)與你傳遞給基礎構造函數的規則名稱不匹配的事實規則類型名稱(「DoTheRightThing」vs「DoTheRightThingRule」)。

+0

感謝您的幫助,重新創建項目後,它正在工作... 最好的問候 – Tim 2009-11-17 13:43:53