Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ public void Visit(ElementNode node, INode parentNode)
if (adderRef.ReturnType.FullName != "System.Void")
Context.IL.Emit(Pop);
}

else
throw new BuildException(BuildExceptionCode.ContentPropertyAttributeMissing, node, null, ((IElementNode)parentNode).XmlType.Name);
}
Expand Down
26 changes: 5 additions & 21 deletions src/Controls/src/SourceGen/Visitors/SetPropertiesVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,27 +153,11 @@ public void Visit(ElementNode node, INode parentNode)
{
Writer.WriteLine($"{parentVar.Name}.Add({Context.Variables[node].Name});");
}

// Context.IL.Append(SetPropertyValue(Context.Variables[(IElementNode)parentNode], name, node, Context, node));
// }
// // Collection element, implicit content, or implicit collection element.
// else if (parentVar.VariableType.ImplementsInterface(Context.Cache, Module.ImportReference(Context.Cache, ("mscorlib", "System.Collections", "IEnumerable")))
// && parentVar.VariableType.GetMethods(Context.Cache, md => md.Name == "Add" && md.Parameters.Count == 1, Module).Any())
// {
// var elementType = parentVar.VariableType;
// var adderTuple = elementType.GetMethods(Context.Cache, md => md.Name == "Add" && md.Parameters.Count == 1, Module).First();
// var adderRef = Module.ImportReference(adderTuple.Item1);
// adderRef = Module.ImportReference(adderRef.ResolveGenericParameters(adderTuple.Item2, Module));

// Context.IL.Emit(Ldloc, parentVar);
// Context.IL.Append(vardef.LoadAs(Context.Cache, adderRef.Parameters[0].ParameterType.ResolveGenericParameters(adderRef), Module));
// Context.IL.Emit(Callvirt, adderRef);
// if (adderRef.ReturnType.FullName != "System.Void")
// Context.IL.Emit(Pop);
// }

// else
// throw new BuildException(BuildExceptionCode.ContentPropertyAttributeMissing, node, null, ((IElementNode)parentNode).XmlType.Name);
else
{
var location = LocationCreate(Context.ProjectItem.RelativePath!, (IXmlLineInfo)node, ((IElementNode)parentNode).XmlType.Name);
Copy link

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method LocationCreate is being called but it's not defined in this class or imported. This will cause a compilation error.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I challenge you on this one, copilot

context.ReportDiagnostic(Diagnostic.Create(Descriptors.XamlParserError, location, $"Cannot set the content of {((IElementNode)parentNode).XmlType.Name} as it doesn't have a ContentPropertyAttribute"));
}
}
else if (parentNode.IsCollectionItem(node) && parentNode is ListNode parentList)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,5 @@ private partial void InitializeComponent()
Assert.IsFalse(result.Diagnostics.Any());

Assert.AreEqual(expected, generated);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<DisableMSBuildAssemblyCopyCheck>true</DisableMSBuildAssemblyCopyCheck>
<MauiEnableXamlCBindingWithSourceCompilation>true</MauiEnableXamlCBindingWithSourceCompilation>
<DefineConstants>$(DefineConstants);MauiAllowImplicitXmlnsDeclaration</DefineConstants>
<!-- <MauiXamlEnableDiagnostics>false</MauiXamlEnableDiagnostics> -->
<!-- We can't yet disable the namescope generation, ConstraintTypeConverter and ReferenceTypeConverter need to be ported to sourcegen
<DefineConstants>$(DefineConstants);_MAUIXAML_SG_NAMESCOPE_DISABLE</DefineConstants>
-->
Expand Down
7 changes: 1 addition & 6 deletions src/Controls/tests/Xaml.UnitTests/Issues/Bz43694.rt.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ public partial class Bz43694 : ContentPage
class Tests
{
[Test]
#if FIXME_BEFORE_PUBLIC_RELEASE
public void xStaticWithOnPlatformChildInRD([Values(XamlInflator.XamlC, XamlInflator.Runtime)] XamlInflator inflator)
#else
public void xStaticWithOnPlatformChildInRD([Values] XamlInflator inflator)
#endif
{
if (inflator == XamlInflator.XamlC)
Assert.Throws(new BuildExceptionConstraint(9, 6), () => MockCompiler.Compile(typeof(Bz43694)));
Expand All @@ -37,10 +33,9 @@ public partial class Bz43694 : ContentPage
}
""")
.RunMauiSourceGenerator(typeof(Bz43694));
var generated = result.GeneratedInitializeComponent();
Assert.That(result.Diagnostics.Any());
}
else
Assert.Ignore("Unknown inflator");
}
}
}
Loading