diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs index 7180443f01c7..c3890597245b 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs @@ -62,18 +62,18 @@ public record DiagnosticsResult(string Id); foreach (var scenarioFolder in Directory.EnumerateDirectories(ScenariosFolder, "*.*", SearchOption.TopDirectoryOnly)) { var scenarioName = Path.GetFileName(scenarioFolder); - var path = Path.Combine(scenarioFolder, "Scenario.json"); + var scenarioConfig = Path.Combine(scenarioFolder, "Scenario.json"); #if DEBUG && false - if (!path.Contains("When_Base_Type_Grid_To_Page")) + if (!scenarioName.Contains("When_DataTemplate_Event_Add")) { continue; } #endif - if (File.Exists(path)) + if (File.Exists(scenarioConfig)) { - var scenariosDescriptor = ReadScenarioConfig(path); + var scenariosDescriptor = ReadScenarioConfig(scenarioConfig); if (scenariosDescriptor is not null) { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/0/p1/MainPage.xaml b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/0/p1/MainPage.xaml new file mode 100644 index 000000000000..32e62f956917 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/0/p1/MainPage.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/0/p1/MainPage.xaml.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/0/p1/MainPage.xaml.cs new file mode 100644 index 000000000000..46867f561656 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/0/p1/MainPage.xaml.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; + +namespace Test01; + +public sealed partial class MainPage : Page +{ + public MainPage() + { + this.InitializeComponent(); + } +} diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/1/p1/MainPage.xaml b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/1/p1/MainPage.xaml new file mode 100644 index 000000000000..33ce0aea6766 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/1/p1/MainPage.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/1/p1/MainPage.xaml.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/1/p1/MainPage.xaml.cs new file mode 100644 index 000000000000..46867f561656 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/1/p1/MainPage.xaml.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; + +namespace Test01; + +public sealed partial class MainPage : Page +{ + public MainPage() + { + this.InitializeComponent(); + } +} diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/Scenario.json b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/Scenario.json new file mode 100644 index 000000000000..902d6383b5fd --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/Scenario.json @@ -0,0 +1,24 @@ +{ + "Scenarios": [ + { + "IsDebug": true, + "IsMono": false, + "PassResults": [ + { + "MetadataUpdates": 1, + "Diagnostics": [] + } + ] + }, + { + "IsDebug": true, + "IsMono": true, + "PassResults": [ + { + "MetadataUpdates": 1, + "Diagnostics": [] + } + ] + } + ] +} diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/0/p1/MainPage.xaml b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/0/p1/MainPage.xaml new file mode 100644 index 000000000000..32e62f956917 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/0/p1/MainPage.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/0/p1/MainPage.xaml.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/0/p1/MainPage.xaml.cs new file mode 100644 index 000000000000..46867f561656 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/0/p1/MainPage.xaml.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; + +namespace Test01; + +public sealed partial class MainPage : Page +{ + public MainPage() + { + this.InitializeComponent(); + } +} diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/1/p1/MainPage.xaml b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/1/p1/MainPage.xaml new file mode 100644 index 000000000000..33ce0aea6766 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/1/p1/MainPage.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/1/p1/MainPage.xaml.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/1/p1/MainPage.xaml.cs new file mode 100644 index 000000000000..46867f561656 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/1/p1/MainPage.xaml.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; + +namespace Test01; + +public sealed partial class MainPage : Page +{ + public MainPage() + { + this.InitializeComponent(); + } +} diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/2/p1/MainPage.xaml b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/2/p1/MainPage.xaml new file mode 100644 index 000000000000..32e62f956917 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/2/p1/MainPage.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/2/p1/MainPage.xaml.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/2/p1/MainPage.xaml.cs new file mode 100644 index 000000000000..46867f561656 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/2/p1/MainPage.xaml.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; + +namespace Test01; + +public sealed partial class MainPage : Page +{ + public MainPage() + { + this.InitializeComponent(); + } +} diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/Scenario.json b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/Scenario.json new file mode 100644 index 000000000000..3c52d719dc04 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/Scenario.json @@ -0,0 +1,32 @@ +{ + "Scenarios": [ + { + "IsDebug": true, + "IsMono": false, + "PassResults": [ + { + "MetadataUpdates": 1, + "Diagnostics": [] + }, + { + "MetadataUpdates": 1, + "Diagnostics": [] + } + ] + }, + { + "IsDebug": true, + "IsMono": true, + "PassResults": [ + { + "MetadataUpdates": 1, + "Diagnostics": [] + }, + { + "MetadataUpdates": 1, + "Diagnostics": [] + } + ] + } + ] +} diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/0/p1/MainPage.xaml b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/0/p1/MainPage.xaml new file mode 100644 index 000000000000..33ce0aea6766 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/0/p1/MainPage.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/0/p1/MainPage.xaml.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/0/p1/MainPage.xaml.cs new file mode 100644 index 000000000000..46867f561656 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/0/p1/MainPage.xaml.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; + +namespace Test01; + +public sealed partial class MainPage : Page +{ + public MainPage() + { + this.InitializeComponent(); + } +} diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/1/p1/MainPage.xaml b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/1/p1/MainPage.xaml new file mode 100644 index 000000000000..32e62f956917 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/1/p1/MainPage.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/1/p1/MainPage.xaml.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/1/p1/MainPage.xaml.cs new file mode 100644 index 000000000000..46867f561656 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/1/p1/MainPage.xaml.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; + +namespace Test01; + +public sealed partial class MainPage : Page +{ + public MainPage() + { + this.InitializeComponent(); + } +} diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/Scenario.json b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/Scenario.json new file mode 100644 index 000000000000..902d6383b5fd --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/Scenario.json @@ -0,0 +1,24 @@ +{ + "Scenarios": [ + { + "IsDebug": true, + "IsMono": false, + "PassResults": [ + { + "MetadataUpdates": 1, + "Diagnostics": [] + } + ] + }, + { + "IsDebug": true, + "IsMono": true, + "PassResults": [ + { + "MetadataUpdates": 1, + "Diagnostics": [] + } + ] + } + ] +} diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/0/p1/MainPage.xaml b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/0/p1/MainPage.xaml new file mode 100644 index 000000000000..33ce0aea6766 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/0/p1/MainPage.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/0/p1/MainPage.xaml.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/0/p1/MainPage.xaml.cs new file mode 100644 index 000000000000..46867f561656 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/0/p1/MainPage.xaml.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; + +namespace Test01; + +public sealed partial class MainPage : Page +{ + public MainPage() + { + this.InitializeComponent(); + } +} diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/1/p1/MainPage.xaml b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/1/p1/MainPage.xaml new file mode 100644 index 000000000000..8c77c9f199b2 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/1/p1/MainPage.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/1/p1/MainPage.xaml.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/1/p1/MainPage.xaml.cs new file mode 100644 index 000000000000..46867f561656 --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/1/p1/MainPage.xaml.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; + +namespace Test01; + +public sealed partial class MainPage : Page +{ + public MainPage() + { + this.InitializeComponent(); + } +} diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/Scenario.json b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/Scenario.json new file mode 100644 index 000000000000..902d6383b5fd --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/Scenario.json @@ -0,0 +1,24 @@ +{ + "Scenarios": [ + { + "IsDebug": true, + "IsMono": false, + "PassResults": [ + { + "MetadataUpdates": 1, + "Diagnostics": [] + } + ] + }, + { + "IsDebug": true, + "IsMono": true, + "PassResults": [ + { + "MetadataUpdates": 1, + "Diagnostics": [] + } + ] + } + ] +} diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SBUIIOFFE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SBUIIOFFE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index aea9e14cc033..2f14a53a9f62 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SBUIIOFFE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SBUIIOFFE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -104,6 +104,11 @@ private void ApplyMethod_3(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPag __p1.CreationComplete(); } + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private class __MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPage + { + } private interface IMainPage_Bindings { void Initialize(); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFDOTAFE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFDOTAFE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index 3927204b0ead..74c027651864 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFDOTAFE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFDOTAFE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -104,7 +104,7 @@ private void InitializeComponent() new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { return - new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0().Build(__owner) + new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new __MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPage.SC0().Build(__owner) ) .GenericApply(__that, __nameScope, (ApplyMethod_6 )) ; } @@ -116,7 +116,7 @@ private void InitializeComponent() { IsParsing = true, Name = "TheListView", - HeaderTemplate = new global::Microsoft.UI.Xaml.DataTemplate(this, (__owner) => new _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC1().Build(__owner) + HeaderTemplate = new global::Microsoft.UI.Xaml.DataTemplate(this, (__owner) => new __MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPage.SC1().Build(__owner) ) .GenericApply(__that, __nameScope, (ApplyMethod_7 )) , // Source 0\MainPage.xaml (Line 40:4) @@ -323,150 +323,165 @@ private void ApplyMethod_10(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPa } } [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - private class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private class __MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPage { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; - global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); - global::System.Object __ResourceOwner_1; - _View __rootInstance = null; - public _View Build(object __ResourceOwner_1) + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] + public class SC0 { - var __that = this; - this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = - new global::Microsoft.UI.Xaml.Controls.StackPanel + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; + global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); + global::System.Object __ResourceOwner_1; + _View __rootInstance = null; + public _View Build(object __ResourceOwner_1) { - IsParsing = true, - // Source 0\MainPage.xaml (Line 14:8) - Children = + var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = + new global::Microsoft.UI.Xaml.Controls.StackPanel { - new global::Microsoft.UI.Xaml.Controls.TextBlock + IsParsing = true, + // Source 0\MainPage.xaml (Line 14:8) + Children = { - IsParsing = true, - // Source 0\MainPage.xaml (Line 15:10) + new global::Microsoft.UI.Xaml.Controls.TextBlock + { + IsParsing = true, + // Source 0\MainPage.xaml (Line 15:10) + } + .GenericApply(__that, __nameScope, (ApplyMethod_17 )) + , + new global::Microsoft.UI.Xaml.Controls.Button + { + IsParsing = true, + Content = @"DoSomething", + // Source 0\MainPage.xaml (Line 16:10) + } + .GenericApply(__that, __nameScope, (ApplyMethod_18 )) + , } - .GenericApply(__that, __nameScope, (ApplyMethod_17 )) - , - new global::Microsoft.UI.Xaml.Controls.Button + } + .GenericApply(__that, __nameScope, (ApplyMethod_19 )) + ; + if (__rootInstance is FrameworkElement __fe) + { + __fe.Loading += __UpdateBindingsAndResources; + } + if (__rootInstance is DependencyObject d) + { + if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) { - IsParsing = true, - Content = @"DoSomething", - // Source 0\MainPage.xaml (Line 16:10) + global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); + __nameScope.Owner = d; } - .GenericApply(__that, __nameScope, (ApplyMethod_18 )) - , + global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); } + return __rootInstance; } - .GenericApply(__that, __nameScope, (ApplyMethod_19 )) - ; - if (__rootInstance is FrameworkElement __fe) + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Controls.Button _component_0 { - __fe.Loading += __UpdateBindingsAndResources; - } - if (__rootInstance is DependencyObject d) - { - if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) + get { - global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); - __nameScope.Owner = d; + return (global::Microsoft.UI.Xaml.Controls.Button)_component_0_Holder.Instance; + } + set + { + _component_0_Holder.Instance = value; } - global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); - } - return __rootInstance; - } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); - private global::Microsoft.UI.Xaml.Controls.Button _component_0 - { - get - { - return (global::Microsoft.UI.Xaml.Controls.Button)_component_0_Holder.Instance; } - set + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) { - _component_0_Holder.Instance = value; + var owner = this; + _component_0.UpdateResourceBindings(); } - } - private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) - { - var owner = this; - _component_0.UpdateResourceBindings(); - } - private void ApplyMethod_17(global::Microsoft.UI.Xaml.Controls.TextBlock __p1, _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) - { - __p1.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Path = @"", - } - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 15, 10); - __p1.CreationComplete(); - } + private void ApplyMethod_17(global::Microsoft.UI.Xaml.Controls.TextBlock __p1, SC0 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Path = @"", + } + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 15, 10); + __p1.CreationComplete(); + } - private void ApplyMethod_18(global::Microsoft.UI.Xaml.Controls.Button __p1, _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) - { - /* _isTopLevelDictionary:False */ - __that._component_0 = __p1; - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.Button.StyleProperty, "MyCustomButtonStyle", isThemeResourceExtension: false, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 16, 10); - __p1.CreationComplete(); - } + private void ApplyMethod_18(global::Microsoft.UI.Xaml.Controls.Button __p1, SC0 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.Button.StyleProperty, "MyCustomButtonStyle", isThemeResourceExtension: false, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 16, 10); + __p1.CreationComplete(); + } - private void ApplyMethod_19(global::Microsoft.UI.Xaml.Controls.StackPanel __p1, _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + private void ApplyMethod_19(global::Microsoft.UI.Xaml.Controls.StackPanel __p1, SC0 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 14, 8); + __p1.CreationComplete(); + } + + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private class __MainPage_d6cd66944958ced0c513e0a04797b51d_MyProject__ResourcesSC0_TestReproMainPage { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 14, 8); - __p1.CreationComplete(); } - - } - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - private class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC1 - { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; + } [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; - global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); - global::System.Object __ResourceOwner_1; - _View __rootInstance = null; - public _View Build(object __ResourceOwner_1) + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] + public class SC1 { - var __that = this; - this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = - new global::Microsoft.UI.Xaml.Controls.TextBlock - { - IsParsing = true, - Text = "Header", - // Source 0\MainPage.xaml (Line 43:10) - } - .GenericApply(__that, __nameScope, (ApplyMethod_20 )) - ; - if (__rootInstance is DependencyObject d) + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; + global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); + global::System.Object __ResourceOwner_1; + _View __rootInstance = null; + public _View Build(object __ResourceOwner_1) { - if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) + var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = + new global::Microsoft.UI.Xaml.Controls.TextBlock { - global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); - __nameScope.Owner = d; + IsParsing = true, + Text = "Header", + // Source 0\MainPage.xaml (Line 43:10) + } + .GenericApply(__that, __nameScope, (ApplyMethod_20 )) + ; + if (__rootInstance is DependencyObject d) + { + if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) + { + global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); + __nameScope.Owner = d; + } + global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); } - global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); + return __rootInstance; } - return __rootInstance; - } - private void ApplyMethod_20(global::Microsoft.UI.Xaml.Controls.TextBlock __p1, _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC1 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + private void ApplyMethod_20(global::Microsoft.UI.Xaml.Controls.TextBlock __p1, SC1 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 43, 10); + __p1.CreationComplete(); + } + + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private class __MainPage_d6cd66944958ced0c513e0a04797b51d_MyProject__ResourcesSC1_TestReproMainPage { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 43, 10); - __p1.CreationComplete(); } - + } } private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.ListView _component_0 diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLR/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLR/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index b23afc309341..9527c505510d 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLR/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLR/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -104,7 +104,7 @@ private void InitializeComponent() new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { return - new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0().Build(__owner) + new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new __MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPage.SC0().Build(__owner) ) .GenericApply(__that, __nameScope, (ApplyMethod_6 )) ; } @@ -173,107 +173,117 @@ private void ApplyMethod_9(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPag } [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - private class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private class __MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPage { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; - global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); - global::System.Object __ResourceOwner_1; - _View __rootInstance = null; - public _View Build(object __ResourceOwner_1) + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] + public class SC0 { - var __that = this; - this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = - new global::Microsoft.UI.Xaml.Controls.StackPanel + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; + global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); + global::System.Object __ResourceOwner_1; + _View __rootInstance = null; + public _View Build(object __ResourceOwner_1) { - IsParsing = true, - // Source 0\MainPage.xaml (Line 14:8) - Children = + var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = + new global::Microsoft.UI.Xaml.Controls.StackPanel { - new global::Microsoft.UI.Xaml.Controls.TextBlock + IsParsing = true, + // Source 0\MainPage.xaml (Line 14:8) + Children = { - IsParsing = true, - // Source 0\MainPage.xaml (Line 15:10) + new global::Microsoft.UI.Xaml.Controls.TextBlock + { + IsParsing = true, + // Source 0\MainPage.xaml (Line 15:10) + } + .GenericApply(__that, __nameScope, (ApplyMethod_10 )) + , + new global::Microsoft.UI.Xaml.Controls.Button + { + IsParsing = true, + Content = @"DoSomething", + // Source 0\MainPage.xaml (Line 16:10) + } + .GenericApply(__that, __nameScope, (ApplyMethod_11 )) + , } - .GenericApply(__that, __nameScope, (ApplyMethod_10 )) - , - new global::Microsoft.UI.Xaml.Controls.Button + } + .GenericApply(__that, __nameScope, (ApplyMethod_12 )) + ; + if (__rootInstance is FrameworkElement __fe) + { + __fe.Loading += __UpdateBindingsAndResources; + } + if (__rootInstance is DependencyObject d) + { + if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) { - IsParsing = true, - Content = @"DoSomething", - // Source 0\MainPage.xaml (Line 16:10) + global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); + __nameScope.Owner = d; } - .GenericApply(__that, __nameScope, (ApplyMethod_11 )) - , + global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); } + return __rootInstance; } - .GenericApply(__that, __nameScope, (ApplyMethod_12 )) - ; - if (__rootInstance is FrameworkElement __fe) - { - __fe.Loading += __UpdateBindingsAndResources; - } - if (__rootInstance is DependencyObject d) + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Controls.Button _component_0 { - if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) + get { - global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); - __nameScope.Owner = d; + return (global::Microsoft.UI.Xaml.Controls.Button)_component_0_Holder.Instance; + } + set + { + _component_0_Holder.Instance = value; } - global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); - } - return __rootInstance; - } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); - private global::Microsoft.UI.Xaml.Controls.Button _component_0 - { - get - { - return (global::Microsoft.UI.Xaml.Controls.Button)_component_0_Holder.Instance; } - set + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) { - _component_0_Holder.Instance = value; + var owner = this; + _component_0.UpdateResourceBindings(); } - } - private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) - { - var owner = this; - _component_0.UpdateResourceBindings(); - } - private void ApplyMethod_10(global::Microsoft.UI.Xaml.Controls.TextBlock __p1, _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) - { - __p1.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Path = @"", - } - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 15, 10); - __p1.CreationComplete(); - } + private void ApplyMethod_10(global::Microsoft.UI.Xaml.Controls.TextBlock __p1, SC0 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Path = @"", + } + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 15, 10); + __p1.CreationComplete(); + } - private void ApplyMethod_11(global::Microsoft.UI.Xaml.Controls.Button __p1, _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) - { - /* _isTopLevelDictionary:False */ - __that._component_0 = __p1; - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.Button.StyleProperty, "MyCustomButtonStyle", isThemeResourceExtension: false, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 16, 10); - __p1.CreationComplete(); - } + private void ApplyMethod_11(global::Microsoft.UI.Xaml.Controls.Button __p1, SC0 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.Button.StyleProperty, "MyCustomButtonStyle", isThemeResourceExtension: false, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 16, 10); + __p1.CreationComplete(); + } - private void ApplyMethod_12(global::Microsoft.UI.Xaml.Controls.StackPanel __p1, _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + private void ApplyMethod_12(global::Microsoft.UI.Xaml.Controls.StackPanel __p1, SC0 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 14, 8); + __p1.CreationComplete(); + } + + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private class __MainPage_d6cd66944958ced0c513e0a04797b51d_MyProject__ResourcesSC0_TestReproMainPage { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 14, 8); - __p1.CreationComplete(); } - + } } private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Page _component_0 diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index 85f788efadce..fd070072aae8 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -155,6 +155,11 @@ private void ApplyMethod_8(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPag __p1.CreationComplete(); } + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private class __MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPage + { + } private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Page _component_0 { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFRT/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFRT/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index c1e61bc48c8c..accf46780812 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFRT/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFRT/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -121,6 +121,11 @@ private void ApplyMethod_3(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPag __p1.CreationComplete(); } + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private class __MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPage + { + } private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Page _component_0 { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFTLRD/XamlCodeGenerator_MyDictionary_b7707bcf1e73425b710b6a5d04177088.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFTLRD/XamlCodeGenerator_MyDictionary_b7707bcf1e73425b710b6a5d04177088.cs index 609b3797756e..1afe0bcd0310 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFTLRD/XamlCodeGenerator_MyDictionary_b7707bcf1e73425b710b6a5d04177088.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFTLRD/XamlCodeGenerator_MyDictionary_b7707bcf1e73425b710b6a5d04177088.cs @@ -46,6 +46,11 @@ public void InitializeComponent() global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(this, "OriginalSourceLocation", "file:///C:/Project/0/MyDictionary.xaml#L1:2"); } + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private class __MyDictionary_b7707bcf1e73425b710b6a5d04177088_TestNamespaceTestClass + { + } } } namespace MyProject @@ -116,4 +121,9 @@ public ResourceDictionarySingleton__MyDictionary_b7707bcf1e73425b710b6a5d0417708 } namespace MyProject.__Resources { + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + internal class __MyDictionary_b7707bcf1e73425b710b6a5d04177088_MyDictionaryRD + { + } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TDBMIDTIRD/XamlCodeGenerator_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TDBMIDTIRD/XamlCodeGenerator_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57.cs index c7541b4efd5a..f43f1f9bce45 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TDBMIDTIRD/XamlCodeGenerator_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TDBMIDTIRD/XamlCodeGenerator_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57.cs @@ -48,7 +48,7 @@ public void InitializeComponent() new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { return - new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionarySC0().Build(__owner) + new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new __MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionary.SC0().Build(__owner) ) ; } ) @@ -56,98 +56,103 @@ public void InitializeComponent() } [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - private class _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionarySC0 + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private class __MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionary { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_prefix_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; - global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); - global::System.Object __ResourceOwner_1; - _View __rootInstance = null; - public _View Build(object __ResourceOwner_1) + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] + public class SC0 { - var __that = this; - this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = - new global::Microsoft.UI.Xaml.Controls.TextBlock + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_prefix_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; + global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); + global::System.Object __ResourceOwner_1; + _View __rootInstance = null; + public _View Build(object __ResourceOwner_1) { - IsParsing = true, - Name = "tb", - // Source 0\MyResourceDictionary.xaml (Line 12:5) - } - .MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_XamlApply((MyResourceDictionary_92716e07ff456818f6d4125e055d4d57XamlApplyExtensions.XamlApplyHandler0)(__p1 => - { - /* _isTopLevelDictionary:True */ - __that._component_0 = __p1; - __nameScope.RegisterName("tb", __p1); - __that.tb = __p1; - __p1.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() + var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = + new global::Microsoft.UI.Xaml.Controls.TextBlock { - Mode = BindingMode.OneWay, + IsParsing = true, + Name = "tb", + // Source 0\MyResourceDictionary.xaml (Line 12:5) } - .BindingApply(___b => /*defaultBindModeOneWay*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, null, ___ctx => ___ctx is global::TestRepro.MyModel ___tctx ? (TryGetInstance_xBind_1(___tctx, out var bindResult1) ? (true, bindResult1) : (false, default)) : (false, default), null , new [] {"MyString"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57); - __p1.CreationComplete(); - } - )) - ; - if (__rootInstance is FrameworkElement __fe) - { - __fe.Loading += __UpdateBindingsAndResources; - } - if (__rootInstance is DependencyObject d) - { - if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) + .MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_XamlApply((MyResourceDictionary_92716e07ff456818f6d4125e055d4d57XamlApplyExtensions.XamlApplyHandler0)(__p1 => { - global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); - __nameScope.Owner = d; + /* _isTopLevelDictionary:True */ + __that._component_0 = __p1; + __nameScope.RegisterName("tb", __p1); + __that.tb = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = BindingMode.OneWay, + } + .BindingApply(___b => /*defaultBindModeOneWay*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, null, ___ctx => ___ctx is global::TestRepro.MyModel ___tctx ? (TryGetInstance_xBind_1(___tctx, out var bindResult1) ? (true, bindResult1) : (false, default)) : (false, default), null , new [] {"MyString"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57); + __p1.CreationComplete(); } - global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); + )) + ; + if (__rootInstance is FrameworkElement __fe) + { + __fe.Loading += __UpdateBindingsAndResources; + } + if (__rootInstance is DependencyObject d) + { + if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) + { + global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); + __nameScope.Owner = d; + } + global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); + } + return __rootInstance; } - return __rootInstance; - } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); - private global::Microsoft.UI.Xaml.Controls.TextBlock _component_0 - { - get + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Controls.TextBlock _component_0 { - return (global::Microsoft.UI.Xaml.Controls.TextBlock)_component_0_Holder.Instance; + get + { + return (global::Microsoft.UI.Xaml.Controls.TextBlock)_component_0_Holder.Instance; + } + set + { + _component_0_Holder.Instance = value; + } } - set + private global::Microsoft.UI.Xaml.Data.ElementNameSubject _tbSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); + private global::Microsoft.UI.Xaml.Controls.TextBlock tb { - _component_0_Holder.Instance = value; + get + { + return (global::Microsoft.UI.Xaml.Controls.TextBlock)_tbSubject.ElementInstance; + } + set + { + _tbSubject.ElementInstance = value; + } } - } - private global::Microsoft.UI.Xaml.Data.ElementNameSubject _tbSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); - private global::Microsoft.UI.Xaml.Controls.TextBlock tb - { - get + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) { - return (global::Microsoft.UI.Xaml.Controls.TextBlock)_tbSubject.ElementInstance; + var owner = this; + _component_0.UpdateResourceBindings(); + _component_0.ApplyXBind(); } - set + private static bool TryGetInstance_xBind_1(global::TestRepro.MyModel ___tctx, out object o) { - _tbSubject.ElementInstance = value; + o = null; + o = ___tctx.MyString; + return true; } } - private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) - { - var owner = this; - _component_0.UpdateResourceBindings(); - _component_0.ApplyXBind(); - } - private static bool TryGetInstance_xBind_1(global::TestRepro.MyModel ___tctx, out object o) - { - o = null; - o = ___tctx.MyString; - return true; - } } } } @@ -191,7 +196,7 @@ public ResourceDictionarySingleton__MyResourceDictionary_92716e07ff456818f6d4125 [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] private object Get_1(object __ResourceOwner_1) => - new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new __Resources._MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC1().Build(__owner) + new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new __Resources.__MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRD.SC1().Build(__owner) ) ; private global::Microsoft.UI.Xaml.ResourceDictionary _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_ResourceDictionary; @@ -212,7 +217,7 @@ private object Get_1(object __ResourceOwner_1) => new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { return - new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new __Resources._MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC2().Build(__owner) + new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new __Resources.__MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRD.SC2().Build(__owner) ) ; } ) @@ -235,192 +240,197 @@ private object Get_1(object __ResourceOwner_1) => namespace MyProject.__Resources { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - class _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC1 + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + internal class __MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRD { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_prefix_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; - global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); - global::System.Object __ResourceOwner_1; - _View __rootInstance = null; - public _View Build(object __ResourceOwner_1) + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] + public class SC1 { - var __that = this; - this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = - new global::Microsoft.UI.Xaml.Controls.TextBlock - { - IsParsing = true, - Name = "tb", - // Source 0\MyResourceDictionary.xaml (Line 12:5) - } - .MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_XamlApply((MyResourceDictionary_92716e07ff456818f6d4125e055d4d57XamlApplyExtensions.XamlApplyHandler0)(__p1 => + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_prefix_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; + global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); + global::System.Object __ResourceOwner_1; + _View __rootInstance = null; + public _View Build(object __ResourceOwner_1) { - /* _isTopLevelDictionary:True */ - __that._component_0 = __p1; - __nameScope.RegisterName("tb", __p1); - __that.tb = __p1; - __p1.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() + var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = + new global::Microsoft.UI.Xaml.Controls.TextBlock { - Mode = BindingMode.OneWay, + IsParsing = true, + Name = "tb", + // Source 0\MyResourceDictionary.xaml (Line 12:5) } - .BindingApply(___b => /*defaultBindModeOneWay*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, null, ___ctx => ___ctx is global::TestRepro.MyModel ___tctx ? (TryGetInstance_xBind_2(___tctx, out var bindResult2) ? (true, bindResult2) : (false, default)) : (false, default), null , new [] {"MyString"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57); - __p1.CreationComplete(); - } - )) - ; - if (__rootInstance is FrameworkElement __fe) - { - __fe.Loading += __UpdateBindingsAndResources; - } - if (__rootInstance is DependencyObject d) - { - if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) + .MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_XamlApply((MyResourceDictionary_92716e07ff456818f6d4125e055d4d57XamlApplyExtensions.XamlApplyHandler0)(__p1 => + { + /* _isTopLevelDictionary:True */ + __that._component_0 = __p1; + __nameScope.RegisterName("tb", __p1); + __that.tb = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = BindingMode.OneWay, + } + .BindingApply(___b => /*defaultBindModeOneWay*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, null, ___ctx => ___ctx is global::TestRepro.MyModel ___tctx ? (TryGetInstance_xBind_2(___tctx, out var bindResult2) ? (true, bindResult2) : (false, default)) : (false, default), null , new [] {"MyString"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57); + __p1.CreationComplete(); + } + )) + ; + if (__rootInstance is FrameworkElement __fe) + { + __fe.Loading += __UpdateBindingsAndResources; + } + if (__rootInstance is DependencyObject d) { - global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); - __nameScope.Owner = d; + if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) + { + global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); + __nameScope.Owner = d; + } + global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); } - global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); + return __rootInstance; } - return __rootInstance; - } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); - private global::Microsoft.UI.Xaml.Controls.TextBlock _component_0 - { - get + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Controls.TextBlock _component_0 { - return (global::Microsoft.UI.Xaml.Controls.TextBlock)_component_0_Holder.Instance; + get + { + return (global::Microsoft.UI.Xaml.Controls.TextBlock)_component_0_Holder.Instance; + } + set + { + _component_0_Holder.Instance = value; + } } - set + private global::Microsoft.UI.Xaml.Data.ElementNameSubject _tbSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); + private global::Microsoft.UI.Xaml.Controls.TextBlock tb { - _component_0_Holder.Instance = value; + get + { + return (global::Microsoft.UI.Xaml.Controls.TextBlock)_tbSubject.ElementInstance; + } + set + { + _tbSubject.ElementInstance = value; + } } - } - private global::Microsoft.UI.Xaml.Data.ElementNameSubject _tbSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); - private global::Microsoft.UI.Xaml.Controls.TextBlock tb - { - get + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) { - return (global::Microsoft.UI.Xaml.Controls.TextBlock)_tbSubject.ElementInstance; + var owner = this; + _component_0.UpdateResourceBindings(); + _component_0.ApplyXBind(); } - set + private static bool TryGetInstance_xBind_2(global::TestRepro.MyModel ___tctx, out object o) { - _tbSubject.ElementInstance = value; + o = null; + o = ___tctx.MyString; + return true; } } - private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) - { - var owner = this; - _component_0.UpdateResourceBindings(); - _component_0.ApplyXBind(); - } - private static bool TryGetInstance_xBind_2(global::TestRepro.MyModel ___tctx, out object o) - { - o = null; - o = ___tctx.MyString; - return true; - } - } - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - class _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC2 - { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_prefix_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; - global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); - global::System.Object __ResourceOwner_1; - _View __rootInstance = null; - public _View Build(object __ResourceOwner_1) + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] + public class SC2 { - var __that = this; - this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = - new global::Microsoft.UI.Xaml.Controls.TextBlock - { - IsParsing = true, - Name = "tb", - // Source 0\MyResourceDictionary.xaml (Line 12:5) - } - .MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_XamlApply((MyResourceDictionary_92716e07ff456818f6d4125e055d4d57XamlApplyExtensions.XamlApplyHandler0)(__p1 => + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_prefix_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; + global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); + global::System.Object __ResourceOwner_1; + _View __rootInstance = null; + public _View Build(object __ResourceOwner_1) { - /* _isTopLevelDictionary:True */ - __that._component_0 = __p1; - __nameScope.RegisterName("tb", __p1); - __that.tb = __p1; - __p1.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() + var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = + new global::Microsoft.UI.Xaml.Controls.TextBlock + { + IsParsing = true, + Name = "tb", + // Source 0\MyResourceDictionary.xaml (Line 12:5) + } + .MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_XamlApply((MyResourceDictionary_92716e07ff456818f6d4125e055d4d57XamlApplyExtensions.XamlApplyHandler0)(__p1 => { - Mode = BindingMode.OneWay, + /* _isTopLevelDictionary:True */ + __that._component_0 = __p1; + __nameScope.RegisterName("tb", __p1); + __that.tb = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = BindingMode.OneWay, + } + .BindingApply(___b => /*defaultBindModeOneWay*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, null, ___ctx => ___ctx is global::TestRepro.MyModel ___tctx ? (TryGetInstance_xBind_3(___tctx, out var bindResult3) ? (true, bindResult3) : (false, default)) : (false, default), null , new [] {"MyString"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57); + __p1.CreationComplete(); } - .BindingApply(___b => /*defaultBindModeOneWay*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, null, ___ctx => ___ctx is global::TestRepro.MyModel ___tctx ? (TryGetInstance_xBind_3(___tctx, out var bindResult3) ? (true, bindResult3) : (false, default)) : (false, default), null , new [] {"MyString"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57); - __p1.CreationComplete(); - } - )) - ; - if (__rootInstance is FrameworkElement __fe) - { - __fe.Loading += __UpdateBindingsAndResources; - } - if (__rootInstance is DependencyObject d) - { - if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) + )) + ; + if (__rootInstance is FrameworkElement __fe) { - global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); - __nameScope.Owner = d; + __fe.Loading += __UpdateBindingsAndResources; } - global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); + if (__rootInstance is DependencyObject d) + { + if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) + { + global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); + __nameScope.Owner = d; + } + global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); + } + return __rootInstance; } - return __rootInstance; - } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); - private global::Microsoft.UI.Xaml.Controls.TextBlock _component_0 - { - get + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Controls.TextBlock _component_0 { - return (global::Microsoft.UI.Xaml.Controls.TextBlock)_component_0_Holder.Instance; + get + { + return (global::Microsoft.UI.Xaml.Controls.TextBlock)_component_0_Holder.Instance; + } + set + { + _component_0_Holder.Instance = value; + } } - set + private global::Microsoft.UI.Xaml.Data.ElementNameSubject _tbSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); + private global::Microsoft.UI.Xaml.Controls.TextBlock tb { - _component_0_Holder.Instance = value; + get + { + return (global::Microsoft.UI.Xaml.Controls.TextBlock)_tbSubject.ElementInstance; + } + set + { + _tbSubject.ElementInstance = value; + } } - } - private global::Microsoft.UI.Xaml.Data.ElementNameSubject _tbSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); - private global::Microsoft.UI.Xaml.Controls.TextBlock tb - { - get + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) { - return (global::Microsoft.UI.Xaml.Controls.TextBlock)_tbSubject.ElementInstance; + var owner = this; + _component_0.UpdateResourceBindings(); + _component_0.ApplyXBind(); } - set + private static bool TryGetInstance_xBind_3(global::TestRepro.MyModel ___tctx, out object o) { - _tbSubject.ElementInstance = value; + o = null; + o = ___tctx.MyString; + return true; } } - private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) - { - var owner = this; - _component_0.UpdateResourceBindings(); - _component_0.ApplyXBind(); - } - private static bool TryGetInstance_xBind_3(global::TestRepro.MyModel ___tctx, out object o) - { - o = null; - o = ___tctx.MyString; - return true; - } } } namespace MyProject diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTIXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTIXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index d4ebf2833915..c361fb6ce554 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTIXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTIXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -99,7 +99,7 @@ private void InitializeComponent() { IsParsing = true, Name = "inner2", - Template = new global::Microsoft.UI.Xaml.Controls.ControlTemplate(this, (__owner) => new _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0().Build(__owner) + Template = new global::Microsoft.UI.Xaml.Controls.ControlTemplate(this, (__owner) => new __MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPage.SC0().Build(__owner) ) , // Source 0\MainPage.xaml (Line 15:5) } @@ -321,88 +321,93 @@ private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkEle } } [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - private class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private class __MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPage { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; - global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); - global::System.Object __ResourceOwner_1; - _View __rootInstance = null; - public _View Build(object __ResourceOwner_1) + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] + public class SC0 { - var __that = this; - this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = - new global::Microsoft.UI.Xaml.Controls.Grid + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; + global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); + global::System.Object __ResourceOwner_1; + _View __rootInstance = null; + public _View Build(object __ResourceOwner_1) { - IsParsing = true, - Name = "gridInsideTemplate", - // Source 0\MainPage.xaml (Line 18:8) - Children = + var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = + new global::Microsoft.UI.Xaml.Controls.Grid { - new global::Microsoft.UI.Xaml.Controls.Grid + IsParsing = true, + Name = "gridInsideTemplate", + // Source 0\MainPage.xaml (Line 18:8) + Children = { - IsParsing = true, - Name = "gridInsideGridInsideTemplate", - // Source 0\MainPage.xaml (Line 19:9) + new global::Microsoft.UI.Xaml.Controls.Grid + { + IsParsing = true, + Name = "gridInsideGridInsideTemplate", + // Source 0\MainPage.xaml (Line 19:9) + } + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => + { + __nameScope.RegisterName("gridInsideGridInsideTemplate", __p1); + __that.gridInsideGridInsideTemplate = __p1; + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); + } + )) + , } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => + } + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => + { + __nameScope.RegisterName("gridInsideTemplate", __p1); + __that.gridInsideTemplate = __p1; + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); + } + )) + ; + if (__rootInstance is DependencyObject d) + { + if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) { - __nameScope.RegisterName("gridInsideGridInsideTemplate", __p1); - __that.gridInsideGridInsideTemplate = __p1; - global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - __p1.CreationComplete(); + global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); + __nameScope.Owner = d; } - )) - , + global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); } + return __rootInstance; } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => - { - __nameScope.RegisterName("gridInsideTemplate", __p1); - __that.gridInsideTemplate = __p1; - global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - __p1.CreationComplete(); - } - )) - ; - if (__rootInstance is DependencyObject d) + private global::Microsoft.UI.Xaml.Data.ElementNameSubject _gridInsideGridInsideTemplateSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); + private global::Microsoft.UI.Xaml.Controls.Grid gridInsideGridInsideTemplate { - if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) + get { - global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); - __nameScope.Owner = d; + return (global::Microsoft.UI.Xaml.Controls.Grid)_gridInsideGridInsideTemplateSubject.ElementInstance; + } + set + { + _gridInsideGridInsideTemplateSubject.ElementInstance = value; } - global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); - } - return __rootInstance; - } - private global::Microsoft.UI.Xaml.Data.ElementNameSubject _gridInsideGridInsideTemplateSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); - private global::Microsoft.UI.Xaml.Controls.Grid gridInsideGridInsideTemplate - { - get - { - return (global::Microsoft.UI.Xaml.Controls.Grid)_gridInsideGridInsideTemplateSubject.ElementInstance; - } - set - { - _gridInsideGridInsideTemplateSubject.ElementInstance = value; - } - } - private global::Microsoft.UI.Xaml.Data.ElementNameSubject _gridInsideTemplateSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); - private global::Microsoft.UI.Xaml.Controls.Grid gridInsideTemplate - { - get - { - return (global::Microsoft.UI.Xaml.Controls.Grid)_gridInsideTemplateSubject.ElementInstance; } - set + private global::Microsoft.UI.Xaml.Data.ElementNameSubject _gridInsideTemplateSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); + private global::Microsoft.UI.Xaml.Controls.Grid gridInsideTemplate { - _gridInsideTemplateSubject.ElementInstance = value; + get + { + return (global::Microsoft.UI.Xaml.Controls.Grid)_gridInsideTemplateSubject.ElementInstance; + } + set + { + _gridInsideTemplateSubject.ElementInstance = value; + } } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WBENIT/XamlCodeGenerator_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WBENIT/XamlCodeGenerator_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca.cs index 0252c59a7451..6428bc529096 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WBENIT/XamlCodeGenerator_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WBENIT/XamlCodeGenerator_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca.cs @@ -59,7 +59,7 @@ private void InitializeComponent() IsParsing = true, Name = "topLevel", Tag = @"42", - ContentTemplate = new global::Microsoft.UI.Xaml.DataTemplate(this, (__owner) => new _Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_UnoUITestsWindows_UI_Xaml_DataBindingTestsControlsBinding_ElementName_In_TemplateSC0().Build(__owner) + ContentTemplate = new global::Microsoft.UI.Xaml.DataTemplate(this, (__owner) => new __Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_UnoUITestsWindows_UI_Xaml_DataBindingTestsControlsBinding_ElementName_In_Template.SC0().Build(__owner) ) , // Source 0\Binding_ElementName_In_Template.xaml (Line 11:4) } @@ -116,92 +116,97 @@ private void InitializeComponent() } } [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - private class _Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_UnoUITestsWindows_UI_Xaml_DataBindingTestsControlsBinding_ElementName_In_TemplateSC0 + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private class __Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_UnoUITestsWindows_UI_Xaml_DataBindingTestsControlsBinding_ElementName_In_Template { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_prefix_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca = "ms-appx:///TestProject/"; - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca = "ms-appx:///TestProject/"; - global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); - global::System.Object __ResourceOwner_1; - _View __rootInstance = null; - public _View Build(object __ResourceOwner_1) + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] + public class SC0 { - var __that = this; - this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = - new global::Microsoft.UI.Xaml.Controls.TextBlock - { - IsParsing = true, - Name = "innerTextBlock", - // Source 0\Binding_ElementName_In_Template.xaml (Line 14:7) - } - .Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_XamlApply((Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237ecaXamlApplyExtensions.XamlApplyHandler3)(__p1 => + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_prefix_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca = "ms-appx:///TestProject/"; + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca = "ms-appx:///TestProject/"; + global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); + global::System.Object __ResourceOwner_1; + _View __rootInstance = null; + public _View Build(object __ResourceOwner_1) { - /* _isTopLevelDictionary:False */ - __that._component_0 = __p1; - __nameScope.RegisterName("innerTextBlock", __p1); - __that.innerTextBlock = __p1; - __p1.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() + var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = + new global::Microsoft.UI.Xaml.Controls.TextBlock { - Path = @"Tag", - ElementName = _topLevelSubject, + IsParsing = true, + Name = "innerTextBlock", + // Source 0\Binding_ElementName_In_Template.xaml (Line 14:7) } - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca); - __p1.CreationComplete(); - } - )) - ; - if (__rootInstance is FrameworkElement __fe) - { - __fe.Loading += __UpdateBindingsAndResources; - } - if (__rootInstance is DependencyObject d) - { - if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) + .Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_XamlApply((Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237ecaXamlApplyExtensions.XamlApplyHandler3)(__p1 => { - global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); - __nameScope.Owner = d; + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __nameScope.RegisterName("innerTextBlock", __p1); + __that.innerTextBlock = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Path = @"Tag", + ElementName = _topLevelSubject, + } + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca); + __p1.CreationComplete(); } - global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); - } - return __rootInstance; - } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); - private global::Microsoft.UI.Xaml.Controls.TextBlock _component_0 - { - get - { - return (global::Microsoft.UI.Xaml.Controls.TextBlock)_component_0_Holder.Instance; + )) + ; + if (__rootInstance is FrameworkElement __fe) + { + __fe.Loading += __UpdateBindingsAndResources; + } + if (__rootInstance is DependencyObject d) + { + if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) + { + global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); + __nameScope.Owner = d; + } + global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); + } + return __rootInstance; } - set + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Controls.TextBlock _component_0 { - _component_0_Holder.Instance = value; + get + { + return (global::Microsoft.UI.Xaml.Controls.TextBlock)_component_0_Holder.Instance; + } + set + { + _component_0_Holder.Instance = value; + } } - } - private global::Microsoft.UI.Xaml.Data.ElementNameSubject _innerTextBlockSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); - private global::Microsoft.UI.Xaml.Controls.TextBlock innerTextBlock - { - get + private global::Microsoft.UI.Xaml.Data.ElementNameSubject _innerTextBlockSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); + private global::Microsoft.UI.Xaml.Controls.TextBlock innerTextBlock { - return (global::Microsoft.UI.Xaml.Controls.TextBlock)_innerTextBlockSubject.ElementInstance; + get + { + return (global::Microsoft.UI.Xaml.Controls.TextBlock)_innerTextBlockSubject.ElementInstance; + } + set + { + _innerTextBlockSubject.ElementInstance = value; + } } - set + private global::Microsoft.UI.Xaml.Data.ElementNameSubject _topLevelSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(isRuntimeBound: true, name: "topLevel"); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) { - _innerTextBlockSubject.ElementInstance = value; + var owner = this; + _component_0.UpdateResourceBindings(); } } - private global::Microsoft.UI.Xaml.Data.ElementNameSubject _topLevelSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(isRuntimeBound: true, name: "topLevel"); - private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) - { - var owner = this; - _component_0.UpdateResourceBindings(); - } } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNWSRAE/XamlCodeGenerator_ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNWSRAE/XamlCodeGenerator_ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20.cs index b925ff3b30c4..3c5eabde86ee 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNWSRAE/XamlCodeGenerator_ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNWSRAE/XamlCodeGenerator_ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20.cs @@ -52,7 +52,7 @@ private void InitializeComponent() new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { return - new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new _ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20_UnoUITestsGiven_ResourceDictionaryWhen_Nested_With_Sibling_Ref_And_EventSC0().Build(__owner) + new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new __ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20_UnoUITestsGiven_ResourceDictionaryWhen_Nested_With_Sibling_Ref_And_Event.SC0().Build(__owner) ) ; } ) @@ -81,124 +81,129 @@ private void InitializeComponent() } partial void OnInitializeCompleted(); [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] - [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - private class _ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20_UnoUITestsGiven_ResourceDictionaryWhen_Nested_With_Sibling_Ref_And_EventSC0 + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private class __ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20_UnoUITestsGiven_ResourceDictionaryWhen_Nested_With_Sibling_Ref_And_Event { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_prefix_ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20 = "ms-appx:///TestProject/"; - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - private const string __baseUri_ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20 = "ms-appx:///TestProject/"; - global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); - global::System.Object __ResourceOwner_1; - _View __rootInstance = null; - public _View Build(object __ResourceOwner_1) + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] + [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] + public class SC0 { - var __that = this; - this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = - new global::Microsoft.UI.Xaml.Controls.Border + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_prefix_ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20 = "ms-appx:///TestProject/"; + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + private const string __baseUri_ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20 = "ms-appx:///TestProject/"; + global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); + global::System.Object __ResourceOwner_1; + _View __rootInstance = null; + public _View Build(object __ResourceOwner_1) { - IsParsing = true, - Resources = { - [ - "SiblingResource" - ] = - new global::Microsoft.UI.Xaml.Controls.FontIconSource - { - // Source 0\ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event.xaml (Line 14:7) - } - , - [ - "FailingResource" - ] = - new global::Uno.UI.Xaml.WeakResourceInitializer(__ResourceOwner_1, __ResourceOwner_2 => + var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = + new global::Microsoft.UI.Xaml.Controls.Border { - return - new global::Microsoft.UI.Xaml.Controls.SwipeItems - { - // Source 0\ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event.xaml (Line 15:7) - } - .ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20_XamlApply((ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20XamlApplyExtensions.XamlApplyHandler1)(__p1 => - { - __p1.Add( - new global::Microsoft.UI.Xaml.Controls.SwipeItem + IsParsing = true, + Resources = { + [ + "SiblingResource" + ] = + new global::Microsoft.UI.Xaml.Controls.FontIconSource + { + // Source 0\ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event.xaml (Line 14:7) + } + , + [ + "FailingResource" + ] = + new global::Uno.UI.Xaml.WeakResourceInitializer(__ResourceOwner_1, __ResourceOwner_2 => + { + return + new global::Microsoft.UI.Xaml.Controls.SwipeItems { - // Source 0\ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event.xaml (Line 16:8) + // Source 0\ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event.xaml (Line 15:7) } - .ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20_XamlApply((ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20XamlApplyExtensions.XamlApplyHandler2)(__p1 => + .ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20_XamlApply((ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20XamlApplyExtensions.XamlApplyHandler1)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = __p1; - global::Microsoft.UI.Xaml.NameScope.SetNameScope(__that._component_0, __nameScope); - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.SwipeItem.IconSourceProperty, "SiblingResource", isThemeResourceExtension: false, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); - var Invoked_AnEventHandler_That = (__ResourceOwner_2 as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference; - /* second level */ __p1.Invoked += (AnEventHandler_sender,AnEventHandler_args) => (Invoked_AnEventHandler_That.Target as global::Uno.UI.Tests.Given_ResourceDictionary.When_Nested_With_Sibling_Ref_And_Event)?.AnEventHandler(AnEventHandler_sender,AnEventHandler_args); + __p1.Add( + new global::Microsoft.UI.Xaml.Controls.SwipeItem + { + // Source 0\ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event.xaml (Line 16:8) + } + .ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20_XamlApply((ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20XamlApplyExtensions.XamlApplyHandler2)(__p1 => + { + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + global::Microsoft.UI.Xaml.NameScope.SetNameScope(__that._component_0, __nameScope); + global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.SwipeItem.IconSourceProperty, "SiblingResource", isThemeResourceExtension: false, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); + var Invoked_AnEventHandler_That = (__ResourceOwner_2 as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference; + /* second level */ __p1.Invoked += (AnEventHandler_sender,AnEventHandler_args) => (Invoked_AnEventHandler_That.Target as global::Uno.UI.Tests.Given_ResourceDictionary.When_Nested_With_Sibling_Ref_And_Event)?.AnEventHandler(AnEventHandler_sender,AnEventHandler_args); + } + )) + ); } )) - ); - } - )) - ; + ; + } + ) + , + }, + // Source 0\ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event.xaml (Line 12:5) } - ) - , - }, - // Source 0\ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event.xaml (Line 12:5) - } - .ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20_XamlApply((ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20XamlApplyExtensions.XamlApplyHandler3)(__p1 => - { - /* _isTopLevelDictionary:False */ - __that._component_1 = __p1; - global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20); - __p1.CreationComplete(); - } - )) - ; - if (__rootInstance is FrameworkElement __fe) - { - __fe.Loading += __UpdateBindingsAndResources; - } - if (__rootInstance is DependencyObject d) - { - if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) + .ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20_XamlApply((ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20XamlApplyExtensions.XamlApplyHandler3)(__p1 => { - global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); - __nameScope.Owner = d; + /* _isTopLevelDictionary:False */ + __that._component_1 = __p1; + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20); + __p1.CreationComplete(); } - global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); - } - return __rootInstance; - } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); - private global::Microsoft.UI.Xaml.Controls.SwipeItem _component_0 - { - get - { - return (global::Microsoft.UI.Xaml.Controls.SwipeItem)_component_0_Holder.Instance; + )) + ; + if (__rootInstance is FrameworkElement __fe) + { + __fe.Loading += __UpdateBindingsAndResources; + } + if (__rootInstance is DependencyObject d) + { + if (global::Microsoft.UI.Xaml.NameScope.GetNameScope(d) == null) + { + global::Microsoft.UI.Xaml.NameScope.SetNameScope(d, __nameScope); + __nameScope.Owner = d; + } + global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); + } + return __rootInstance; } - set + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Controls.SwipeItem _component_0 { - _component_0_Holder.Instance = value; + get + { + return (global::Microsoft.UI.Xaml.Controls.SwipeItem)_component_0_Holder.Instance; + } + set + { + _component_0_Holder.Instance = value; + } } - } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); - private global::Microsoft.UI.Xaml.Controls.Border _component_1 - { - get + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Controls.Border _component_1 { - return (global::Microsoft.UI.Xaml.Controls.Border)_component_1_Holder.Instance; + get + { + return (global::Microsoft.UI.Xaml.Controls.Border)_component_1_Holder.Instance; + } + set + { + _component_1_Holder.Instance = value; + } } - set + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) { - _component_1_Holder.Instance = value; + var owner = this; + _component_0.UpdateResourceBindings(); } } - private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) - { - var owner = this; - _component_0.UpdateResourceBindings(); - } } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Verifiers/CSGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Verifiers/CSGenerator.cs index 4d4b3dd32761..383632841446 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Verifiers/CSGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Verifiers/CSGenerator.cs @@ -1,6 +1,8 @@ -// Uncomment the following line to write expected files to disk +#if DEBUG +// Uncomment the following line to write expected files to disk // Don't commit this line uncommented. // #define WRITE_EXPECTED +#endif using System.Collections.Immutable; using System.Diagnostics; diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/Subclass.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/Subclass.cs index 359f3b29fa38..e62597c79186 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/Subclass.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/Subclass.cs @@ -8,19 +8,5 @@ namespace Uno.UI.SourceGenerators.XamlGenerator { - internal class Subclass - { - public Subclass(XamlMemberDefinition contentOwner, string returnType, string defaultBindMode) - { - ContentOwner = contentOwner; - ReturnType = returnType; - DefaultBindMode = defaultBindMode; - } - - public XamlMemberDefinition ContentOwner { get; } - - public string ReturnType { get; } - - public string DefaultBindMode { get; } - } + internal record Subclass(XamlMemberDefinition ContentOwner, string ReturnType, string DefaultBindMode); } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 9271265638c8..cef68b5ec94c 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -899,9 +899,17 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel _isInChildSubclass = true; TryAnnotateWithGeneratorSource(writer); var ns = $"{_defaultNamespace}.__Resources"; - var disposable = isTopLevel ? writer.BlockInvariant($"namespace {ns}") : null; + using var _ = isTopLevel ? writer.BlockInvariant($"namespace {ns}") : null; - using (disposable) + // If _isHotReloadEnabled we generate it anyway so we can remove sub-classes without causing rude edit. + if (!_isHotReloadEnabled && CurrentScope.Subclasses is not { Count: >= 1 }) + { + return; + } + + writer.AppendLineIndented("[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]"); + writer.AppendLineIndented("[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate]"); + using (writer.BlockInvariant($"{(isTopLevel ? "internal" : "private")} class __{_fileUniqueId}_{string.Join("_", _scopeStack.Select(scope => scope.Name))}")) { foreach (var kvp in CurrentScope.Subclasses) { @@ -912,12 +920,10 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel { using (Scope(ns, className)) { - var classAccessibility = isTopLevel ? "" : "private"; - writer.AppendLineIndented("[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]"); writer.AppendLineIndented("[global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage(\"Trimming\", \"IL2026\")]"); writer.AppendLineIndented("[global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage(\"Trimming\", \"IL2111\")]"); - using (writer.BlockInvariant($"{classAccessibility} class {className}")) + using (writer.BlockInvariant($"public class {className}")) { BuildBaseUri(writer); @@ -6595,16 +6601,17 @@ bool IsValid(string mode) private void BuildChildThroughSubclass(IIndentedStringBuilder writer, XamlMemberDefinition contentOwner, string returnType) { TryAnnotateWithGeneratorSource(writer); - // To prevent conflicting names whenever we are working with dictionaries, subClass index is a Guid in those cases - var subClassPrefix = _scopeStack.Aggregate("", (val, scope) => val + scope.Name); - var namespacePrefix = _scopeStack.Count == 1 && _scopeStack.Last().Name.EndsWith("RD", StringComparison.Ordinal) ? "__Resources." : ""; + var isTopLevel = _scopeStack.Count == 1 && _scopeStack.Last().Name.EndsWith("RD", StringComparison.Ordinal); - var subclassName = $"_{_fileUniqueId}_{subClassPrefix}SC{(_subclassIndex++).ToString(CultureInfo.InvariantCulture)}"; + // To prevent conflicting names whenever we are working with dictionaries, subClass index is a Guid in those cases + var namespacePrefix = isTopLevel ? "__Resources." : ""; + var subClassesRoot = $"__{_fileUniqueId}_{string.Join("_", _scopeStack.Select(scope => scope.Name))}"; + var subclassName = $"SC{(_subclassIndex++).ToString(CultureInfo.InvariantCulture)}"; RegisterChildSubclass(subclassName, contentOwner, returnType); - var activator = $"new {namespacePrefix}{subclassName}()"; + var activator = $"new {namespacePrefix}{subClassesRoot}.{subclassName}()"; #if USE_NEW_TP_CODEGEN writer.AppendLineIndented($"{activator}.Build(__owner, __settings)");