[Xaml] Support correctly custom resource providers (#4236)
authorAndoni Morales Alastruey <ylatuya@gmail.com>
Wed, 7 Nov 2018 14:07:18 +0000 (15:07 +0100)
committerStephane Delcroix <stephane@delcroix.org>
Wed, 7 Nov 2018 14:07:18 +0000 (15:07 +0100)
Xamarin.Forms.Xaml/XamlLoader.cs

index b21e9b0..b9df698 100644 (file)
@@ -157,6 +157,11 @@ namespace Xamarin.Forms.Xaml
                        var assembly = type.GetTypeInfo().Assembly;
                        var resourceId = XamlResourceIdAttribute.GetResourceIdForType(type);
 
+                       var alternateXaml = ResourceLoader.ResourceProvider?.Invoke(assembly.GetName(), XamlResourceIdAttribute.GetPathForType(type));
+                       if (alternateXaml != null) {
+                               return alternateXaml;
+                       }
+
                        if (resourceId == null)
                                return LegacyGetXamlForType(type);
 
@@ -168,8 +173,7 @@ namespace Xamarin.Forms.Xaml
                                        xaml = null;
                        }
 
-                       var alternateXaml = ResourceLoader.ResourceProvider?.Invoke(assembly.GetName(), XamlResourceIdAttribute.GetPathForType(type));
-                       return alternateXaml ?? xaml;
+                       return xaml;
                }
 
                //if the assembly was generated using a version of XamlG that doesn't outputs XamlResourceIdAttributes, we still need to find the resource, and load it