{"record":{"id":"d705ecaf49564d09","repo":"AvaloniaUI/Avalonia","slug":"expected-end-of-expression","errorCode":null,"errorMessage":"Expected end of expression.","messagePattern":"Expected end of expression\\.","errorType":"validation","errorClass":"ExpressionParseException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Data/Core/Parsers/BindingExpressionGrammar.cs","lineNumber":98,"sourceCode":"                    case State.TypeCast:\n                        state = ParseTypeCast(ref r, nodes);\n                        break;\n\n                    case State.ElementName:\n                        state = ParseElementName(ref r, nodes);\n                        mode = SourceMode.Control;\n                        break;\n\n                    case State.RelativeSource:\n                        state = ParseRelativeSource(ref r, nodes);\n                        mode = SourceMode.Control;\n                        break;\n                }\n            }\n\n            if (!r.End)\n            {\n                throw new ExpressionParseException(r.Position, \"Expected end of expression.\");\n            }\n\n            if (state is State.BeforeMember or State.BeforeMemberNullable)\n            {\n                throw new ExpressionParseException(r.Position, \"Unexpected end of expression.\");\n            }\n\n            return mode;\n        }\n\n        private static State ParseStart(ref CharacterReader r, IList<INode> nodes)\n        {\n            if (ParseNot(ref r))\n            {\n                nodes.Add(new NotNode());\n                return State.Start;\n            }\n","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Data/Core/Parsers/BindingExpressionGrammar.cs#L80-L116","documentation":"BindingExpressionGrammar.Parse throws ExpressionParseException('Expected end of expression.') when the main parse loop exits with State.End but the reader is not exhausted — i.e. a valid expression was parsed and then leftover characters remain that the grammar cannot consume. The grammar requires the entire string to be a single, well-formed expression.","triggerScenarios":"A binding path with trailing characters after a valid expression, e.g. `Foo bar`, `Foo;bar`, two expressions concatenated, or an operator/character the grammar does not accept at that position.","commonSituations":"Typos in XAML binding paths; concatenating expressions; stray whitespace-only tokens that break a path; an unsupported character (e.g. `=`) left in the path.","solutions":["Ensure the binding path is exactly one valid expression with no trailing characters.","Remove stray separators, duplicate members, or unsupported characters from the path.","If combining logic is needed, use a multi-binding or converter instead of concatenating paths."],"exampleFix":"// before\n{Binding Foo bar}\n{Binding Foo;Bar}\n// after\n{Binding Foo}\n{Binding Bar}","handlingStrategy":"try-catch","validationCode":"// Reject paths with trailing garbage after a valid expression.\nstatic bool PathIsSingleExpression(string path)\n{\n    try\n    {\n        var r = new Avalonia.Utilities.CharacterReader(path.AsSpan());\n        var (nodes, _) = BindingExpressionGrammar.Parse(ref r);\n        return r.End; // true only if the whole string was consumed\n    }\n    catch { return false; }\n}\nif (!PathIsSingleExpression(path)) throw new ArgumentException(\"Malformed binding path.\");","typeGuard":null,"tryCatchPattern":"try { var (nodes, mode) = BindingExpressionGrammar.Parse(path); }\ncatch (ExpressionParseException ex) when (ex.Message.Contains(\"Expected end of expression\"))\n{ /* remove trailing characters after the valid expression */ }","preventionTips":["Keep binding paths to a single well-formed expression with no trailing chars.","Avoid string-concatenating expressions; use multi-bindings or converters.","Lint/validate binding path strings in CI."],"tags":["data-binding","binding-path","parser","grammar"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}