{"record":{"id":"0e7fe99cee0a8f0f","repo":"stride3d/stride","slug":"could-not-parse-semantic-index-from-the-semantic-name","errorCode":null,"errorMessage":"Could not parse semantic index from the semantic name","messagePattern":"Could not parse semantic index from the semantic name","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/VertexElement.cs","lineNumber":100,"sourceCode":"    ///   <paramref name=\"semanticName\"/> is <see langword=\"null\"/> or an empty <see langword=\"string\"/>.\n    /// </exception>\n    public VertexElement(string semanticName, PixelFormat format)\n        : this()\n    {\n        ArgumentException.ThrowIfNullOrWhiteSpace(semanticName);\n\n        // All semantics will be upper case\n        semanticName = semanticName.ToUpperInvariant();\n\n        var match = MatchSemanticIndex.Match(semanticName);\n        if (match.Success)\n        {\n            // Convert to singleton string in order to speed up things\n            // TODO: Stale comment? Use string.Intern?\n            this.semanticName = match.Groups[1].Value;\n\n            if (!uint.TryParse(match.Groups[2].Value, out var semanticIndex))\n                throw new ArgumentException(\"Could not parse semantic index from the semantic name\", nameof(semanticName));\n\n            this.semanticIndex = (int) semanticIndex;\n        }\n        else this.semanticName = semanticName;\n\n        this.format = format;\n        alignedByteOffset = AppendAligned;\n\n        // Precalculate hashcode\n        hashCode = ComputeHashCode();\n    }\n\n    /// <summary>\n    ///   Initializes a new instance of the <see cref=\"VertexElement\" /> structure.\n    /// </summary>\n    /// <param name=\"semanticName\">\n    ///   The semantic name associated with this element, such as <c>\"POSITION\"</c>, <c>\"TEXCOORD\"</c>, or <c>\"NORMAL\"</c>.\n    /// </param>","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/VertexElement.cs#L82-L118","documentation":"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.","triggerScenarios":"Constructing VertexElement with a semantic name containing a non-numeric index part, e.g. \"POSITION_\" or \"TEXCOORDX\" or \"COLOR#1\".","commonSituations":"Hand-editing shader semantic names; copying semantics from HLSL with suffixed annotations; typos like \"NORMAL01a\".","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"],"exampleFix":"// before\nnew VertexElement(\"TEXCOORDu\", PixelFormat.R32G32_Float)\n// after\nnew VertexElement(\"TEXCOORD0\", PixelFormat.R32G32_Float)\n// or\nnew VertexElement(\"TEXCOORD\", 0, PixelFormat.R32G32_Float)","handlingStrategy":"validation","validationCode":"static readonly Regex ok = new Regex(@\"^(?<name>[A-Za-z]+)(?<idx>\\d*)$\");\nbool IsValidSemantic(string s) { var m = ok.Match(s); return m.Success && (m.Groups[\"idx\"].Value == \"\" || uint.TryParse(m.Groups[\"idx\"].Value, out _)); }","typeGuard":null,"tryCatchPattern":"try { var e = new VertexElement(name, format); } catch (ArgumentException) { useExplicitIndexConstructor(); }","preventionTips":["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"],"tags":["graphics","vertex-declaration","semantic","parsing"],"backgroundTag":"invalid-identifier-format","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}