CQL to CQLinq Automatic Conversion

Since NDepend v4, the CQLinq language replaces the CQL language. The CQL languages is still 100% supported for compatibility reasons. If you used NDepend before v4, it is advised to convert your CQL queries and rules to the CQLinq syntax. While CQL can lead to a bit faster execution of code queries, there are no significant reasons to prefer CQL over CQLinq.

An automatic converter from CQL to CQLinq is proposed. This converter only works for CQL queries and rules that compile. There are 4 ways to use this converter:
  • Convert a CQL query edited to the CQLinq syntax: Just click the wizard button that appears automatically in the query editor when a CQL query or rule is edited. The conversion is considered as a modification by the query editor, and just doing undo with Ctrl+Z will cancel it:


  • Convert several CQL queries to the CQLinq syntax at once: Just right-click a group in the Queries and Rules Explorer panel. If the group contains some CQL queries, a menu is shown to convert them to CQLinq. When clicking the menu, a message box will appear to ask you if you want to create a backup NDepend project file, before the conversion.


  • Use the Power Tool to convert all CQL queries of an NDepend project to the CQLinq syntax: An open-source Power tool exists to convert all CQL queries of a NDepend project to the CQLinq syntax. The power tool will ask you if you want to create a backup NDepend project file, before the conversion.


  • Programmatically convert some CQL queries to the CQLinq syntax: The single extension method ConvertToCQLinq() is proposed to use the CQL to CQLinq converter. This extension method is used in the source code of the Power Tool shown above. If you want to use this method, we advise to get inspired from this Power Tool source code contained in $NDependInstallDir$\NDepend.PowerTools.SourceCode\CQL2CQLinq\CQL2CQLinqPowerTool.cs.