unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.88k stars 719 forks source link

ReadLocalValue() is never returning UnsetValue #18531

Open ajpinedam opened 2 hours ago

ajpinedam commented 2 hours ago

Current behavior

There are a few places in the Uno code where we use ReadLocalValue to validate whether a DependencyProperty has been set, returning UnsetValue. I have seen situations where we are returning null for DPs that still need to be set, and this behavior change is causing some issues.

Expected behavior

No response

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

No response

Workaround

N/A

Works on UWP/WinUI

None

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

5.6.0-dev.149

Affected platforms

WebAssembly, Android, iOS, Mac Catalyst, Skia (WPF), Skia (Linux X11), Skia (macOS), Skia (Linux Framebuffer), Skia (GTK)

IDE

Visual Studio 2022, Visual Studio Code

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

ajpinedam commented 2 hours ago

cc: @Youssef1313 I saw this issue while debugging a fix on PR https://github.com/unoplatform/uno/pull/18492

Youssef1313 commented 1 hour ago

That's quite strange. The implementation is currently:

https://github.com/unoplatform/uno/blob/b6333bd85ef09975ae45e538230dae337a96e43f/src/Uno.UI/UI/Xaml/DependencyObjectStore.cs#L281-L295

ajpinedam commented 1 hour ago

if (details?.GetBaseValueSource() == DependencyPropertyValuePrecedences.Local)

While debugging the code entered here

if (details?.GetBaseValueSource() == DependencyPropertyValuePrecedences.Local) 
{ 
    return details.GetBaseValue(); 
} 

and

return details.GetBaseValue(); 

is returning null instead of UnsetValue

cc: @Youssef1313

Youssef1313 commented 1 hour ago

That should mean that a local value of null was set. Are you able to track the SetValue calls?

ajpinedam commented 57 minutes ago

This is for the SelectedItem on the TabView (TabView.Properties file). I set a breakpoint inside the Set, which is never hit before hitting this method call.

We can get some time tomorrow and do a quick sync whenever you're available to look into it

cc: @Youssef1313