From 7aae564996528686acbc8671dcc732480a7df157 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 13 Dec 2024 16:55:42 -0500 Subject: [PATCH] fix(reg): Fix HR no allowing to remove x:Bind as first change --- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 30 ++--- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 28 ++--- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 12 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 12 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 12 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 10 +- ...ionary_92716e07ff456818f6d4125e055d4d57.cs | 48 ++++---- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 12 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 12 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 10 +- ...Window_c93db19a7202d9eb84ddc41d72fcb89b.cs | 10 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 15 ++- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 10 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 35 +++--- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 12 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 15 ++- ...mplate_66bf0a54f1801c397a6fa4930a237eca.cs | 14 +-- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 12 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 19 ++-- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 12 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 12 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 12 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 12 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 12 +- ...erties_4891310bc693a433ba9a8e9f5113f94f.cs | 10 +- ...erties_5147419e44d1bc3e3f86860ad528476f.cs | 10 +- .../XamlGenerator/NameScope.cs | 24 ++-- .../XamlGenerator/XamlFileGenerator.cs | 103 +++++++++++------- 28 files changed, 282 insertions(+), 253 deletions(-) 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 ce510446357b..3927204b0ead 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 @@ -131,13 +131,13 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.UpdateResources(); + } private void ApplyMethod_1(global::Microsoft.UI.Xaml.Style __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) { global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__p1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L7:6"); @@ -364,14 +364,9 @@ public _View Build(object __ResourceOwner_1) } .GenericApply(__that, __nameScope, (ApplyMethod_19 )) ; - if (__rootInstance is FrameworkElement __fe) + if (__rootInstance is FrameworkElement __fe) { - var owner = this; - __fe.Loading += delegate - { - _component_0.UpdateResourceBindings(); - } - ; + __fe.Loading += __UpdateBindingsAndResources; } if (__rootInstance is DependencyObject d) { @@ -384,7 +379,7 @@ public _View Build(object __ResourceOwner_1) } return __rootInstance; } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; set; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 @@ -395,6 +390,11 @@ public _View Build(object __ResourceOwner_1) { _component_0_Holder.Instance = value; } + } + 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) { @@ -468,7 +468,7 @@ private void ApplyMethod_20(global::Microsoft.UI.Xaml.Controls.TextBlock __p1, _ } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; set; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 { get @@ -480,7 +480,7 @@ private void ApplyMethod_20(global::Microsoft.UI.Xaml.Controls.TextBlock __p1, _ _component_0_Holder.Instance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_1_Holder { get; set; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_1_Holder { get; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Page _component_1 { get 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 07029301e0c7..b23afc309341 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 @@ -127,13 +127,13 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.UpdateResources(); + } private void ApplyMethod_1(global::Microsoft.UI.Xaml.Style __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) { global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__p1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L7:6"); @@ -214,14 +214,9 @@ public _View Build(object __ResourceOwner_1) } .GenericApply(__that, __nameScope, (ApplyMethod_12 )) ; - if (__rootInstance is FrameworkElement __fe) + if (__rootInstance is FrameworkElement __fe) { - var owner = this; - __fe.Loading += delegate - { - _component_0.UpdateResourceBindings(); - } - ; + __fe.Loading += __UpdateBindingsAndResources; } if (__rootInstance is DependencyObject d) { @@ -234,7 +229,7 @@ public _View Build(object __ResourceOwner_1) } return __rootInstance; } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; set; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 @@ -245,6 +240,11 @@ public _View Build(object __ResourceOwner_1) { _component_0_Holder.Instance = value; } + } + 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) { @@ -275,7 +275,7 @@ private void ApplyMethod_12(global::Microsoft.UI.Xaml.Controls.StackPanel __p1, } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; set; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 { get 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 4a56a1cc951e..85f788efadce 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 @@ -115,13 +115,13 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.UpdateResources(); + } private void ApplyMethod_1(global::Microsoft.UI.Xaml.Style __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) { global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__p1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L7:6"); @@ -155,7 +155,7 @@ private void ApplyMethod_8(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPag __p1.CreationComplete(); } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; set; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 { get 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 419110c4f838..c1e61bc48c8c 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 @@ -85,13 +85,13 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.UpdateResources(); + } private void ApplyMethod_0(global::Microsoft.UI.Xaml.Controls.TextBlock __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) { global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 9, 3); @@ -121,7 +121,7 @@ private void ApplyMethod_3(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPag __p1.CreationComplete(); } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; set; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 { get diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TAA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TAA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index bdcb63a024a6..ae0cdd46d8c3 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TAA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TAA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -108,14 +108,14 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.Update(); - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.Update(); + this.Bindings.UpdateResources(); + } 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 { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TBTNSICB/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TBTNSICB/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index a61d2310f646..4f97d3c0a537 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TBTNSICB/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TBTNSICB/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -117,13 +117,13 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.UpdateResources(); + } 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.Page _component_0 { 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 bbcd4288b325..c7541b4efd5a 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 @@ -97,15 +97,9 @@ public _View Build(object __ResourceOwner_1) } )) ; - if (__rootInstance is FrameworkElement __fe) + if (__rootInstance is FrameworkElement __fe) { - var owner = this; - __fe.Loading += delegate - { - _component_0.UpdateResourceBindings(); - _component_0.ApplyXBind(); - } - ; + __fe.Loading += __UpdateBindingsAndResources; } if (__rootInstance is DependencyObject d) { @@ -142,6 +136,12 @@ public _View Build(object __ResourceOwner_1) _tbSubject.ElementInstance = value; } } + 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; @@ -276,15 +276,9 @@ public _View Build(object __ResourceOwner_1) } )) ; - if (__rootInstance is FrameworkElement __fe) + if (__rootInstance is FrameworkElement __fe) { - var owner = this; - __fe.Loading += delegate - { - _component_0.UpdateResourceBindings(); - _component_0.ApplyXBind(); - } - ; + __fe.Loading += __UpdateBindingsAndResources; } if (__rootInstance is DependencyObject d) { @@ -321,6 +315,12 @@ public _View Build(object __ResourceOwner_1) _tbSubject.ElementInstance = value; } } + 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; @@ -370,15 +370,9 @@ public _View Build(object __ResourceOwner_1) } )) ; - if (__rootInstance is FrameworkElement __fe) + if (__rootInstance is FrameworkElement __fe) { - var owner = this; - __fe.Loading += delegate - { - _component_0.UpdateResourceBindings(); - _component_0.ApplyXBind(); - } - ; + __fe.Loading += __UpdateBindingsAndResources; } if (__rootInstance is DependencyObject d) { @@ -415,6 +409,12 @@ public _View Build(object __ResourceOwner_1) _tbSubject.ElementInstance = value; } } + 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; diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIDFA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIDFA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index d3fd547b6c12..659994de7711 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIDFA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIDFA/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -105,14 +105,14 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.Update(); - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.Update(); + this.Bindings.UpdateResources(); + } 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.TextBox _component_0 { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIM/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIM/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index aba6d7f4b2bc..323de5cb709d 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIM/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TIM/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -158,14 +158,14 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.Update(); - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.Update(); + this.Bindings.UpdateResources(); + } private global::System.Action __0_Click_P1_Button_Click_Builder; private global::System.Action __1_Click_P2_Button_Click_Builder; private global::System.Action __2_Click_P3_Button_Click_Builder; diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSFEL/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSFEL/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index 3be428f72e15..fc8d241d6fd8 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSFEL/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSFEL/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -71,13 +71,13 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.UpdateResources(); + } private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::TestRepro.BasePage _component_0 { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSWA/XamlCodeGenerator_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSWA/XamlCodeGenerator_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b.cs index 4219c6c9e7b1..8fccea5a61e6 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSWA/XamlCodeGenerator_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TMEWSWA/XamlCodeGenerator_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b.cs @@ -83,13 +83,13 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainWindow_Bindings(this); - ((global::Microsoft.UI.Xaml.Window)this).Activated += (s, e) => - { - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.Window)this).Activated += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(object s, global::Microsoft.UI.Xaml.WindowActivatedEventArgs e) + { + this.Bindings.UpdateResources(); + } 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.Page _component_0 { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TPXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TPXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index 67d9eff9d45b..16dec2879e8c 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TPXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TPXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -98,7 +98,6 @@ private void InitializeComponent() ); __that._component_1 = __p1; var _component_1_update_That = (this as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference; - var _component_1_update_subject_capture = _LoadElementSubject; void _component_1_update(global::Microsoft.UI.Xaml.ElementStub sender) { if (_component_1_update_That.Target is global::TestRepro.MainPage that) @@ -110,7 +109,7 @@ void _component_1_update(global::Microsoft.UI.Xaml.ElementStub sender) } else { - _LoadElementSubject.ElementInstance = null; + that._LoadElementSubject.ElementInstance = null; } } } @@ -204,14 +203,14 @@ void _component_1_materializing(object sender) OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.Update(); - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.Update(); + this.Bindings.UpdateResources(); + } private global::Microsoft.UI.Xaml.Data.ElementNameSubject _LoadElementSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); public global::Microsoft.UI.Xaml.Controls.Primitives.ToggleButton LoadElement { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TRDAAPSSTP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TRDAAPSSTP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index 51723c0884fd..fa18888180f4 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TRDAAPSSTP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TRDAAPSSTP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -118,13 +118,13 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.UpdateResources(); + } 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.Page _component_0 { 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 81834e675e7c..d4ebf2833915 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 @@ -172,7 +172,6 @@ private void InitializeComponent() ); __that._component_1 = __p1; var _component_1_update_That = (this as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference; - var _component_1_update_subject_capture = _outerGridSubject; void _component_1_update(global::Microsoft.UI.Xaml.ElementStub sender) { if (_component_1_update_That.Target is global::TestRepro.MainPage that) @@ -184,17 +183,17 @@ void _component_1_update(global::Microsoft.UI.Xaml.ElementStub sender) } else { - _outerGridSubject.ElementInstance = null; - _inner1Subject.ElementInstance = null; - _inner1Subject.ElementInstance = null; - _inner1ButtonSubject.ElementInstance = null; - _inner1ButtonSubject.ElementInstance = null; - _inner2Subject.ElementInstance = null; - _inner2Subject.ElementInstance = null; - _inner3Subject.ElementInstance = null; - _inner3Subject.ElementInstance = null; - _inner3ButtonSubject.ElementInstance = null; - _inner3ButtonSubject.ElementInstance = null; + that._outerGridSubject.ElementInstance = null; + that._inner1Subject.ElementInstance = null; + that._inner1Subject.ElementInstance = null; + that._inner1ButtonSubject.ElementInstance = null; + that._inner1ButtonSubject.ElementInstance = null; + that._inner2Subject.ElementInstance = null; + that._inner2Subject.ElementInstance = null; + that._inner3Subject.ElementInstance = null; + that._inner3Subject.ElementInstance = null; + that._inner3ButtonSubject.ElementInstance = null; + that._inner3ButtonSubject.ElementInstance = null; } } } @@ -241,14 +240,14 @@ void _component_1_materializing(object sender) OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.Update(); - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.Update(); + this.Bindings.UpdateResources(); + } private global::Microsoft.UI.Xaml.Data.ElementNameSubject _inner1ButtonSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); private global::Microsoft.UI.Xaml.Controls.Button inner1Button { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTW/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTW/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index e055399428c6..4ef8ea923aaa 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTW/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTW/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -108,14 +108,14 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.Update(); - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.Update(); + this.Bindings.UpdateResources(); + } 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 { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index 728220287c6d..04a78ae5a2a3 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TXBRXLE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -98,7 +98,6 @@ private void InitializeComponent() ); __that._component_1 = __p1; var _component_1_update_That = (this as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference; - var _component_1_update_subject_capture = _LoadElementSubject; void _component_1_update(global::Microsoft.UI.Xaml.ElementStub sender) { if (_component_1_update_That.Target is global::TestRepro.MainPage that) @@ -110,7 +109,7 @@ void _component_1_update(global::Microsoft.UI.Xaml.ElementStub sender) } else { - _LoadElementSubject.ElementInstance = null; + that._LoadElementSubject.ElementInstance = null; } } } @@ -205,14 +204,14 @@ void _component_1_materializing(object sender) OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.Update(); - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.Update(); + this.Bindings.UpdateResources(); + } private global::Microsoft.UI.Xaml.Data.ElementNameSubject _LoadElementSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); public global::Microsoft.UI.Xaml.Controls.Primitives.ToggleButton LoadElement { 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 319f3672239f..0252c59a7451 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 @@ -157,14 +157,9 @@ public _View Build(object __ResourceOwner_1) } )) ; - if (__rootInstance is FrameworkElement __fe) + if (__rootInstance is FrameworkElement __fe) { - var owner = this; - __fe.Loading += delegate - { - _component_0.UpdateResourceBindings(); - } - ; + __fe.Loading += __UpdateBindingsAndResources; } if (__rootInstance is DependencyObject d) { @@ -202,6 +197,11 @@ public _View Build(object __ResourceOwner_1) } } 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/WBOP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WBOP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index 3addc3837b18..b4d2cb15eb3c 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WBOP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WBOP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -107,14 +107,14 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.Update(); - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.Update(); + this.Bindings.UpdateResources(); + } 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.ToggleSwitch _component_0 { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WLCHB/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WLCHB/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index b75b3a0cb20f..56f440117fa9 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WLCHB/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WLCHB/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -98,7 +98,6 @@ private void InitializeComponent() _topLevelContentSubject.ElementInstance = __p1; __that._component_1 = __p1; var _component_1_update_That = (this as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference; - var _component_1_update_subject_capture = _topLevelContentSubject; void _component_1_update(global::Microsoft.UI.Xaml.ElementStub sender) { if (_component_1_update_That.Target is global::TestRepro.MainPage that) @@ -110,9 +109,9 @@ void _component_1_update(global::Microsoft.UI.Xaml.ElementStub sender) } else { - _topLevelContentSubject.ElementInstance = null; - _innerTextBlockSubject.ElementInstance = null; - _innerTextBlockSubject.ElementInstance = null; + that._topLevelContentSubject.ElementInstance = null; + that._innerTextBlockSubject.ElementInstance = null; + that._innerTextBlockSubject.ElementInstance = null; } } } @@ -150,14 +149,14 @@ void _component_1_materializing(object sender) OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.Update(); - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.Update(); + this.Bindings.UpdateResources(); + } private global::Microsoft.UI.Xaml.Data.ElementNameSubject _innerTextBlockSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); public global::Microsoft.UI.Xaml.Controls.TextBlock innerTextBlock { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNBOP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNBOP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index 5438152f2298..2d33b95efc60 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNBOP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNBOP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -107,14 +107,14 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.Update(); - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.Update(); + this.Bindings.UpdateResources(); + } 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.ToggleSwitch _component_0 { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPADNE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPADNE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index b83cc2b638ea..996b6e0904dd 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPADNE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPADNE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -149,14 +149,14 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.Update(); - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.Update(); + this.Bindings.UpdateResources(); + } 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 { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE__name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE__name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index b83cc2b638ea..996b6e0904dd 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE__name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE__name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -149,14 +149,14 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.Update(); - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.Update(); + this.Bindings.UpdateResources(); + } 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 { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_m_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_m_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index b83cc2b638ea..996b6e0904dd 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_m_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_m_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -149,14 +149,14 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.Update(); - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.Update(); + this.Bindings.UpdateResources(); + } 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 { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index b83cc2b638ea..996b6e0904dd 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WOPAE_name/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -149,14 +149,14 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new MainPage_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.Update(); - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.Update(); + this.Bindings.UpdateResources(); + } 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 { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWCP/XamlCodeGenerator_Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWCP/XamlCodeGenerator_Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f.cs index 041619dbe325..4e6a057101e0 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWCP/XamlCodeGenerator_Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWCP/XamlCodeGenerator_Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f.cs @@ -127,13 +127,13 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new Binding_Xaml_Object_With_Common_Properties_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.UpdateResources(); + } private global::Microsoft.UI.Xaml.Data.ElementNameSubject _topLevelSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); public global::Microsoft.UI.Xaml.Controls.TextBlock topLevel { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWXOP/XamlCodeGenerator_Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWXOP/XamlCodeGenerator_Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f.cs index c9e5ed42f4eb..2ae263c0e244 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWXOP/XamlCodeGenerator_Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXOWXOP/XamlCodeGenerator_Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f.cs @@ -119,13 +119,13 @@ private void InitializeComponent() OnInitializeCompleted(); Bindings = new Binding_Xaml_Object_With_Xaml_Object_Properties_Bindings(this); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - __that.Bindings.UpdateResources(); - } - ; + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources; } partial void OnInitializeCompleted(); + private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e) + { + this.Bindings.UpdateResources(); + } private global::Microsoft.UI.Xaml.Data.ElementNameSubject _topLevelSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); public global::Microsoft.UI.Xaml.Controls.TextBlock topLevel { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/NameScope.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/NameScope.cs index 3c2e58f5d7a4..41c1efcb2f49 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/NameScope.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/NameScope.cs @@ -1,6 +1,8 @@ #nullable enable +using System; using System.Collections.Generic; +using Uno.Extensions; namespace Uno.UI.SourceGenerators.XamlGenerator { @@ -19,31 +21,33 @@ public NameScope(string? @namespace, string className) /// /// Used to detect duplicate x:Name and report error for those. /// - public HashSet DeclaredNames { get; } = new HashSet(); + public HashSet DeclaredNames { get; } = []; - public List BackingFields { get; } = new List(); + public List BackingFields { get; } = []; /// /// List of action handlers for registering x:Bind events /// - public List xBindEventsHandlers { get; } = new(); + public List xBindEventsHandlers { get; } = []; /// /// Lists the ElementStub builder holder variables used to pin references for implicit pinning platforms /// - public List ElementStubHolders { get; } = new List(); + public List ElementStubHolders { get; } = []; - public HashSet ReferencedElementNames { get; } = new HashSet(); + public HashSet ReferencedElementNames { get; } = []; - public Dictionary Subclasses { get; } = new Dictionary(); + public Dictionary Subclasses { get; } = []; - public List Components { get; } = new List(); + public List Components { get; } = []; - public List XBindExpressions { get; } = new List(); + public List XBindExpressions { get; } = []; - public List XBindTryGetMethodDeclarations { get; } = new List(); + public List XBindTryGetMethodDeclarations { get; } = []; - public List ExplicitApplyMethods { get; } = new List(); + public List ExplicitApplyMethods { get; } = []; + + public List> EventHandlers { get; } = []; public int ComponentCount => Components.Count; } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 6c37e9ddf5a8..b422b1f943d8 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -385,6 +385,8 @@ private SourceText InnerGenerateFile() BuildPartials(writer); + BuildEventHandlers(writer); + BuildExplicitApplyMethods(writer); BuildBackingFields(writer); @@ -826,9 +828,17 @@ private void BuildXBindTryGetDeclarations(IIndentedStringBuilder writer) } } + private void BuildEventHandlers(IIndentedStringBuilder writer) + { + foreach (var eventHandler in CurrentScope.EventHandlers) + { + eventHandler(writer); + } + } + private void BuildBackingFields(IIndentedStringBuilder writer) { - var accessors = _isHotReloadEnabled ? " { get; set; }" : null; // We use property for HR so we can remove them without causing rude edit. + var rAccessor = _isHotReloadEnabled ? " { get; set; }" : null; // We use property for HR so we can remove them without causing rude edit. TryAnnotateWithGeneratorSource(writer); foreach (var backingFieldDefinition in CurrentScope.BackingFields.Distinct()) @@ -840,8 +850,7 @@ private void BuildBackingFields(IIndentedStringBuilder writer) CurrentScope.ReferencedElementNames.Remove(sanitizedFieldName); } - writer.AppendLineIndented($"private global::Microsoft.UI.Xaml.Data.ElementNameSubject _{sanitizedFieldName}Subject{accessors} = new global::Microsoft.UI.Xaml.Data.ElementNameSubject();"); - + writer.AppendLineIndented($"private global::Microsoft.UI.Xaml.Data.ElementNameSubject _{sanitizedFieldName}Subject{rAccessor} = new global::Microsoft.UI.Xaml.Data.ElementNameSubject();"); using (writer.BlockInvariant($"{FormatAccessibility(backingFieldDefinition.Accessibility)} {backingFieldDefinition.GlobalizedTypeName} {sanitizedFieldName}")) { @@ -860,13 +869,13 @@ private void BuildBackingFields(IIndentedStringBuilder writer) foreach (var xBindEventHandler in CurrentScope.xBindEventsHandlers) { // Create load-time subjects for ElementName references not in local scope - writer.AppendLineIndented($"{FormatAccessibility(xBindEventHandler.Accessibility)} {xBindEventHandler.GlobalizedTypeName} {xBindEventHandler.Name}{accessors ?? ";"}"); + writer.AppendLineIndented($"{FormatAccessibility(xBindEventHandler.Accessibility)} {xBindEventHandler.GlobalizedTypeName} {xBindEventHandler.Name}{rAccessor ?? ";"}"); } foreach (var remainingReference in CurrentScope.ReferencedElementNames) { // Create load-time subjects for ElementName references not in local scope - writer.AppendLineIndented($"private global::Microsoft.UI.Xaml.Data.ElementNameSubject _{remainingReference}Subject{accessors} = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(isRuntimeBound: true, name: \"{remainingReference}\");"); + writer.AppendLineIndented($"private global::Microsoft.UI.Xaml.Data.ElementNameSubject _{remainingReference}Subject{rAccessor} = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(isRuntimeBound: true, name: \"{remainingReference}\");"); } } @@ -956,6 +965,8 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel BuildBackingFields(writer); + BuildEventHandlers(writer); + BuildExplicitApplyMethods(writer); BuildChildSubclasses(writer); @@ -1022,23 +1033,34 @@ private void BuildCompiledBindingsInitializer(IndentedStringBuilder writer, INam { // Casting to FrameworkElement or Window is important to avoid issues when there // is a member named Loading or Activated that shadows the ones from FrameworkElement/Window - var eventSubscription = isFrameworkElement - ? "((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) =>" - : "((global::Microsoft.UI.Xaml.Window)this).Activated += (s, e) =>"; - using (writer.BlockInvariant(eventSubscription)) + string callbackSignature; + if (isFrameworkElement) { - if (hasXBindExpressions) - { - writer.AppendLineIndented("__that.Bindings.Update();"); - } - - writer.AppendLineIndented("__that.Bindings.UpdateResources();"); + callbackSignature = "private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e)"; + writer.AppendLineIndented("((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += __UpdateBindingsAndResources;"); + } + else + { + callbackSignature = "private void __UpdateBindingsAndResources(object s, global::Microsoft.UI.Xaml.WindowActivatedEventArgs e)"; + writer.AppendLineIndented("((global::Microsoft.UI.Xaml.Window)this).Activated += __UpdateBindingsAndResources;"); } - writer.AppendLineIndented(";"); + CurrentScope.EventHandlers.Add(eventWriter => + { + using (eventWriter.BlockInvariant(callbackSignature)) + { + if (hasXBindExpressions) + { + eventWriter.AppendLineIndented("this.Bindings.Update();"); + } + + eventWriter.AppendLineIndented("this.Bindings.UpdateResources();"); + } + }); } } + private void BuildCompiledBindingsInitializerForTemplate(IIndentedStringBuilder writer) { TryAnnotateWithGeneratorSource(writer); @@ -1046,17 +1068,21 @@ private void BuildCompiledBindingsInitializerForTemplate(IIndentedStringBuilder if (hasResourceExtensions) { - using (writer.BlockInvariant($"if (__rootInstance is FrameworkElement __fe) ")) + using (writer.BlockInvariant($"if (__rootInstance is FrameworkElement __fe)")) { - writer.AppendLineIndented($"var owner = this;"); + writer.AppendLineIndented("__fe.Loading += __UpdateBindingsAndResources;"); - using (writer.BlockInvariant($"__fe.Loading += delegate")) + CurrentScope.EventHandlers.Add(eventWriter => { - BuildComponentResouceBindingUpdates(writer); - BuildXBindApply(writer); - BuildxBindEventHandlerInitializers(writer, CurrentScope.xBindEventsHandlers); - } - writer.AppendLineIndented(";"); + using (writer.BlockInvariant("private void __UpdateBindingsAndResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e)")) + { + eventWriter.AppendLineIndented("var owner = this;"); + + BuildComponentResouceBindingUpdates(eventWriter); + BuildXBindApply(eventWriter); + BuildxBindEventHandlerInitializers(eventWriter, CurrentScope.xBindEventsHandlers); + } + }); } } } @@ -1110,7 +1136,7 @@ private void BuildComponentFields(IIndentedStringBuilder writer) var typeName = GetType(current.XamlObject.Type).GetFullyQualifiedTypeIncludingGlobal(); var isWeak = current.IsWeakReference ? "true" : "false"; - var accessors = _isHotReloadEnabled ? " { get; set; }" : ""; // We use property for HR so we can remove them without causing rude edit. + var accessors = _isHotReloadEnabled ? " { get; }" : ""; // We use property for HR so we can remove them without causing rude edit. writer.AppendLineIndented($"private global::Microsoft.UI.Xaml.Markup.ComponentHolder {componentName}_Holder{accessors} = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: {isWeak});"); using (writer.BlockInvariant($"private {typeName} {componentName}")) @@ -1392,6 +1418,8 @@ IDisposable WrapSingleton() } BuildXBindTryGetDeclarations(writer); + + BuildEventHandlers(writer); } } @@ -1729,6 +1757,7 @@ private void BuildResourceDictionaryBackingClass(IIndentedStringBuilder writer, writer.AppendLine(); + BuildEventHandlers(writer); BuildChildSubclasses(writer); BuildXBindTryGetDeclarations(writer); } @@ -1813,16 +1842,20 @@ bool IsGenerateUpdateResourceBindings(KeyValuePair if (resourcesTogenerateUpdateBindings.Length > 0) { - using (writer.BlockInvariant("Loading += (s, e) =>")) + writer.AppendLineIndented("Loading += __UpdateNamedResources;"); + + CurrentScope.EventHandlers.Add(eventWriter => { - foreach (var namedResource in resourcesTogenerateUpdateBindings) + using (eventWriter.BlockInvariant("private void __UpdateNamedResources(global::Microsoft.UI.Xaml.FrameworkElement s, object e)")) { - var type = GetType(namedResource.Value.Type); + foreach (var namedResource in resourcesTogenerateUpdateBindings) + { + var type = GetType(namedResource.Value.Type); - writer.AppendLineIndented($"{namedResource.Key}.UpdateResourceBindings();"); + eventWriter.AppendLineIndented($"{namedResource.Key}.UpdateResourceBindings();"); + } } - } - writer.AppendLineIndented(";"); + }); } } @@ -3686,6 +3719,7 @@ IMethodSymbol FindTargetMethodSymbol(INamedTypeSymbol? sourceType) writer.AppendLineIndented($"global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__owner, \"{eventTarget}\", {thatVariableName});"); } + //CurrentScope.ExplicitApplyMethods ICI using (writer.BlockInvariant($"/* first level targetMethod:{targetContext.targetMethod} */ __owner.{member.Member.Name} += ({parms}) => ")) { if (isStaticTarget) @@ -6409,11 +6443,6 @@ private IEnumerable EnumerateSubElements(IEnumerable EnumerateSubElements(IEnumerable