CQL Query Composition

Can I query queries in CQL?

I would like to write something like:

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

Thanks Vans

+3
source share
1 answer

The NDepend team is proud to finally give an elegant answer to this question :) Thanks to the new NDepend v4 function, the LINQ Code Query Function (CQLinq) , what you ask for can be written, for example:

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 a request, but this method is by far the most concise and optimized one (the upper right panel reports that it is completed in 4 ms):

Code Query Composition through CQLinq

+3
source

All Articles