现在的 nDepend 和 CQL 是否可以直接使用派生类型的类来请求类?

发布于 2024-11-02 09:22:06 字数 445 浏览 0 评论 0原文

阅读了大量的问题和帖子,发现直到下一个版本才支持子查询/嵌套查询/查询组合。然而我不确定这是否是我需要的,在我的脑海里我会这样写,但我可能会让事情变得复杂。

我想像

WARN IF Count > 0 IN
SELECT TYPES WHERE
      IsDirectlyUsing "MTNE.Web.OneWeb.^.*\p{Proxy}+$" IN
      SELECT TYPES WHERE DeriveFrom "System.Web.Services.Protocols.SoapHttpClientProtocol"

所以我想做的是检查类型是否直接使用给定名称空间中具有后缀 Proxy 的其他类型,并且代理类型是否派生自 SoapHttpClientProtocol。如果类型直接使用代理类型,则会发出警告。

有建议、提示、提示、指点或答案吗?

Been reading through a lot of Q's and posts and see that subqueries/nested queries/query composition will not be supported until the next version. However I'm not sure if that is what I need, in my head it I would write it that way but I might be complicating things.

I imagine it like

WARN IF Count > 0 IN
SELECT TYPES WHERE
      IsDirectlyUsing "MTNE.Web.OneWeb.^.*\p{Proxy}+$" IN
      SELECT TYPES WHERE DeriveFrom "System.Web.Services.Protocols.SoapHttpClientProtocol"

So what I'd like to do is check if types are directly using other types in a given namespace which has the suffix Proxy, and that the proxy type is derived from SoapHttpClientProtocol. If a type is directly using the proxy type announce a warning.

Suggestions, hints, tips, pointers or answers anyone?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终弃我 2024-11-09 09:22:06

有多种方法可以编写基于 LINQ 查询的代码规则 (CQLinq) 提出的查询。当然,最优雅、简洁和优化的方法是:

warnif count > 0
let soapClientTypes = Application.Types.Where(t => t.DeriveFrom("System.Web.Services.Protocols.SoapHttpClientProtocol"))
let mnteTypes = Application.Types.WithFullNameLike(@"MTNE.Web.OneWeb.^.*\p{Proxy}+$").ToHashSet()
from t in soapClientTypes.UsingAny(mnteTypes)
select new { t, 
             mnteTypesUsed = t.TypesUsed.Intersect(mnteTypes) }

注意我们如何首先定义 2 个集合,并使用扩展方法 ToHashSet() 来优化 Intersect() 方法。

另请注意方法 UsingAny( ),在一次调用中,执行大量工作。

There are several ways to write the query asked with Code Rule over LINQ Query (CQLinq). Certainly the most elegant, concise and optimized way is:

warnif count > 0
let soapClientTypes = Application.Types.Where(t => t.DeriveFrom("System.Web.Services.Protocols.SoapHttpClientProtocol"))
let mnteTypes = Application.Types.WithFullNameLike(@"MTNE.Web.OneWeb.^.*\p{Proxy}+$").ToHashSet()
from t in soapClientTypes.UsingAny(mnteTypes)
select new { t, 
             mnteTypesUsed = t.TypesUsed.Intersect(mnteTypes) }

Notice how we first define 2 sets, and also use the extension method ToHashSet() to optimize the execution of the Intersect() method.

Notice also the usage of the method UsingAny() that, in a single call, perform a lot of work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文