stride3d/stride · error · ArgumentNullException

specialCollectionMember can not be null

Error message

specialCollectionMember can not be null

What it means

SerializerSettings.SpecialCollectionMember names the property treated as a special collection (must look like a qualified member name, length >= 2, containing '.', '~' or '-' not in first position). Setting it to null throws ArgumentNullException because null is not a meaningful member selector.

Solutions

  1. Assign a valid qualified member name string, e.g. "Namespace.Type~Member"
  2. Leave the property unset if no special collection member is needed instead of assigning null

Example fix

// before
settings.SpecialCollectionMember = config.SpecialMember; // null
// after
if (config.SpecialMember != null) settings.SpecialCollectionMember = config.SpecialMember;
Defensive patterns

Strategy: validation

Validate before calling

if (memberName != null) settings.SpecialCollectionMember = memberName;

Try / catch

try { settings.SpecialCollectionMember = memberName; } catch (ArgumentNullException) { /* leave default */ }

Prevention

When it happens

Trigger: `settings.SpecialCollectionMember = null` or assigning a variable that was never initialized.

Common situations: Copying settings objects field-by-field and passing through nulls; config lookup returning null for the member name.

Related errors


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

Appendix: source

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

        /// Gets or sets the prefix used to serialize items for a non pure <see cref="System.Collections.IDictionary" /> or
        /// <see cref="System.Collections.ICollection" />
        /// . Default to "~Items", see remarks.
        /// </summary>
        /// <value>The prefix for items.</value>
        /// <exception cref="System.ArgumentNullException">value</exception>
        /// <exception cref="System.ArgumentException">Expecting length >= 2 and at least a special character '.', '~', '-' (not starting on first char for '-')</exception>
        /// <remarks>A pure <see cref="System.Collections.IDictionary" /> or <see cref="System.Collections.ICollection" /> is a class that inherits from these types but are not adding any
        /// public properties or fields. When these types are pure, they are respectively serialized as a YAML mapping (for dictionary) or a YAML sequence (for collections).
        /// If the collection type to serialize is not pure, the type is serialized as a YAML mapping sequence that contains the public properties/fields as well as a
        /// special fielx (e.g. "~Items") that contains the actual items of the collection (either a mapping for dictionary or a sequence for collections).
        /// The <see cref="SpecialCollectionMember" /> is this special key that is used when serializing items of a non-pure collection.</remarks>
        public string SpecialCollectionMember
        {
            get { return specialCollectionMember; }
            set
            {
                if (value == null)
                    throw new ArgumentNullException("value", $"{nameof(specialCollectionMember)} can not be null");

                // TODO this is a poor check. Need to verify this against the specs
                if (value.Length < 2 || !(value.Contains(".") || value.Contains("~") || value.IndexOf('-') > 0))
                {
                    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
        {

View on GitHub (pinned to 96fad776d2)