Repository: AvaloniaUI/Avalonia
File: src/Avalonia.Base/Media/Brush.cs (C#)

Code before:
            set => SetValue(TransformProperty, value);
        }

        /// <summary>
        /// Gets or sets the origin of the brush <see cref="Transform"/>
        /// </summary>
        public RelativePoint TransformOrigin
        {
            get => GetValue(TransformOriginProperty);
            set => SetValue(TransformOriginProperty, value);
        }

        /// <summary>
        /// Parses a brush string.
        /// </summary>
        /// <param name="s">The brush string.</param>
        /// <returns>The <see cref="Color"/>.</returns>
        public static IBrush Parse(string s)
        {
            _ = s ?? throw new ArgumentNullException(nameof(s));

            if (s.Length > 0)
            {
                if (Color.TryParse(s, out Color color))
                {
                    return new ImmutableSolidColorBrush(color);
                }

                var brush = KnownColors.GetKnownBrush(s);
                if (brush != null)
                {
                    return brush;
                }
            }

            throw new FormatException($"Invalid brush string: '{s}'.");
        }

        protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
        {
            if (change.Property == TransformProperty) 
                _resource.ProcessPropertyChangeNotification(change);

            RegisterForSerialization();

            base.OnPropertyChanged(change);
        }
        
        private protected void RegisterForSerialization() =>
            _resource.RegisterForInvalidationOnAllCompositors(this);


Review comment (suggestion):
This is now redundant. I actually think we should remove `KnownColors.GetKnownBrush()` completely here and mark as obsolete in v12. It doesn't do anything special for brush that color doesn't already provide.

Code after:
            set => SetValue(TransformProperty, value);
        }

        /// <summary>
        /// Gets or sets the origin of the brush <see cref="Transform"/>
        /// </summary>
        public RelativePoint TransformOrigin
        {
            get => GetValue(TransformOriginProperty);
            set => SetValue(TransformOriginProperty, value);
        }

        /// <summary>
        /// Parses a brush string.
        /// </summary>
        /// <param name="s">The brush string.</param>
        /// <returns>The <see cref="Color"/>.</returns>
        public static IBrush Parse(string s)
        {
            _ = s ?? throw new ArgumentNullException(nameof(s));

            if (s.Length > 0)
            {
                // Attempt to get a cached known brush first
                // This is a performance optimization for known colors
                var brush = KnownColors.GetKnownBrush(s);
                if (brush != null)
                {
                    return brush;
                }

                if (Color.TryParse(s, out Color color))
                {
                    return new ImmutableSolidColorBrush(color);
                }
            }

            throw new FormatException($"Invalid brush string: '{s}'.");
        }

        protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
        {
            if (change.Property == TransformProperty) 
                _resource.ProcessPropertyChangeNotification(change);

            RegisterForSerialization();

            base.OnPropertyChanged(change);
        }
        
        private protected void RegisterForSerialization() =>