AvaloniaUI/Avalonia · error · ExpressionParseException

Expected '{open}'.

Error message

Expected '{open}'.

What it means

ArgumentListParser.ParseArguments throws ExpressionParseException("Expected '{open}'.") at line 50 when invoked but the current character is not the expected open bracket. The caller is expected to have already peeked for the open character; reaching this throw means ParseArguments was called without the open bracket present.

Source

Thrown at src/Avalonia.Base/Data/Core/Parsers/ArgumentListParser.cs:50

                    else if (r.TakeIf(close))
                    {
                        return result;
                    }
                    else
                    {
                        if (r.Take() != delimiter)
                        {
                            throw new ExpressionParseException(r.Position, $"Expected '{delimiter}'.");
                        }

                        r.SkipWhitespace();
                    }
                }

                throw new ExpressionParseException(r.Position, $"Expected '{close}'.");
            }

            throw new ExpressionParseException(r.Position, $"Expected '{open}'.");
        }
    }
}

View on GitHub (pinned to 11c5427268)

Solutions

  1. Ensure the reader is positioned at the open bracket before calling ParseArguments (peek first).
  2. If you hit this from normal binding strings, check for a stray/empty expression that reached argument parsing unexpectedly.

Example fix

// before - calling parse without the open bracket present
var args = r.ParseArguments('[', ']');
// after
if (!r.End && r.Peek == '[')
    var args = r.ParseArguments('[', ']');
Defensive patterns

Strategy: try-catch

Validate before calling

// ParseArguments should only be called when positioned at the open bracket.
if (r.End || r.Peek != '[') return Array.Empty<string>();
var args = r.ParseArguments('[', ']');

Try / catch

try { var args = r.ParseArguments('[', ']'); }
catch (ExpressionParseException ex) when (ex.Message.Contains("Expected '['"))
{ /* caller misused ParseArguments; peek for '[' first */ }

Prevention

When it happens

Trigger: Calling ParseArguments when the reader is not positioned at the open bracket character, or when the reader is at end of input. In normal grammar flow this is guarded by PeekOpenBracket, so it indicates a misuse or an orphaned direct call.

Common situations: A custom parser/code path calling ParseArguments directly without first checking for the open bracket; a malformed expression that slips past the grammar's peek guard.

Related errors


AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13). Data as JSON: /api/errors/b998eb90d70f296f. Report an issue: GitHub.