Repository: AvaloniaUI/Avalonia
File: src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs (C#)

Code before:
            return label is Control c ? GetOrCreate(c) : null;
        }

        protected override string? GetNameCore()
        {
            var result = AutomationProperties.GetName(Owner);

            if (string.IsNullOrWhiteSpace(result) && GetLabeledBy() is AutomationPeer labeledBy)
            {
                result = labeledBy.GetName();
            }

            return result;
        }
        protected override string? GetHelpTextCore()
        {
            var result = AutomationProperties.GetHelpText(Owner);

            if (string.IsNullOrWhiteSpace(result))
            {
                result = ToolTip.GetTip(Owner) as string;
            }

            if (string.IsNullOrWhiteSpace(result))
            {
                var errors = DataValidationErrors.GetErrors(Owner);
                var errorsStringList = errors?.Select(x => x.ToString());
                result = errorsStringList != null ? string.Join("\n", errorsStringList.ToArray()) : null;
            }

            return result;
        }
        protected override AutomationPeer? GetParentCore()
        {
            EnsureConnected();
            return _parent;
        }

        protected override AutomationPeer? GetVisualRootCore()
        {
            if (Owner.GetVisualRoot() is Control c)
                return CreatePeerForElement(c);
            return null;
        }

        /// <summary>
        /// Invalidates the peer's children and causes a re-read from <see cref="GetChildrenCore"/>.
        /// </summary>
        protected void InvalidateChildren()
        {
            _childrenValid = false;

Review comment (suggestion):
Shouldn't this take higher priority than the tooltip fallback above? Validation errors should be one of the first things shown.

Code after:
            return label is Control c ? GetOrCreate(c) : null;
        }

        protected override string? GetNameCore()
        {
            var result = AutomationProperties.GetName(Owner);

            if (string.IsNullOrWhiteSpace(result) && GetLabeledBy() is AutomationPeer labeledBy)
            {
                result = labeledBy.GetName();
            }

            return result;
        }
        protected override string? GetHelpTextCore()
        {
            var result = AutomationProperties.GetHelpText(Owner);

            if (string.IsNullOrWhiteSpace(result))
            {
                var errors = DataValidationErrors.GetErrors(Owner);
                var errorsStringList = errors?.Select(x => x.ToString());
                result = errorsStringList != null ? string.Join(Environment.NewLine, errorsStringList.ToArray()) : null;
            }

            if (string.IsNullOrWhiteSpace(result))
            {
                result = ToolTip.GetTip(Owner) as string;
            }

            return result;
        }
        protected override AutomationPeer? GetParentCore()
        {
            EnsureConnected();
            return _parent;
        }

        protected override AutomationPeer? GetVisualRootCore()
        {
            if (Owner.GetVisualRoot() is Control c)
                return CreatePeerForElement(c);
            return null;
        }

        /// <summary>
        /// Invalidates the peer's children and causes a re-read from <see cref="GetChildrenCore"/>.
        /// </summary>
        protected void InvalidateChildren()
        {
            _childrenValid = false;