AvaloniaUI/Avalonia · error · ExpressionParseException
Unexpected data
Error message
Unexpected data
What it means
Error "Unexpected data " thrown in AvaloniaUI/Avalonia.
Source
Thrown at src/Avalonia.Base/Rendering/Composition/Expressions/ExpressionParser.cs:18
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
// ReSharper disable StringLiteralTypo
namespace Avalonia.Rendering.Composition.Expressions
{
internal class ExpressionParser
{
public static Expression Parse(ReadOnlySpan<char> s)
{
var p = new TokenParser(s);
var parsed = ParseTillTerminator(ref p, "", false, false, out _);
p.SkipWhitespace();
if (p.Length != 0)
throw new ExpressionParseException("Unexpected data ", p.Position);
return parsed;
}
private static ReadOnlySpan<char> Dot => ".".AsSpan();
static bool TryParseAtomic(ref TokenParser parser,
[MaybeNullWhen(returnValue: false)] out Expression expr)
{
// We can parse keywords, parameter names and constants
expr = null;
if (parser.TryParseKeywordLowerCase(ExpressionKeywords.StartingValue))
expr = new KeywordExpression(ExpressionKeyword.StartingValue);
else if(parser.TryParseKeywordLowerCase(ExpressionKeywords.CurrentValue))
expr = new KeywordExpression(ExpressionKeyword.CurrentValue);
else if(parser.TryParseKeywordLowerCase(ExpressionKeywords.FinalValue))
expr = new KeywordExpression(ExpressionKeyword.FinalValue);
else if(parser.TryParseKeywordLowerCase(ExpressionKeywords.Pi))
expr = new KeywordExpression(ExpressionKeyword.Pi);
else if(parser.TryParseKeywordLowerCase(ExpressionKeywords.True))View on GitHub (pinned to 11c5427268)
Solutions
- Fix the composition expression syntax: remove the trailing or unexpected extra tokens (e.g. an unmatched operator or closing parenthesis) from the expression string.
- Validate the expression with a known-good sample from the Avalonia composition animation docs before using it in StartAnimation.
When it happens
Trigger: Raised by the composition expression parser when extra tokens remain after a complete expression was parsed. Defend by validating expression strings before assigning them to composition animations and by rejecting trailing characters after the top-level expression.
Common situations: See trigger scenarios.
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/6c4e509f64ac4657.
Report an issue: GitHub.