AvaloniaUI/Avalonia · warning · InvalidOperationException

Enumeration has ended.

Error message

Enumeration has ended.

What it means

Centralized ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumEnded throws InvalidOperationException "Enumeration has ended." It is the BCL-style helper for reading Current after MoveNext returned false. As with error 133, it has no active call site in this codebase: the shipped PooledStack enumerator inlines its own "Enumeration has ended." message, and PooledList uses the combined EnumOpCantHappen helper. Reserved/vestigial.

Source

Thrown at src/Avalonia.Base/Collections/Pooled/ThrowHelper.cs:294

            throw new OutOfMemoryException();
        }

        [DoesNotReturn]
        internal static void ThrowArgumentException_Argument_InvalidArrayType()
        {
            throw new ArgumentException("Invalid array type.");
        }

        [DoesNotReturn]
        internal static void ThrowInvalidOperationException_InvalidOperation_EnumNotStarted()
        {
            throw new InvalidOperationException("Enumeration has not started.");
        }

        [DoesNotReturn]
        internal static void ThrowInvalidOperationException_InvalidOperation_EnumEnded()
        {
            throw new InvalidOperationException("Enumeration has ended.");
        }

        [DoesNotReturn]
        internal static void ThrowInvalidOperationException_EnumCurrent(int index)
        {
            throw GetInvalidOperationException_EnumCurrent(index);
        }

        [DoesNotReturn]
        internal static void ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion()
        {
            throw new InvalidOperationException("Collection was modified during enumeration.");
        }

        [DoesNotReturn]
        internal static void ThrowInvalidOperationException_InvalidOperation_EnumOpCantHappen()
        {
            throw new InvalidOperationException("Invalid enumerator state: enumeration cannot proceed.");

View on GitHub (pinned to 11c5427268)

Solutions

  1. Unreachable via shipped enumerators — verify you are not invoking a forked enumerator.
  2. If you maintain such an enumerator, reset or recreate the enumerator instead of reading Current after exhaustion.
  3. Use foreach to avoid reading Current after MoveNext returns false.
Defensive patterns

Strategy: validation

Validate before calling

// Unreachable via shipped enumerators. Do not read Current after MoveNext
// returns false; recreate the enumerator to restart.

Prevention

When it happens

Trigger: Would be thrown by an enumerator's Current getter when the cursor is past the last element. Not routed to by any shipped enumerator here.

Common situations: Not reachable via public enumerators; would surface only from a custom enumerator that calls this helper.

Related errors


AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13). Data as JSON: /api/errors/af303c75a0e83956. Report an issue: GitHub.