stride3d/stride · warning · InvalidOperationException

Internal error, the collection has already muted to a…

Error message

Internal error, the collection has already muted to a dictionary.

What it means

The private ChangeOver method converts the internal list storage to a Dictionary; it throws InvalidOperationException if the transition already happened (list is null). This is an internal invariant guard — user code should never trigger it directly; hitting it indicates a bug or misuse via reflection.

Solutions

  1. Report as a bug if hit through normal public API usage
  2. Avoid concurrent mutation of the HybridDictionary from multiple threads without synchronization
  3. Do not call private members via reflection
Defensive patterns

Strategy: try-catch

Try / catch

try { collection.Add(kvp); }
catch (InvalidOperationException) { /* internal invariant bug — report */ }

Prevention

When it happens

Trigger: Only reachable if ChangeOver is invoked after the collection already cut over to dictionary mode — an internal invariant violation, not a normal usage error.

Common situations: Practically never hit by library users; would indicate corrupted internal state, a race between threads mutating the collection, or reflection-based misuse.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/93e42d6482fb3de9. Report an issue: GitHub.

Appendix: source

Thrown at sources/core/Stride.Core.Design/Collections/HybridDictionary.cs:339

        if (list != null)
        {
            if (list.Count + 1 < CutoverPoint)
            {
                list.Add(item);
                return;
            }
            else
            {
                ChangeOver();
            }
        }
        dictionary!.Add(item.Key, item.Value);
    }

    private void ChangeOver()
    {
        if (list == null)
            throw new InvalidOperationException("Internal error, the collection has already muted to a dictionary.");

        dictionary = new Dictionary<TKey, TValue>(InitialDictionarySize, keyComparer);
        foreach (var item in list)
        {
            dictionary.Add(item.Key, item.Value);
        }
        list = null;
    }
}

View on GitHub (pinned to 96fad776d2)