Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CQL request composition

Tags:

cql

ndepend

Is it possible to compose requests in CQL ?

I would like to write something like:

SELECT TYPES FROM ASSEMBLIES "myassemblie" WHERE IsUsing SELECT METHODS FROM ASSEMBLIES "myotherassemblie" WHERE IsStatic

Thanks, Vans

like image 399
vans Avatar asked Jun 25 '26 13:06

vans


1 Answers

The NDepend team is proud to finally provides an elegant answer to this question :) Thanks to the new NDepend v4 Code Query LINQ (CQLinq) feature, what you are asking for can be written for example like:

let staticMethods = Application.Assemblies.WithName("nunit.core")
                    .ChildMethods().Where(m => m.IsStatic)

from t in Application.Assemblies.WithName("nunit.util")
          .ChildTypes().UsingAny(staticMethods )

let staticMethodsUsed = staticMethods.UsedBy(t)
select new { t, staticMethodsUsed  }

There are many other ways to write such query, but this way is certainly the most concise and optimized one (the top-right panel tells it is executed in 4ms):

Code Query Composition through CQLinq

like image 102
Patrick from NDepend team Avatar answered Jun 27 '26 03:06

Patrick from NDepend team



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!