Check that all namespaces begins with CompanyName.ProductName

Rule ND9916 Samples of Custom rules / Custom Naming Conventions

A widely adopted practice: all namespaces of a product start with "CompanyName.ProductName". Adapt the rule with your own "CompanyName.ProductName".

How to fix

Update all namespaces definitions in source code to satisfy this rule.

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 all namespaces begins with CompanyName.ProductName</Name>
// <Id>ND9916:ExplicitId9916</Id>

warnif count > 0 from n in Application.Namespaces where 
  !n.NameLike (@"^CompanyName.ProductName")
select new { 
   n, 
   n.NbLinesOfCode,
   Debt = 10.ToMinutes().ToDebt(),
   Severity = Severity.High
} 

//<Expl>
// The *{0}* name should start with *CompanyName.ProductName*.
//</Expl>

//<Desc>
// A widely adopted practice: all namespaces of a product start with
// "CompanyName.ProductName". Adapt the rule with your own
// **"CompanyName.ProductName"**.
//</Desc>

//<HowToFix>
// Update all namespaces definitions in source code to satisfy this rule.
//</HowToFix>

Samples of Custom rules / Custom Naming Conventions: all 2 items