{"record":{"id":"dd60a7f81ac00ce7","repo":"spectreconsole/spectre.console","slug":"emoji-has-null-emoji","errorCode":null,"errorMessage":"Emoji has null emoji","messagePattern":"Emoji has null emoji","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console.SourceGenerator/Emojis/EmojiModel.cs","lineNumber":42,"sourceCode":"internal 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\";\n            }\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console.SourceGenerator/Emojis/EmojiModel.cs#L24-L60","documentation":"Thrown by EmojiModel.ParseAll: an emoji.json element had label and hexcode but its emoji property parsed to null. The literal emoji character is required for the generated code, so a null value aborts parsing.","triggerScenarios":"An emoji.json element contains \"emoji\": null or otherwise yields null for the emoji property.","commonSituations":"Editing emoji.json and clearing the literal glyph; encoding loss stripping the emoji field to null; schema drift.","solutions":["Locate the offending element and restore the literal emoji string","Restore emoji.json from the Spectre.Console package (keep UTF-8 encoding intact)","Validate the JSON before replacing the bundled file"],"exampleFix":"// before\n{ \"label\": \"grinning face\", \"hexcode\": \"1F600\", \"emoji\": null }\n// after\n{ \"label\": \"grinning face\", \"hexcode\": \"1F600\", \"emoji\": \"\\ud83d\\ude00\" }","handlingStrategy":"validation","validationCode":"// Scan emoji.json for null emoji literals before replacing the file\nusing var doc = JsonDocument.Parse(File.ReadAllText(\"emoji.json\"));\nforeach (var e in doc.RootElement.EnumerateArray())\n    if (e.GetProperty(\"emoji\").ValueKind == JsonValueKind.Null)\n        Console.Error.WriteLine(\"emoji has null emoji literal\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate edited emoji.json before shipping","Preserve UTF-8 encoding when copying the file"],"tags":["json","source-generator","data-integrity","emoji","encoding"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}