Skip to main content

DebuggingCollection<T>

A class in Root.Township, Alta.Utilities.

Collection wrapper that logs an error with a stack trace when it is changed during enumeration, so you can find the code that did it.

Constructors​

MemberWhat it is
DebuggingCollection(ICollection<T> internalCollection)Creates a DebuggingCollection from internalCollection.

Fields​

3 private and internal fields
MemberWhat it is
private DebuggingCollection<T, T> enumeratorThe latest enumerator handed out.
private ICollection<T> internalCollectionThe wrapped collection.
private static Logger loggerClass logger.

Properties​

MemberWhat it is
int Count { get; }Item count of the wrapped collection.
bool IsReadOnly { get; }Read-only flag of the wrapped collection.

Methods​

MemberWhat it is
void Add(T item)Adds to the wrapped collection. Logs an error first if an enumeration is running.
void Clear()Clears the wrapped collection. Logs an error first if an enumeration is running.
bool Contains(T item)Passes through to the wrapped collection.
void CopyTo(T[] array, int arrayIndex)Passes through to the wrapped collection.
IEnumerator GetEnumerator()Returns a tracking enumerator over the wrapped collection. Only the latest one handed out is watched.
bool Remove(T item)Removes from the wrapped collection. Logs an error first if an enumeration is running.
2 private and internal methods
MemberWhat it is
private void CheckForEnumerationViolation()Logs an error with a stack trace if the latest enumerator is still running.
private void RemoveEnumerator()Callback that stops tracking once enumeration reaches the end.