Browse Source

Merge pull request #6849 from workgroupengineering/fixes/Issue_6848

fixes(DevTools): Ambiguous match found Exception
# Conflicts:
#	src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs
release/0.10.11-rc.1
Tako 5 years ago
committed by Dan Walmsley
parent
commit
46e0c4df1f
  1. 4
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/AvaloniaPropertyViewModel.cs
  2. 4
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/ClrPropertyViewModel.cs
  3. 11
      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 ? Name = property.IsAttached ?
$"[{property.OwnerType.Name}.{property.Name}]" : $"[{property.OwnerType.Name}.{property.Name}]" :
property.Name; property.Name;
DeclaringType = property.OwnerType;
Update(); Update();
} }
@ -50,6 +50,8 @@ namespace Avalonia.Diagnostics.ViewModels
public override string Group => _group; public override string Group => _group;
public override System.Type? DeclaringType { get; }
// [MemberNotNull(nameof(_type), nameof(_group), nameof(_priority))] // [MemberNotNull(nameof(_type), nameof(_group), nameof(_priority))]
public override void Update() 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; Name = property.DeclaringType.Name + '.' + property.Name;
} }
DeclaringType = property.DeclaringType;
Update(); Update();
} }
@ -55,6 +55,8 @@ namespace Avalonia.Diagnostics.ViewModels
public override bool? IsAttached => public override bool? IsAttached =>
default; default;
public override System.Type? DeclaringType { get; }
// [MemberNotNull(nameof(_type))] // [MemberNotNull(nameof(_type))]
public override void Update() public override void Update()
{ {

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

@ -24,7 +24,7 @@ namespace Avalonia.Diagnostics.ViewModels
private bool _showInactiveStyles; private bool _showInactiveStyles;
private string? _styleStatus; private string? _styleStatus;
private object _selectedEntity; 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 _selectedEntityName;
private string _selectedEntityType; private string _selectedEntityType;
@ -404,11 +404,14 @@ namespace Avalonia.Diagnostics.ViewModels
var property = (_selectedEntity as IControl)?.GetValue(SelectedProperty.Key as AvaloniaProperty); var property = (_selectedEntity as IControl)?.GetValue(SelectedProperty.Key as AvaloniaProperty);
if (property == null) if (property == null)
{ {
property = _selectedEntity.GetType().GetProperty(SelectedProperty.Name)?.GetValue(_selectedEntity); property = _selectedEntity.GetType().GetProperties()
.FirstOrDefault(pi => pi.Name == _selectedProperty?.Name
&& pi.DeclaringType == _selectedProperty.DeclaringType
&& pi.PropertyType.Name == _selectedProperty.Type)
?.GetValue(_selectedEntity);
} }
if (property == null) return; if (property == null) return;
_selectedEntitiesStack.Push(new Tuple<string, object>(SelectedEntityName, SelectedEntity)); _selectedEntitiesStack.Push(new (SelectedEntityName, SelectedEntity));
NavigateToProperty(property, SelectedProperty.Name); NavigateToProperty(property, SelectedProperty.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 Name { get; }
public abstract string Group { get; } public abstract string Group { get; }
public abstract string Type { get; } public abstract string Type { 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; }
public abstract bool? IsAttached { get; } public abstract bool? IsAttached { get; }

Loading…
Cancel
Save