无法使用 fxcop 查看我的自定义规则

发布于 2024-08-11 06:28:32 字数 1166 浏览 4 评论 0原文

我正在尝试为 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 并将构建操作设置为嵌入式资源),

<?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 添加规则。

我可以看到“我的规则”文件夹,但其中没有规则...

我错过了什么?

感谢您的帮助, 此致

I'm trying to develop a custom rule for fxcop.

I've this code :

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

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

I've this xml (named Rules.xml and set build action to embedded 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>

I compile, run fxcop and add rules with this dll .

I can see the "My Rules" folder but in it, there's no rule...

What Am I missing ?

Thanks for your help,
Best regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我一直都在从未离去 2024-08-18 06:28:32

请参阅 http ://msmvps.com/blogs/calinoiu/archive/2007/04/21/no-rules-in-your-fxcop-rule- assembly.aspx 了解导致规则缺失的一些最常见问题。根据您提供的详细信息,我猜测问题在于您的资源名称,或者(如果您粘贴了确切的代码)您传递给基本构造函数的规则名称与您的规则名称不匹配规则类型名称(“DoTheRightThing”与“DoTheRightThingRule”)。

See http://msmvps.com/blogs/calinoiu/archive/2007/04/21/no-rules-in-your-fxcop-rule-assembly.aspx for some of the most common problems that lead to missing rules. From the details you've provided, I'm guessing that the problem lies either with your resource name or (if you have pasted your exact code) with the fact that the rule name you're passing to the base constructor does not match your rule type name ("DoTheRightThing" vs "DoTheRightThingRule").

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文