{"record":{"id":"85df59d42fa7e66d","repo":"AvaloniaUI/Avalonia","slug":"expected-indexer-argument","errorCode":null,"errorMessage":"Expected indexer argument.","messagePattern":"Expected indexer argument\\.","errorType":"validation","errorClass":"ExpressionParseException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Data/Core/Parsers/ArgumentListParser.cs","lineNumber":21,"sourceCode":"\nnamespace Avalonia.Data.Core.Parsers\n{\n    internal static class ArgumentListParser\n    {\n        public static IList<string> ParseArguments(this ref CharacterReader r, char open, char close, char delimiter = ',')\n        {\n            if (r.Peek == open)\n            {\n                var result = new List<string>();\n\n                r.Take();\n\n                while (!r.End)\n                {\n                    var argument = r.TakeWhile(c => c != delimiter && c != close && !char.IsWhiteSpace(c));\n                    if (argument.IsEmpty)\n                    {\n                        throw new ExpressionParseException(r.Position, \"Expected indexer argument.\");\n                    }\n\n                    result.Add(argument.ToString());\n\n                    r.SkipWhitespace();\n\n                    if (r.End)\n                    {\n                        throw new ExpressionParseException(r.Position, $\"Expected '{delimiter}'.\");\n                    }\n                    else if (r.TakeIf(close))\n                    {\n                        return result;\n                    }\n                    else\n                    {\n                        if (r.Take() != delimiter)\n                        {","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Data/Core/Parsers/ArgumentListParser.cs#L3-L39","documentation":"ArgumentListParser.ParseArguments throws ExpressionParseException('Expected indexer argument.') when, inside an argument list, TakeWhile consumes nothing because the next character is the delimiter, the close bracket, or whitespace. This means an argument slot is empty (e.g. `[]`, `[,0]`, or `[ ]`).","triggerScenarios":"A binding path indexer with an empty argument, such as `Items[]`, `Items[,1]`, or whitespace-only `Items[ ]`.","commonSituations":"Typing a binding path with missing index values; dynamically building a path string and leaving an empty slot; trailing/leading delimiter inside brackets.","solutions":["Provide a non-empty value for every indexer argument.","When building paths programmatically, filter out empty tokens before joining with the delimiter."],"exampleFix":"// before\n{Binding Items[]}\n{Binding Matrix[,1]}\n// after\n{Binding Items[0]}\n{Binding Matrix[0,1]}","handlingStrategy":"validation","validationCode":"// Reject indexer paths with empty argument slots before binding.\nstatic bool IndexerArgsAreValid(string path)\n{\n    // crude check: no empty slots between [ and ]\n    int start = path.IndexOf('[');\n    if (start < 0) return true;\n    int end = path.IndexOf(']', start);\n    if (end < 0) return false;\n    var inner = path.Substring(start + 1, end - start - 1);\n    foreach (var tok in inner.Split(','))\n        if (string.IsNullOrWhiteSpace(tok)) return false;\n    return true;\n}\nif (!IndexerArgsAreValid(path)) throw new ArgumentException(\"Empty indexer argument.\");","typeGuard":null,"tryCatchPattern":"try { var nodes = BindingExpressionGrammar.Parse(path); }\ncatch (ExpressionParseException ex) when (ex.Message.Contains(\"Expected indexer argument\"))\n{ /* fix the path: fill empty indexer slots */ }","preventionTips":["Always supply a value for every indexer slot.","When building paths dynamically, drop empty tokens.","Lint binding path strings in CI/XAML validation."],"tags":["data-binding","binding-path","parser","indexer"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}