You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VisualStateGroup.Name and VisualState.Name return null instead of an empty string when unnamed #25370
difficulty/starter 🚀Categorizes an issue for which the difficulty level is reachable by newcomerskind/bugSomething isn't workingplatform/allCategorizes an issue or PR as relevant to the all platformsproject/styling 👔Categorizes an issue or PR as relevant to element styling
VisualStateGroup.Name (and VisualState.Name) returns null for an unnamed group/state. WinUI returns an empty string.
On master, VisualStateGroup.Name is public string Name { get; internal set; } with no default and no null normalization (src/Uno.UI/UI/Xaml/VisualStateGroup.cs), and VisualState.Name is a plain { get; set; }. ToString() and the logging code already special-case the null.
Code that compares or concatenates names sees null instead of "". Impact is small. A third-party library hit it as a failing test asserting string.Empty after the setter became internal.
Expected behavior 🎯
An unnamed VisualStateGroup / VisualState has Name == "".
Backed by the WinUI C++ sources: both getters read the DependencyObject_Name property through GetValue and return the HSTRING value, whose default is empty:
VisualStateGroup::get_NameImpl in dxaml/xcp/dxaml/lib/VisualStateGroup_Partial.cpp
VisualState::get_NameImpl in dxaml/xcp/dxaml/lib/visualstate.cpp
Confirmed by code inspection of master (0599dad), not by a new runtime test. The same assertion for the group failed in a downstream library's runtime tests on WebAssembly.
Workaround 🛠️
Treat null as empty, or set the name via the public Uno.UI.Helpers.MarkupHelper.SetXName(group, string.Empty).
difficulty/starter 🚀Categorizes an issue for which the difficulty level is reachable by newcomerskind/bugSomething isn't workingplatform/allCategorizes an issue or PR as relevant to the all platformsproject/styling 👔Categorizes an issue or PR as relevant to element styling
Activity