【问题标题】:How to define NDepend API CQLinq execution context in c#?如何在 C# 中定义 NDepend API CQLinq 执行上下文?
【发布时间】:2013-10-05 21:00:20
【问题描述】:

当我将 NDepend CQLinq 查询移植到 C# 时,我必须始终开始定义要查询的 codeBase,所以这个 CQLinq 查询

from m in Methods
where m.ILCyclomaticComplexity > 10 
select new {m}

在 C# 中使用 NDepend API 我必须移植到:

ICodeBase codeBase

from m in codeBase.Application.Methods
where m.ILCyclomaticComplexity > 10 
select m 

我看到有一个 ICQLinqExecutionContext。我可以为查询定义上下文,以便我可以直接使用程序集、方法、JustMyCode 等吗?

谢谢!

【问题讨论】:

    标签: api ndepend cqlinq


    【解决方案1】:

    正如ICQLinqExecutionContext 文档中的解释:此接口保留给 CQLinq 实现使用,不打算在您的代码中使用。

    但正如您所注意到的,只需稍微重写,您就可以访问 100% 的 CQLinq 功能(例如使用 codeBase.Application.Methods 而不是 Methods

    另外,通过阅读 CQLinq syntax doc about predefined domain,您可以看到 CQLinq 中的 Methods 之类的域在 CQLinq 编译后时被转换为 context.CodeBase.Methods。你真正缺少的不是接口ICQLinqExecutionContext,而是C#中没有的CQLinq编译后时间。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-12
      • 2020-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-22
      相关资源
      最近更新 更多