From 504593de062ff3a1b70b0f93c19a0fb17bce0869 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 14 Jan 2025 17:15:04 -0500 Subject: [PATCH 1/4] feat(hr): Add ability to remove root of a DataTemplate with HR without cnomua --- .../Given_HotReloadService.cs | 2 +- .../0/p1/MainPage.xaml | 17 + .../0/p1/MainPage.xaml.cs | 24 + .../1/p1/MainPage.xaml | 19 + .../1/p1/MainPage.xaml.cs | 24 + .../When_DataTemplate_Root_Add/Scenario.json | 24 + .../0/p1/MainPage.xaml | 17 + .../0/p1/MainPage.xaml.cs | 24 + .../1/p1/MainPage.xaml | 19 + .../1/p1/MainPage.xaml.cs | 24 + .../2/p1/MainPage.xaml | 17 + .../2/p1/MainPage.xaml.cs | 24 + .../Scenario.json | 32 ++ .../0/p1/MainPage.xaml | 19 + .../0/p1/MainPage.xaml.cs | 24 + .../1/p1/MainPage.xaml | 17 + .../1/p1/MainPage.xaml.cs | 24 + .../Scenario.json | 24 + .../0/p1/MainPage.xaml | 19 + .../0/p1/MainPage.xaml.cs | 24 + .../1/p1/MainPage.xaml | 19 + .../1/p1/MainPage.xaml.cs | 24 + .../Scenario.json | 24 + ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 2 + ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 248 ++++----- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 173 +++---- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 2 + ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 2 + ...ionary_b7707bcf1e73425b710b6a5d04177088.cs | 4 + ...ionary_92716e07ff456818f6d4125e055d4d57.cs | 469 +++++++++--------- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 141 +++--- ...mplate_66bf0a54f1801c397a6fa4930a237eca.cs | 149 +++--- ..._Event_6d62c5ee15120ed189e095faf6d37e20.cs | 203 ++++---- .../Verifiers/CSGenerator.cs | 4 +- .../XamlGenerator/XamlFileGenerator.cs | 14 +- 35 files changed, 1222 insertions(+), 674 deletions(-) create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/2/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/2/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Add_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_Root_Update/Scenario.json 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..69b36c196b5e 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs @@ -65,7 +65,7 @@ public record DiagnosticsResult(string Id); var path = Path.Combine(scenarioFolder, "Scenario.json"); #if DEBUG && false - if (!path.Contains("When_Base_Type_Grid_To_Page")) + if (!path.Contains("When_DataTemplate_Root_Remove")) { continue; } 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..6232e61aca02 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,8 @@ private void ApplyMethod_3(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPag __p1.CreationComplete(); } + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private partial class SubClasses; 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..7a031a142323 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 SubClasses._MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0().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 SubClasses._MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC1().Build(__owner) ) .GenericApply(__that, __nameScope, (ApplyMethod_7 )) , // Source 0\MainPage.xaml (Line 40:4) @@ -322,151 +322,163 @@ private void ApplyMethod_10(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPa _NarrowStateSubject.ElementInstance = value; } } - [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 partial class SubClasses; + partial class SubClasses { [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 _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 { - 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) - { - __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_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, _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_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, _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_19(global::Microsoft.UI.Xaml.Controls.StackPanel __p1, _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 __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(); - } + private void ApplyMethod_19(global::Microsoft.UI.Xaml.Controls.StackPanel __p1, _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 __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.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private partial class SubClasses; + } } - [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 + partial class SubClasses { [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 _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC1 { - 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) } - global::Uno.UI.FrameworkElementHelper.AddObjectReference(d, this); - } - return __rootInstance; - } - private void ApplyMethod_20(global::Microsoft.UI.Xaml.Controls.TextBlock __p1, _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC1 __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(); + .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); + } + return __rootInstance; } + private void ApplyMethod_20(global::Microsoft.UI.Xaml.Controls.TextBlock __p1, _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC1 __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.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private partial class SubClasses; + } } 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..cdea90203bbf 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 SubClasses._MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0().Build(__owner) ) .GenericApply(__that, __nameScope, (ApplyMethod_6 )) ; } @@ -172,108 +172,115 @@ private void ApplyMethod_9(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPag __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_TestReproMainPageSC0 + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private partial class SubClasses; + partial class SubClasses { [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 _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 { - 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, _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_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, _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_12(global::Microsoft.UI.Xaml.Controls.StackPanel __p1, _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 __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(); - } + private void ApplyMethod_12(global::Microsoft.UI.Xaml.Controls.StackPanel __p1, _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 __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.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private partial class SubClasses; + } } 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..c906bd3d3ce1 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,8 @@ private void ApplyMethod_8(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPag __p1.CreationComplete(); } + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private partial class SubClasses; 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..f22baf0ea692 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,8 @@ private void ApplyMethod_3(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPag __p1.CreationComplete(); } + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private partial class SubClasses; 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..5d9d6aa4a23c 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,8 @@ public void InitializeComponent() global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(this, "OriginalSourceLocation", "file:///C:/Project/0/MyDictionary.xaml#L1:2"); } + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + private partial class SubClasses; } } namespace MyProject @@ -116,4 +118,6 @@ public ResourceDictionarySingleton__MyDictionary_b7707bcf1e73425b710b6a5d0417708 } namespace MyProject.__Resources { + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + internal partial class SubClasses; } 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..d2403e893330 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,106 +48,111 @@ 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 SubClasses._MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionarySC0().Build(__owner) ) ; } ) ; } - [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 partial class SubClasses; + partial class SubClasses { [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 _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionarySC0 { - 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.SubClasses._MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC1().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.SubClasses._MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC2().Build(__owner) ) ; } ) @@ -234,193 +239,201 @@ 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 partial class SubClasses; + partial class SubClasses { [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 _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC1 { - 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 + partial class SubClasses { [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 _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC2 { - 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_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) + .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_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(); } - 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_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..6f846fd1bd79 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 SubClasses._MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0().Build(__owner) ) , // Source 0\MainPage.xaml (Line 15:5) } @@ -320,89 +320,94 @@ private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkEle _outerGridSubject.ElementInstance = value; } } - [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 partial class SubClasses; + partial class SubClasses { [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 _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 { - 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 => + private global::Microsoft.UI.Xaml.Data.ElementNameSubject _gridInsideGridInsideTemplateSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); + private global::Microsoft.UI.Xaml.Controls.Grid gridInsideGridInsideTemplate { - __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) + 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..f8f39095ef68 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 SubClasses._Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_UnoUITestsWindows_UI_Xaml_DataBindingTestsControlsBinding_ElementName_In_TemplateSC0().Build(__owner) ) , // Source 0\Binding_ElementName_In_Template.xaml (Line 11:4) } @@ -115,93 +115,98 @@ private void InitializeComponent() _topLevelSubject.ElementInstance = value; } } - [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 partial class SubClasses; + partial class SubClasses { [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 _Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_UnoUITestsWindows_UI_Xaml_DataBindingTestsControlsBinding_ElementName_In_TemplateSC0 { - 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..68627a4ef302 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 SubClasses._ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20_UnoUITestsGiven_ResourceDictionaryWhen_Nested_With_Sibling_Ref_And_EventSC0().Build(__owner) ) ; } ) @@ -80,125 +80,130 @@ 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 partial class SubClasses; + partial class SubClasses { [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 _ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20_UnoUITestsGiven_ResourceDictionaryWhen_Nested_With_Sibling_Ref_And_EventSC0 { - 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/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 9271265638c8..c8b0917bc376 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -903,6 +903,13 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel using (disposable) { + if (_isHotReloadEnabled || CurrentScope.Subclasses is { Count: > 0 }) + { + // If _isHotReloadEnabled we generate it anyway so we can remove classes without causing rude edit. + writer.AppendLineIndented("[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate]"); + writer.AppendLineIndented($"{(isTopLevel ? "internal" : "private")} partial class SubClasses;"); + } + foreach (var kvp in CurrentScope.Subclasses) { var className = kvp.Key; @@ -911,13 +918,12 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel using (TrySetDefaultBindMode(contentOwner.Owner, kvp.Value.DefaultBindMode)) { using (Scope(ns, className)) + using (writer.BlockInvariant("partial class SubClasses")) { - 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); @@ -6604,7 +6610,7 @@ private void BuildChildThroughSubclass(IIndentedStringBuilder writer, XamlMember RegisterChildSubclass(subclassName, contentOwner, returnType); - var activator = $"new {namespacePrefix}{subclassName}()"; + var activator = $"new {namespacePrefix}SubClasses.{subclassName}()"; #if USE_NEW_TP_CODEGEN writer.AppendLineIndented($"{activator}.Build(__owner, __settings)"); From 258f84d01efb7cea534491046bcbb0b0b63dad98 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 15 Jan 2025 16:49:46 -0500 Subject: [PATCH 2/4] fix: Fix invalid code gen of top resource dictionnaries --- .../Given_HotReloadService.cs | 8 ++--- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 4 ++- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 30 +++++++++---------- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 17 ++++++----- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 4 ++- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 4 ++- ...ionary_b7707bcf1e73425b710b6a5d04177088.cs | 8 +++-- ...ionary_92716e07ff456818f6d4125e055d4d57.cs | 21 +++++-------- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 7 ++--- ...mplate_66bf0a54f1801c397a6fa4930a237eca.cs | 7 ++--- ..._Event_6d62c5ee15120ed189e095faf6d37e20.cs | 7 ++--- .../XamlGenerator/Subclass.cs | 16 +--------- .../XamlGenerator/XamlFileGenerator.cs | 29 +++++++++++------- 13 files changed, 79 insertions(+), 83 deletions(-) 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 69b36c196b5e..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_DataTemplate_Root_Remove")) + 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/XamlCodeGeneratorTests/Out/SBUIIOFFE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SBUIIOFFE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index 6232e61aca02..1f52182fe9cd 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 @@ -105,7 +105,9 @@ private void ApplyMethod_3(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPag } [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] - private partial class SubClasses; + 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 7a031a142323..8411aad58b33 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 SubClasses._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 SubClasses._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,13 +323,12 @@ private void ApplyMethod_10(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPa } } [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] - private partial class SubClasses; - partial class SubClasses + private class __MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPage { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - public class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 + public class SC0 { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; @@ -400,7 +399,7 @@ private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkEle 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) + 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, @@ -413,7 +412,7 @@ private void ApplyMethod_17(global::Microsoft.UI.Xaml.Controls.TextBlock __p1, _ __p1.CreationComplete(); } - private void ApplyMethod_18(global::Microsoft.UI.Xaml.Controls.Button __p1, _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + 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; @@ -422,22 +421,21 @@ private void ApplyMethod_18(global::Microsoft.UI.Xaml.Controls.Button __p1, _Mai __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.Runtime.CompilerServices.CreateNewOnMetadataUpdate] - private partial class SubClasses; + private class __MainPage_d6cd66944958ced0c513e0a04797b51d_MyProject__ResourcesSC0_TestReproMainPage + { + } } - } - partial class SubClasses - { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - public class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC1 + public class SC1 { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; @@ -470,14 +468,16 @@ public _View Build(object __ResourceOwner_1) } 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.Runtime.CompilerServices.CreateNewOnMetadataUpdate] - private partial class SubClasses; + private class __MainPage_d6cd66944958ced0c513e0a04797b51d_MyProject__ResourcesSC1_TestReproMainPage + { + } } } private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); 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 cdea90203bbf..696642ab9a10 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 SubClasses._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,13 +173,12 @@ private void ApplyMethod_9(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPag } [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] - private partial class SubClasses; - partial class SubClasses + private class __MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPage { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - public class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 + public class SC0 { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; @@ -250,7 +249,7 @@ private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkEle 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) + 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, @@ -263,7 +262,7 @@ private void ApplyMethod_10(global::Microsoft.UI.Xaml.Controls.TextBlock __p1, _ __p1.CreationComplete(); } - private void ApplyMethod_11(global::Microsoft.UI.Xaml.Controls.Button __p1, _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + 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; @@ -272,14 +271,16 @@ private void ApplyMethod_11(global::Microsoft.UI.Xaml.Controls.Button __p1, _Mai __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.Runtime.CompilerServices.CreateNewOnMetadataUpdate] - private partial class SubClasses; + private class __MainPage_d6cd66944958ced0c513e0a04797b51d_MyProject__ResourcesSC0_TestReproMainPage + { + } } } private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); 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 c906bd3d3ce1..18ac3dcda7a8 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 @@ -156,7 +156,9 @@ private void ApplyMethod_8(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPag } [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] - private partial class SubClasses; + 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 f22baf0ea692..99d4ec4fed63 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 @@ -122,7 +122,9 @@ private void ApplyMethod_3(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPag } [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] - private partial class SubClasses; + 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 5d9d6aa4a23c..0b5f097c6e97 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 @@ -47,7 +47,9 @@ public void InitializeComponent() } [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] - private partial class SubClasses; + private class __MyDictionary_b7707bcf1e73425b710b6a5d04177088_TestNamespaceTestClass + { + } } } namespace MyProject @@ -119,5 +121,7 @@ public ResourceDictionarySingleton__MyDictionary_b7707bcf1e73425b710b6a5d0417708 namespace MyProject.__Resources { [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] - internal partial class SubClasses; + 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 d2403e893330..b4ed794ea47f 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 SubClasses._MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionarySC0().Build(__owner) + new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new __MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionary.SC0().Build(__owner) ) ; } ) @@ -56,13 +56,12 @@ public void InitializeComponent() } [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] - private partial class SubClasses; - partial class SubClasses + private class __MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionary { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - public class _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionarySC0 + public class SC0 { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] private const string __baseUri_prefix_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; @@ -196,7 +195,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.SubClasses._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; @@ -217,7 +216,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.SubClasses._MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC2().Build(__owner) + new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new __Resources.__MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRD.SC2().Build(__owner) ) ; } ) @@ -240,13 +239,12 @@ private object Get_1(object __ResourceOwner_1) => namespace MyProject.__Resources { [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] - internal partial class SubClasses; - partial class SubClasses + internal class __MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRD { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - public class _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC1 + public class SC1 { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] private const string __baseUri_prefix_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; @@ -337,13 +335,10 @@ private static bool TryGetInstance_xBind_2(global::TestRepro.MyModel ___tctx, ou return true; } } - } - partial class SubClasses - { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - public class _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC2 + public class SC2 { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] private const string __baseUri_prefix_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; 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 6f846fd1bd79..d5ce0df5afdf 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 SubClasses._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,13 +321,12 @@ private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkEle } } [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] - private partial class SubClasses; - partial class SubClasses + private class __MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPage { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - public class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 + public class SC0 { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; 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 f8f39095ef68..0d6f3374454c 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 SubClasses._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,13 +116,12 @@ private void InitializeComponent() } } [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] - private partial class SubClasses; - partial class SubClasses + private class __Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_UnoUITestsWindows_UI_Xaml_DataBindingTestsControlsBinding_ElementName_In_Template { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - public class _Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_UnoUITestsWindows_UI_Xaml_DataBindingTestsControlsBinding_ElementName_In_TemplateSC0 + public class SC0 { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] private const string __baseUri_prefix_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca = "ms-appx:///TestProject/"; 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 68627a4ef302..a1bd941513c5 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 SubClasses._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,13 +81,12 @@ private void InitializeComponent() } partial void OnInitializeCompleted(); [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] - private partial class SubClasses; - partial class SubClasses + 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)] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - public class _ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20_UnoUITestsGiven_ResourceDictionaryWhen_Nested_With_Sibling_Ref_And_EventSC0 + public class SC0 { [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/"; 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 c8b0917bc376..d16ed2dcc7e9 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -899,17 +899,24 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel _isInChildSubclass = true; TryAnnotateWithGeneratorSource(writer); var ns = $"{_defaultNamespace}.__Resources"; - var disposable = isTopLevel ? writer.BlockInvariant($"namespace {ns}") : null; - using (disposable) + IDisposable? SubClassesRoot() { - if (_isHotReloadEnabled || CurrentScope.Subclasses is { Count: > 0 }) + if (_isHotReloadEnabled || CurrentScope.Subclasses is { Count: >= 1 }) { - // If _isHotReloadEnabled we generate it anyway so we can remove classes without causing rude edit. + // If _isHotReloadEnabled we generate it anyway so we can remove sub-classes without causing rude edit. writer.AppendLineIndented("[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate]"); - writer.AppendLineIndented($"{(isTopLevel ? "internal" : "private")} partial class SubClasses;"); + return writer.BlockInvariant($"{(isTopLevel ? "internal" : "private")} class __{_fileUniqueId}_{string.Join("_", _scopeStack.Select(scope => scope.Name))}"); } + else + { + return null; + } + } + using (isTopLevel ? writer.BlockInvariant($"namespace {ns}") : null) + using (SubClassesRoot()) + { foreach (var kvp in CurrentScope.Subclasses) { var className = kvp.Key; @@ -918,7 +925,6 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel using (TrySetDefaultBindMode(contentOwner.Owner, kvp.Value.DefaultBindMode)) { using (Scope(ns, className)) - using (writer.BlockInvariant("partial class SubClasses")) { writer.AppendLineIndented("[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]"); writer.AppendLineIndented("[global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage(\"Trimming\", \"IL2026\")]"); @@ -6601,16 +6607,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}SubClasses.{subclassName}()"; + var activator = $"new {namespacePrefix}{subClassesRoot}.{subclassName}()"; #if USE_NEW_TP_CODEGEN writer.AppendLineIndented($"{activator}.Build(__owner, __settings)"); From 26936c013d7da62c79026e612e0f2ea523215d9f Mon Sep 17 00:00:00 2001 From: David Date: Wed, 15 Jan 2025 16:58:33 -0500 Subject: [PATCH 3/4] chore: Add EditoirBrowsable.Never --- ...lCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 1 + ...lCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 3 +++ ...lCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 2 ++ ...lCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 1 + ...lCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 1 + ...eGenerator_MyDictionary_b7707bcf1e73425b710b6a5d04177088.cs | 2 ++ ...or_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57.cs | 2 ++ ...lCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 1 + ...ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca.cs | 1 + ...h_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20.cs | 1 + .../Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs | 1 + 11 files changed, 16 insertions(+) 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 1f52182fe9cd..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,7 @@ 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 { 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 8411aad58b33..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 @@ -322,6 +322,7 @@ private void ApplyMethod_10(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPa _NarrowStateSubject.ElementInstance = value; } } + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] private class __MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPage { @@ -427,6 +428,7 @@ private void ApplyMethod_19(global::Microsoft.UI.Xaml.Controls.StackPanel __p1, __p1.CreationComplete(); } + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] private class __MainPage_d6cd66944958ced0c513e0a04797b51d_MyProject__ResourcesSC0_TestReproMainPage { @@ -474,6 +476,7 @@ private void ApplyMethod_20(global::Microsoft.UI.Xaml.Controls.TextBlock __p1, S __p1.CreationComplete(); } + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] private class __MainPage_d6cd66944958ced0c513e0a04797b51d_MyProject__ResourcesSC1_TestReproMainPage { 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 696642ab9a10..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 @@ -172,6 +172,7 @@ private void ApplyMethod_9(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 { @@ -277,6 +278,7 @@ private void ApplyMethod_12(global::Microsoft.UI.Xaml.Controls.StackPanel __p1, __p1.CreationComplete(); } + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] private class __MainPage_d6cd66944958ced0c513e0a04797b51d_MyProject__ResourcesSC0_TestReproMainPage { 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 18ac3dcda7a8..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,7 @@ 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 { 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 99d4ec4fed63..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,7 @@ 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 { 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 0b5f097c6e97..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,7 @@ 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 { @@ -120,6 +121,7 @@ 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 b4ed794ea47f..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 @@ -55,6 +55,7 @@ public void InitializeComponent() ; } + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] private class __MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionary { @@ -238,6 +239,7 @@ private object Get_1(object __ResourceOwner_1) => } namespace MyProject.__Resources { + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] internal class __MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRD { 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 d5ce0df5afdf..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 @@ -320,6 +320,7 @@ private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkEle _outerGridSubject.ElementInstance = value; } } + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] private class __MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPage { 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 0d6f3374454c..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 @@ -115,6 +115,7 @@ private void InitializeComponent() _topLevelSubject.ElementInstance = value; } } + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] private class __Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_UnoUITestsWindows_UI_Xaml_DataBindingTestsControlsBinding_ElementName_In_Template { 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 a1bd941513c5..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 @@ -80,6 +80,7 @@ private void InitializeComponent() } partial void OnInitializeCompleted(); + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] private class __ResourceDictionary_When_Nested_With_Sibling_Ref_And_Event_6d62c5ee15120ed189e095faf6d37e20_UnoUITestsGiven_ResourceDictionaryWhen_Nested_With_Sibling_Ref_And_Event { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index d16ed2dcc7e9..097b42cf2429 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -905,6 +905,7 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel if (_isHotReloadEnabled || CurrentScope.Subclasses is { Count: >= 1 }) { // If _isHotReloadEnabled we generate it anyway so we can remove sub-classes without causing rude edit. + writer.AppendLineIndented("[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]"); writer.AppendLineIndented("[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate]"); return writer.BlockInvariant($"{(isTopLevel ? "internal" : "private")} class __{_fileUniqueId}_{string.Join("_", _scopeStack.Select(scope => scope.Name))}"); } From fee7e8938f5d13f6a6ecf919ef411afab06d7f09 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 15 Jan 2025 17:41:52 -0500 Subject: [PATCH 4/4] chore: Improve readability --- .../XamlGenerator/XamlFileGenerator.cs | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 097b42cf2429..cef68b5ec94c 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -899,24 +899,17 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel _isInChildSubclass = true; TryAnnotateWithGeneratorSource(writer); var ns = $"{_defaultNamespace}.__Resources"; + using var _ = isTopLevel ? writer.BlockInvariant($"namespace {ns}") : null; - IDisposable? SubClassesRoot() + // If _isHotReloadEnabled we generate it anyway so we can remove sub-classes without causing rude edit. + if (!_isHotReloadEnabled && CurrentScope.Subclasses is not { Count: >= 1 }) { - if (_isHotReloadEnabled || CurrentScope.Subclasses is { Count: >= 1 }) - { - // If _isHotReloadEnabled we generate it anyway so we can remove sub-classes without causing rude edit. - writer.AppendLineIndented("[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]"); - writer.AppendLineIndented("[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate]"); - return writer.BlockInvariant($"{(isTopLevel ? "internal" : "private")} class __{_fileUniqueId}_{string.Join("_", _scopeStack.Select(scope => scope.Name))}"); - } - else - { - return null; - } + return; } - using (isTopLevel ? writer.BlockInvariant($"namespace {ns}") : null) - using (SubClassesRoot()) + 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) {