Repository: AvaloniaUI/Avalonia
File: src/Avalonia.Base/Animation/Animators/GradientBrushAnimator.cs (C#)

Code before:
                    return progress >= 0.5 ? newValue : oldValue;
            }
        }

        public override IDisposable BindAnimation(Animatable control, IObservable<IGradientBrush?> instance)
        {
            if (Property is null)
            {
                throw new InvalidOperationException("Animator has no property specified.");
            }

            return control.Bind((AvaloniaProperty<IBrush?>)Property, instance, BindingPriority.Animation);
        }

        private static ImmutableTransform? InterpolateTransform(double progress,
            ITransform? oldTransform, ITransform? newTransform)
        {
            if (oldTransform is TransformOperations oldTransformOperations
                && newTransform is TransformOperations newTransformOperations)
            {

                return new ImmutableTransform(TransformOperations
                    .Interpolate(oldTransformOperations, newTransformOperations, progress).Value);
            }

            if (oldTransform is { })
            {
                return new ImmutableTransform(oldTransform.Value);
            }
            
            return null;
        }
    
        private static IReadOnlyList<ImmutableGradientStop> InterpolateStops(double progress, IReadOnlyList<IGradientStop> oldValue, IReadOnlyList<IGradientStop> newValue)
        {
            var resultCount = Math.Max(oldValue.Count, newValue.Count);
            var stops = new ImmutableGradientStop[resultCount];

            for (int index = 0, oldIndex = 0, newIndex = 0; index < resultCount; index++)
            {
                stops[index] = new ImmutableGradientStop(
                    s_doubleAnimator.Interpolate(progress, oldValue[oldIndex].Offset, newValue[newIndex].Offset),
                    ColorAnimator.InterpolateCore(progress, oldValue[oldIndex].Color, newValue[newIndex].Color));

                if (oldIndex < oldValue.Count - 1)
                {
                    oldIndex++;
                }

                if (newIndex < newValue.Count - 1)
                {

Review comment (suggestion):
```suggestion
            if (oldTransform is not null)
```

Code after:
                    return progress >= 0.5 ? newValue : oldValue;
            }
        }

        public override IDisposable BindAnimation(Animatable control, IObservable<IGradientBrush?> instance)
        {
            if (Property is null)
            {
                throw new InvalidOperationException("Animator has no property specified.");
            }

            return control.Bind((AvaloniaProperty<IBrush?>)Property, instance, BindingPriority.Animation);
        }

        private static ImmutableTransform? InterpolateTransform(double progress,
            ITransform? oldTransform, ITransform? newTransform)
        {
            if (oldTransform is TransformOperations oldTransformOperations
                && newTransform is TransformOperations newTransformOperations)
            {

                return new ImmutableTransform(TransformOperations
                    .Interpolate(oldTransformOperations, newTransformOperations, progress).Value);
            }

            if (oldTransform is not null)
            {
                return new ImmutableTransform(oldTransform.Value);
            }
            
            return null;
        }
    
        private static IReadOnlyList<ImmutableGradientStop> InterpolateStops(double progress, IReadOnlyList<IGradientStop> oldValue, IReadOnlyList<IGradientStop> newValue)
        {
            var resultCount = Math.Max(oldValue.Count, newValue.Count);
            var stops = new ImmutableGradientStop[resultCount];

            for (int index = 0, oldIndex = 0, newIndex = 0; index < resultCount; index++)
            {
                stops[index] = new ImmutableGradientStop(
                    s_doubleAnimator.Interpolate(progress, oldValue[oldIndex].Offset, newValue[newIndex].Offset),
                    ColorAnimator.InterpolateCore(progress, oldValue[oldIndex].Color, newValue[newIndex].Color));

                if (oldIndex < oldValue.Count - 1)
                {
                    oldIndex++;
                }

                if (newIndex < newValue.Count - 1)
                {