Tag: fxcop customrules

FxCop中的自定义规则仅适用于特定类型方法调用的方法

我想创建一个应用方法的FxRule,只有在从特定类调用该方法时才会这样做。 注意:我不想只是将规则应用于特定类的方法,我希望能够处理调用其他方法调用其他方法进行装箱的方法。 我想让FxCop报告与拳击方法相关的问题。 以下是我到目前为止的代码: using System; using System.Linq; using Microsoft.FxCop.Sdk; using System.Collections.Generic; class CheckUpdatableComponents : BaseIntrospectionRule { private string[] MethodsToCheck = new string[] { “BeginDraw”, “BeginRun”, “Draw”, “EndRun”, “EndDraw”, “Update” }; /// Gets the base class hooked up. public CheckUpdatableComponents() : base(“CheckUpdatableComponents”, “FxCopRules.Rules”, typeof(CheckUpdatableComponents).Assembly) { } public override ProblemCollection Check(string namespaceName, TypeNodeCollection types) { foreach […]