Check that only 3 assemblies are using System.Collections.Concurrent

Rule ND9906 Samples of Custom rules / Check Architecture

A sample rule to adapt to your need: enforces that a particular assembly is only used by any 3 other assemblies.

How to fix

This is a sample rule, there is nothing to fix as is.

CQLinq source

This rule is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.

// <Name>Check that only 3 assemblies are using System.Collections.Concurrent</Name>
// <Id>ND9906:ExplicitId9906</Id>

warnif count != 3 from a in Application.Assemblies where 
  a.IsUsing ("System.Collections.Concurrent".AllowNoMatch().MatchAssembly())
select new {
   a,
   Debt = 30.ToMinutes().ToDebt(),
   Severity = Severity.High
}

//<Expl>
// The *{0}* are using *System.Collections.Concurrent* but only 3 assemblies should be using it.
//</Expl>

//<Desc>
// A *sample rule to adapt to your need*: enforces that a particular
// assembly is **only used by** any 3 other assemblies.
//</Desc>

//<HowToFix>
// This is a *sample rule*, there is nothing to fix *as is*.
//</HowToFix>

Samples of Custom rules / Check Architecture: all 10 items