stride3d/stride · error · ArgumentException
Invalid half format.
Error message
Invalid half format.
What it means
Parse failure in Half3Converter.ConvertFrom: the string being converted to a Half3 does not match the expected numeric format (three comma/space-separated half values), so parsing was abandoned. The faulting input is the string passed via the value parameter to the type converter.
Solutions
- Provide exactly three values separated by the culture's list separator: '1.0, 2.0, 3.0'
- Match the culture used at write time when parsing (invariant vs localized)
- Pre-validate: trimmed string must contain exactly 2 separator characters and 3 non-empty parts
- Catch ArgumentException and normalize/retry with corrected format
Example fix
// before converter.ConvertFromString(null, culture, "1.0, 2.0") // after converter.ConvertFromString(null, culture, "1.0, 2.0, 3.0")
Defensive patterns
Strategy: validation
Validate before calling
var parts = s.Trim().Split(culture.TextInfo.ListSeparator[0]);
if (parts.Length != 3) throw new FormatException("Half3 needs exactly 3 values"); Try / catch
try { v = (Half3)converter.ConvertFrom(s); }
catch (ArgumentException) { /* prompt for 'x, y, z' format */ } Prevention
- Match writer/reader cultures
- Validate 3 parts before parsing
- Never paste 2D/4D data into Half3 fields
When it happens
Trigger: Calling ConvertFrom/ConvertFromString with a string splitting into != 3 parts: '1.5, 2.0' (2), '1.5, 2.0, 3.0, 4.0' (4), missing separators, or a locale with a different list separator than the one used in the string.
Common situations: Copy-pasting 2D or 4D vectors into a Half3 field; serialized scene data with wrong arity; regional settings (e.g. ';' separators or decimal commas) conflicting with the writer's culture.
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
- Invalid half format.
- Invalid half format.
- Invalid half format.
- The string does not match the expected format.
- Can't cast from to (more components)
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/69fec49aead60926.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Design/TypeConverters/Half3Converter.cs:128
/// </summary>
/// <param name = "context">A <see cref = "T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param>
/// <param name = "culture">A <see cref = "T:System.Globalization.CultureInfo" />. If <c>null</c> is passed, the current culture is assumed.</param>
/// <param name = "value">The <see cref = "T:System.Object" /> to convert.</param>
/// <returns>An <see cref = "T:System.Object" /> that represents the converted value.</returns>
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
{
culture ??= CultureInfo.CurrentCulture;
if (value is not string str)
{
return base.ConvertFrom(context, culture, value);
}
str = str.Trim();
TypeConverter converter = TypeDescriptor.GetConverter(typeof(Half));
char[] separator = [culture.TextInfo.ListSeparator[0]];
string[] stringArray = str.Split(separator);
if (stringArray.Length != 3)
{
throw new ArgumentException("Invalid half format.");
}
Half x = (Half)converter.ConvertFromString(context, culture, stringArray[0])!;
Half y = (Half)converter.ConvertFromString(context, culture, stringArray[1])!;
Half z = (Half)converter.ConvertFromString(context, culture, stringArray[2])!;
return new Half3(x, y, z);
}
/// <summary>
/// Converts the given value object to the specified type, using the specified context and culture information.
/// </summary>
/// <param name = "context">A <see cref = "T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param>
/// <param name = "culture">A <see cref = "T:System.Globalization.CultureInfo" />. If <c>null</c> is passed, the current culture is assumed.</param>
/// <param name = "value">The <see cref = "T:System.Object" /> to convert.</param>
/// <param name = "destinationType">A <see cref = "T:System.Type" /> that represents the type you want to convert to.</param>
/// <returns>An <see cref = "T:System.Object" /> that represents the converted value.</returns>
public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
{
#if NET6_0_OR_GREATERView on GitHub (pinned to 96fad776d2)