{"record":{"id":"38aac4c05dd0ab0a","repo":"spectreconsole/spectre.console","slug":"failed-to-read-emoji-json-at-file-path","errorCode":null,"errorMessage":"Failed to read emoji.json at {file.Path}","messagePattern":"Failed to read emoji\\.json at (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console.SourceGenerator/Emojis/EmojiGenerator.cs","lineNumber":28,"sourceCode":"/// </summary>\n[Generator]\npublic class EmojiGenerator : IIncrementalGenerator\n{\n    // UTF-8 without a BOM, matching the repository's source file convention\n    // and keeping the checked-in generated files deterministic.\n    private static readonly Encoding Utf8NoBom = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);\n\n    /// <inheritdoc />\n    public void Initialize(IncrementalGeneratorInitializationContext context)\n    {\n        // Find emoji.json and parse it in the pipeline (for caching)\n        // Step 1: Extract text (cached by string value equality)\n        // Step 2: Parse to models (cached by EquatableArray value equality)\n        var emojis = context.AdditionalTextsProvider\n            .Where(static file => file.Path.EndsWith(\"emoji.json\", StringComparison.OrdinalIgnoreCase))\n            .Select(static (file, ct) =>\n                file.GetText(ct)?.ToString()\n                ?? throw new InvalidOperationException($\"Failed to read emoji.json at {file.Path}\"))\n            .Select(static (text, _) => EmojiParser.ParseAll(text))\n            .Collect();\n\n        // Register implementation source output - we do not use these emojis directly in the source\n        // and this will allow IDEs to optionally skip running this generator for intellisense and the such, but it will\n        // always run when compiling.\n        // see https://github.com/dotnet/roslyn/blob/main/docs/features/incremental-generators.md#outputting-values\n        context.RegisterImplementationSourceOutput(emojis, static (spc, models) =>\n        {\n            if (models.IsEmpty)\n            {\n                return;\n            }\n\n            if (models.Length > 1)\n            {\n                spc.ReportDiagnostic(Diagnostic.Create(\n                    new DiagnosticDescriptor(","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console.SourceGenerator/Emojis/EmojiGenerator.cs#L10-L46","documentation":"Thrown inside the emoji.json Roslyn incremental source generator when an AdditionalFiles entry ending in emoji.json matched but GetText returned null. Same shape as the colors.json read failure but for the emoji data file; it surfaces as a compile-time InvalidOperationException in the generator pipeline.","triggerScenarios":"The emoji.json AdditionalFiles item is in the project graph but its text cannot be read at generation time (locked, deleted mid-build, unreadable, or empty).","commonSituations":"Corrupted emoji.json; antivirus file lock; partial checkout; package restore that left emoji.json missing or zero-byte; a broken AdditionalFiles include.","solutions":["Clean rebuild (dotnet clean && dotnet build) to re-read AdditionalFiles","Confirm the emoji.json used by the generator exists and is readable on disk","Restore/reinstall the Spectre.Console package to refresh emoji.json","Release any process lock (other IDE, antivirus) on emoji.json"],"exampleFix":"# before: emoji.json unreadable during generation\n# after: clean generation\ndotnet clean\ndotnet restore\ndotnet build","handlingStrategy":"validation","validationCode":"// Pre-build check: confirm emoji.json AdditionalFiles item resolves\ndotnet msbuild -getItem:AdditionalFiles | findstr emoji.json","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not hand-edit or truncate emoji.json","CI step failing on zero-byte/missing data files prevents partial checkouts shipping"],"tags":["source-generator","build","json","roslyn","emoji"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}