Critical Rules and Build Failure

NDepend comes with the notion of Critical CQLinq Rule. Critical rules represent a mean to define high priority rules that must never be violated. With critical rules, it is possible to break the Build Process when a critical rule violation occurs.

A critical rule is just a CQLinq rule with the flag Critical Rule checked:



At Build Process time, when a critical rule is violated the process NDepend.Console.exe returns a non-zero exit code. For that, the report section CQLinq Rules Violated must be activated in the NDepend Project. This behavior can be used to break the Build Process if a critical rule is violated. Also, NDepend.Console.exe outputs in the $OutDir$ a file named CodeRuleCriticalResult.xml that contains the names of the rules violated. Hence, this information can be easily used by the Build Process if needed.



At Development time, the NDepend interactive UI (integrated in VisualStudio, or VisualNDepend.exe standalone) comes with several visual indicators when a critical rule is violated:

  • The bottom-right circle becomes red.
  • The number of critical rule violated is shown in the bottom-right circle tooltip panel.
  • In Queries and Rules Explorer panel, violated rules status have a top-left red flag.
  • In Queries and Rules Explorer panel, the status of groups that contains a violated rules have a top-left red flag.





▲▲ Go to Top ▲▲