{"record":{"id":"7c13d83821482a6c","repo":"spectreconsole/spectre.console","slug":"emoji-has-null-hexcode","errorCode":null,"errorMessage":"Emoji has null hexcode","messagePattern":"Emoji has null hexcode","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console.SourceGenerator/Emojis/EmojiModel.cs","lineNumber":40,"sourceCode":"/// Parses emoji data from JSON.\n/// </summary>\ninternal static class EmojiParser\n{\n    /// <summary>\n    /// Parses the emoji.json file and returns all emoji models.\n    /// Filters out emojis with multiple codepoints (combinators).\n    /// </summary>\n    public static EquatableArray<EmojiModel> ParseAll(string json)\n    {\n        var document = JsonDocument.Parse(json);\n        var emojis = new List<EmojiModel>();\n\n        foreach (var element in document.RootElement.EnumerateArray())\n        {\n            var label = element.GetProperty(\"label\").GetString()\n                ?? throw new InvalidOperationException(\"Emoji has null label\");\n            var hexcode = element.GetProperty(\"hexcode\").GetString()\n                ?? throw new InvalidOperationException(\"Emoji has null hexcode\");\n            var emoji = element.GetProperty(\"emoji\").GetString()\n                ?? throw new InvalidOperationException(\"Emoji has null emoji\");\n\n            // Skip anything that is not a single code point for now\n            if (hexcode.Contains(\"-\"))\n            {\n                continue;\n            }\n\n            // Transform hexcode to Unicode escape sequence\n            var code = TransformToUnicode(hexcode);\n\n            // If the emoji does not have the Emoji_Presentation=Yes property,\n            // then it doesn't have a Variation Selector-16 suffix, and we should add it.\n            var codepoint = int.Parse(hexcode, NumberStyles.HexNumber, CultureInfo.InvariantCulture);\n            if (!HasEmojiPresentation(codepoint))\n            {\n                code += \"\\\\uFE0F\";","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console.SourceGenerator/Emojis/EmojiModel.cs#L22-L58","documentation":"Thrown by EmojiModel.ParseAll: an emoji.json element had a valid label but its hexcode property parsed to null. The hexcode is required to build the Unicode escape sequence for the generated code, so a null value aborts parsing.","triggerScenarios":"An emoji.json element contains \"hexcode\": null or yields null for the hexcode property.","commonSituations":"Editing emoji.json and clearing the hexcode; malformed upstream emoji data; schema drift.","solutions":["Locate the offending element and restore a valid hexcode string (e.g. \"1F600\")","Restore emoji.json from the Spectre.Console package","Validate the JSON before replacing the bundled file"],"exampleFix":"// before\n{ \"label\": \"grinning face\", \"hexcode\": null, \"emoji\": \"\\ud83d\\ude00\" }\n// after\n{ \"label\": \"grinning face\", \"hexcode\": \"1F600\", \"emoji\": \"\\ud83d\\ude00\" }","handlingStrategy":"validation","validationCode":"// Scan emoji.json for null hexcodes before replacing the file\nusing var doc = JsonDocument.Parse(File.ReadAllText(\"emoji.json\"));\nforeach (var e in doc.RootElement.EnumerateArray())\n    if (e.GetProperty(\"hexcode\").ValueKind == JsonValueKind.Null)\n        Console.Error.WriteLine(\"emoji has null hexcode\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate edited emoji.json before shipping","Keep the bundled data; restore from the package if unsure"],"tags":["json","source-generator","data-integrity","emoji","hexcode"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}