{"record":{"id":"86e5e5fe4f4e89c5","repo":"AvaloniaUI/Avalonia","slug":"expected","errorCode":null,"errorMessage":"Expected ')'.","messagePattern":"Expected '\\)'\\.","errorType":"validation","errorClass":"ExpressionParseException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Data/Core/Parsers/BindingExpressionGrammar.cs","lineNumber":243,"sourceCode":"                nodes.Add(new TypeCastNode() { Namespace = ns, TypeName = owner });\n                return State.AfterMember;\n            }\n\n            if (r.End || !r.TakeIf('.'))\n            {\n                throw new ExpressionParseException(r.Position, \"Invalid attached property name.\");\n            }\n\n            var name = r.ParseIdentifier();\n\n            if (name.Length == 0)\n            {\n                throw new ExpressionParseException(r.Position, \"Attached Property name expected after '.'.\");\n            }\n\n            if (r.End || !r.TakeIf(')'))\n            {\n                throw new ExpressionParseException(r.Position, \"Expected ')'.\");\n            }\n\n            nodes.Add(new AttachedPropertyNameNode\n            {\n                AcceptsNull = acceptsNull,\n                Namespace = ns,\n                TypeName = owner,\n                PropertyName = name.ToString()\n            });\n            return State.AfterMember;\n        }\n\n        private static State ParseIndexer(ref CharacterReader r, List<INode> nodes)\n        {\n            var args = r.ParseArguments('[', ']');\n\n            if (args.Count == 0)\n            {","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Data/Core/Parsers/BindingExpressionGrammar.cs#L225-L261","documentation":"Thrown by ParseAttachedProperty after the full '(Owner.Property' path has been parsed (type name, dot, and property name all consumed) but the closing ')' is missing from the string or a non-')' character appears where ')' is expected. Avalonia requires balanced parentheses around every attached-property or type-cast expression in the binding mini-language.","triggerScenarios":"Writing '(Grid.Row' at end of string, or '(Grid.Row;More' where ')' is expected but a different character is present. The parser has consumed the property name via ParseIdentifier and now checks r.TakeIf(')') which returns false.","commonSituations":"Truncated binding string where the closing paren was cut off during copy-paste; building attached-property paths dynamically and forgetting to append ')'; mixing up the compact '(Type.Property)' syntax with the full XAML '{Binding Path=(Type.Property)}' wrapper and losing a paren.","solutions":["Add the missing ')' at the end of the attached-property expression.","Check that the total open-paren and close-paren counts in the binding path are balanced.","Use the Column property from the exception to locate where ')' was expected."],"exampleFix":"<!-- before: missing closing ')' -->\n<TextBox Text=\"{Binding (Grid.Row}\" />\n\n<!-- after: closing ')' added -->\n<TextBox Text=\"{Binding (Grid.Row)}\" />","handlingStrategy":"validation","validationCode":"// Validate that parentheses are balanced in a binding path\nstatic void ValidateBalancedParens(string path)\n{\n    int depth = 0;\n    for (int i = 0; i < path.Length; i++)\n    {\n        if (path[i] == '(') depth++;\n        else if (path[i] == ')') depth--;\n        if (depth < 0)\n            throw new ArgumentException($\"Unbalanced ')' at position {i}\");\n    }\n    if (depth != 0)\n        throw new ArgumentException($\"Unbalanced '(' — {depth} unclosed paren group(s)\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var binding = new Binding(path);\n}\ncatch (ExpressionParseException ex) when (ex.Message.Contains(\"Expected ')'\"))\n{\n    logger.LogError($\"Missing ')' at column {ex.Column} in binding path\");\n}","preventionTips":["Count open and close parentheses before using a binding path with attached properties or casts.","Use a linter or editor extension that highlights unbalanced parentheses in XAML.","When building paths programmatically, use a helper that tracks paren depth and appends ')' as needed."],"tags":["avalonia","binding","xaml","binding-expression","attached-property","parser","syntax-error","unbalanced-parens"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}