Properties and fields that represent a collection of items should be named Items.

Rule ND2017 Naming Conventions

Properties and fields typed with a collection of items should be named with the plural form of Items (e.g. NewDirectories, Words, Values), for readability and predictability.

No warning when any word in the identifier ends with s (TasksToRun, KeysDisabled, ListOfElementsInResult… are valid), nor when the identifier contains Empty (common pattern for a shared immutable empty collection).

Collection types are those implementing IEnumerable<T>, except:

- Non generic types: rarely seen as collections (e.g. System.String implements IEnumerable<char> but strings are named like FirstName).

- Dictionaries: mappings rather than collections, commonly suffixed Map, Table or Dictionary (though names like PersonsByNames often satisfy this rule anyway).

How to fix

Rename by making plural the word best describing the items:

- ListOfDir can be renamed Directories.

- Children can be renamed ChildrenItems

- QueueForCache can be renamed QueueOfItemsForCache

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>Properties and fields that represent a collection of items should be named Items.</Name>
// <Id>ND2017:PropertiesAndFieldsThatRepresentACollectionOfItemsShouldBeNamedItems</Id>

warnif count > 0 

let collectionTypes = Types.Where(t => 
   t.Implement("System.Collections.Generic.IEnumerable<T>".AllowNoMatch()) &&
   t.IsGeneric && 
   t.FullName != "System.Collections.Generic.IDictionary<TKey,TValue>" &&
  !t.Implement("System.Collections.Generic.IDictionary<TKey,TValue>".AllowNoMatch()) &&
   t.FullName != "System.Collections.Generic.IReadOnlyDictionary<TKey,TValue>" &&
  !t.Implement("System.Collections.Generic.IReadOnlyDictionary<TKey,TValue>".AllowNoMatch())).ToHashSetEx()

let properties = from p in JustMyCode.Properties
where p.PropertyType != null && collectionTypes.Contains(p.PropertyType)
select new { Member = (IMember)p, Type = p.PropertyType }

let fields = from f in JustMyCode.Fields
where f.FieldType != null && collectionTypes.Contains(f.FieldType)
select new { Member = (IMember)f, Type = f.FieldType }

from pair in properties.Concat(fields)
let identifier = pair.Member.SimpleName
where !identifier.EndsWith("s") &&
      !identifier.Contains('<') // Remove potential generated fields like backing fields, and also potential generated properties accessors

let words = identifier.GetWords()
where !words.Any(word => 
          word.EndsWith("s") ||  // Don't warn if any word ends with an s
          word == "Empty")       // Don't warn if any word in the identifier is Empty

select new { pair.Member, pair.Type  }

//<Expl>
// The *{0}* is typed with the *collection {1}*.
// Its name should contain the plural form of *Items* 
// in the collection to enhance code readability.
//</Expl>

//<Desc>
// Properties and fields typed with a collection of *items* should be named
// with the plural form of *Items* (e.g. *NewDirectories*, *Words*,
// *Values*), for readability and predictability.
//
// No warning when any word in the identifier ends with *s* (**TasksToRun**,
// **KeysDisabled**, **ListOfElementsInResult**… are valid), nor when the
// identifier contains **Empty** (common pattern for a shared immutable
// empty collection).
//
// Collection types are those implementing *IEnumerable<T>*, except:
//
// - Non generic types: rarely seen as collections (e.g. *System.String*
//   implements *IEnumerable<char>* but strings are named like *FirstName*).
//
// - Dictionaries: mappings rather than collections, commonly suffixed
//   *Map*, *Table* or *Dictionary* (though names like *PersonsByNames*
//   often satisfy this rule anyway).
//</Desc>

//<HowToFix>
// Rename by making plural the word best describing the *items*:
//
// - **ListOfDir** can be renamed **Directories**.
//
// - **Children** can be renamed **ChildrenItems**
//
// - **QueueForCache** can be renamed **QueueOfItemsForCache**
//</HowToFix>

Naming Conventions: all 23 items