Skip to content

AutomationProperties string attached properties (HelpText, AcceleratorKey, ...) default to null instead of an empty string #25260

Closed

Description

@MartinZikmund

Current behavior 🐛

Several string attached properties on AutomationProperties are registered with default(string), so reading them on an element that never set them returns null:

var b = new Button();
AutomationProperties.GetHelpText(b);            // null
AutomationProperties.GetAcceleratorKey(b);      // null

Affected properties (all registered with new FrameworkPropertyMetadata(default(string)) in AutomationProperties.cs):

AcceleratorKey, AccessKey, FullDescription, HelpText, ItemStatus, ItemType, LocalizedControlType, LocalizedLandmarkType.

Only Name (and AutomationId) already default to "".

Expected behavior 🎯

Same as WinUI: the getters return string.Empty when the property was never set. In WinUI these are HSTRING attached properties declared without a default value (StaticMetadata.g.cpp: the AutomationProperties_AcceleratorKey etc. entries carry only type and flags, no default), and the getters just forward to GetValueByKnownIndex (AutomationProperties.cpp). An unset string reads as an empty HSTRING, which C# sees as "".

This is backed by WinUI C++ source inspection (no native WinUI run). WinUI-ported tests also rely on it, e.g. Verify.AreEqual(string.Empty, AutomationProperties.GetHelpText(element)).

How to reproduce it (as minimally and precisely as possible) 🔬

  1. Create any Uno app (Skia desktop is enough).
  2. Run:
var b = new Button();
Assert.AreEqual(string.Empty, AutomationProperties.GetHelpText(b));            // fails, actual: null
Assert.AreEqual(string.Empty, AutomationProperties.GetAcceleratorKey(b));      // fails, actual: null
// same for AccessKey, FullDescription, ItemStatus, ItemType, LocalizedControlType, LocalizedLandmarkType
  1. Compare with WinUI, where all of these return "".

Confirmed by code inspection on master at cc48541 (the registrations above). The effect was also hit at runtime on Skia desktop through ported WinUI tests that assert string.Empty for HelpText.

Workaround 🛠️

AutomationProperties.GetXxx(element) ?? string.Empty

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

All (shared Uno.UI code).

Uno.SDK version (and other relevant versions) 📦

master @ cc48541

IDE version 🧑‍💻

N/A

Anything else we need to know? 💬

Suggested fix: change the defaults to string.Empty and audit consumers that compare to null (e.g. AriaMapper and the automation peers). Most already use IsNullOrEmpty / ?? string.Empty. A fix for HelpText is in progress; the other seven properties still need the same change.

Activity

  1. added
    kind/bug
    triage/untriaged
    area/a11y
    platform/all
    difficulty/medium 🤔
    on Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/a11ydifficulty/medium 🤔kind/bugplatform/alltriage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions