gpt4 book ai didi

c# - NDepend 能否将所有方法中的代码输出到特定方法的依赖树中?

转载 作者:太空狗 更新时间:2023-10-29 21:44:04 26 4
gpt4 key购买 nike

我希望能够将在每次构建后与之前构建后对特定方法列表的任何依赖项所做的任何代码更改进行比较的能力集成到我们的构建过程中。

因此,如果我有两个访问数据库的方法,我希望能够判断调用这两个方法中的任何一个的方法是否有任何代码更改,一直到依赖树。

最佳答案

这样的代码查询应该可以满足您的需求:

// <Name>Methods that call Parse(String) or get_TestName() and that was added or where cpde was changed</Name>
from m in Methods
let depth0 = m.DepthOfIsUsing("NUnit.Core.RuntimeFramework.Parse(String)")
let depth1 = m.DepthOfIsUsing("NUnit.Core.Test.get_TestName()")
where (depth0 >= 0 || depth1 >= 0)
&& (m.CodeWasChanged() || m.WasAdded())

orderby (depth0 != null ? depth0 : depth1)
select new { m, depth0, depth1 }

当然,如果您愿意,可以使用前缀 warnif count > 0 将其转换为规则。

下面是这个代码查询,下划线方法是代码自基线以来更改的方法,粗体是自基线以来添加的方法。

NDepend calls in dependency tree diff methods

您可以右键单击带下划线的方法到ask to see diff in source code使用您首选的差异工具。

您还可以将结果导出到图表(按钮导出到图表),但这样您可能会得到不相交的图表,因为未更改的方法将丢失:

enter image description here

关于c# - NDepend 能否将所有方法中的代码输出到特定方法的依赖树中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31818487/

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