stride3d/stride · error · ArgumentException
Expecting length >= 2 and at least a special character '.'…
Error message
Expecting length >= 2 and at least a special character '.', '~', '-' (not starting on first char for '-')
What it means
SpecialCollectionMember must be a string of length >= 2 containing at least one of the characters '.', '~', or '-' (with '-' not allowed as the first character), because the value is interpreted as a qualified member pattern rather than a plain name. Plain names or too-short strings throw ArgumentException.
Solutions
- Use the fully qualified form including a type separator, e.g. "MyNamespace.MyType~MyCollection" or "MyNamespace.MyType.Member"
- Ensure length >= 2 and that '-' is not the first character
Example fix
// before settings.SpecialCollectionMember = "Items"; // after settings.SpecialCollectionMember = "MyApp.Model.MyType~Items";
Defensive patterns
Strategy: validation
Validate before calling
bool IsValidSpecialMember(string v) => v != null && v.Length >= 2 && (v.Contains(".") || v.Contains("~") || v.IndexOf('-') > 0);
if (!IsValidSpecialMember(memberName)) throw new FormatException($"{memberName} is not a qualified special collection member"); Type guard
bool IsValidSpecialMember(string v) => v != null && v.Length >= 2 && (v.Contains(".") || v.Contains("~") || v.IndexOf('-') > 0); Try / catch
try { settings.SpecialCollectionMember = memberName; } catch (ArgumentException ex) { throw new FormatException("Invalid SpecialCollectionMember", ex); } Prevention
- Always use fully qualified member patterns (Type.Member or Type~Member)
- Never assign bare property names or single characters
When it happens
Trigger: Setting SpecialCollectionMember to values like "x", "items", "a-", or any string lacking '.', '~' and a non-initial '-'.
Common situations: Typing a bare property name instead of the fully qualified pattern; trimming/cleaning config values so separators are lost.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Expecting value > 0
- NamingConvention can not be null
- specialCollectionMember can not be null
- 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/e914ec762baff00e.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Serialization/SerializerSettings.cs:256
/// <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
{
get { return attributeRegistry; }
set
{
if (value == null)
throw new ArgumentNullException("value", $"{nameof(Attributes)} can not be null");View on GitHub (pinned to 96fad776d2)