{"record":{"id":"37ebf196ffd3577e","repo":"stride3d/stride","slug":"warning-at-line-column-msg","errorCode":null,"errorMessage":"Warning at {line}:{column}: {msg}","messagePattern":"Warning at (.+?):(.+?): (.+?)","errorType":"exception","errorClass":"LexerException","httpStatus":null,"severity":"warning","filePath":"sources/shaders/Stride.Shaders.Parsers/CppNet/Preprocessor.cs","lineNumber":305,"sourceCode":"\t * @see #error(int, int, String)\n\t */\n\tprotected void error(Token tok, String msg) {\n\t\terror(tok.getLine(), tok.getColumn(), msg);\n\t}\n\n\t/**\n\t * Handles a warning.\n\t *\n\t * If a PreprocessorListener is installed, it receives the\n\t * warning. Otherwise, an exception is thrown.\n\t */\n\tprotected void warning(int line, int column, String msg) {\n\t\tif (warnings.HasFlag(Warning.ERROR))\n\t\t\terror(line, column, msg);\n\t\telse if (listener != null)\n\t\t\tlistener.handleWarning(source, line, column, msg);\n\t\telse\n\t\t\tthrow new LexerException(\"Warning at \" + line + \":\" + column + \": \" + msg);\n\t}\n\n\t/**\n\t * Handles a warning.\n\t *\n\t * If a PreprocessorListener is installed, it receives the\n\t * warning. Otherwise, an exception is thrown.\n\t *\n\t * @see #warning(int, int, String)\n\t */\n\tprotected void warning(Token tok, String msg) {\n\t\twarning(tok.getLine(), tok.getColumn(), msg);\n\t}\n\n\t/**\n\t * Adds a Macro to this Preprocessor.\n\t *\n\t * The given {@link Macro} object encapsulates both the name","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/CppNet/Preprocessor.cs#L287-L323","documentation":"The C preprocessor emits warnings via Preprocessor.warning(). If a PreprocessorListener is installed, the warning is handed to listener.handleWarning(); if no listener exists, the warning is fatal and thrown as a LexerException. Additionally, if the Warning.ERROR flag is set, warnings are escalated to errors.","triggerScenarios":"Preprocessing shader source that triggers a preprocessor warning (e.g. #warning directive or questionable token handling) while no PreprocessorListener is attached to the Preprocessor, or while Warning.ERROR is set.","commonSituations":"Developers running the SDSL/CppNet preprocessor over shader files directly (console tools) without installing a listener; CI pipelines that enable warnings-as-errors and hit a #warning in shader code.","solutions":["Install a PreprocessorListener (with handleWarning) on the Preprocessor so warnings are reported instead of thrown","Remove or fix the offending #warning/construct in the shader source","Unset the Warning.ERROR feature flag if warnings should not be fatal","Catch LexerException around Preprocessor.process()/token() calls"],"exampleFix":"// before\nvar pp = new Preprocessor();\npp.addInput(new FileLexer(sourceFile));\n// after\nvar pp = new Preprocessor();\npp.setListener(new MyPreprocessorListener());\npp.addInput(new FileLexer(sourceFile));","handlingStrategy":"try-catch","validationCode":"if (pp.Listener == null) pp.setListener(new DefaultPreprocessorListener());","typeGuard":"bool hasListener = preprocessor.getListener() != null;","tryCatchPattern":"try { pp.addInput(lexer); pp.process(); } catch (LexerException e) { log.Warn($\"Preprocessor warning escalated: {e.Message}\"); }","preventionTips":["Always install a PreprocessorListener before processing","Decide explicitly whether warnings should be fatal (Warning.ERROR)"],"tags":["shader","preprocessor","lexer"],"backgroundTag":"invalid-argument-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}