如何在c#中定义NDepend API CQLinq执行上下文?

时间:2013-10-05 21:00:20

标签: api ndepend cqlinq

当我将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。我可以定义查询的上下文,以便我可以直接使用Assemblies,Methods,JustMyCode,...等?

谢谢!

1 个答案:

答案 0 :(得分:1)

作为ICQLinqExecutionContext doc中的解释:此接口保留用于CQLinq实现用法,不应在代码中使用。

但正如您所注意到的,只需稍加重写,您就可以访问100%的CQLinq功能(例如使用codeBase.Application.Methods的{​​{1}}内容

同样通过阅读CQLinq syntax doc about predefined domain,您可以看到CQLinq中的Methods这样的域在CQLinq编译后的时间内被转换为Methods。你真正缺少的不是接口context.CodeBase.Methods,而是CQLinq在C#中不可用的编译后时间。