diff --git a/src/Controls/src/Build.Tasks/CreateObjectVisitor.cs b/src/Controls/src/Build.Tasks/CreateObjectVisitor.cs index b0ab313cd380..45705331c637 100644 --- a/src/Controls/src/Build.Tasks/CreateObjectVisitor.cs +++ b/src/Controls/src/Build.Tasks/CreateObjectVisitor.cs @@ -51,17 +51,6 @@ public void Visit(ElementNode node, INode parentNode) var typeref = Module.ImportReference(node.XmlType.GetTypeReference(Context.Cache, Module, node)); TypeDefinition typedef = typeref.ResolveCached(Context.Cache); - if (IsXaml2009LanguagePrimitive(node)) - { - var vardef = new VariableDefinition(typeref); - Context.Variables[node] = vardef; - Context.Body.Variables.Add(vardef); - - Context.IL.Append(PushValueFromLanguagePrimitive(typedef, node)); - Context.IL.Emit(Stloc, vardef); - return; - } - //if this is a MarkupExtension that can be compiled directly, compile and returns the value var compiledMarkupExtensionName = typeref .GetCustomAttribute(Context.Cache, Module, ("Microsoft.Maui.Controls", "Microsoft.Maui.Controls.Xaml", "ProvideCompiledAttribute")) @@ -92,6 +81,17 @@ public void Visit(ElementNode node, INode parentNode) return; } + if (IsXaml2009LanguagePrimitive(node)) + { + var vardef = new VariableDefinition(typeref); + Context.Variables[node] = vardef; + Context.Body.Variables.Add(vardef); + + Context.IL.Append(PushValueFromLanguagePrimitive(typedef, node)); + Context.IL.Emit(Stloc, vardef); + return; + } + MethodDefinition factoryCtorInfo = null; MethodDefinition factoryMethodInfo = null; MethodDefinition parameterizedCtorInfo = null;