{"record":{"id":"4a7d999e5462a62a","repo":"antlr/antlr4","slug":"listener-4a7d99","errorCode":null,"errorMessage":"listener","messagePattern":"listener","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"runtime/CSharp/src/Parser.cs","lineNumber":454,"sourceCode":"        /// behavior of the listener calls.</li>\n        /// <li>Alterations to the command line options passed to ANTLR 4 when\n        /// generating the parser may change the behavior of the listener calls.</li>\n        /// <li>Changing the version of the ANTLR Tool used to generate the parser\n        /// may change the behavior of the listener calls.</li>\n        /// </ul>\n        /// </summary>\n        /// <param name=\"listener\">the listener to add</param>\n        /// <exception cref=\"System.ArgumentNullException\">\n        /// if\n        /// <c/>\n        /// listener is\n        /// <see langword=\"null\"/>\n        /// </exception>\n        public virtual void AddParseListener(IParseTreeListener listener)\n        {\n            if (listener == null)\n            {\n                throw new ArgumentNullException(\"listener\");\n            }\n            if (_parseListeners == null)\n            {\n                _parseListeners = new List<IParseTreeListener>();\n            }\n            this._parseListeners.Add(listener);\n        }\n\n        /// <summary>\n        /// Remove\n        /// <paramref name=\"listener\"/>\n        /// from the list of parse listeners.\n        /// <p>If\n        /// <paramref name=\"listener\"/>\n        /// is\n        /// <see langword=\"null\"/>\n        /// or has not been added as a parse\n        /// listener, this method does nothing.</p>","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/antlr/antlr4/blob/7d5770395bb7b02eb56e7c62662cb1d7c08f42a3/runtime/CSharp/src/Parser.cs#L436-L472","documentation":"Error \"listener\" thrown in antlr/antlr4.","triggerScenarios":"Parser.RemoveErrorListener(null) or similar call passes a null listener argument.","commonSituations":"Only add/remove non-null IAntlrErrorListener instances; keep references to listeners added so removal passes the same instance.","solutions":["Do not pass a null listener to AddParseListener/RemoveParseListener; check for null before calling.","If removing, pass the same listener instance previously added."],"exampleFix":"var listener = new MyListener();\nparser.AddParseListener(listener);\n// later\nparser.RemoveParseListener(listener);","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d5770395bb7b02eb56e7c62662cb1d7c08f42a3","analyzedAt":"2026-08-14T14:47:56.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}