NDepend and Code Query Linq (CQLinq)

What is NDepend?

NDepend is one of the popular tool to analyse the .NET code that supports huge number of code metrics and also includes some cool visualization of the dependencies in your .NET assembly and also lets you achieve high code quality.

Below is a screenshot of my Windows Phone project that was analysed using NDepend 4.

One of the cool feature of the NDepend 4 is the support for Code Query Linq (CQLinq) .The CQLinq lets the developers to query the .NET code using LINQ queries.

CQLinq query can be edited in Visual Studio or NDepend Professional (Standalone) Application.

CQLinq has some advantages like

  • Easy to query the .NET code with the Linq query
  • Let’s you to query a huge code base quickly
  • Code completion or intellisense support
  • Tooltip documentation on mouse hovering.

For example, assume that you need to identify all the methods in project that is more than 10 lines of code. How do we achieve it?

NDepend makes it easy with the CQLinq to solve scenarios like this.

from m in Methods where m.NbLinesOfCode >10
select m

In the above example, there is a predefined domain called “Methods” which is a IEnumerable<Methods> that lets you to query the Methods. Similarly, NDepend defines other predefined domains like

  • Types
  • Fields
  • Namespaces
  • Assemblies
  • And more…

Interesting isn’t it? I will explore more about the NDepend and write about it in the coming posts.

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Reply


Interesting BlogPosts to read

Column Alias and Square brackets in SQL Query.
When we want to specify a alias for a column in SQL Query , we tend to use the double quotes or sing...
How to get the MAX row with group by in LINQ query using C# ?
Below is a sample code snippet demonstrating how to retreive the max row with the group by in LINQ Q...
How to Merge string Arrays and keep distinct values using LINQ in C# ?
Do you want to merge string arrays and yet want to keep the distinct values in C# ? . One of the opt...