Skip to content

Commit

Permalink
Prioritize compiled markup extensions over primitive types (#20808)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrozsival authored Feb 27, 2024
1 parent 508f53c commit 39a169a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Controls/src/Build.Tasks/CreateObjectVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 39a169a

Please sign in to comment.