gpt4 book ai didi

.net - 如何编写代码分析(FxCop)规则以防止方法调用

转载 作者:行者123 更新时间:2023-12-04 16:14:47 24 4
gpt4 key购买 nike

如何为vs2008编写代码分析工具以防止特定的框架调用,例如GC.WaitForFullGCComplete()或Application.DoEvents()

我尝试覆盖自定义规则中的VisitMethodCall,但无法弄清楚Microsoft.FxCop.Sdk.MethodCall参数真正包含的内容。在网络上找不到示例。

有人可以指出我正确的方向吗?

最佳答案

System.Web.HttpUtility.HtmlEncode(System.String)替换为您要查找和阻止的方法签名。

    public override ProblemCollection Check(Member member)
{
if (member is Method)
{
var callees = new List<Method>(Callees.CalleesFor((Method)member));
foreach (var callee in callees)
{
if (callee.FullName == "System.Web.HttpUtility.HtmlEncode(System.String)")
{
Problems.Add(new Problem(GetResolution()));
}
}
}

return Problems;
}

关于.net - 如何编写代码分析(FxCop)规则以防止方法调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/648934/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com