diff --git a/src/Controls/src/Xaml/XamlNode.cs b/src/Controls/src/Xaml/XamlNode.cs index a84f923c76e7..36dbe6fe6dbe 100644 --- a/src/Controls/src/Xaml/XamlNode.cs +++ b/src/Controls/src/Xaml/XamlNode.cs @@ -208,7 +208,7 @@ public override void Accept(IXamlNodeVisitor visitor, INode parentNode) { foreach (var node in Properties.Values.ToList()) node.Accept(visitor, this); - foreach (var node in CollectionItems) + foreach (var node in CollectionItems.ToList()) node.Accept(visitor, this); } diff --git a/src/Controls/tests/Xaml.UnitTests/Issues/Maui17222.xaml.cs b/src/Controls/tests/Xaml.UnitTests/Issues/Maui17222.xaml.cs index 6df8db5ecc97..ad7fd5f5b858 100644 --- a/src/Controls/tests/Xaml.UnitTests/Issues/Maui17222.xaml.cs +++ b/src/Controls/tests/Xaml.UnitTests/Issues/Maui17222.xaml.cs @@ -27,6 +27,7 @@ class Test #if DEBUG [SetUp] public void Setup() => AppInfo.SetCurrent(new MockAppInfo()); [TearDown] public void TearDown() => AppInfo.SetCurrent(null); + [Test] public void GetsourceInfo([Values(false)] bool useCompiledXaml) { diff --git a/src/Controls/tests/Xaml.UnitTests/Issues/Maui17333.xaml b/src/Controls/tests/Xaml.UnitTests/Issues/Maui17333.xaml new file mode 100644 index 000000000000..3e6232437851 --- /dev/null +++ b/src/Controls/tests/Xaml.UnitTests/Issues/Maui17333.xaml @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/src/Controls/tests/Xaml.UnitTests/Issues/Maui17333.xaml.cs b/src/Controls/tests/Xaml.UnitTests/Issues/Maui17333.xaml.cs new file mode 100644 index 000000000000..2b94672f3da2 --- /dev/null +++ b/src/Controls/tests/Xaml.UnitTests/Issues/Maui17333.xaml.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System; +using Microsoft.Maui.ApplicationModel; +using Microsoft.Maui.Controls.Core.UnitTests; +using Microsoft.Maui.Controls.Shapes; +using Microsoft.Maui.Devices; +using Microsoft.Maui.Graphics; +using NUnit.Framework; + +namespace Microsoft.Maui.Controls.Xaml.UnitTests; + +public partial class Maui17333 : ResourceDictionary +{ + + public Maui17333() => InitializeComponent(); + + public Maui17333(bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Test + { + [SetUp] public void Setup() => AppInfo.SetCurrent(new MockAppInfo()); + [TearDown] public void TearDown() => AppInfo.SetCurrent(null); + + [Test] + public void CompilerDoesntThrowOnOnPlatform([Values(true)] bool useCompiledXaml) + { + if (useCompiledXaml) + { + MockCompiler.Compile(typeof(Maui17333),targetFramework: "net-ios"); + } + } + } +} \ No newline at end of file