使用 NDepend 查找放置特定对象类型的位置 System.Web.Caching.Cache

Using NDepend to find out places where specific objec types are placed in System.Web.Caching.Cache

我试图在一个相当大的代码库中搜索大型对象最终被用于任何 System.Web.Caching.Cache 方法的方法。这些类型有时会很大,以至于它们最终会出现在大对象堆中,这反过来又是一件坏事。

基本上我们有 class ExternalProject.ReallyBigType 被继承到几个不同的 classes。 我们有一些不同的方法,让我们称之为 CacheUsingMethods,它们使用 System.Web.Caching.Cache 中的方法(通过其他实现等)。 我想找到使用 ExternalProject.ReallyBigType 类型的对象(或派生自 ExternalProject.ReallyBigType 的对象)的 CacheUsingMethods,并使它们最终出现在 System.Web.Caching.Cache 中的任何方法中。

有没有什么方法可以使用 NDepend 来完成此操作?

怎么样:

let bigTypes = Application.Types.Where(t => t.DeriveFrom("ExternalProject.ReallyBigType"))
let cacheUsingMethods = Application.Methods.WithNameLike("RegeExToMatchThoseMethods")
from m in cacheUsingMethods.UsingAny(bigTypes)
let bigTypesUsed = bigTypes.UsedBy(m)
select new { m, bigTypesUsed }