dotnetcore/CAP · error · NotImplementedException
Specified method is not supported.
Error message
Specified method is not supported.
What it means
CircularBuffer<T>.Contains(T item) is a stub that unconditionally throws NotImplementedException, surfaced as NotSupportedException ("Specified method is not supported.") via the ICollection<T> contract. The Dashboard's in-memory ring buffer simply never implemented membership testing. Calling it will always fail regardless of arguments.
Solutions
- Do not call Contains on CircularBuffer; implement the membership check in caller code by iterating the buffer manually.
- Implement Contains in CircularBuffer by iterating items and using EqualityComparer<T>.Default.Equals.
- If reached via LINQ, force enumeration with AsEnumerable() or ToList() first so a different Contains path is used.
- Upgrade DotNetCore.CAP in case a newer version implemented the method.
Example fix
// before
if (buffer.Contains(messageId)) { ... }
// after
bool contains = false;
foreach (var item in buffer)
{
if (EqualityComparer<string>.Default.Equals(item, messageId)) { contains = true; break; }
}
if (contains) { ... } Defensive patterns
Strategy: validation
Validate before calling
if (buffer is CircularBuffer<T> cb) { /* Contains unsupported */ }
// do membership check manually:
bool contains = false;
foreach (var item in buffer) if (EqualityComparer<T>.Default.Equals(item, target)) { contains = true; break; } Type guard
static bool SupportsContains<T>(ICollection<T> c) => !(c is DotNetCore.CAP.Dashboard.CircularBuffer<T>);
Try / catch
try { buffer.Contains(item); }
catch (NotImplementedException) { /* fall back to manual scan */ } Prevention
- Avoid LINQ Contains on CircularBuffer instances
- Wrap buffer in your own helper that implements membership via iteration
- Check the type before using generic ICollection<T> algorithms
When it happens
Trigger: Calling Contains(item) on any CircularBuffer<T> instance, e.g. code that treats the buffer as an ICollection<T>/IReadOnlyCollection<T> and invokes Contains for membership checks.
Common situations: LINQ chains that resolve to ICollection<T>.Contains (e.g. some Contains optimizations), custom dashboard code checking whether a message/id is already buffered, or generic collection algorithms that probe for membership before insert.
Related errors
- Value cannot be null. (Parameter 'array')
- Specified argument was out of the range of valid values…
- arrayIndex
- Specified method is not supported.
- Value cannot be null. (Parameter 'topicNames')
AI-assisted analysis of dotnetcore/CAP@e52b8508e5 (2026-09-14).
Data as JSON: /api/errors/aa0cad35e2ada4a2.
Report an issue: GitHub.
Appendix: source
Thrown at src/DotNetCore.CAP.Dashboard/CircularBuffer.cs:155
}
else
{
itemIndex = _firstIndex + Count;
Count++;
}
_items[itemIndex] = item;
}
public void Clear()
{
_firstIndex = 0;
Count = 0;
}
public bool Contains(T item)
{
throw new NotImplementedException();
}
public void CopyTo(T[] array, int arrayIndex)
{
if (array == null) throw new ArgumentNullException(nameof(array));
if (arrayIndex < 0) throw new ArgumentOutOfRangeException(nameof(arrayIndex));
if (Count > array.Length - arrayIndex) throw new ArgumentException("arrayIndex");
// Iterate through the buffer in correct order.
foreach (var item in this)
{
array[arrayIndex++] = item;
}
}
public bool Remove(T item)View on GitHub (pinned to e52b8508e5)