{"record":{"id":"5b7bb905b7f58df3","repo":"antlr/antlr4","slug":"the-specified-start-and-stop-symbols-are-not-suppo","errorCode":null,"errorMessage":"The specified start and stop symbols are not supported.","messagePattern":"The specified start and stop symbols are not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"runtime/CSharp/src/UnbufferedTokenStream.cs","lineNumber":183,"sourceCode":"        public virtual string GetText()\n        {\n            return string.Empty;\n        }\n\n        [return: NotNull]\n        public virtual string GetText(RuleContext ctx)\n        {\n            return GetText(ctx.SourceInterval);\n        }\n\n        [return: NotNull]\n        public virtual string GetText(IToken start, IToken stop)\n        {\n            if (start != null && stop != null)\n            {\n                return GetText(Interval.Of(start.TokenIndex, stop.TokenIndex));\n            }\n            throw new NotSupportedException(\"The specified start and stop symbols are not supported.\");\n        }\n\n        public virtual void Consume()\n        {\n            if (LA(1) == TokenConstants.EOF)\n            {\n                throw new InvalidOperationException(\"cannot consume EOF\");\n            }\n            // buf always has at least tokens[p==0] in this method due to ctor\n            lastToken = tokens[p];\n            // track last token for LT(-1)\n            // if we're at last token and no markers, opportunity to flush buffer\n            if (p == n - 1 && numMarkers == 0)\n            {\n                n = 0;\n                p = -1;\n                // p++ will leave this at 0\n                lastTokenBufferStart = lastToken;","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/antlr/antlr4/blob/7d5770395bb7b02eb56e7c62662cb1d7c08f42a3/runtime/CSharp/src/UnbufferedTokenStream.cs#L165-L201","documentation":"UnbufferedTokenStream.GetText(IToken start, IToken stop) supports only a concrete start and stop token pair; if either argument is null it cannot form a token-index interval and throws NotSupportedException. This is stricter than BufferedTokenStream, which returns an empty string for null arguments.","triggerScenarios":"Calling GetText(null, null) expecting all text; passing null for either endpoint when a token was unavailable; or porting BufferedTokenStream call sites directly to UnbufferedTokenStream.","commonSituations":"Optional start/stop tokens from error handling; code that uses null to mean beginning/end of stream; runtime migration from buffered to unbuffered token streams.","solutions":["Pass non-null IToken instances for both start and stop.","Use GetText() with no arguments for the stream's text where appropriate.","If null means all text, substitute explicit first/last tokens or switch to BufferedTokenStream."],"exampleFix":"// before\nstring all = tokens.GetText(null, null);\n\n// after\nstring all = tokens.GetText();","handlingStrategy":"validation","validationCode":"if (start == null || stop == null)\n    text = tokens.GetText();\nelse\n    text = tokens.GetText(start, stop);","typeGuard":null,"tryCatchPattern":"try { text = tokens.GetText(start, stop); }\ncatch (NotSupportedException ex) when (ex.Message == \"The specified start and stop symbols are not supported.\") { /* supply non-null tokens or use GetText() */ }","preventionTips":["Never pass null start/stop to UnbufferedTokenStream.","Use GetText() for whole-stream text.","Check endpoint tokens from error handling before extraction."],"tags":["antlr","csharp","token-stream","text-extraction","null-safety"],"backgroundTag":null,"analyzedSha":"7d5770395bb7b02eb56e7c62662cb1d7c08f42a3","analyzedAt":"2026-08-14T14:47:56.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}