stride3d/stride · error · ArgumentNullException

Attributes can not be null

Error message

Attributes can not be null

What it means

SerializerSettings.Attributes must reference an IAttributeRegistry used to look up custom attributes during serialization. Assigning null throws ArgumentNullException since attribute resolution is a required component of the pipeline.

Solutions

  1. Assign a live IAttributeRegistry instance (e.g. the registry provided by the service registry / AssetRegistry)
  2. Initialize the registry before constructing SerializerSettings

Example fix

// before
settings.Attributes = null;
// after
settings.Attributes = new AttributeRegistry();
Defensive patterns

Strategy: validation

Validate before calling

settings.Attributes = attributeRegistry ?? new AttributeRegistry();

Try / catch

try { settings.Attributes = registry; } catch (ArgumentNullException) { settings.Attributes = new AttributeRegistry(); }

Prevention

When it happens

Trigger: `settings.Attributes = null`, or passing a registry obtained from a failed service lookup.

Common situations: Custom serializer bootstrap code where the registry is resolved lazily and can be null; copying settings between environments.

Related errors


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

Appendix: source

Thrown at sources/core/Stride.Core.Yaml/Serialization/SerializerSettings.cs:274

                    throw new ArgumentException(
                        "Expecting length >= 2 and at least a special character '.', '~', '-' (not starting on first char for '-')");
                }

                specialCollectionMember = value;
            }
        }

        /// <summary>
        /// Gets the attribute registry.
        /// </summary>
        /// <value>The attribute registry.</value>
        public IAttributeRegistry Attributes
        {
            get { return attributeRegistry; }
            set
            {
                if (value == null)
                    throw new ArgumentNullException("value", $"{nameof(Attributes)} can not be null");
                attributeRegistry = value;
            }
        }

        /// <summary>
        /// Gets or sets the ObjectSerializerBackend. Default implementation is <see cref="DefaultObjectSerializerBackend"/>
        /// </summary>
        /// <value>The ObjectSerializerBackend.</value>
        public IObjectSerializerBackend ObjectSerializerBackend
        {
            get { return objectSerializerBackend; }
            set
            {
                if (value == null)
                    throw new ArgumentNullException("value", $"{nameof(ObjectSerializerBackend)} can not be null");
                objectSerializerBackend = value;
            }
        }

View on GitHub (pinned to 96fad776d2)