stride3d/stride · error · ArgumentNullException

NamingConvention can not be null

Error message

NamingConvention can not be null

What it means

SerializerSettings.NamingConvention is a required dependency used to convert member names to/from YAML keys. Assigning null throws ArgumentNullException because the serializer cannot function without a naming convention (e.g. CamelCase, UnderscoreDashed).

Solutions

  1. Assign a concrete IMemberNamingConvention such as new CamelCaseNamingConvention() or CoreYamlNamingConvention.Instance
  2. Guard any lookup that produces the convention before assigning it

Example fix

// before
settings.NamingConvention = null;
// after
settings.NamingConvention = new CamelCaseNamingConvention();
Defensive patterns

Strategy: validation

Validate before calling

if (convention == null) convention = new CamelCaseNamingConvention();
settings.NamingConvention = convention;

Type guard

bool IsValidConvention(IMemberNamingConvention c) => c != null;

Try / catch

try { settings.NamingConvention = convention; } catch (ArgumentNullException) { settings.NamingConvention = new CamelCaseNamingConvention(); }

Prevention

When it happens

Trigger: Assigning null explicitly: `settings.NamingConvention = null`, or passing a null-returning factory/resolved value into the property.

Common situations: Resolving the convention via DI or a config string lookup that fails and returns null; refactor removing a default convention instance.

Related errors


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

Appendix: source

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

        public IComparer<object> ComparerForKeySorting { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to serialize dictionary items as regular members.s
        /// </summary>
        /// <value><c>true</c> if [enable dictionary items as members]; otherwise, <c>false</c>.</value>
        public bool SerializeDictionaryItemsAsMembers { get; set; }

        /// <summary>
        /// Gets or sets the naming convention. Default is to output name as-is <see cref="DefaultNamingConvention"/>.
        /// </summary>
        /// <value>The naming convention.</value>
        public IMemberNamingConvention NamingConvention
        {
            get { return _namingConvention; }
            set
            {
                if (value == null)
                    throw new ArgumentNullException("value", $"{nameof(NamingConvention)} can not be null");
                _namingConvention = value;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether to emit short type name (type, assembly name) or full <see cref="Type.AssemblyQualifiedName"/>. Default is false.
        /// </summary>
        /// <value><c>true</c> to emit short type name; otherwise, <c>false</c>.</value>
        public bool EmitShortTypeName { get { return AssemblyRegistry.UseShortTypeName; } set { AssemblyRegistry.UseShortTypeName = value; } }

        /// <summary>
        /// Gets the tag type registry.
        /// </summary>
        /// <value>The tag type registry.</value>
        public ITagTypeRegistry TagTypeRegistry { get { return AssemblyRegistry; } }

        /// <summary>
        /// Gets or sets the default <see cref="DataStyle"/>. Default is <see cref="DataStyle.Normal"/>. See <see cref="DynamicStyleFormat"/> to understand the resolution of styles.

View on GitHub (pinned to 96fad776d2)