From bda4a4b9641788e2718a10360f5ae21ee1bfe248 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 29 Sep 2022 23:24:17 +0200 Subject: [PATCH] Include inherited/default values in diagnostic. --- src/Avalonia.Base/PropertyStore/ValueStore.cs | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Base/PropertyStore/ValueStore.cs b/src/Avalonia.Base/PropertyStore/ValueStore.cs index eb97009355..9b80002a33 100644 --- a/src/Avalonia.Base/PropertyStore/ValueStore.cs +++ b/src/Avalonia.Base/PropertyStore/ValueStore.cs @@ -619,11 +619,29 @@ namespace Avalonia.PropertyStore public AvaloniaPropertyValue GetDiagnostic(AvaloniaProperty property) { - var effective = GetEffectiveValue(property); + object? value; + BindingPriority priority; + + if (_effectiveValues.TryGetValue(property, out var v)) + { + value = v.Value; + priority = v.Priority; + } + else if (property.Inherits && TryGetInheritedValue(property, out v)) + { + value = v.Value; + priority = BindingPriority.Inherited; + } + else + { + value = GetDefaultValue(property); + priority = BindingPriority.Unset; + } + return new AvaloniaPropertyValue( property, - effective?.Value, - effective?.Priority ?? BindingPriority.Unset, + value, + priority, null); }