From 6e271ed069db253e76011ed59c05a5e05bb20535 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Sun, 29 Jan 2023 03:34:29 -0500 Subject: [PATCH] Fix test cases with DataTemplates --- ...valoniaXamlIlDataContextTypeTransformer.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlDataContextTypeTransformer.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlDataContextTypeTransformer.cs index 16049be5dc..a24d4eb6e9 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlDataContextTypeTransformer.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlDataContextTypeTransformer.cs @@ -95,16 +95,16 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers { inferredDataContextTypeNode = InferDataContextOfPresentedItem(context, on, parentObject, propertyName); } - - if (inferredDataContextTypeNode is null - // Only for IDataTemplate, as we want to notify user as early as possible, - // and IDataTemplate cannot inherit DataType from the parent implicitly. - && context.GetAvaloniaTypes().IDataTemplate.IsAssignableFrom(on.Type.GetClrType())) - { - // We can't infer the collection type and the currently calculated type is definitely wrong. - // Notify the user that we were unable to infer the data context type if they use a compiled binding. - inferredDataContextTypeNode = new AvaloniaXamlIlUninferrableDataContextMetadataNode(on); - } + } + + if (inferredDataContextTypeNode is null + // Only for IDataTemplate, as we want to notify user as early as possible, + // and IDataTemplate cannot inherit DataType from the parent implicitly. + && context.GetAvaloniaTypes().IDataTemplate.IsAssignableFrom(on.Type.GetClrType())) + { + // We can't infer the collection type and the currently calculated type is definitely wrong. + // Notify the user that we were unable to infer the data context type if they use a compiled binding. + inferredDataContextTypeNode = new AvaloniaXamlIlUninferrableDataContextMetadataNode(on); } }