Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ambiguous match found Exception #6849

Merged
merged 2 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public AvaloniaPropertyViewModel(AvaloniaObject o, AvaloniaProperty property)
Name = property.IsAttached ?
$"[{property.OwnerType.Name}.{property.Name}]" :
property.Name;

DeclaringType = property.OwnerType;
Update();
}

Expand Down Expand Up @@ -50,6 +50,8 @@ public override string Value

public override string Group => _group;

public override System.Type? DeclaringType { get; }

// [MemberNotNull(nameof(_type), nameof(_group), nameof(_priority))]
public override void Update()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public ClrPropertyViewModel(object o, PropertyInfo property)
{
Name = property.DeclaringType.Name + '.' + property.Name;
}

DeclaringType = property.DeclaringType;
Update();
}

Expand Down Expand Up @@ -55,6 +55,8 @@ public override string Value
public override bool? IsAttached =>
default;

public override System.Type? DeclaringType { get; }

// [MemberNotNull(nameof(_type))]
public override void Update()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal class ControlDetailsViewModel : ViewModelBase, IDisposable
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;

Expand Down Expand Up @@ -399,25 +399,35 @@ private int GroupIndex(string? group)

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()
{
if (_selectedEntitiesStack.Any())
{
var property = _selectedEntitiesStack.Pop();
NavigateToProperty(property.Item2, property.Item1);
NavigateToProperty(property.Entry, property.Name);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal abstract class PropertyViewModel : ViewModelBase
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; }
Expand Down