Writing your own CQLinq (NDepend) functions

To be honest this is well documented on NDpend’s web site – Defining a procedure in a query.

A previous post on CQLinq covered using a query to filter types for use in another CQLinq query. An alternate might be to create your own filter function.

To create a function in CQLinq we can simply create a Func variable and then create the code that is called when the variable is used, for example

let Ignore = new Func<IField, bool>(f => 
   f.ParentAssembly.Name == "ThirdPartAssembly"
)

Now to use the function we simply use it like this

from f in JustMyCode.Fields where
   !Ignore(f)