stride3d/stride · error · ArgumentOutOfRangeException
Expecting value > 0
Error message
Expecting value > 0
What it means
SerializerSettings.PreferredIndent rejects any value less than 1 with an ArgumentOutOfRangeException. The property controls the number of spaces used for YAML block indentation, which must be a positive integer for the emitter to produce valid nested output. It is a guard against misconfigured serializer settings.
Solutions
- Set PreferredIndent to a positive integer (commonly 2 or 4)
- Clamp or default the value when loading from configuration: `settings.PreferredIndent = Math.Max(1, configuredIndent)`
Example fix
// before
var settings = new SerializerSettings { PreferredIndent = indentFromConfig }; // 0
// after
var settings = new SerializerSettings { PreferredIndent = indentFromConfig > 0 ? indentFromConfig : 2 }; Defensive patterns
Strategy: validation
Validate before calling
if (settings.PreferredIndent < 1) settings.PreferredIndent = 2;
Try / catch
try { settings.PreferredIndent = indent; } catch (ArgumentOutOfRangeException) { settings.PreferredIndent = 2; } Prevention
- Never assign indent values straight from config without clamping to >= 1
- Default to 2 or 4, the common YAML conventions
When it happens
Trigger: Setting `new SerializerSettings().PreferredIndent = 0` (or any negative number) before constructing a Serializer with those settings.
Common situations: Reading the indent value from a config file or environment variable where it defaults to 0, or computing it from user input without clamping.
Related errors
- NamingConvention can not be null
- specialCollectionMember can not be null
- Expecting length >= 2 and at least a special character '.'…
- Attributes can not be null
- ObjectSerializerBackend can not be null
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/7234185ee2078d7c.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Serialization/SerializerSettings.cs:126
public ChainedSerializer PreSerializer { get; set; }
/// <summary>
/// Gets or sets a serializer that is executed after all other serializers, including <see cref="TagTypeSerializer"/>.
/// </summary>
public ChainedSerializer PostSerializer { get; set; }
/// <summary>
/// Gets or sets the preferred indentation. Default is 2.
/// </summary>
/// <value>The preferred indentation.</value>
/// <exception cref="System.ArgumentOutOfRangeException">value;Expecting value > 0</exception>
public int PreferredIndent
{
get { return preferredIndent; }
set
{
if (value < 1)
throw new ArgumentOutOfRangeException("value", "Expecting value > 0");
preferredIndent = value;
}
}
/// <summary>
/// Gets or sets a value indicating whether to emit anchor alias. Default is true.
/// </summary>
/// <value><c>true</c> to emit anchor alias; otherwise, <c>false</c>.</value>
public bool EmitAlias { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to emit tags when serializing. Default is true.
/// </summary>
/// <value><c>true</c> to emit tags when serializing; otherwise, <c>false</c>.</value>
public bool EmitTags { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the identation is trying to lessView on GitHub (pinned to 96fad776d2)