AvaloniaUI/Avalonia · error · ArgumentNullException
propertyName
Error message
propertyName
What it means
StopAnimation guards its contract by rejecting a null property name with ArgumentNullException(nameof(propertyName)) before touching the server object. It is a pure argument-validation failure independent of any server state.
Source
Thrown at src/Avalonia.Base/Rendering/Composition/CompositionObject.cs:73
}
/// <summary>
/// Connects an animation with the specified property of the object and starts the animation.
/// </summary>
public void StartAnimation(string propertyName, CompositionAnimation animation)
=> StartAnimation(propertyName, animation, null);
internal virtual void StartAnimation(string propertyName, CompositionAnimation animation, ExpressionVariant? finalValue)
{
throw new ArgumentException("Unknown property " + propertyName);
}
/// <summary>Disconnects an animation from the specified property and stops the animation.</summary>
/// <param name="propertyName">The name of the property to disconnect the animation from.</param>
public void StopAnimation(string propertyName)
{
if (propertyName is null)
throw new ArgumentNullException(nameof(propertyName));
if (Server is not ServerObject srv)
return;
var prop = srv.GetCompositionProperty(propertyName) ?? throw new ArgumentException("Unknown property " + propertyName);
srv.Animations?.RemoveAnimationForProperty(prop);
}
/// <summary>
/// Starts an animation group.
/// The StartAnimationGroup method on CompositionObject lets you start CompositionAnimationGroup.
/// All the animations in the group will be started at the same time on the object.
/// </summary>
public void StartAnimationGroup(ICompositionAnimationBase grp)
{
if (grp is CompositionAnimation animation)
{
if(animation.Target == null)
throw new ArgumentException("Animation Target can't be null");
StartAnimation(animation.Target, animation);View on GitHub (pinned to 11c5427268)
Solutions
- Pass a non-null property name literal or validate the string before calling StopAnimation.
- Guard with a null check (or string.IsNullOrEmpty) and skip the call when there is nothing to stop.
- Store the property name used at StartAnimation time and reuse the same value when stopping.
Example fix
// before
visual.StopAnimation(_maybeNullField);
// after
if (!string.IsNullOrEmpty(_maybeNullField))
visual.StopAnimation(_maybeNullField); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(propertyName)) return; visual.StopAnimation(propertyName);
Type guard
static bool IsValidPropertyName(string? s) => !string.IsNullOrEmpty(s);
Prevention
- Validate property-name inputs before calling StopAnimation.
- Store the property name used at StartAnimation time and reuse it when stopping.
- Avoid passing unchecked external strings directly as property names.
When it happens
Trigger: Calling StopAnimation(null) on any CompositionObject.
Common situations: Passing a null/unchecked string variable as the property name, or calling StopAnimation inside cleanup code where the property name field was never initialized.
Related errors
- obj
- No Setter property assigned.
- Unknown PlaybackBehavior value: {_playbackBehavior}
- SpeedRatio value cannot be negative.
- Delay value cannot be negative.
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/c8d6e4acbeb52c80.
Report an issue: GitHub.