Browse Source

Implement diagnostic API.

Doesn't actually fill in the "details" property for styled properties because this API is going to change shortly with the new devtools.
pull/3287/head
Steven Kirk 6 years ago
parent
commit
6ddc953103
  1. 27
      src/Avalonia.Base/AvaloniaObject.cs
  2. 31
      src/Avalonia.Base/Diagnostics/AvaloniaObjectExtensions.cs
  3. 17
      src/Avalonia.Base/ValueStore.cs

27
src/Avalonia.Base/AvaloniaObject.cs

@ -587,6 +587,33 @@ namespace Avalonia
}
}
internal AvaloniaPropertyValue GetDiagnosticInternal(AvaloniaProperty property)
{
if (property.IsDirect)
{
return new AvaloniaPropertyValue(
property,
GetValue(property),
BindingPriority.Unset,
"Local Value");
}
else if (_values != null)
{
var result = _values.GetDiagnostic(property);
if (result != null)
{
return result;
}
}
return new AvaloniaPropertyValue(
property,
GetValue(property),
BindingPriority.Unset,
"Unset");
}
/// <summary>
/// Logs a binding error for a property.
/// </summary>

31
src/Avalonia.Base/Diagnostics/AvaloniaObjectExtensions.cs

@ -22,36 +22,7 @@ namespace Avalonia.Diagnostics
/// </returns>
public static AvaloniaPropertyValue GetDiagnostic(this AvaloniaObject o, AvaloniaProperty property)
{
throw new NotImplementedException();
////var set = o.GetSetValues();
////if (set.TryGetValue(property, out var obj))
////{
//// if (obj is PriorityValue value)
//// {
//// return new AvaloniaPropertyValue(
//// property,
//// o.GetValue(property),
//// (BindingPriority)value.ValuePriority,
//// value.GetDiagnostic());
//// }
//// else
//// {
//// return new AvaloniaPropertyValue(
//// property,
//// obj,
//// BindingPriority.LocalValue,
//// "Local value");
//// }
////}
////else
////{
//// return new AvaloniaPropertyValue(
//// property,
//// o.GetValue(property),
//// BindingPriority.Unset,
//// "Unset");
////}
return o.GetDiagnosticInternal(property);
}
}
}

17
src/Avalonia.Base/ValueStore.cs

@ -129,6 +129,23 @@ namespace Avalonia
}
}
public Diagnostics.AvaloniaPropertyValue? GetDiagnostic(AvaloniaProperty property)
{
if (_values.TryGetValue(property, out var slot))
{
if (slot is IValue value)
{
return new Diagnostics.AvaloniaPropertyValue(
property,
value.Value.HasValue ? (object)value.Value : AvaloniaProperty.UnsetValue,
value.ValuePriority,
null);
}
}
return null;
}
void IValueSink.ValueChanged<T>(
StyledPropertyBase<T> property,
BindingPriority priority,

Loading…
Cancel
Save