diff --git a/src/Avalonia.Styling/LogicalTree/ControlLocator.cs b/src/Avalonia.Styling/LogicalTree/ControlLocator.cs index 491f38c153..a8ec84bfa6 100644 --- a/src/Avalonia.Styling/LogicalTree/ControlLocator.cs +++ b/src/Avalonia.Styling/LogicalTree/ControlLocator.cs @@ -3,9 +3,6 @@ using System; using System.Linq; -using System.Reactive.Linq; -using System.Reflection; -using Avalonia.Controls; using Avalonia.Reactive; namespace Avalonia.LogicalTree @@ -25,7 +22,7 @@ namespace Avalonia.LogicalTree private readonly ILogical _relativeTo; private readonly int _ancestorLevel; private readonly Type _ancestorType; - ILogical _value; + private ILogical _value; public ControlTracker(ILogical relativeTo, int ancestorLevel, Type ancestorType) { @@ -69,7 +66,7 @@ namespace Avalonia.LogicalTree private void Update() { _value = _relativeTo.GetLogicalAncestors() - .Where(x => _ancestorType?.GetTypeInfo().IsAssignableFrom(x.GetType().GetTypeInfo()) ?? true) + .Where(x => _ancestorType?.IsAssignableFrom(x.GetType()) ?? true) .ElementAtOrDefault(_ancestorLevel); } } diff --git a/src/Avalonia.Styling/Styling/Setter.cs b/src/Avalonia.Styling/Styling/Setter.cs index 9312d38c51..9244232ff5 100644 --- a/src/Avalonia.Styling/Styling/Setter.cs +++ b/src/Avalonia.Styling/Styling/Setter.cs @@ -3,9 +3,7 @@ using System; using System.Reactive.Disposables; -using System.Reflection; using Avalonia.Animation; -using Avalonia.Controls; using Avalonia.Data; using Avalonia.Metadata; using Avalonia.Reactive; @@ -92,14 +90,15 @@ namespace Avalonia.Styling if (binding == null) { - var template = value as ITemplate; - bool isPropertyOfTypeITemplate = typeof(ITemplate).GetTypeInfo() - .IsAssignableFrom(Property.PropertyType.GetTypeInfo()); - - if (template != null && !isPropertyOfTypeITemplate) + if (value is ITemplate template) { - var materialized = template.Build(); - value = materialized; + bool isPropertyOfTypeITemplate = typeof(ITemplate).IsAssignableFrom(Property.PropertyType); + + if (!isPropertyOfTypeITemplate) + { + var materialized = template.Build(); + value = materialized; + } } if (activator == null) diff --git a/src/Avalonia.Styling/Styling/TypeNameAndClassSelector.cs b/src/Avalonia.Styling/Styling/TypeNameAndClassSelector.cs index f1fd2f6c7f..401fa54fb5 100644 --- a/src/Avalonia.Styling/Styling/TypeNameAndClassSelector.cs +++ b/src/Avalonia.Styling/Styling/TypeNameAndClassSelector.cs @@ -114,7 +114,7 @@ namespace Avalonia.Styling } else { - if (!TargetType.GetTypeInfo().IsAssignableFrom(controlType.GetTypeInfo())) + if (!TargetType.IsAssignableFrom(controlType)) { return SelectorMatch.NeverThisType; }