Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XamlC] Prioritize compiled markup extensions over primitive types #20808

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading