Browse Source

fixes(DevTools): Ambiguous match found Exception

pull/6849/head
Giuseppe Lippolis 5 years ago
parent
commit
01582cb552
  1. 4
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/AvaloniaPropertyViewModel.cs
  2. 4
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/ClrPropertyViewModel.cs
  3. 24
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs
  4. 1
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/PropertyViewModel.cs

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

@ -19,7 +19,7 @@ namespace Avalonia.Diagnostics.ViewModels
Name = property.IsAttached ?
$"[{property.OwnerType.Name}.{property.Name}]" :
property.Name;
DeclaringType = property.OwnerType;
Update();
}
@ -50,6 +50,8 @@ namespace Avalonia.Diagnostics.ViewModels
public override string Group => _group;
public override System.Type? DeclaringType { get; }
// [MemberNotNull(nameof(_type), nameof(_group), nameof(_priority))]
public override void Update()
{

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

@ -24,7 +24,7 @@ namespace Avalonia.Diagnostics.ViewModels
{
Name = property.DeclaringType.Name + '.' + property.Name;
}
DeclaringType = property.DeclaringType;
Update();
}
@ -55,6 +55,8 @@ namespace Avalonia.Diagnostics.ViewModels
public override bool? IsAttached =>
default;
public override System.Type? DeclaringType { get; }
// [MemberNotNull(nameof(_type))]
public override void Update()
{

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

@ -24,7 +24,7 @@ namespace Avalonia.Diagnostics.ViewModels
private bool _showInactiveStyles;
private string? _styleStatus;
private object _selectedEntity;
private readonly Stack<Tuple<string, object>> _selectedEntitiesStack = new Stack<Tuple<string, object>>();
private readonly Stack<(string Name,object Entry)> _selectedEntitiesStack = new();
private string _selectedEntityName;
private string _selectedEntityType;
@ -399,17 +399,27 @@ namespace Avalonia.Diagnostics.ViewModels
public void ApplySelectedProperty()
{
if (SelectedProperty == null) return;
var selectedProperty = SelectedProperty;
var selectedEntity = SelectedEntity;
var selectedEntityName = SelectedEntityName;
if (selectedProperty == null) return;
var property = (_selectedEntity as IControl)?.GetValue(SelectedProperty.Key as AvaloniaProperty);
var property = (selectedEntity as IControl)?.GetValue(selectedProperty.Key as AvaloniaProperty);
if (property == null)
{
property = _selectedEntity.GetType().GetProperty(SelectedProperty.Name)?.GetValue(_selectedEntity);
property = selectedEntity.GetType().GetProperties()
.FirstOrDefault(pi =>
{
return pi.Name == selectedProperty.Name
&& pi.DeclaringType == selectedProperty.DeclaringType
&& pi.PropertyType.Name == selectedProperty.Type;
})
?.GetValue(selectedEntity);
}
if (property == null) return;
_selectedEntitiesStack.Push(new Tuple<string, object>(SelectedEntityName, SelectedEntity));
NavigateToProperty(property, SelectedProperty.Name);
_selectedEntitiesStack.Push((Name:selectedEntityName, Entry:selectedEntity));
NavigateToProperty(property, selectedProperty.Name);
}
public void ApplyParentProperty()
@ -417,7 +427,7 @@ namespace Avalonia.Diagnostics.ViewModels
if (_selectedEntitiesStack.Any())
{
var property = _selectedEntitiesStack.Pop();
NavigateToProperty(property.Item2, property.Item1);
NavigateToProperty(property.Entry, property.Name);
}
}

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

@ -15,6 +15,7 @@ namespace Avalonia.Diagnostics.ViewModels
public abstract string Name { get; }
public abstract string Group { get; }
public abstract string Type { get; }
public abstract Type? DeclaringType { get; }
public abstract string Value { get; set; }
public abstract string Priority { get; }
public abstract bool? IsAttached { get; }

Loading…
Cancel
Save