Check that AsmABC is the only assembly that is using System.Collections.Concurrent

Rule ND9905 Samples of Custom rules / Check Architecture

A sample rule to adapt to your need: enforces that a particular assembly is only used by another particular assembly.

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 AsmABC is the only assembly that is using System.Collections.Concurrent</Name>
// <Id>ND9905:ExplicitId9905</Id>

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

//<Expl>
// The *{0}* is using *System.Collections.Concurrent* but only the *assembly AsmABC* should use it.
//</Expl>

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

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

Samples of Custom rules / Check Architecture: all 10 items