Browse Source

Merge remote-tracking branch 'origin/master' into fixes/wasm-props

pull/7144/head
Dan Walmsley 5 years ago
parent
commit
7a215e04bd
  1. 8
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/AvaloniaPropertyViewModel.cs
  2. 6
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/ClrPropertyViewModel.cs
  3. 8
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs
  4. 2
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/PropertyViewModel.cs
  5. 2
      src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml

8
src/Avalonia.Diagnostics/Diagnostics/ViewModels/AvaloniaPropertyViewModel.cs

@ -3,7 +3,7 @@ namespace Avalonia.Diagnostics.ViewModels
internal class AvaloniaPropertyViewModel : PropertyViewModel internal class AvaloniaPropertyViewModel : PropertyViewModel
{ {
private readonly AvaloniaObject _target; private readonly AvaloniaObject _target;
private string _type; private System.Type _type;
private object? _value; private object? _value;
private string _priority; private string _priority;
private string _group; private string _group;
@ -32,7 +32,7 @@ namespace Avalonia.Diagnostics.ViewModels
public override string Priority => public override string Priority =>
_priority; _priority;
public override string Type => _type; public override System.Type Type => _type;
public override string Value public override string Value
{ {
@ -58,7 +58,7 @@ namespace Avalonia.Diagnostics.ViewModels
if (Property.IsDirect) if (Property.IsDirect)
{ {
RaiseAndSetIfChanged(ref _value, _target.GetValue(Property), nameof(Value)); RaiseAndSetIfChanged(ref _value, _target.GetValue(Property), nameof(Value));
RaiseAndSetIfChanged(ref _type, _value?.GetType().Name ?? Property.PropertyType.Name, nameof(Type)); RaiseAndSetIfChanged(ref _type, _value?.GetType() ?? Property.PropertyType, nameof(Type));
RaiseAndSetIfChanged(ref _priority, "Direct", nameof(Priority)); RaiseAndSetIfChanged(ref _priority, "Direct", nameof(Priority));
_group = "Properties"; _group = "Properties";
@ -68,7 +68,7 @@ namespace Avalonia.Diagnostics.ViewModels
var val = _target.GetDiagnostic(Property); var val = _target.GetDiagnostic(Property);
RaiseAndSetIfChanged(ref _value, val?.Value, nameof(Value)); RaiseAndSetIfChanged(ref _value, val?.Value, nameof(Value));
RaiseAndSetIfChanged(ref _type, _value?.GetType().Name ?? Property.PropertyType.Name, nameof(Type)); RaiseAndSetIfChanged(ref _type, _value?.GetType() ?? Property.PropertyType, nameof(Type));
if (val != null) if (val != null)
{ {

6
src/Avalonia.Diagnostics/Diagnostics/ViewModels/ClrPropertyViewModel.cs

@ -5,7 +5,7 @@ namespace Avalonia.Diagnostics.ViewModels
internal class ClrPropertyViewModel : PropertyViewModel internal class ClrPropertyViewModel : PropertyViewModel
{ {
private readonly object _target; private readonly object _target;
private string _type; private System.Type _type;
private object? _value; private object? _value;
#nullable disable #nullable disable
@ -33,7 +33,7 @@ namespace Avalonia.Diagnostics.ViewModels
public override string Name { get; } public override string Name { get; }
public override string Group => "CLR Properties"; public override string Group => "CLR Properties";
public override string Type => _type; public override System.Type Type => _type;
public override string Value public override string Value
{ {
@ -62,7 +62,7 @@ namespace Avalonia.Diagnostics.ViewModels
{ {
var val = Property.GetValue(_target); var val = Property.GetValue(_target);
RaiseAndSetIfChanged(ref _value, val, nameof(Value)); RaiseAndSetIfChanged(ref _value, val, nameof(Value));
RaiseAndSetIfChanged(ref _type, _value?.GetType().Name ?? Property.PropertyType.Name, nameof(Type)); RaiseAndSetIfChanged(ref _type, _value?.GetType() ?? Property.PropertyType, nameof(Type));
} }
} }
} }

8
src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs

@ -403,7 +403,11 @@ namespace Avalonia.Diagnostics.ViewModels
var selectedProperty = SelectedProperty; var selectedProperty = SelectedProperty;
var selectedEntity = SelectedEntity; var selectedEntity = SelectedEntity;
var selectedEntityName = SelectedEntityName; var selectedEntityName = SelectedEntityName;
if (selectedEntity == null || selectedProperty == null) if (selectedEntity == null
|| selectedProperty == null
|| selectedProperty.Type == typeof(string)
|| selectedProperty.Type.IsValueType
)
return; return;
object? property; object? property;
@ -416,7 +420,7 @@ namespace Avalonia.Diagnostics.ViewModels
property = selectedEntity.GetType().GetProperties() property = selectedEntity.GetType().GetProperties()
.FirstOrDefault(pi => pi.Name == selectedProperty.Name .FirstOrDefault(pi => pi.Name == selectedProperty.Name
&& pi.DeclaringType == selectedProperty.DeclaringType && pi.DeclaringType == selectedProperty.DeclaringType
&& pi.PropertyType.Name == selectedProperty.Type) && pi.PropertyType.Name == selectedProperty.Type.Name)
?.GetValue(selectedEntity); ?.GetValue(selectedEntity);
} }
if (property == null) return; if (property == null) return;

2
src/Avalonia.Diagnostics/Diagnostics/ViewModels/PropertyViewModel.cs

@ -14,7 +14,7 @@ namespace Avalonia.Diagnostics.ViewModels
public abstract object Key { get; } public abstract object Key { get; }
public abstract string Name { get; } public abstract string Name { get; }
public abstract string Group { get; } public abstract string Group { get; }
public abstract string Type { get; } public abstract Type Type { get; }
public abstract Type? DeclaringType { get; } public abstract Type? DeclaringType { get; }
public abstract string Value { get; set; } public abstract string Value { get; set; }
public abstract string Priority { get; } public abstract string Priority { get; }

2
src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml

@ -40,7 +40,7 @@
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="Property" Binding="{Binding Name}" IsReadOnly="True" /> <DataGridTextColumn Header="Property" Binding="{Binding Name}" IsReadOnly="True" />
<DataGridTextColumn Header="Value" Binding="{Binding Value}" /> <DataGridTextColumn Header="Value" Binding="{Binding Value}" />
<DataGridTextColumn Header="Type" Binding="{Binding Type}" /> <DataGridTextColumn Header="Type" Binding="{Binding Type.Name}" />
<DataGridTextColumn Header="Priority" Binding="{Binding Priority}" IsReadOnly="True" /> <DataGridTextColumn Header="Priority" Binding="{Binding Priority}" IsReadOnly="True" />
</DataGrid.Columns> </DataGrid.Columns>

Loading…
Cancel
Save