stride3d/stride · error · ArgumentException
Could not parse semantic index from the semantic name
Error message
Could not parse semantic index from the semantic name
What it means
VertexElement's string-based constructor parses an optional numeric index out of the semantic name (e.g. "TEXCOORD0"). If the name matches a pattern with a trailing/numeric component that fails uint.TryParse, the library cannot extract the semantic index and throws ArgumentException.
Solutions
- Use a valid semantic name with an integer index suffix, e.g. "TEXCOORD0"
- Drop the suffix entirely if no index is needed (index defaults to 0)
- Use the explicit-index constructor overload with a plain semantic name like "TEXCOORD" and semanticIndex: 1
Example fix
// before
new VertexElement("TEXCOORDu", PixelFormat.R32G32_Float)
// after
new VertexElement("TEXCOORD0", PixelFormat.R32G32_Float)
// or
new VertexElement("TEXCOORD", 0, PixelFormat.R32G32_Float) Defensive patterns
Strategy: validation
Validate before calling
static readonly Regex ok = new Regex(@"^(?<name>[A-Za-z]+)(?<idx>\d*)$");
bool IsValidSemantic(string s) { var m = ok.Match(s); return m.Success && (m.Groups["idx"].Value == "" || uint.TryParse(m.Groups["idx"].Value, out _)); } Try / catch
try { var e = new VertexElement(name, format); } catch (ArgumentException) { useExplicitIndexConstructor(); } Prevention
- Only use integer suffixes on semantic names
- Prefer the explicit (name, index, format) constructor to avoid string parsing
- Uppercase-only semantic names without extra annotations
When it happens
Trigger: Constructing VertexElement with a semantic name containing a non-numeric index part, e.g. "POSITION_" or "TEXCOORDX" or "COLOR#1".
Common situations: Hand-editing shader semantic names; copying semantics from HLSL with suffixed annotations; typos like "NORMAL01a".
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- Cannot specify a semantic index when using the constructor…
- Duplicate s found with the same semantic name and index
- A overlaps with another element. Check the element's offset
- The 's offset and size makes it extend beyond the vertex…
- The offset of the is not a multiple of 4 bytes
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/0e7fe99cee0a8f0f.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/VertexElement.cs:100
/// <paramref name="semanticName"/> is <see langword="null"/> or an empty <see langword="string"/>.
/// </exception>
public VertexElement(string semanticName, PixelFormat format)
: this()
{
ArgumentException.ThrowIfNullOrWhiteSpace(semanticName);
// All semantics will be upper case
semanticName = semanticName.ToUpperInvariant();
var match = MatchSemanticIndex.Match(semanticName);
if (match.Success)
{
// Convert to singleton string in order to speed up things
// TODO: Stale comment? Use string.Intern?
this.semanticName = match.Groups[1].Value;
if (!uint.TryParse(match.Groups[2].Value, out var semanticIndex))
throw new ArgumentException("Could not parse semantic index from the semantic name", nameof(semanticName));
this.semanticIndex = (int) semanticIndex;
}
else this.semanticName = semanticName;
this.format = format;
alignedByteOffset = AppendAligned;
// Precalculate hashcode
hashCode = ComputeHashCode();
}
/// <summary>
/// Initializes a new instance of the <see cref="VertexElement" /> structure.
/// </summary>
/// <param name="semanticName">
/// The semantic name associated with this element, such as <c>"POSITION"</c>, <c>"TEXCOORD"</c>, or <c>"NORMAL"</c>.
/// </param>View on GitHub (pinned to 96fad776d2)