Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Cleanup of AccessibilityExtensions #27052

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public static void SetAutomationPropertiesAutomationId(this FrameworkElement Con
_defaultAutomationPropertiesName = currentValue = (string)Control.GetValue(NativeAutomationProperties.NameProperty);
}

#pragma warning disable CS0618 // Type or member is obsolete
var elemValue = (string)Element.GetValue(AutomationProperties.NameProperty);
#pragma warning restore CS0618 // Type or member is obsolete

var elemValue = (string)Element.GetValue(SemanticProperties.DescriptionProperty);
string newValue = !string.IsNullOrWhiteSpace(elemValue) ? elemValue : _defaultAutomationPropertiesName;

if (currentValue is null || currentValue != newValue)
Expand Down Expand Up @@ -88,10 +85,7 @@ public static void SetAutomationPropertiesAutomationId(this FrameworkElement Con
_defaultAutomationPropertiesHelpText = currentValue = (string)Control.GetValue(NativeAutomationProperties.HelpTextProperty);
}

#pragma warning disable CS0618 // Type or member is obsolete
var elemValue = (string)Element.GetValue(AutomationProperties.HelpTextProperty);
#pragma warning restore CS0618 // Type or member is obsolete

var elemValue = (string)Element.GetValue(SemanticProperties.HintProperty);
string newValue = !string.IsNullOrWhiteSpace(elemValue) ? elemValue : _defaultAutomationPropertiesHelpText;

if (currentValue is null || newValue != currentValue)
Expand Down Expand Up @@ -123,9 +117,8 @@ public static void SetAutomationPropertiesAutomationId(this FrameworkElement Con
{
_defaultAutomationPropertiesLabeledBy = currentValue = (UIElement)Control.GetValue(NativeAutomationProperties.LabeledByProperty);
}
#pragma warning disable CS0618 // Type or member is obsolete
var elemValue = (VisualElement)Element.GetValue(AutomationProperties.LabeledByProperty);
#pragma warning restore CS0618 // Type or member is obsolete

var elemValue = (VisualElement)Element.GetValue(SemanticProperties.DescriptionProperty);
FrameworkElement? nativeElement = null;

if (mauiContext != null)
Expand All @@ -137,9 +130,7 @@ public static void SetAutomationPropertiesAutomationId(this FrameworkElement Con

if (currentValue is null || newValue != currentValue)
{
#pragma warning disable CS0618 // Type or member is obsolete
Control.SetValue(AutomationProperties.LabeledByProperty, newValue);
#pragma warning restore CS0618 // Type or member is obsolete
Control.SetValue(SemanticProperties.DescriptionProperty, newValue);
}

return _defaultAutomationPropertiesLabeledBy;
Expand All @@ -161,22 +152,10 @@ public static void SetBackButtonTitle(this PageControl Control, Element? Element

static string ConcatenateNameAndHint(Element Element)
{
string separator;

#pragma warning disable CS0618 // Type or member is obsolete
var name = (string)Element.GetValue(AutomationProperties.NameProperty);

var hint = (string)Element.GetValue(AutomationProperties.HelpTextProperty);
#pragma warning restore CS0618 // Type or member is obsolete
var name = (string)Element.GetValue(SemanticProperties.DescriptionProperty);
var hint = (string)Element.GetValue(SemanticProperties.HintProperty);

if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(hint))
{
separator = "";
}
else
{
separator = ". ";
}
string separator = string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(hint) ? "" : ". ";

return string.Join(separator, name, hint);

Expand Down
52 changes: 26 additions & 26 deletions src/Core/src/Handlers/IElementHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,49 @@
/// </summary>
public interface IElementHandler
{
/// <summary>
/// <summary>
/// Sets the .NET MAUI context for the element handler.
/// </summary>
/// <param name="mauiContext">The .NET MAUI context to set.</param>
/// </summary>
/// <param name="mauiContext">The .NET MAUI context to set.</param>
void SetMauiContext(IMauiContext mauiContext);

/// <summary>
/// <summary>
/// Sets the cross-platform virtual view associated with the handler.
/// </summary>
/// <param name="view">The element to handle.</param>
/// </summary>
/// <param name="view">The element to handle.</param>
void SetVirtualView(IElement view);

/// <summary>
/// Updates the value of the specified property on the handler.
/// </summary>
/// <param name="property">The name of the property to update.</param>
/// <summary>
/// Updates the value of the specified property on the handler.
/// </summary>
/// <param name="property">The name of the property to update.</param>
void UpdateValue(string property);

/// <summary>
/// Invokes the specified command on the element with the given arguments.
/// </summary>
/// <param name="command">The name of the command to invoke.</param>
/// <param name="args">Optional arguments to pass to the command.</param>
/// <summary>
/// Invokes the specified command on the element with the given arguments.
/// </summary>
/// <param name="command">The name of the command to invoke.</param>
/// <param name="args">Optional arguments to pass to the command.</param>
void Invoke(string command, object? args = null);

/// <summary>
/// <summary>
/// Disconnects the element handler from the element for clean up.
/// </summary>
/// </summary>
void DisconnectHandler();

/// <summary>
/// Gets the platform-specific view object associated with the handler.
/// </summary>
/// <summary>
/// Gets the platform-specific view object associated with the handler.
/// </summary>
object? PlatformView { get; }

/// <summary>
/// Gets the cross-platform virtual view associated with the handler.
/// </summary>
/// <summary>
/// Gets the cross-platform virtual view associated with the handler.
/// </summary>
IElement? VirtualView { get; }

/// <summary>
/// Gets the .NET MAUI context associated with the element.
/// </summary>
/// <summary>
/// Gets the .NET MAUI context associated with the element.
/// </summary>
IMauiContext? MauiContext { get; }
}
}
Loading