繁体   English   中英

Fxcop自定义规则未显示在Fxcop GUI中

[英]Fxcop custom rule not showing in Fxcop GUI

我创建了Fxcop自定义规则并定义了xml文件。 当我在Fxcop GUI中添加自定义规则程序集时,它没有显示规则。 请在下面找到相关信息:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.FxCop.Sdk;

namespace TestCustomRules
{
    public class TestRule : BaseIntrospectionRule
    {
        public TestRule() : base("TestRule", "TestCustomRules.TestRules", typeof(TestRule).Assembly) { }

        public override ProblemCollection Check(Member member)
        {
            Problems.Add(new Problem(new Resolution("TEST Rule {0}", "Chill out")));
            return Problems;
        }
    }
}

xml文件:

<?xml version="1.0" encoding="utf-8" ?>
<Rules FriendlyName="Test Rules">
  <Rule TypeName="TestRule" Category="TestRule" CheckId="TR1000">
    <Name>Test Rule</Name>
    <Description>Test Rule</Description>
    <Owner>Vibgy Joseph</Owner>
    <Url />
    <Resolution>This is just a test rule.</Resolution>
    <Email />
    <MessageLevel Certainty="99"> Warning</MessageLevel>
    <FixCategories> Breaking </FixCategories>
  </Rule>
</Rules>

以下是我添加时在Fxcop中显示的信息。 请注意,儿童总数为0。

FxCop Rule Assembly c:\users\vibgy.j\documents\projects\01_common\testcustomrules\testcustomrules\bin\debug\testcustomrules.dll
{
    Checked              : True   (Boolean)
    Children             : Count == 1  (NodeBaseDictionaryCollection)
    Container            : Count == 10  (NodeBaseDictionary)
    DefaultCheckState    : True   (Boolean)
    DisplayName          : TestCustomRules.dll  (String)
    FileIdentifier       : C:\Users\vibgy.j\Documents\Projects\01_Common\TestCustomRules\TestCustomRules\bin\Debug\TestCustomRules.dll  (String)
    FileName             : C:\Users\vibgy.j\Documents\Projects\01_Common\TestCustomRules\TestCustomRules\bin\Debug\TestCustomRules.dll  (String)
    FullyQualifiedName   : C:\Users\vibgy.j\Documents\Projects\01_Common\TestCustomRules\TestCustomRules\bin\Debug\TestCustomRules.dll  (String)
    HasChildren          : True   (Boolean)
    HasMessages          : True   (Boolean)
    ImageIndex           : 1  (Int32)
    LoadExceptions       : Microsoft.FxCop.Common.ExceptionCollection  (ExceptionCollection)
    LocalFileName        : TestCustomRules.dll  (String)
    Messages             : Count == 0  (MessageStatusNodeBaseMessageDictionary)
    Metadata             : <null>  (Object)
    Name                 : c:\users\vibgy.j\documents\projects\01_common\testcustomrules\testcustomrules\bin\debug\testcustomrules.dll  (String)
    Rules                : Count == 0  (RuleDictionary)
    Status               : New  (NodeStatus)
    TotalChildren        : 0  (Int32)
    TotalChildrenChecked : 0  (Int32)
    Version              : 1.0.0.0  (String)
}

糟糕! 我错过了将xml文件的“生成操作”属性设置为“嵌入式资源”。 现在,它正在Fxcop中显示。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM