{"record":{"id":"01e64df2749c1e44","repo":"stride3d/stride","slug":"unable-to-set-the-node-value-the-collection-is-unsupported-01e64d","errorCode":null,"errorMessage":"Unable to set the node value, the collection is unsupported","messagePattern":"Unable to set the node value, the collection is unsupported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Quantum/ObjectNode.cs","lineNumber":109,"sourceCode":"            NodeIndex index = NodeIndex.Empty;\n            switch (collectionDescriptor.Category)\n            {\n                case DescriptorCategory.List:\n                    index = new NodeIndex(collectionDescriptor.GetCollectionCount(value));\n                    break;\n                case DescriptorCategory.Set:\n                    index = new NodeIndex(newItem);\n                    break;\n            }\n            var args = new ItemChangeEventArgs(this, index, ContentChangeType.CollectionAdd, null, newItem);\n            NotifyItemChanging(args);\n            collectionDescriptor.Add(value, newItem);\n            UpdateReferences();\n            NotifyItemChanged(args);\n        }\n        else\n        {\n            throw new NotSupportedException(\"Unable to set the node value, the collection is unsupported\");\n        }\n    }\n\n    /// <inheritdoc/>\n    public void Add(object newItem, NodeIndex itemIndex)\n    {\n        if (Descriptor is CollectionDescriptor collectionDescriptor)\n        {\n            var index = collectionDescriptor.Category == DescriptorCategory.Collection\n                ? NodeIndex.Empty\n                : itemIndex;\n            var args = new ItemChangeEventArgs(this, index, ContentChangeType.CollectionAdd, null, newItem);\n            NotifyItemChanging(args);\n            if (!collectionDescriptor.HasInsert || collectionDescriptor.GetCollectionCount(value) == itemIndex.Int)\n            {\n                collectionDescriptor.Add(value, newItem);\n            }\n            else","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Quantum/ObjectNode.cs#L91-L127","documentation":"Add attempts to insert an item into the node's underlying collection, but the collection's descriptor does not support the Add operation (e.g. it is not a list/array-like collection with a known Add strategy). The library throws NotSupportedException because the value cannot be applied to this kind of collection. This is an API-usage/unsupported-collection error, not a data error.","triggerScenarios":"Calling Add(object, NodeIndex) (or the value-update path that routes into it) on a node whose collection descriptor has no Add implementation — e.g. an immutable collection, an IDictionary-like type without a compatible overload, or a non-collection value node.","commonSituations":"Attempting to add items to readonly arrays, immutable lists (ImmutableArray/ImmutableList), or custom collections without a registered ICollectionDescriptor; treating a plain object node as a collection; custom type descriptors that did not implement Add.","solutions":["Verify the underlying type actually supports Add (IList, array with resize semantics, registered ICollectionDescriptor)","Register a custom ITypeDescriptor/CollectionDescriptor that implements Add for your custom collection type","Replace the collection with a mutable, descriptor-supported type before mutating via the node","Use Update on existing indices instead of Add when the collection has fixed size (e.g. arrays)"],"exampleFix":"// before\nnode.Add(newItem, index); // NotSupportedException on ImmutableList\n// after\nvar newList = immutableList.Add(newItem);\nnode.Update(newList); // replace the whole value for unsupported collections","handlingStrategy":"try-catch","validationCode":"if (node.Descriptor is ICollectionDescriptor cd && !cd.SupportsAdd) throw new InvalidOperationException(\"Collection does not support Add\");","typeGuard":"static bool CollectionSupportsAdd(object collection) => collection is System.Collections.IList || collection is System.Collections.Generic.ICollection<object>;","tryCatchPattern":"try { node.Add(newItem, index); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"collection is unsupported\"))\n{ /* replace the whole value via Update or mutate the source collection and refresh */ }","preventionTips":["Only Add via nodes whose underlying collection is mutable and descriptor-supported","Register ICollectionDescriptor implementations for custom collection types","For fixed-size or immutable collections, replace the whole value with Update instead of Add"],"tags":["csharp","quantum","collections","not-supported"],"backgroundTag":"unsupported-operation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}