From 979a659b49794400e513bdd3886640ff2f53d98d Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Fri, 13 Nov 2020 21:00:16 +0200 Subject: [PATCH] remove duplicate condition --- .../XamlIlBindingPathHelper.cs | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs index 3bea580da0..1974dfe3bc 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs @@ -198,24 +198,21 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions case BindingExpressionGrammar.AncestorNode ancestor: if (ancestor.Namespace is null && ancestor.TypeName is null) { - if (ancestor.Namespace is null && ancestor.TypeName is null) + var styledElementType = context.GetAvaloniaTypes().StyledElement; + var ancestorType = context + .ParentNodes() + .OfType() + .Where(x => styledElementType.IsAssignableFrom(x.Type.GetClrType())) + .Skip(1) + .ElementAtOrDefault(ancestor.Level) + ?.Type.GetClrType(); + + if (ancestorType is null) { - var styledElementType = context.GetAvaloniaTypes().StyledElement; - var ancestorType = context - .ParentNodes() - .OfType() - .Where(x => styledElementType.IsAssignableFrom(x.Type.GetClrType())) - .Skip(1) - .ElementAtOrDefault(ancestor.Level) - ?.Type.GetClrType(); - - if (ancestorType is null) - { - throw new XamlX.XamlParseException("Unable to resolve implicit ancestor type based on XAML tree.", lineInfo); - } - - nodes.Add(new FindAncestorPathElementNode(ancestorType, ancestor.Level)); + throw new XamlX.XamlParseException("Unable to resolve implicit ancestor type based on XAML tree.", lineInfo); } + + nodes.Add(new FindAncestorPathElementNode(ancestorType, ancestor.Level)); } else { @@ -622,10 +619,10 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions private readonly IXamlAstValueNode _rawSource; public RawSourcePathElementNode(IXamlAstValueNode rawSource) - :base(rawSource) + : base(rawSource) { _rawSource = rawSource; - + } public IXamlType Type => _rawSource.Type.GetClrType();