stride3d/stride · error · NotSupportedException

Collections that do not have indexer accessors are not…

Error message

Collections that do not have indexer accessors are not supported in Quantum.

What it means

DefaultNodeBuilder.VisitCollection throws NotSupportedException because Quantum graph nodes require collections to expose indexer accessors so individual items can be addressed and observed. Collections without indexers cannot be represented in the node graph.

Solutions

  1. Replace the collection with an indexer-backed type (List<T>, T[], Dictionary<K,V>, ObservableCollection<T>)
  2. Implement indexer accessors on your custom collection so its CollectionDescriptor reports HasIndexerAccessors
  3. Keep non-indexed collections out of the observed graph; wrap them in an indexed container
  4. Catch NotSupportedException during Build and fall back to manual handling of that member

Example fix

// before
public HashSet<string> Tags { get; } = new HashSet<string>();
// after
public ObservableCollection<string> Tags { get; } = new ObservableCollection<string>();
Defensive patterns

Strategy: validation

Validate before calling

var d = TypeDescriptorFactory.Default.Find(coll.GetType()); if (d is CollectionDescriptor cd && !cd.HasIndexerAccessors) throw new InvalidOperationException($"{coll.GetType()} has no indexer accessors");

Type guard

bool IsQuantumCompatible<T>(T c) => c is IList || c is System.Collections.IDictionary || c is Array;

Try / catch

try { container.Build(root); } catch (NotSupportedException ex) { logger.LogError(ex, "Unsupported collection in model"); }

Prevention

When it happens

Trigger: Building a node graph (Build/Visit) over a property or field whose type is IEnumerable-like but lacks an indexer, e.g. HashSet<T>, ISet<T>, or a custom IEnumerable<T> without this[int]/this[key].

Common situations: Exposing HashSet<T> or a custom collection in a model bound to Quantum; replacing a List<T> property with a set type; third-party collection types without indexer accessors.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at sources/presentation/Stride.Core.Quantum/DefaultNodeBuilder.cs:91

        }

        if (!PrimitiveTypeFilter.IsPrimitiveType(currentDescriptor.Type))
        {
            base.VisitObject(obj, descriptor, true);
        }

        if (isRootNode)
        {
            PopContextNode();
            rootNode!.Seal();
        }
    }

    /// <inheritdoc/>
    public override void VisitCollection(IEnumerable collection, CollectionDescriptor descriptor)
    {
        if (!descriptor.HasIndexerAccessors)
            throw new NotSupportedException("Collections that do not have indexer accessors are not supported in Quantum.");

        // Don't visit items unless they are primitive or enumerable (collections within collections)
        if (IsCollection(descriptor.ElementType))
        {
            base.VisitCollection(collection, descriptor);
        }
    }

    /// <inheritdoc/>
    public override void VisitDictionary(object dictionary, DictionaryDescriptor descriptor)
    {
        if (!PrimitiveTypeFilter.IsPrimitiveType(descriptor.KeyType))
            throw new InvalidOperationException("The type of dictionary key must be a primary type.");

        // Don't visit items unless they are primitive or enumerable (collections within collections)
        if (IsCollection(descriptor.ValueType))
        {
            base.VisitDictionary(dictionary, descriptor);

View on GitHub (pinned to 96fad776d2)