From 28e12c5c638e5df4a2f533c3c64d937bc57119b3 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Tue, 16 Jul 2024 09:00:24 +0300 Subject: [PATCH 01/30] chore: Remove attribute --- .../Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs | 2 +- .../Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs index 9c46c9a78a15..cad6ccc5889c 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs @@ -682,7 +682,7 @@ private SourceText GenerateGlobalResources(IEnumerable files if (_isDebug) { - writer.AppendLineIndented("[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate]"); + //writer.AppendLineIndented("[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate]"); } using (writer.BlockInvariant("public sealed partial class GlobalStaticResources")) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 1af7fa57c6be..fb0d9a3b431a 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -1446,7 +1446,7 @@ private void WriteMetadataNewTypeAttribute(IIndentedStringBuilder writer) { if (_isHotReloadEnabled) { - writer.AppendLineIndented("[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate]"); + //writer.AppendLineIndented("[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate]"); } } From 46b481a852e056c560a103e8c25ff2c1d294911f Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Wed, 17 Jul 2024 17:38:35 -0400 Subject: [PATCH 02/30] chore: Refactor to generate methods instead of lambdas for generic apply --- .../Given_HotReloadService.cs | 5 ++ .../Scenario.json | 7 +- .../Scenario.json | 7 +- .../When_Simple_Xaml_Add_xLoad/Scenario.json | 7 +- .../Scenario.json | 8 +- .../Scenario.json | 7 +- .../Scenario.json | 6 +- .../Scenario.json | 51 ++++--------- .../Scenario.json | 14 +--- .../Scenario.json | 9 +-- .../HotReloadWorkspaceProvider.cs | 10 +++ .../Uno.UI.SourceGenerators.Tests.csproj | 8 +- .../Verifiers/CSGenerator.cs | 2 + .../XamlGenerator/NameScope.cs | 2 + .../XamlGenerator/XamlFileGenerator.cs | 74 +++++++++++++------ ...amlLazyApplyBlockIIndentedStringBuilder.cs | 55 ++++++++++---- 16 files changed, 145 insertions(+), 127 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 90cd7c6ca69a..3afa83d9ceae 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs @@ -63,6 +63,11 @@ public record DiagnosticsResult(string Id); var scenarioName = Path.GetFileName(scenarioFolder); var path = Path.Combine(scenarioFolder, "Scenario.json"); + //if (!path.Contains("When_Simple_Xaml_Add_xBind_Function_Property_Update")) + //{ + // continue; + //} + if (File.Exists(path)) { var scenariosDescriptor = ReadScenarioConfig(path); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Add_xBind_Function_Property_Add/Scenario.json b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Add_xBind_Function_Property_Add/Scenario.json index 4cf322b56ccb..b5b0bc0ca853 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Add_xBind_Function_Property_Add/Scenario.json +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Add_xBind_Function_Property_Add/Scenario.json @@ -15,11 +15,8 @@ "IsMono": true, "PassResults": [ { - "MetadataUpdates": 0, - "Diagnostics": [ - { "Id": "ENC0100" }, - { "Id": "ENC0100" } - ] + "MetadataUpdates": 1, + "Diagnostics": [] } ] }, diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Add_xBind_Simple_Property/Scenario.json b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Add_xBind_Simple_Property/Scenario.json index 5fadff3f63f6..902d6383b5fd 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Add_xBind_Simple_Property/Scenario.json +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Add_xBind_Simple_Property/Scenario.json @@ -15,11 +15,8 @@ "IsMono": true, "PassResults": [ { - "MetadataUpdates": 0, - "Diagnostics": [ - { "Id": "ENC0100" }, - { "Id": "ENC0100" } - ] + "MetadataUpdates": 1, + "Diagnostics": [] } ] } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Add_xLoad/Scenario.json b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Add_xLoad/Scenario.json index b47b1f7a5ffb..902d6383b5fd 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Add_xLoad/Scenario.json +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Add_xLoad/Scenario.json @@ -15,11 +15,8 @@ "IsMono": true, "PassResults": [ { - "MetadataUpdates": 0, - "Diagnostics": [ - // MainPage_c2bc688a73eab5431d787dcd21fe32b9.cs(68,83): error ENC0049: Ceasing to capture variable '__that' requires restarting the application. - { "Id": "ENC0049" } - ] + "MetadataUpdates": 1, + "Diagnostics": [] } ] } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_ElementName_Add/Scenario.json b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_ElementName_Add/Scenario.json index 9ad219e48030..902d6383b5fd 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_ElementName_Add/Scenario.json +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_ElementName_Add/Scenario.json @@ -15,12 +15,8 @@ "IsMono": true, "PassResults": [ { - "MetadataUpdates": 0, - "Diagnostics": [ - // error ENC0100: Adding field requires restarting the application. - { "Id": "ENC0100" }, - { "Id": "ENC0100" } - ] + "MetadataUpdates": 1, + "Diagnostics": [] } ] } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_ResourceDictionary_Change_One/Scenario.json b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_ResourceDictionary_Change_One/Scenario.json index 86551eda6a53..de8d12250139 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_ResourceDictionary_Change_One/Scenario.json +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_ResourceDictionary_Change_One/Scenario.json @@ -16,11 +16,8 @@ "IsMono": true, "PassResults": [ { - "MetadataUpdates": 0, - "Diagnostics": [ - { "Id": "ENC0100" }, - { "Id": "ENC0100" } - ] + "MetadataUpdates": 1, + "Diagnostics": [] } ] } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add/Scenario.json b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add/Scenario.json index fd80816c40ad..902d6383b5fd 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add/Scenario.json +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add/Scenario.json @@ -15,10 +15,8 @@ "IsMono": true, "PassResults": [ { - "MetadataUpdates": 0, - "Diagnostics": [ - { "Id": "ENC0100" } - ] + "MetadataUpdates": 1, + "Diagnostics": [] } ] } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add_Twice/Scenario.json b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add_Twice/Scenario.json index 79bdfccfc0c5..95ac22803882 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add_Twice/Scenario.json +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add_Twice/Scenario.json @@ -13,28 +13,22 @@ "Diagnostics": [] } ] - }, + } + , { "IsDebug": true, "IsMono": true, "PassResults": [ { - "MetadataUpdates": 0, - "Diagnostics": [ - // error ENC0100: Adding field requires restarting the application. - { "Id": "ENC0100" } - ] + "MetadataUpdates": 1, + "Diagnostics": [] }, { - "MetadataUpdates": 0, - "Diagnostics": [ - // MainPage_c2bc688a73eab5431d787dcd21fe32b9.cs(102,59): error ENC0100: Adding field requires restarting the application. - { "Id": "ENC0100" }, - { "Id": "ENC0100" } - ] + "MetadataUpdates": 1, + "Diagnostics": [] } ] - }, + }, { "IsDebug": false, "IsMono": false, @@ -44,16 +38,8 @@ "Diagnostics": [] }, { - "MetadataUpdates": 0, - "Diagnostics": [ - // MainPage_c2bc688a73eab5431d787dcd21fe32b9.cs(68,83): error ENC0049: Ceasing to capture variable '__that' requires restarting the application. - { "Id": "ENC0049" }, - { "Id": "ENC0049" }, - - // error ENC0009: Updating the type of method requires restarting the application. - { "Id": "ENC0009" }, - { "Id": "ENC0009" } - ] + "MetadataUpdates": 1, + "Diagnostics": [] } ] }, @@ -62,23 +48,12 @@ "IsMono": true, "PassResults": [ { - "MetadataUpdates": 0, - "Diagnostics": [ - // error ENC0100: Adding field requires restarting the application. - { "Id": "ENC0100" } - ] + "MetadataUpdates": 1, + "Diagnostics": [] }, { - "MetadataUpdates": 0, - "Diagnostics": [ - // MainPage_c2bc688a73eab5431d787dcd21fe32b9.cs(68,83): error ENC0049: Ceasing to capture variable '__that' requires restarting the application. - { "Id": "ENC0049" }, - { "Id": "ENC0049" }, - - // error ENC0009: Updating the type of method requires restarting the application. - { "Id": "ENC0009" }, - { "Id": "ENC0009" } - ] + "MetadataUpdates": 1, + "Diagnostics": [] } ] } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Change/Scenario.json b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Change/Scenario.json index ad26e810ea37..902d6383b5fd 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Change/Scenario.json +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Change/Scenario.json @@ -5,11 +5,8 @@ "IsMono": false, "PassResults": [ { - "MetadataUpdates": 0, - "Diagnostics": [ - // error ENC0009: Updating the type of method requires restarting the application. - { "Id": "ENC0009" } - ] + "MetadataUpdates": 1, + "Diagnostics": [] } ] }, @@ -18,11 +15,8 @@ "IsMono": true, "PassResults": [ { - "MetadataUpdates": 0, - "Diagnostics": [ - // error ENC0009: Updating the type of method requires restarting the application. - { "Id": "ENC0009" } - ] + "MetadataUpdates": 1, + "Diagnostics": [] } ] } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Add/Scenario.json b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Add/Scenario.json index 4e475a075a5d..902d6383b5fd 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Add/Scenario.json +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Add/Scenario.json @@ -15,13 +15,8 @@ "IsMono": true, "PassResults": [ { - "MetadataUpdates": 0, - "Diagnostics": [ - // MainPage_c2bc688a73eab5431d787dcd21fe32b9.cs(132,3): error ENC0100: Adding auto-property requires restarting the application. - { "Id": "ENC0100" }, - { "Id": "ENC0100" }, - { "Id": "ENC0100" } - ] + "MetadataUpdates": 1, + "Diagnostics": [] } ] } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs index b4a5f9bedbc9..3b4d7889129b 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs @@ -21,8 +21,18 @@ internal class HotReloadWorkspace { public record UpdateResult(ImmutableArray Diagnostics, ImmutableArray MetadataUpdates); +#if NET7_0 const string NetCoreCapsRaw = "Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition ChangeCustomAttributes UpdateParameters"; const string MonoCapsRaw = "Baseline AddMethodToExistingType AddStaticFieldToExistingType NewTypeDefinition ChangeCustomAttributes"; +#elif NET8_0 + const string NetCoreCapsRaw = "Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition ChangeCustomAttributes UpdateParameters GenericUpdateMethod GenericAddMethodToExistingType GenericAddFieldToExistingType"; + const string MonoCapsRaw = "Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition ChangeCustomAttributes UpdateParameters GenericUpdateMethod GenericAddMethodToExistingType GenericAddFieldToExistingType"; +#elif NET9_0 + const string NetCoreCapsRaw = "Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition ChangeCustomAttributes UpdateParameters GenericUpdateMethod GenericAddMethodToExistingType GenericAddFieldToExistingType"; + const string MonoCapsRaw = "Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition ChangeCustomAttributes UpdateParameters GenericUpdateMethod GenericAddMethodToExistingType GenericAddFieldToExistingType"; +#else +#error This runtime is not supported yet, find the caps in the .NET runtime's sources +#endif private readonly string _baseWorkFolder; private readonly bool _isDebugCompilation; diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Uno.UI.SourceGenerators.Tests.csproj b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Uno.UI.SourceGenerators.Tests.csproj index d15532a30aa0..57ba3406e9fb 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Uno.UI.SourceGenerators.Tests.csproj +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Uno.UI.SourceGenerators.Tests.csproj @@ -41,10 +41,10 @@ - - - - + + + + diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Verifiers/CSGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Verifiers/CSGenerator.cs index 85a8073a1f1d..ac290995273f 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Verifiers/CSGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Verifiers/CSGenerator.cs @@ -13,7 +13,9 @@ namespace Uno.UI.SourceGenerators.Tests.Verifiers public static partial class CSharpSourceGeneratorVerifier where TSourceGenerator : ISourceGenerator, new() { +#pragma warning disable CS0618 // Type or member is obsolete public class Test : CSharpSourceGeneratorTest +#pragma warning restore CS0618 // Type or member is obsolete { public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.Default; public bool IgnoreAccessibility { get; set; } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/NameScope.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/NameScope.cs index 48e7ceb81451..3c2e58f5d7a4 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/NameScope.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/NameScope.cs @@ -43,6 +43,8 @@ public NameScope(string? @namespace, string className) public List XBindTryGetMethodDeclarations { get; } = new List(); + public List ExplicitApplyMethods { get; } = new List(); + 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 fb0d9a3b431a..3be75fdb333b 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -395,6 +395,8 @@ private SourceText InnerGenerateFile() BuildPartials(writer); + BuildExplicitApplyMethods(writer); + BuildBackingFields(writer); BuildChildSubclasses(writer); @@ -548,7 +550,7 @@ void ApplyLiteralProperties() { writer.AppendLineIndented("this"); - using (var blockWriter = CreateApplyBlock(writer, null, out var closure)) + using (var blockWriter = CreateApplyBlock(writer, FindType(topLevelControl.Type), out var closure)) { blockWriter.AppendLineInvariantIndented( "// Source {0} (Line {1}:{2})", @@ -794,7 +796,8 @@ private void BuildGenericControlInitializerBody(IndentedStringBuilder writer, Xa writer.AppendLineIndented("this"); - using (var blockWriter = CreateApplyBlock(writer, null, out var closure)) + + using (var blockWriter = CreateApplyBlock(writer, topLevelControlType, out var closure)) { blockWriter.AppendLineInvariantIndented( "// Source {0} (Line {1}:{2})", @@ -830,6 +833,15 @@ private void BuildPartials(IIndentedStringBuilder writer) } } + private void BuildExplicitApplyMethods(IIndentedStringBuilder writer) + { + TryAnnotateWithGeneratorSource(writer); + foreach (var applyMethod in CurrentScope.ExplicitApplyMethods) + { + writer.AppendLineIndented(applyMethod); + } + } + private void BuildXBindTryGetDeclarations(IIndentedStringBuilder writer) { foreach (var xBindMethodDeclaration in CurrentScope.XBindTryGetMethodDeclarations) @@ -943,6 +955,7 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel using (ResourceOwnerScope()) { writer.AppendLineIndented("global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();"); + writer.AppendLineIndented($"global::System.Object {CurrentResourceOwner};"); #if USE_NEW_TP_CODEGEN using (writer.BlockInvariant($"public {kvp.Value.ReturnType} Build(object {CurrentResourceOwner}, global::Microsoft.UI.Xaml.TemplateMaterializationSettings __settings)")) @@ -952,6 +965,7 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel { writer.AppendLineIndented($"{kvp.Value.ReturnType} __rootInstance = null;"); writer.AppendLineIndented($"var __that = this;"); + writer.AppendLineIndented($"this.{CurrentResourceOwner} = {CurrentResourceOwner};"); writer.AppendLineIndented("__rootInstance = "); // Is never considered in Global Resources because class encapsulation @@ -982,6 +996,8 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel BuildBackingFields(writer); + BuildExplicitApplyMethods(writer); + BuildChildSubclasses(writer); BuildXBindTryGetDeclarations(writer); @@ -3766,7 +3782,8 @@ IMethodSymbol FindTargetMethodSymbol(INamedTypeSymbol? sourceType) // use the WeakReferenceProvider to get a self reference to avoid adding the cost of the // creation of a WeakReference. // - writer.AppendLineIndented($"var {member.Member.Name}_{sanitizedMemberValue}_That = ({eventSource} as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference;"); + var thatEventSource = eventSource != "__that" ? "__that." + eventSource : eventSource; + writer.AppendLineIndented($"var {member.Member.Name}_{sanitizedMemberValue}_That = ({thatEventSource} as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference;"); writer.AppendLineIndented($"/* second level */ {closureName}.{member.Member.Name} += ({parms}) => ({member.Member.Name}_{sanitizedMemberValue}_That.Target as {_xClassName})?.{member.Value}({parms});"); } @@ -3938,8 +3955,7 @@ private void BuildSetAttachedProperty(IIndentedStringBuilder writer, string clos private XamlLazyApplyBlockIIndentedStringBuilder CreateApplyBlock(IIndentedStringBuilder writer, INamedTypeSymbol? appliedType, out string closureName) { TryAnnotateWithGeneratorSource(writer); - closureName = "c" + (_applyIndex++).ToString(CultureInfo.InvariantCulture); - + closureName = "__p1"; // // Since we're using strings to generate the code, we can't know ahead of time if // content will be generated only by looking at the Xaml object model. @@ -3975,7 +3991,16 @@ private XamlLazyApplyBlockIIndentedStringBuilder CreateApplyBlock(IIndentedStrin closureName, appliedType != null && !_isHotReloadEnabled ? _fileUniqueId : null, delegateType, - !_isTopLevelDictionary && _isHotReloadEnabled); + !_isTopLevelDictionary, + RegisterApplyMethod, + appliedType?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) ?? "global::System.Object", + CurrentScope.ClassName, + $"ApplyMethod_{(_applyIndex++).ToString(CultureInfo.InvariantCulture)}"); + } + + private void RegisterApplyMethod(string applyMethodBody) + { + CurrentScope.ExplicitApplyMethods.Add(applyMethodBody); } private void RegisterPartial(string format, params object[] values) @@ -6429,29 +6454,30 @@ private IEnumerable EnumerateSubElements(IEnumerable EnumerateSubElements(IEnumerable(sender, \"{componentName}_owner\");"); + innerWriter.AppendLineIndented($"var owner = global::Uno.UI.Helpers.MarkupHelper.GetElementProperty<{CurrentScope.ClassName}>(sender, \"{componentName}_owner\");"); } // Refresh the bindings when the ElementStub is unloaded. This assumes that // ElementStub will be unloaded **after** the stubbed control has been created // in order for the component field to be filled, and Bindings.Update() to do its work. - using (writer.BlockInvariant($"if ({componentName}_update_That.Target is {_xClassName} that)")) + using (innerWriter.BlockInvariant($"if ({componentName}_update_That.Target is {_xClassName} that)")) { if (CurrentXLoadScope != null) { foreach (var component in CurrentXLoadScope.Components) { - writer.AppendLineIndented($"that.{component.VariableName}.ApplyXBind();"); - writer.AppendLineIndented($"that.{component.VariableName}.UpdateResourceBindings();"); + innerWriter.AppendLineIndented($"that.{component.VariableName}.ApplyXBind();"); + innerWriter.AppendLineIndented($"that.{component.VariableName}.UpdateResourceBindings();"); } - BuildxBindEventHandlerInitializers(writer, CurrentXLoadScope.xBindEventsHandlers, "that."); + BuildxBindEventHandlerInitializers(innerWriter, CurrentXLoadScope.xBindEventsHandlers, "that."); } } } - writer.AppendLineIndented($"{closureName}.Materializing += {componentName}_materializing;"); + innerWriter.AppendLineIndented($"{closureName}.Materializing += {componentName}_materializing;"); } else { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs index 079544d735b5..ef82dcb881dc 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs @@ -17,17 +17,26 @@ internal class XamlLazyApplyBlockIIndentedStringBuilder : IIndentedStringBuilder private bool _applyOpened; private readonly string _closureName; private readonly IIndentedStringBuilder _source; + private readonly IndentedStringBuilder _inner = new(); private IDisposable? _applyDisposable; private readonly string? _applyPrefix; private readonly string? _delegateType; private readonly IDisposable? _parentDisposable; private readonly bool _exposeContext; + private readonly Action _onRegisterApplyMethodBody; + private readonly string? _exposeContextMethod; + private readonly string? _appliedType; + private readonly string? _topLevelType; public XamlLazyApplyBlockIIndentedStringBuilder( IIndentedStringBuilder source, string closureName, string? applyPrefix, string? delegateType, bool exposeContext, + Action onRegisterApplyMethodBody, + string? appliedType, + string? topLevelType, + string? exposeContextMethod, IDisposable? parentDisposable = null) { _closureName = closureName; @@ -36,6 +45,10 @@ public XamlLazyApplyBlockIIndentedStringBuilder( _delegateType = delegateType; _parentDisposable = parentDisposable; _exposeContext = exposeContext; + _onRegisterApplyMethodBody = onRegisterApplyMethodBody; + _exposeContextMethod = exposeContextMethod; + _appliedType = appliedType; + _topLevelType = topLevelType; } private void TryWriteApply() @@ -44,7 +57,9 @@ private void TryWriteApply() { _applyOpened = true; - IDisposable blockDisposable; + _inner.Indent(_source.CurrentLevel); + + IDisposable? blockDisposable; var delegateString = !_delegateType.IsNullOrEmpty() ? "(" + _delegateType + ")" : ""; @@ -55,7 +70,9 @@ private void TryWriteApply() else if (_exposeContext) { // This syntax is used to avoid closing on __that and __namescope when running in HotReload. - blockDisposable = _source.BlockInvariant(".GenericApply(__that, __nameScope, {1}(({0}, __that, __nameScope) => ", _closureName, delegateString); + _source.AppendIndented($".GenericApply(__that, __nameScope, ({_exposeContextMethod}"); + + blockDisposable = _inner.BlockInvariant($"private void {_exposeContextMethod}({_appliedType} {_closureName}, {_topLevelType} __that, global::Microsoft.UI.Xaml.NameScope __nameScope)"); } else { @@ -64,65 +81,75 @@ private void TryWriteApply() _applyDisposable = new DisposableAction(() => { - blockDisposable.Dispose(); + if (!_exposeContext) + { + _source.Append(_inner.ToString()); + blockDisposable.Dispose(); + } + else + { + blockDisposable.Dispose(); + _onRegisterApplyMethodBody(_inner.ToString()); + } + _source.AppendLineIndented("))"); }); } } - public int CurrentLevel => _source.CurrentLevel; + public int CurrentLevel => _inner.CurrentLevel; public void Append(string text) { TryWriteApply(); - _source.Append(text); + _inner.Append(text); } public void AppendLine() { TryWriteApply(); - _source.AppendLine(); + _inner.AppendLine(); } public void AppendMultiLineIndented(string text) { TryWriteApply(); - _source.AppendMultiLineIndented(text); + _inner.AppendMultiLineIndented(text); } public IDisposable Block(IFormatProvider formatProvider, string pattern, params object[] parameters) { TryWriteApply(); - return _source.Block(formatProvider, pattern, parameters); + return _inner.Block(formatProvider, pattern, parameters); } public IDisposable Block(int count = 1) { TryWriteApply(); - return _source.Block(count); + return _inner.Block(count); } public IDisposable Indent(int count = 1) { TryWriteApply(); - return _source.Indent(count); + return _inner.Indent(count); } public void AppendIndented(string text) { TryWriteApply(); - _source.AppendIndented(text); + _inner.AppendIndented(text); } public void AppendIndented(ReadOnlySpan text) { TryWriteApply(); - _source.AppendIndented(text); + _inner.AppendIndented(text); } public void AppendFormatIndented(IFormatProvider formatProvider, string text, params object[] replacements) { TryWriteApply(); - _source.AppendFormatIndented(formatProvider, text, replacements); + _inner.AppendFormatIndented(formatProvider, text, replacements); } public void Dispose() @@ -131,7 +158,7 @@ public void Dispose() _parentDisposable?.Dispose(); } - public override string ToString() => _source.ToString(); + public override string ToString() => _inner.ToString(); } } From ae0897934043bed8b35c48284174d7b7c6c32023 Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Wed, 17 Jul 2024 19:01:31 -0400 Subject: [PATCH 03/30] chore: Adjust formatting --- .../Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 3be75fdb333b..f441827a1849 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -3783,7 +3783,7 @@ IMethodSymbol FindTargetMethodSymbol(INamedTypeSymbol? sourceType) // creation of a WeakReference. // var thatEventSource = eventSource != "__that" ? "__that." + eventSource : eventSource; - writer.AppendLineIndented($"var {member.Member.Name}_{sanitizedMemberValue}_That = ({thatEventSource} as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference;"); + writer.AppendLineIndented($"var {member.Member.Name}_{sanitizedMemberValue}_That = ({thatEventSource} as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference;"); writer.AppendLineIndented($"/* second level */ {closureName}.{member.Member.Name} += ({parms}) => ({member.Member.Name}_{sanitizedMemberValue}_That.Target as {_xClassName})?.{member.Value}({parms});"); } From 812683707728b37bc7477f7cd661af0b913e9f1f Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Wed, 17 Jul 2024 20:38:12 -0400 Subject: [PATCH 04/30] chore: Adjust apply generation --- .../Given_HotReloadService.cs | 8 ++-- .../Scenario.json | 38 +++++++++++++++---- ...amlLazyApplyBlockIIndentedStringBuilder.cs | 6 +-- 3 files changed, 37 insertions(+), 15 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 3afa83d9ceae..41184f98166b 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs @@ -63,10 +63,10 @@ public record DiagnosticsResult(string Id); var scenarioName = Path.GetFileName(scenarioFolder); var path = Path.Combine(scenarioFolder, "Scenario.json"); - //if (!path.Contains("When_Simple_Xaml_Add_xBind_Function_Property_Update")) - //{ - // continue; - //} + if (!path.Contains("When_Simple_Xaml_Single_xName_Add_Twice")) + { + continue; + } if (File.Exists(path)) { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add_Twice/Scenario.json b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add_Twice/Scenario.json index 95ac22803882..c874338e4299 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add_Twice/Scenario.json +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add_Twice/Scenario.json @@ -34,12 +34,23 @@ "IsMono": false, "PassResults": [ { - "MetadataUpdates": 1, - "Diagnostics": [] + "MetadataUpdates": 0, + "Diagnostics": [ + // MainPage_e249a1283df7035b4d61c8549853c03e.cs(75,138): error ENC0053: Changing the parameters of lambda requires restarting the application. + { "Id": "ENC0053" }, + { "Id": "ENC0053" }, + { "Id": "ENC0053" } + ] }, { - "MetadataUpdates": 1, - "Diagnostics": [] + "MetadataUpdates": 0, + "Diagnostics": [ + // MainPage_e249a1283df7035b4d61c8549853c03e.cs(75,138): error ENC0053: Changing the parameters of lambda requires restarting the application. + { "Id": "ENC0053" }, + { "Id": "ENC0053" }, + { "Id": "ENC0053" }, + { "Id": "ENC0053" } + ] } ] }, @@ -48,12 +59,23 @@ "IsMono": true, "PassResults": [ { - "MetadataUpdates": 1, - "Diagnostics": [] + "MetadataUpdates": 0, + "Diagnostics": [ + // MainPage_e249a1283df7035b4d61c8549853c03e.cs(75,138): error ENC0053: Changing the parameters of lambda requires restarting the application. + { "Id": "ENC0053" }, + { "Id": "ENC0053" }, + { "Id": "ENC0053" } + ] }, { - "MetadataUpdates": 1, - "Diagnostics": [] + "MetadataUpdates": 0, + "Diagnostics": [ + // MainPage_e249a1283df7035b4d61c8549853c03e.cs(75,138): error ENC0053: Changing the parameters of lambda requires restarting the application. + { "Id": "ENC0053" }, + { "Id": "ENC0053" }, + { "Id": "ENC0053" }, + { "Id": "ENC0053" } + ] } ] } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs index ef82dcb881dc..8ea3561229c4 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs @@ -81,15 +81,15 @@ private void TryWriteApply() _applyDisposable = new DisposableAction(() => { - if (!_exposeContext) + if (_applyPrefix != null || !_exposeContext) { _source.Append(_inner.ToString()); blockDisposable.Dispose(); } - else + else if (_exposeContext) { blockDisposable.Dispose(); - _onRegisterApplyMethodBody(_inner.ToString()); + _onRegisterApplyMethodBody("/* registration */" + _inner.ToString()); } _source.AppendLineIndented("))"); From 30a468df9cc8a30de86708e9ec1c8c4026f26aee Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Wed, 17 Jul 2024 20:48:23 -0400 Subject: [PATCH 05/30] chore: Remove more createnewtype facilites --- .../Given_HotReloadService.cs | 8 +- .../XamlGenerator/XamlFileGenerator.cs | 94 +------------------ 2 files changed, 9 insertions(+), 93 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 41184f98166b..121e1a8e40f4 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs @@ -63,10 +63,10 @@ public record DiagnosticsResult(string Id); var scenarioName = Path.GetFileName(scenarioFolder); var path = Path.Combine(scenarioFolder, "Scenario.json"); - if (!path.Contains("When_Simple_Xaml_Single_xName_Add_Twice")) - { - continue; - } + //if (!path.Contains("When_Simple_Xaml_Single_xName_Add_Twice")) + //{ + // continue; + //} if (File.Exists(path)) { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index f441827a1849..ca5dc47c5d3d 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -367,18 +367,8 @@ private SourceText InnerGenerateFile() var controlBaseType = GetType(topLevelControl.Type); - WriteMetadataNewTypeAttribute(writer); - using (writer.BlockInvariant("partial class {0} : {1}", _xClassName.ClassName, controlBaseType.GetFullyQualifiedTypeIncludingGlobal())) { - if (_isHotReloadEnabled) - { - // Create a public member to avoid having to remove all unused member warnings - // The member is a method to avoid this error: error ENC0011: Updating the initializer of const field requires restarting the application. - writer.AppendLineIndented("[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]"); - writer.AppendLineIndented($"internal string __checksum() => \"{_fileDefinition.Checksum}\";"); - } - BuildBaseUri(writer); using (Scope(_xClassName.Namespace, _xClassName.ClassName)) @@ -443,18 +433,6 @@ private void BuildInitializeComponent(IndentedStringBuilder writer, XamlObjectDe } else { - if (_isHotReloadEnabled) - { - // Insert hot reload support - writer.AppendLineIndented($"var __resourceLocator = new global::System.Uri(\"file:///{_fileDefinition.FilePath.Replace("\\", "/")}\");"); - - using (writer.BlockInvariant($"if(global::Uno.UI.ApplicationHelper.IsLoadableComponent(__resourceLocator))")) - { - writer.AppendLineIndented($"global::Microsoft.UI.Xaml.Application.LoadComponent(this, __resourceLocator);"); - writer.AppendLineIndented($"return;"); - } - } - BuildGenericControlInitializerBody(writer, topLevelControl); BuildNamedResources(writer, _namedResources); } @@ -472,8 +450,6 @@ private void BuildXamlApplyBlocks(IndentedStringBuilder writer) { using (writer.BlockInvariant("namespace {0}", _defaultNamespace)) { - WriteMetadataNewTypeAttribute(writer); - using (writer.BlockInvariant("static class {0}XamlApplyExtensions", _fileUniqueId)) { foreach (var typeInfo in _xamlAppliedTypes) @@ -925,30 +901,12 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel { using (Scope(ns, className)) { - var hrInterfaceName = _isHotReloadEnabled ? $"I{className}" : ""; - var hrInterfaceImpl = _isHotReloadEnabled ? $": {hrInterfaceName}" : ""; - - if (_isHotReloadEnabled) - { - // Build an interface that can be used to hide the actual replaced - // implementation of a type during hot reload. - using (writer.BlockInvariant($"internal interface {hrInterfaceName}")) - { -#if USE_NEW_TP_CODEGEN - writer.AppendLineIndented($"{kvp.Value.ReturnType} Build(object owner, global::Microsoft.UI.Xaml.TemplateMaterializationSettings __settings);"); -#else - writer.AppendLineIndented($"{kvp.Value.ReturnType} Build(object owner);"); -#endif - } - } - var classAccessibility = isTopLevel ? "" : "private"; - WriteMetadataNewTypeAttribute(writer); 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} {hrInterfaceImpl}")) + using (writer.BlockInvariant($"{classAccessibility} class {className}")) { BuildBaseUri(writer); @@ -1053,21 +1011,13 @@ private void BuildCompiledBindingsInitializer(IndentedStringBuilder writer, INam if (hasXBindExpressions || hasResourceExtensions) { - var activator = _isHotReloadEnabled - ? $"(({GetBindingsTypeNames(_xClassName.ClassName).bindingsInterfaceName})global::Uno.UI.Helpers.TypeMappings.CreateInstance<{GetBindingsTypeNames(_xClassName.ClassName).bindingsClassName}>(this))" - : $"new {GetBindingsTypeNames(_xClassName.ClassName).bindingsClassName}(this)"; + var activator = $"new {GetBindingsTypeNames(_xClassName.ClassName).bindingsClassName}(this)"; writer.AppendLineIndented($"Bindings = {activator};"); } if ((isFrameworkElement || isWindow) && (hasXBindExpressions || hasResourceExtensions)) { - if (_isHotReloadEnabled) - { - // Attach the current context to itself to avoid having a closure in the lambda - writer.AppendLineIndented($"global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__that, \"owner\", __that);"); - } - // 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 @@ -1076,11 +1026,6 @@ private void BuildCompiledBindingsInitializer(IndentedStringBuilder writer, INam using (writer.BlockInvariant(eventSubscription)) { - if (_isHotReloadEnabled && _xClassName.Symbol != null) - { - writer.AppendLineIndented($"var __that = global::Uno.UI.Helpers.MarkupHelper.GetElementProperty<{_xClassName.Symbol?.GetFullyQualifiedTypeIncludingGlobal()}>(s, \"owner\");"); - } - if (hasXBindExpressions) { writer.AppendLineIndented("__that.Bindings.Update();"); @@ -1164,9 +1109,7 @@ private void BuildComponentFields(IIndentedStringBuilder writer) var isWeak = current.IsWeakReference ? "true" : "false"; - // As of C# 7.0, C# Hot Reload does not support the renaming fields. - var propertySyntax = _isHotReloadEnabled ? "{ get; }" : ""; - writer.AppendLineIndented($"private global::Microsoft.UI.Xaml.Markup.ComponentHolder {componentName}_Holder {propertySyntax} = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: {isWeak});"); + writer.AppendLineIndented($"private global::Microsoft.UI.Xaml.Markup.ComponentHolder {componentName}_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: {isWeak});"); using (writer.BlockInvariant($"private {typeName} {componentName}")) { @@ -1207,8 +1150,6 @@ private void BuildCompiledBindings(IndentedStringBuilder writer) writer.AppendLineIndented($"private {bindingsInterfaceName} Bindings;"); writer.AppendLineIndented($"#pragma warning restore 0169"); - WriteMetadataNewTypeAttribute(writer); - writer.AppendLineIndented($"[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]"); using (writer.BlockInvariant($"private class {bindingsClassName} : {bindingsInterfaceName}")) { @@ -1347,20 +1288,10 @@ private void BuildTopLevelResourceDictionary(IIndentedStringBuilder writer, Xaml { BuildBaseUri(writer); - if (_isHotReloadEnabled) - { - // Create a public member to avoid having to remove all unused member warnings - // The member is a method to avoid this error: error ENC0011: Updating the initializer of const field requires restarting the application. - writer.AppendLineIndented("[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]"); - writer.AppendLineIndented($"internal string __{_fileDefinition.UniqueID}_checksum() => \"{_fileDefinition.Checksum}\";"); - } - IDisposable WrapSingleton() { writer.AppendLineIndented("// This non-static inner class is a means of reducing size of AOT compilations by avoiding many accesses to static members from a static callsite, which adds costly class initializer checks each time."); - WriteMetadataNewTypeAttribute(writer); - var block = writer.BlockInvariant("internal sealed class {0} : {1}", SingletonClassName, DictionaryProviderInterfaceName); _isInSingletonInstance = true; return new DisposableAction(() => @@ -1382,9 +1313,7 @@ IDisposable WrapSingleton() { using (writer.BlockInvariant("if (__that == null)")) { - var activator = _isHotReloadEnabled - ? $"({DictionaryProviderInterfaceName})global::Uno.UI.Helpers.TypeMappings.CreateInstance<{SingletonClassName}>()" - : $"new {SingletonClassName}()"; + var activator = $"new {SingletonClassName}()"; writer.AppendLineInvariantIndented($"__that = {activator};"); } @@ -1458,14 +1387,6 @@ IDisposable WrapSingleton() } } - private void WriteMetadataNewTypeAttribute(IIndentedStringBuilder writer) - { - if (_isHotReloadEnabled) - { - //writer.AppendLineIndented("[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate]"); - } - } - /// ///Build initializers for the current ResourceDictionary. /// @@ -1771,8 +1692,6 @@ private void BuildResourceDictionaryBackingClass(IIndentedStringBuilder writer, using (writer.BlockInvariant("namespace {0}", className.Namespace)) { - WriteMetadataNewTypeAttribute(writer); - using (writer.BlockInvariant("public sealed partial class {0} : {1}", className.ClassName, controlBaseType.GetFullyQualifiedTypeIncludingGlobal())) { BuildBaseUri(writer); @@ -6627,11 +6546,8 @@ private void BuildChildThroughSubclass(IIndentedStringBuilder writer, XamlMember var subclassName = $"_{_fileUniqueId}_{subClassPrefix}SC{(_subclassIndex++).ToString(CultureInfo.InvariantCulture)}"; - RegisterChildSubclass(subclassName, contentOwner, returnType); + var activator = $"new {namespacePrefix}{subclassName}()"; - var activator = _isHotReloadEnabled - ? $"(({namespacePrefix}I{subclassName})global::Uno.UI.Helpers.TypeMappings.CreateInstance<{namespacePrefix}{subclassName}>())" - : $"new {namespacePrefix}{subclassName}()"; #if USE_NEW_TP_CODEGEN writer.AppendLineIndented($"{activator}.Build(__owner, __settings)"); #else From b3f077b6539cb529c2c7e61879d76f1948e84d66 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Dec 2024 10:16:29 -0500 Subject: [PATCH 06/30] test(hr): Fix main HR tests with no cnomua --- src/Directory.Build.props | 2 + .../Given_HotReloadService.cs | 23 +- .../HotReloadWorkspaceProvider.cs | 137 ++++-- .../Uno.UI.SourceGenerators.Tests.csproj | 8 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 61 ++- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 394 +++++++++--------- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 233 ++++++----- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 141 ++++--- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 78 ++-- ...ionary_b7707bcf1e73425b710b6a5d04177088.cs | 6 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 65 +-- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 59 +-- ...ntrol1_81d855d5b3bba02f594dcda3b149beb2.cs | 29 +- ...ionary_92716e07ff456818f6d4125e055d4d57.cs | 140 ++++--- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 57 +-- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 115 ++--- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 31 +- ...Window_c93db19a7202d9eb84ddc41d72fcb89b.cs | 33 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 39 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 35 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 167 ++++---- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 81 ++-- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 213 +++++----- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 29 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 65 +-- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 37 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 169 ++++---- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 41 +- ...mplate_66bf0a54f1801c397a6fa4930a237eca.cs | 85 ++-- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 57 +-- ...Window_c93db19a7202d9eb84ddc41d72fcb89b.cs | 23 +- ...ntaxes_794c1760299b374d12fe38ba3b633206.cs | 35 +- ...Syntax_8659265dc2cabf0b5a684f0f4b26f8b7.cs | 35 +- ...Syntax_9f853e56098ff21d39f15479035509ef.cs | 35 +- ...Syntax_cc38332c9fd4c0da9c1fa0270bbd3609.cs | 35 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 35 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 57 +-- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 35 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 68 +-- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 113 ++--- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 113 ++--- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 113 ++--- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 113 ++--- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 29 +- ...ialog1_4483f06b3f5899cc3b98f0345eeea8e5.cs | 25 +- ...erties_4891310bc693a433ba9a8e9f5113f94f.cs | 81 ++-- ...erties_5147419e44d1bc3e3f86860ad528476f.cs | 81 ++-- .../Verifiers/CSGenerator.cs | 8 +- .../XamlGenerator/XamlCodeGeneration.cs | 5 + .../XamlGenerator/XamlCodeGenerator.cs | 3 + .../XamlGenerator/XamlFileGenerator.cs | 39 +- ...amlLazyApplyBlockIIndentedStringBuilder.cs | 2 +- .../Extensibility/AddIns.cs | 2 + src/Uno.UI.Tests/Uno.UI.Unit.Tests.csproj | 3 +- src/Uno.UI/Uno.UI.Tests.csproj | 3 + 55 files changed, 2061 insertions(+), 1660 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index fc0c0e4e5464..9f737fd6ddca 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -226,6 +226,8 @@ $(NoWarn);UNO0008 + + $(NoWarn);NU1903 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 121e1a8e40f4..992ac2bae031 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs @@ -1,17 +1,6 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; -using System.Runtime.Serialization; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.VisualStudio.TestPlatform.Utilities; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Uno.Extensions; -using Uno.UI.RemoteControl.Host.HotReload.MetadataUpdates; using Uno.UI.SourceGenerators.MetadataUpdates; namespace Uno.UI.SourceGenerators.Tests.MetadataUpdateTests; @@ -27,7 +16,7 @@ public async Task HR(string name, Scenario? scenario, Project[]? projects) { var results = await ApplyScenario(projects, scenario.IsDebug, scenario.IsMono, scenario.UseXamlReaderReload, name); - for (int i = 0; i < scenario.PassResults.Length; i++) + for (var i = 0; i < scenario.PassResults.Length; i++) { var resultValidation = scenario.PassResults[i]; @@ -63,10 +52,12 @@ public record DiagnosticsResult(string Id); var scenarioName = Path.GetFileName(scenarioFolder); var path = Path.Combine(scenarioFolder, "Scenario.json"); - //if (!path.Contains("When_Simple_Xaml_Single_xName_Add_Twice")) - //{ - // continue; - //} +#if DEBUG && false + if (!path.Contains("When_Simple_Xaml_Add_xBind_Function_Property_Add")) + { + continue; + } +#endif if (File.Exists(path)) { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs index 3b4d7889129b..33a69a235b9d 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs @@ -28,8 +28,10 @@ public record UpdateResult(ImmutableArray Diagnostics, ImmutableArra const string NetCoreCapsRaw = "Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition ChangeCustomAttributes UpdateParameters GenericUpdateMethod GenericAddMethodToExistingType GenericAddFieldToExistingType"; const string MonoCapsRaw = "Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition ChangeCustomAttributes UpdateParameters GenericUpdateMethod GenericAddMethodToExistingType GenericAddFieldToExistingType"; #elif NET9_0 + // https://github.com/dotnet/runtime/blob/e99557baffbe864d624cc1c95c9cbf2eefae684f/src/coreclr/System.Private.CoreLib/src/System/Reflection/Metadata/MetadataUpdater.cs#L58 const string NetCoreCapsRaw = "Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition ChangeCustomAttributes UpdateParameters GenericUpdateMethod GenericAddMethodToExistingType GenericAddFieldToExistingType"; - const string MonoCapsRaw = "Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition ChangeCustomAttributes UpdateParameters GenericUpdateMethod GenericAddMethodToExistingType GenericAddFieldToExistingType"; + // https://github.com/dotnet/runtime/blob/e99557baffbe864d624cc1c95c9cbf2eefae684f/src/mono/mono/component/hot_reload.c#L3330 + const string MonoCapsRaw = "Baseline AddMethodToExistingType AddStaticFieldToExistingType NewTypeDefinition ChangeCustomAttributes AddInstanceFieldToExistingType GenericAddMethodToExistingType GenericUpdateMethod UpdateParameters GenericAddFieldToExistingType"; #else #error This runtime is not supported yet, find the caps in the .NET runtime's sources #endif @@ -89,7 +91,18 @@ public void SetSourceFile(string project, string fileName, string content) var basePath = Path.Combine(_baseWorkFolder, project); var filePath = Path.Combine(basePath, fileName); Directory.CreateDirectory(basePath); - File.WriteAllText(filePath, content, Encoding.UTF8); + for (var i = 2; i >= 0; i--) + { + try + { + File.WriteAllText(filePath, content, Encoding.UTF8); + break; + } + catch (IOException) when (i is not 0) + { + Task.Delay(100).Wait(); + } + } if (_currentSolution is not null) { @@ -200,6 +213,19 @@ public async Task Initialize(CancellationToken ct) currentSolution = project.Solution; + // Build the analyzer document additional data information + var analyzerDocumentId = DocumentId.CreateNewId(project.Id); + + // For now, there is no need to customize these for each test. + var globalConfigBuilder = new StringBuilder($""" + is_global = true + build_property.MSBuildProjectFullPath = C:\Project\{project.Name}.csproj + build_property.RootNamespace = {project.Name} + build_property.XamlSourceGeneratorTracingFolder = {_baseWorkFolder} + build_property.Configuration = {(_isDebugCompilation ? "Debug" : "Release")} + + """); + if (_sourceFiles.TryGetValue(projectName, out var sourceFiles)) { foreach (var (fileName, content) in sourceFiles) @@ -227,39 +253,84 @@ public async Task Initialize(CancellationToken ct) filePath: Path.Combine(_baseWorkFolder, project.Name, fileName)); } - if (additionalFiles.Any()) + foreach (var (fileName, content) in additionalFiles.Where(k => k.Key.EndsWith(".xaml"))) { - // Build the analyzer document additional data information - var analyzerDocumentId = DocumentId.CreateNewId(project.Id); - - // For now, there is no need to customize these for each test. - var globalConfigBuilder = new StringBuilder($""" - is_global = true - build_property.MSBuildProjectFullPath = C:\Project\{project.Name}.csproj - build_property.RootNamespace = {project.Name} - build_property.XamlSourceGeneratorTracingFolder = {_baseWorkFolder} - build_property.Configuration = {(_isDebugCompilation ? "Debug" : "Release")} - - """); ; - - foreach (var (fileName, content) in additionalFiles.Where(k => k.Key.EndsWith(".xaml"))) - { - globalConfigBuilder.Append($""" - [{Path.Combine(_baseWorkFolder, project.Name, fileName).Replace("\\", "/")}] - build_metadata.AdditionalFiles.SourceItemGroup = Page - """); - } - - currentSolution = currentSolution.AddAnalyzerConfigDocument( - analyzerDocumentId, - name: ".globalconfig", - filePath: "/.globalconfig", - text: SourceText.From(globalConfigBuilder.ToString()) - ); ; + globalConfigBuilder.Append($""" + [{Path.Combine(_baseWorkFolder, project.Name, fileName).Replace("\\", "/")}] + build_metadata.AdditionalFiles.SourceItemGroup = Page + """); } } + currentSolution = currentSolution.AddAnalyzerConfigDocument( + analyzerDocumentId, + name: ".globalconfig", + filePath: "/.globalconfig", + text: SourceText.From(globalConfigBuilder.ToString()) + ); + workspace.TryApplyChanges(currentSolution); + + //if (_sourceFiles.TryGetValue(projectName, out var sourceFiles)) + //{ + // foreach (var (fileName, content) in sourceFiles) + // { + // var documentId = DocumentId.CreateNewId(project.Id); + + // currentSolution = currentSolution.AddDocument( + // documentId, + // fileName, + // CSharpSyntaxTree.ParseText(content, encoding: Encoding.UTF8).GetText(), + // filePath: Path.Combine(_baseWorkFolder, project.Name, fileName) + // ); + // } + //} + + //if (_additionalFiles.TryGetValue(projectName, out var additionalFiles)) + //{ + // foreach (var (fileName, content) in additionalFiles) + // { + // var documentId = DocumentId.CreateNewId(project.Id); + // currentSolution = currentSolution.AddAdditionalDocument( + // documentId, + // fileName, + // CSharpSyntaxTree.ParseText(content, encoding: Encoding.UTF8).GetText(), + // filePath: Path.Combine(_baseWorkFolder, project.Name, fileName)); + // } + + // if (additionalFiles.Any()) + // { + // // Build the analyzer document additional data information + // var analyzerDocumentId = DocumentId.CreateNewId(project.Id); + + // // For now, there is no need to customize these for each test. + // var globalConfigBuilder = new StringBuilder($""" + // is_global = true + // build_property.MSBuildProjectFullPath = C:\Project\{project.Name}.csproj + // build_property.RootNamespace = {project.Name} + // build_property.XamlSourceGeneratorTracingFolder = {_baseWorkFolder} + // build_property.Configuration = {(_isDebugCompilation ? "Debug" : "Release")} + + // """); ; + + // foreach (var (fileName, content) in additionalFiles.Where(k => k.Key.EndsWith(".xaml"))) + // { + // globalConfigBuilder.Append($""" + // [{Path.Combine(_baseWorkFolder, project.Name, fileName).Replace("\\", "/")}] + // build_metadata.AdditionalFiles.SourceItemGroup = Page + // """); + // } + + // currentSolution = currentSolution.AddAnalyzerConfigDocument( + // analyzerDocumentId, + // name: ".globalconfig", + // filePath: "/.globalconfig", + // text: SourceText.From(globalConfigBuilder.ToString()) + // ); ; + // } + //} + + //workspace.TryApplyChanges(currentSolution); } @@ -381,9 +452,9 @@ private static PortableExecutableReference[] BuildUnoReferences() #endif var availableTargets = new[] { - Path.Combine("Uno.UI.Skia", configuration, "net8.0"), - Path.Combine("Uno.UI.Reference", configuration, "net8.0"), - Path.Combine("Uno.UI.Tests", configuration, "net8.0"), + Path.Combine("Uno.UI.Skia", configuration, "net9.0"), + Path.Combine("Uno.UI.Reference", configuration, "net9.0"), + Path.Combine("Uno.UI.Tests", configuration, "net9.0"), }; var unoUIBase = Path.Combine( diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Uno.UI.SourceGenerators.Tests.csproj b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Uno.UI.SourceGenerators.Tests.csproj index 57ba3406e9fb..83645ba5bdfb 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Uno.UI.SourceGenerators.Tests.csproj +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Uno.UI.SourceGenerators.Tests.csproj @@ -5,7 +5,7 @@ - $(NetPrevious) + net9.0 false enable enable @@ -41,9 +41,9 @@ - - - + + + 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 bfc9addda4b5..2105fd316c32 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 @@ -34,11 +34,8 @@ namespace TestRepro { - [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - internal string __checksum() => "b9972598331e683fbb77aea763a897b0b45bc3d6"; [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)] @@ -46,12 +43,6 @@ partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); private void InitializeComponent() { - var __resourceLocator = new global::System.Uri("file:///C:/Project/0/MainPage.xaml"); - if(global::Uno.UI.ApplicationHelper.IsLoadableComponent(__resourceLocator)) - { - global::Microsoft.UI.Xaml.Application.LoadComponent(this, __resourceLocator); - return; - } NameScope.SetNameScope(this, __nameScope); var __that = this; base.IsParsing = true; @@ -71,43 +62,47 @@ private void InitializeComponent() FontSize = 30d, // Source 0\MainPage.xaml (Line 9:4) } - .GenericApply(__that, __nameScope, ((c0, __that, __nameScope) => - { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 9, 4); - c0.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_0 )) , } } - .GenericApply(__that, __nameScope, ((c1, __that, __nameScope) => - { - global::Uno.UI.Toolkit.VisibleBoundsPadding.SetPaddingMask(c1, global::Uno.UI.Toolkit.VisibleBoundsPadding.PaddingMask.Top); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 8, 3); - c1.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_1 )) ; this - .GenericApply(__that, __nameScope, ((c2, __that, __nameScope) => + .GenericApply(__that, __nameScope, (ApplyMethod_2 )) + .GenericApply(__that, __nameScope, (ApplyMethod_3 )) + ; + OnInitializeCompleted(); + + } + partial void OnInitializeCompleted(); + 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, 4); + __p1.CreationComplete(); + } + + private void ApplyMethod_1(global::Microsoft.UI.Xaml.Controls.Grid __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + global::Uno.UI.Toolkit.VisibleBoundsPadding.SetPaddingMask(__p1, global::Uno.UI.Toolkit.VisibleBoundsPadding.PaddingMask.Top); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 8, 3); + __p1.CreationComplete(); + } + + private void ApplyMethod_2(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) { // Source 0\MainPage.xaml (Line 1:2) - // WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } - )) - .GenericApply(__that, __nameScope, ((c3, __that, __nameScope) => + + private void ApplyMethod_3(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) { // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 1, 2); - c3.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 1, 2); + __p1.CreationComplete(); } - )) - ; - OnInitializeCompleted(); - } - partial void OnInitializeCompleted(); } } 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 65f295fa7b90..196730c23d18 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 @@ -34,11 +34,8 @@ namespace TestRepro { - [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - internal string __checksum() => "346ee2c4a3294fdba50b4b5daaa042583c405e7a"; [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)] @@ -46,12 +43,6 @@ partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); private void InitializeComponent() { - var __resourceLocator = new global::System.Uri("file:///C:/Project/0/MainPage.xaml"); - if(global::Uno.UI.ApplicationHelper.IsLoadableComponent(__resourceLocator)) - { - global::Microsoft.UI.Xaml.Application.LoadComponent(this, __resourceLocator); - return; - } NameScope.SetNameScope(this, __nameScope); var __that = this; base.IsParsing = true; @@ -59,64 +50,67 @@ private void InitializeComponent() typeof(global::Microsoft.UI.Xaml.Controls.TextBlock) ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => - new global::Microsoft.UI.Xaml.Style - { - TargetType = typeof(global::Microsoft.UI.Xaml.Controls.TextBlock), - // Source 0\MainPage.xaml (Line 7:6) - Setters = + { + // var __that = (MainPage)__ResourceOwner_1; + return + new global::Microsoft.UI.Xaml.Style { - new global::Microsoft.UI.Xaml.Setter + TargetType = typeof(global::Microsoft.UI.Xaml.Controls.TextBlock), + // Source 0\MainPage.xaml (Line 7:6) + Setters = { - Property = global::Microsoft.UI.Xaml.Controls.TextBlock.ForegroundProperty, - Value = new global::Microsoft.UI.Xaml.Media.SolidColorBrush(global::Microsoft.UI.Colors.Red), - // Source 0\MainPage.xaml (Line 8:8) + new global::Microsoft.UI.Xaml.Setter + { + Property = global::Microsoft.UI.Xaml.Controls.TextBlock.ForegroundProperty, + Value = new global::Microsoft.UI.Xaml.Media.SolidColorBrush(global::Microsoft.UI.Colors.Red), + // Source 0\MainPage.xaml (Line 8:8) + } + , } - , } - } - .GenericApply(__that, __nameScope, ((c1, __that, __nameScope) => - { - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(c1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L7:6"); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_1 )) + ; + } ) ; Resources[ "MyCustomButtonStyle" ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => - new global::Microsoft.UI.Xaml.Style - { - TargetType = typeof(global::Microsoft.UI.Xaml.Controls.Button), - // Source 0\MainPage.xaml (Line 10:6) - Setters = + { + // var __that = (MainPage)__ResourceOwner_1; + return + new global::Microsoft.UI.Xaml.Style { - new global::Microsoft.UI.Xaml.Setter + TargetType = typeof(global::Microsoft.UI.Xaml.Controls.Button), + // Source 0\MainPage.xaml (Line 10:6) + Setters = { - Property = global::Microsoft.UI.Xaml.Controls.Button.BackgroundProperty, - Value = new global::Microsoft.UI.Xaml.Media.SolidColorBrush(global::Microsoft.UI.Colors.Azure), - // Source 0\MainPage.xaml (Line 11:8) + new global::Microsoft.UI.Xaml.Setter + { + Property = global::Microsoft.UI.Xaml.Controls.Button.BackgroundProperty, + Value = new global::Microsoft.UI.Xaml.Media.SolidColorBrush(global::Microsoft.UI.Colors.Azure), + // Source 0\MainPage.xaml (Line 11:8) + } + , } - , } - } - .GenericApply(__that, __nameScope, ((c4, __that, __nameScope) => - { - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(c4, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L10:6"); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_4 )) + ; + } ) ; Resources[ "MyItemTemplate" ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => - new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => ((I_MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0)global::Uno.UI.Helpers.TypeMappings.CreateInstance<_MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0>()).Build(__owner) - ) .GenericApply(__that, __nameScope, ((c6, __that, __nameScope) => - { - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(c6, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L13:6"); - } - )) + { + // var __that = (MainPage)__ResourceOwner_1; + return + new global::Microsoft.UI.Xaml.DataTemplate(this, (__owner) => new _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0().Build(__owner) + ) .GenericApply(__that, __nameScope, (ApplyMethod_6 )) + ; + } ) ; // Source 0\MainPage.xaml (Line 1:2) @@ -125,43 +119,125 @@ private void InitializeComponent() { IsParsing = true, Name = "TheListView", - HeaderTemplate = new global::Microsoft.UI.Xaml.DataTemplate(this, (__owner) => ((I_MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC1)global::Uno.UI.Helpers.TypeMappings.CreateInstance<_MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC1>()).Build(__owner) - ) .GenericApply(__that, __nameScope, ((c7, __that, __nameScope) => - { - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(c7, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L42:8"); - } - )) + HeaderTemplate = new global::Microsoft.UI.Xaml.DataTemplate(this, (__owner) => new _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC1().Build(__owner) + ) .GenericApply(__that, __nameScope, (ApplyMethod_7 )) , // Source 0\MainPage.xaml (Line 40:4) } - .GenericApply(__that, __nameScope, ((c8, __that, __nameScope) => - { - /* _isTopLevelDictionary:False */ - __that._component_0 = c8; - __nameScope.RegisterName("TheListView", c8); - __that.TheListView = c8; - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c8, global::Microsoft.UI.Xaml.Controls.ListView.ItemTemplateProperty, "MyItemTemplate", isThemeResourceExtension: false, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c8, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 40, 4); - c8.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_8 )) ; this - .GenericApply(__that, __nameScope, ((c9, __that, __nameScope) => + .GenericApply(__that, __nameScope, (ApplyMethod_9 )) + .GenericApply(__that, __nameScope, (ApplyMethod_10 )) + ; + OnInitializeCompleted(); + + Bindings = new MainPage_Bindings(this); + ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => + { + __that.Bindings.UpdateResources(); + } + ; + } + partial void OnInitializeCompleted(); + 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"); + } + + private void ApplyMethod_4(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#L10:6"); + } + + private void ApplyMethod_6(global::System.Object /* oups */ __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__p1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L13:6"); + } + + private void ApplyMethod_7(global::System.Object /* oups */ __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__p1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L42:8"); + } + + private void ApplyMethod_8(global::Microsoft.UI.Xaml.Controls.ListView __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __nameScope.RegisterName("TheListView", __p1); + __that.TheListView = __p1; + global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.ListView.ItemTemplateProperty, "MyItemTemplate", isThemeResourceExtension: false, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 40, 4); + __p1.CreationComplete(); + } + + private void ApplyMethod_9(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) { // Source 0\MainPage.xaml (Line 1:2) - // WARNING Property c9.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } - )) - .GenericApply(__that, __nameScope, ((c10, __that, __nameScope) => + + private void ApplyMethod_11(global::Microsoft.UI.Xaml.AdaptiveTrigger __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__p1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L24:12"); + } + + private void ApplyMethod_12(global::Microsoft.UI.Xaml.VisualState __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + __nameScope.RegisterName("WideState", __p1); + __that.WideState = __p1; + global::Uno.UI.Helpers.MarkupHelper.SetVisualStateLazy(__p1, () => + { + __p1.Name = "WideState"; + __p1.Setters.Add( + new global::Microsoft.UI.Xaml.Setter + { + Target = new global::Microsoft.UI.Xaml.TargetPropertyPath(this._TheListViewSubject, "Background"), + Value = @"Red", + // Source 0\MainPage.xaml (Line 27:12) + } + ); + ; + } + ); + global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__p1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L22:8"); + } + + private void ApplyMethod_14(global::Microsoft.UI.Xaml.AdaptiveTrigger __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__p1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L32:12"); + } + + private void ApplyMethod_15(global::Microsoft.UI.Xaml.VisualState __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + __nameScope.RegisterName("NarrowState", __p1); + __that.NarrowState = __p1; + global::Uno.UI.Helpers.MarkupHelper.SetVisualStateLazy(__p1, () => + { + __p1.Name = "NarrowState"; + __p1.Setters.Add( + new global::Microsoft.UI.Xaml.Setter + { + Target = new global::Microsoft.UI.Xaml.TargetPropertyPath(this._TheListViewSubject, "Background"), + Value = @"Green", + // Source 0\MainPage.xaml (Line 35:12) + } + ); + ; + } + ); + global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__p1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L30:8"); + } + + private void ApplyMethod_10(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) { /* _isTopLevelDictionary:False */ - __that._component_1 = c10; + __that._component_1 = __p1; // Class TestRepro.MainPage - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c10, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Microsoft.UI.Xaml.VisualStateManager.SetVisualStateGroups(c10, + global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); + global::Microsoft.UI.Xaml.VisualStateManager.SetVisualStateGroups(__p1, new[] { new global::Microsoft.UI.Xaml.VisualStateGroup @@ -179,37 +255,13 @@ private void InitializeComponent() MinWindowWidth = 641d, // Source 0\MainPage.xaml (Line 24:12) } - .GenericApply(__that, __nameScope, ((c11, __that, __nameScope) => - { - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(c11, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L24:12"); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_11 )) , } , // Source 0\MainPage.xaml (Line 22:8) } - .GenericApply(__that, __nameScope, ((c12, __that, __nameScope) => - { - __nameScope.RegisterName("WideState", c12); - __that.WideState = c12; - global::Uno.UI.Helpers.MarkupHelper.SetVisualStateLazy(c12, () => - { - c12.Name = "WideState"; - c12.Setters.Add( - new global::Microsoft.UI.Xaml.Setter - { - Target = new global::Microsoft.UI.Xaml.TargetPropertyPath(this._TheListViewSubject, "Background"), - Value = @"Red", - // Source 0\MainPage.xaml (Line 27:12) - } - ); - ; - } - ); - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(c12, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L22:8"); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_12 )) , new global::Microsoft.UI.Xaml.VisualState { @@ -221,59 +273,22 @@ private void InitializeComponent() MinWindowWidth = 0d, // Source 0\MainPage.xaml (Line 32:12) } - .GenericApply(__that, __nameScope, ((c14, __that, __nameScope) => - { - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(c14, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L32:12"); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_14 )) , } , // Source 0\MainPage.xaml (Line 30:8) } - .GenericApply(__that, __nameScope, ((c15, __that, __nameScope) => - { - __nameScope.RegisterName("NarrowState", c15); - __that.NarrowState = c15; - global::Uno.UI.Helpers.MarkupHelper.SetVisualStateLazy(c15, () => - { - c15.Name = "NarrowState"; - c15.Setters.Add( - new global::Microsoft.UI.Xaml.Setter - { - Target = new global::Microsoft.UI.Xaml.TargetPropertyPath(this._TheListViewSubject, "Background"), - Value = @"Green", - // Source 0\MainPage.xaml (Line 35:12) - } - ); - ; - } - ); - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(c15, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L30:8"); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_15 )) , } } , } ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c10, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 1, 2); - c10.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 1, 2); + __p1.CreationComplete(); } - )) - ; - OnInitializeCompleted(); - Bindings = ((IMainPage_Bindings)global::Uno.UI.Helpers.TypeMappings.CreateInstance(this)); - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__that, "owner", __that); - ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => - { - var __that = global::Uno.UI.Helpers.MarkupHelper.GetElementProperty(s, "owner"); - __that.Bindings.UpdateResources(); - } - ; - } - partial void OnInitializeCompleted(); private global::Microsoft.UI.Xaml.Data.ElementNameSubject _TheListViewSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); private global::Microsoft.UI.Xaml.Controls.ListView TheListView { @@ -310,25 +325,24 @@ private void InitializeComponent() _NarrowStateSubject.ElementInstance = value; } } - internal interface I_MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 - { - _View Build(object owner); - } - [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] [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 : I_MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 + private class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 { [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) { _View __rootInstance = null; var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = __rootInstance; __rootInstance = new global::Microsoft.UI.Xaml.Controls.StackPanel { @@ -341,19 +355,7 @@ public _View Build(object __ResourceOwner_1) IsParsing = true, // Source 0\MainPage.xaml (Line 15:10) } - .GenericApply(__that, __nameScope, ((c17, __that, __nameScope) => - { - c17.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Path = @"", - } - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c17, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 15, 10); - c17.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_17 )) , new global::Microsoft.UI.Xaml.Controls.Button { @@ -361,26 +363,13 @@ public _View Build(object __ResourceOwner_1) Content = @"DoSomething", // Source 0\MainPage.xaml (Line 16:10) } - .GenericApply(__that, __nameScope, ((c18, __that, __nameScope) => - { - /* _isTopLevelDictionary:False */ - __that._component_0 = c18; - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c18, global::Microsoft.UI.Xaml.Controls.Button.StyleProperty, "MyCustomButtonStyle", isThemeResourceExtension: false, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c18, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 16, 10); - c18.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_18 )) , } } - .GenericApply(__that, __nameScope, ((c19, __that, __nameScope) => - { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c19, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 14, 8); - c19.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_19 )) ; - if (__rootInstance is FrameworkElement __fe) + if (__that.__rootInstance is FrameworkElement __fe) { var owner = this; __fe.Loading += delegate @@ -400,7 +389,7 @@ public _View Build(object __ResourceOwner_1) } 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.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Button _component_0 { get @@ -412,26 +401,53 @@ public _View Build(object __ResourceOwner_1) _component_0_Holder.Instance = value; } } + 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_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(); + } + } - internal interface I_MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC1 - { - _View Build(object owner); - } - [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] [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 : I_MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC1 + private class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC1 { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] private const string __baseUri_prefix_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] private const string __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d = "ms-appx:///TestProject/"; global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); + global::System.Object __ResourceOwner_1; + _View __rootInstance = null; public _View Build(object __ResourceOwner_1) { _View __rootInstance = null; var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = __rootInstance; __rootInstance = new global::Microsoft.UI.Xaml.Controls.TextBlock { @@ -439,12 +455,7 @@ public _View Build(object __ResourceOwner_1) Text = "Header", // Source 0\MainPage.xaml (Line 43:10) } - .GenericApply(__that, __nameScope, ((c20, __that, __nameScope) => - { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c20, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 43, 10); - c20.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_20 )) ; if (__rootInstance is DependencyObject d) { @@ -457,8 +468,14 @@ 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) + { + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 43, 10); + __p1.CreationComplete(); + } + } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.ListView _component_0 { get @@ -470,7 +487,7 @@ public _View Build(object __ResourceOwner_1) _component_0_Holder.Instance = value; } } - 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.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Page _component_1 { get @@ -493,7 +510,6 @@ private interface IMainPage_Bindings #pragma warning disable 0169 // Suppress unused field warning in case Bindings is not used. private IMainPage_Bindings Bindings; #pragma warning restore 0169 - [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] private class MainPage_Bindings : IMainPage_Bindings { 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 14d428a2c00b..ffc70c3e580c 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 @@ -34,11 +34,8 @@ namespace TestRepro { - [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - internal string __checksum() => "d65e560961295873ce5fb238ed21e219474df252"; [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)] @@ -46,12 +43,6 @@ partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); private void InitializeComponent() { - var __resourceLocator = new global::System.Uri("file:///C:/Project/0/MainPage.xaml"); - if(global::Uno.UI.ApplicationHelper.IsLoadableComponent(__resourceLocator)) - { - global::Microsoft.UI.Xaml.Application.LoadComponent(this, __resourceLocator); - return; - } NameScope.SetNameScope(this, __nameScope); var __that = this; base.IsParsing = true; @@ -59,64 +50,67 @@ private void InitializeComponent() typeof(global::Microsoft.UI.Xaml.Controls.TextBlock) ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => - new global::Microsoft.UI.Xaml.Style - { - TargetType = typeof(global::Microsoft.UI.Xaml.Controls.TextBlock), - // Source 0\MainPage.xaml (Line 7:6) - Setters = + { + // var __that = (MainPage)__ResourceOwner_1; + return + new global::Microsoft.UI.Xaml.Style { - new global::Microsoft.UI.Xaml.Setter + TargetType = typeof(global::Microsoft.UI.Xaml.Controls.TextBlock), + // Source 0\MainPage.xaml (Line 7:6) + Setters = { - Property = global::Microsoft.UI.Xaml.Controls.TextBlock.ForegroundProperty, - Value = new global::Microsoft.UI.Xaml.Media.SolidColorBrush(global::Microsoft.UI.Colors.Red), - // Source 0\MainPage.xaml (Line 8:8) + new global::Microsoft.UI.Xaml.Setter + { + Property = global::Microsoft.UI.Xaml.Controls.TextBlock.ForegroundProperty, + Value = new global::Microsoft.UI.Xaml.Media.SolidColorBrush(global::Microsoft.UI.Colors.Red), + // Source 0\MainPage.xaml (Line 8:8) + } + , } - , } - } - .GenericApply(__that, __nameScope, ((c1, __that, __nameScope) => - { - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(c1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L7:6"); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_1 )) + ; + } ) ; Resources[ "MyCustomButtonStyle" ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => - new global::Microsoft.UI.Xaml.Style - { - TargetType = typeof(global::Microsoft.UI.Xaml.Controls.Button), - // Source 0\MainPage.xaml (Line 10:6) - Setters = + { + // var __that = (MainPage)__ResourceOwner_1; + return + new global::Microsoft.UI.Xaml.Style { - new global::Microsoft.UI.Xaml.Setter + TargetType = typeof(global::Microsoft.UI.Xaml.Controls.Button), + // Source 0\MainPage.xaml (Line 10:6) + Setters = { - Property = global::Microsoft.UI.Xaml.Controls.Button.BackgroundProperty, - Value = new global::Microsoft.UI.Xaml.Media.SolidColorBrush(global::Microsoft.UI.Colors.Azure), - // Source 0\MainPage.xaml (Line 11:8) + new global::Microsoft.UI.Xaml.Setter + { + Property = global::Microsoft.UI.Xaml.Controls.Button.BackgroundProperty, + Value = new global::Microsoft.UI.Xaml.Media.SolidColorBrush(global::Microsoft.UI.Colors.Azure), + // Source 0\MainPage.xaml (Line 11:8) + } + , } - , } - } - .GenericApply(__that, __nameScope, ((c4, __that, __nameScope) => - { - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(c4, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L10:6"); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_4 )) + ; + } ) ; Resources[ "MyItemTemplate" ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => - new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => ((I_MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0)global::Uno.UI.Helpers.TypeMappings.CreateInstance<_MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0>()).Build(__owner) - ) .GenericApply(__that, __nameScope, ((c6, __that, __nameScope) => - { - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(c6, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L13:6"); - } - )) + { + // var __that = (MainPage)__ResourceOwner_1; + return + new global::Microsoft.UI.Xaml.DataTemplate(this, (__owner) => new _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0().Build(__owner) + ) .GenericApply(__that, __nameScope, (ApplyMethod_6 )) + ; + } ) ; // Source 0\MainPage.xaml (Line 1:2) @@ -126,64 +120,79 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 20:4) } - .GenericApply(__that, __nameScope, ((c7, __that, __nameScope) => - { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c7, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 20, 4); - c7.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_7 )) ; this - .GenericApply(__that, __nameScope, ((c8, __that, __nameScope) => - { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c8.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator - } - )) - .GenericApply(__that, __nameScope, ((c9, __that, __nameScope) => - { - /* _isTopLevelDictionary:False */ - __that._component_0 = c9; - // Class TestRepro.MainPage - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c9, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c9, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 1, 2); - c9.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_8 )) + .GenericApply(__that, __nameScope, (ApplyMethod_9 )) ; OnInitializeCompleted(); - Bindings = ((IMainPage_Bindings)global::Uno.UI.Helpers.TypeMappings.CreateInstance(this)); - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__that, "owner", __that); + Bindings = new MainPage_Bindings(this); ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => { - var __that = global::Uno.UI.Helpers.MarkupHelper.GetElementProperty(s, "owner"); __that.Bindings.UpdateResources(); } ; } partial void OnInitializeCompleted(); - internal interface I_MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 - { - _View Build(object owner); - } - [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] + 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"); + } + + private void ApplyMethod_4(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#L10:6"); + } + + private void ApplyMethod_6(global::System.Object /* oups */ __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__p1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L13:6"); + } + + private void ApplyMethod_7(global::Microsoft.UI.Xaml.Controls.ListView __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 20, 4); + __p1.CreationComplete(); + } + + private void ApplyMethod_8(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + } + + private void ApplyMethod_9(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + // Class TestRepro.MainPage + global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 1, 2); + __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 : I_MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 + private class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 { [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) { _View __rootInstance = null; var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = __rootInstance; __rootInstance = new global::Microsoft.UI.Xaml.Controls.StackPanel { @@ -196,19 +205,7 @@ public _View Build(object __ResourceOwner_1) IsParsing = true, // Source 0\MainPage.xaml (Line 15:10) } - .GenericApply(__that, __nameScope, ((c10, __that, __nameScope) => - { - c10.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Path = @"", - } - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c10, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 15, 10); - c10.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_10 )) , new global::Microsoft.UI.Xaml.Controls.Button { @@ -216,26 +213,13 @@ public _View Build(object __ResourceOwner_1) Content = @"DoSomething", // Source 0\MainPage.xaml (Line 16:10) } - .GenericApply(__that, __nameScope, ((c11, __that, __nameScope) => - { - /* _isTopLevelDictionary:False */ - __that._component_0 = c11; - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c11, global::Microsoft.UI.Xaml.Controls.Button.StyleProperty, "MyCustomButtonStyle", isThemeResourceExtension: false, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c11, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 16, 10); - c11.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_11 )) , } } - .GenericApply(__that, __nameScope, ((c12, __that, __nameScope) => - { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c12, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 14, 8); - c12.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_12 )) ; - if (__rootInstance is FrameworkElement __fe) + if (__that.__rootInstance is FrameworkElement __fe) { var owner = this; __fe.Loading += delegate @@ -255,7 +239,7 @@ public _View Build(object __ResourceOwner_1) } 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.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Button _component_0 { get @@ -267,8 +251,36 @@ public _View Build(object __ResourceOwner_1) _component_0_Holder.Instance = value; } } + 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_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 global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 { get @@ -291,7 +303,6 @@ private interface IMainPage_Bindings #pragma warning disable 0169 // Suppress unused field warning in case Bindings is not used. private IMainPage_Bindings Bindings; #pragma warning restore 0169 - [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] private class MainPage_Bindings : IMainPage_Bindings { 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 00be0c571d11..492f1a139bb5 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 @@ -34,11 +34,8 @@ namespace TestRepro { - [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - internal string __checksum() => "3342e09da9b0007e915ae08b62408423c424b95b"; [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)] @@ -46,12 +43,6 @@ partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); private void InitializeComponent() { - var __resourceLocator = new global::System.Uri("file:///C:/Project/0/MainPage.xaml"); - if(global::Uno.UI.ApplicationHelper.IsLoadableComponent(__resourceLocator)) - { - global::Microsoft.UI.Xaml.Application.LoadComponent(this, __resourceLocator); - return; - } NameScope.SetNameScope(this, __nameScope); var __that = this; base.IsParsing = true; @@ -59,52 +50,54 @@ private void InitializeComponent() typeof(global::Microsoft.UI.Xaml.Controls.TextBlock) ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => - new global::Microsoft.UI.Xaml.Style - { - TargetType = typeof(global::Microsoft.UI.Xaml.Controls.TextBlock), - // Source 0\MainPage.xaml (Line 7:6) - Setters = + { + // var __that = (MainPage)__ResourceOwner_1; + return + new global::Microsoft.UI.Xaml.Style { - new global::Microsoft.UI.Xaml.Setter + TargetType = typeof(global::Microsoft.UI.Xaml.Controls.TextBlock), + // Source 0\MainPage.xaml (Line 7:6) + Setters = { - Property = global::Microsoft.UI.Xaml.Controls.TextBlock.ForegroundProperty, - Value = new global::Microsoft.UI.Xaml.Media.SolidColorBrush(global::Microsoft.UI.Colors.Red), - // Source 0\MainPage.xaml (Line 8:8) + new global::Microsoft.UI.Xaml.Setter + { + Property = global::Microsoft.UI.Xaml.Controls.TextBlock.ForegroundProperty, + Value = new global::Microsoft.UI.Xaml.Media.SolidColorBrush(global::Microsoft.UI.Colors.Red), + // Source 0\MainPage.xaml (Line 8:8) + } + , } - , } - } - .GenericApply(__that, __nameScope, ((c1, __that, __nameScope) => - { - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(c1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L7:6"); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_1 )) + ; + } ) ; Resources[ "MyCustomButtonStyle" ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => - new global::Microsoft.UI.Xaml.Style - { - TargetType = typeof(global::Microsoft.UI.Xaml.Controls.Button), - // Source 0\MainPage.xaml (Line 10:6) - Setters = + { + // var __that = (MainPage)__ResourceOwner_1; + return + new global::Microsoft.UI.Xaml.Style { - new global::Microsoft.UI.Xaml.Setter + TargetType = typeof(global::Microsoft.UI.Xaml.Controls.Button), + // Source 0\MainPage.xaml (Line 10:6) + Setters = { - Property = global::Microsoft.UI.Xaml.Controls.Button.BackgroundProperty, - Value = new global::Microsoft.UI.Xaml.Media.SolidColorBrush(global::Microsoft.UI.Colors.Azure), - // Source 0\MainPage.xaml (Line 11:8) + new global::Microsoft.UI.Xaml.Setter + { + Property = global::Microsoft.UI.Xaml.Controls.Button.BackgroundProperty, + Value = new global::Microsoft.UI.Xaml.Media.SolidColorBrush(global::Microsoft.UI.Colors.Azure), + // Source 0\MainPage.xaml (Line 11:8) + } + , } - , } - } - .GenericApply(__that, __nameScope, ((c4, __that, __nameScope) => - { - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(c4, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L10:6"); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_4 )) + ; + } ) ; // Source 0\MainPage.xaml (Line 1:2) @@ -114,46 +107,57 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 14:4) } - .GenericApply(__that, __nameScope, ((c6, __that, __nameScope) => - { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c6, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 14, 4); - c6.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_6 )) ; this - .GenericApply(__that, __nameScope, ((c7, __that, __nameScope) => - { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c7.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator - } - )) - .GenericApply(__that, __nameScope, ((c8, __that, __nameScope) => - { - /* _isTopLevelDictionary:False */ - __that._component_0 = c8; - // Class TestRepro.MainPage - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c8, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c8, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 1, 2); - c8.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_7 )) + .GenericApply(__that, __nameScope, (ApplyMethod_8 )) ; OnInitializeCompleted(); - Bindings = ((IMainPage_Bindings)global::Uno.UI.Helpers.TypeMappings.CreateInstance(this)); - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__that, "owner", __that); + Bindings = new MainPage_Bindings(this); ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => { - var __that = global::Uno.UI.Helpers.MarkupHelper.GetElementProperty(s, "owner"); __that.Bindings.UpdateResources(); } ; } partial void OnInitializeCompleted(); - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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"); + } + + private void ApplyMethod_4(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#L10:6"); + } + + private void ApplyMethod_6(global::Microsoft.UI.Xaml.Controls.ListView __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 14, 4); + __p1.CreationComplete(); + } + + private void ApplyMethod_7(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + } + + private void ApplyMethod_8(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + // Class TestRepro.MainPage + global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 1, 2); + __p1.CreationComplete(); + } + + 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 { get @@ -176,7 +180,6 @@ private interface IMainPage_Bindings #pragma warning disable 0169 // Suppress unused field warning in case Bindings is not used. private IMainPage_Bindings Bindings; #pragma warning restore 0169 - [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] private class MainPage_Bindings : IMainPage_Bindings { 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 25d9f901aaf7..1011f6c8dba4 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 @@ -34,11 +34,8 @@ namespace TestRepro { - [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - internal string __checksum() => "09e2aaf9274c57d3e9cf35f1ca51514a3a6916ed"; [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)] @@ -46,12 +43,6 @@ partial class MainPage : global::Microsoft.UI.Xaml.Controls.Page private global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); private void InitializeComponent() { - var __resourceLocator = new global::System.Uri("file:///C:/Project/0/MainPage.xaml"); - if(global::Uno.UI.ApplicationHelper.IsLoadableComponent(__resourceLocator)) - { - global::Microsoft.UI.Xaml.Application.LoadComponent(this, __resourceLocator); - return; - } NameScope.SetNameScope(this, __nameScope); var __that = this; base.IsParsing = true; @@ -74,12 +65,7 @@ private void InitializeComponent() Text = "use me", // Source 0\MainPage.xaml (Line 9:3) } - .GenericApply(__that, __nameScope, ((c0, __that, __nameScope) => - { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 9, 3); - c0.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_0 )) ; // Source 0\MainPage.xaml (Line 1:2) base.Content = @@ -89,46 +75,53 @@ private void InitializeComponent() Text = "Some content", // Source 0\MainPage.xaml (Line 11:4) } - .GenericApply(__that, __nameScope, ((c1, __that, __nameScope) => - { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 11, 4); - c1.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_1 )) ; this - .GenericApply(__that, __nameScope, ((c2, __that, __nameScope) => - { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator - } - )) - .GenericApply(__that, __nameScope, ((c3, __that, __nameScope) => - { - /* _isTopLevelDictionary:False */ - __that._component_0 = c3; - // Class TestRepro.MainPage - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c3, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 1, 2); - c3.CreationComplete(); - } - )) + .GenericApply(__that, __nameScope, (ApplyMethod_2 )) + .GenericApply(__that, __nameScope, (ApplyMethod_3 )) ; OnInitializeCompleted(); - Bindings = ((IMainPage_Bindings)global::Uno.UI.Helpers.TypeMappings.CreateInstance(this)); - global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__that, "owner", __that); + Bindings = new MainPage_Bindings(this); ((global::Microsoft.UI.Xaml.FrameworkElement)this).Loading += (s, e) => { - var __that = global::Uno.UI.Helpers.MarkupHelper.GetElementProperty(s, "owner"); __that.Bindings.UpdateResources(); } ; } partial void OnInitializeCompleted(); - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder { get; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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); + __p1.CreationComplete(); + } + + private void ApplyMethod_1(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", 11, 4); + __p1.CreationComplete(); + } + + private void ApplyMethod_2(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + } + + private void ApplyMethod_3(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + { + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + // Class TestRepro.MainPage + global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: true, context: global::MyProject.GlobalStaticResources.__ParseContext_); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d, "file:///C:/Project/0/MainPage.xaml", 1, 2); + __p1.CreationComplete(); + } + + 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 { get @@ -151,7 +144,6 @@ private interface IMainPage_Bindings #pragma warning disable 0169 // Suppress unused field warning in case Bindings is not used. private IMainPage_Bindings Bindings; #pragma warning restore 0169 - [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] private class MainPage_Bindings : IMainPage_Bindings { 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 5d32651d4962..7ea52c3b2fda 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 @@ -34,7 +34,6 @@ namespace TestNamespace { - [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] public sealed partial class TestClass : global::Microsoft.UI.Xaml.ResourceDictionary { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] @@ -58,10 +57,7 @@ public sealed partial class GlobalStaticResources private const string __baseUri_prefix_MyDictionary_b7707bcf1e73425b710b6a5d04177088 = "ms-appx:///TestProject/"; [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] private const string __baseUri_MyDictionary_b7707bcf1e73425b710b6a5d04177088 = "ms-appx:///TestProject/"; - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - internal string __MyDictionary_b7707bcf1e73425b710b6a5d04177088_checksum() => "0006bfa967d7b0e0bdb0aa951326268f007434d5"; // This non-static inner class is a means of reducing size of AOT compilations by avoiding many accesses to static members from a static callsite, which adds costly class initializer checks each time. - [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] internal sealed class ResourceDictionarySingleton__MyDictionary_b7707bcf1e73425b710b6a5d04177088 : global::Uno.UI.IXamlResourceDictionaryProvider { private static global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); @@ -72,7 +68,7 @@ internal sealed class ResourceDictionarySingleton__MyDictionary_b7707bcf1e73425b { if (__that == null) { - __that = (global::Uno.UI.IXamlResourceDictionaryProvider)global::Uno.UI.Helpers.TypeMappings.CreateInstance(); + __that = new ResourceDictionarySingleton__MyDictionary_b7707bcf1e73425b710b6a5d04177088(); } return __that; 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 525ffc8e395f..bdcb63a024a6 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 @@ -59,49 +59,49 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 12:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - c0.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = BindingMode.OneTime, - } - .BindingApply(___b => /*defaultBindModeOneTime MyArray.Length*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? (TryGetInstance_xBind_1(___tctx, out var bindResult1) ? (true, bindResult1) : (false, default)) : (false, default), null )) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = BindingMode.OneTime, + } + .BindingApply(___b => /*defaultBindModeOneTime MyArray.Length*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? (TryGetInstance_xBind_1(___tctx, out var bindResult1) ? (true, bindResult1) : (false, default)) : (false, default), null )) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c2) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c3) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_1 = c3; - // Class TestRepro.MainPage - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c3, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_1 = __p1; + // Class TestRepro.MainPage + global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -116,7 +116,7 @@ private void InitializeComponent() ; } partial void OnInitializeCompleted(); - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 @@ -128,7 +128,7 @@ private void InitializeComponent() _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.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Page _component_1 { get @@ -213,5 +213,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } 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 d174782f553a..a61d2310f646 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 @@ -62,10 +62,10 @@ private void InitializeComponent() FontSize = 30d, // Source 0\MainPage.xaml (Line 12:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -73,44 +73,44 @@ private void InitializeComponent() { // Source 0\MainPage.xaml (Line 13:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - c1.SetBinding( - "DataContext", - new Microsoft.UI.Xaml.Data.Binding() - { - Path = @"PreviewDropViewModel", - } - ); + __p1.SetBinding( + "DataContext", + new Microsoft.UI.Xaml.Data.Binding() + { + Path = @"PreviewDropViewModel", + } + ); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(c2 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c2.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c3) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler3)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c3.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c4) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler3)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c4; - // Class TestRepro.MainPage - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c4, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c4, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c4.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + // Class TestRepro.MainPage + global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -124,7 +124,7 @@ private void InitializeComponent() ; } partial void OnInitializeCompleted(); - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 { get @@ -206,5 +206,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler3(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler3 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TBTNSICB/XamlCodeGenerator_UserControl1_81d855d5b3bba02f594dcda3b149beb2.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TBTNSICB/XamlCodeGenerator_UserControl1_81d855d5b3bba02f594dcda3b149beb2.cs index 8bbfc030fecc..4003dff8ad3e 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TBTNSICB/XamlCodeGenerator_UserControl1_81d855d5b3bba02f594dcda3b149beb2.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TBTNSICB/XamlCodeGenerator_UserControl1_81d855d5b3bba02f594dcda3b149beb2.cs @@ -53,27 +53,27 @@ private void InitializeComponent() IsParsing = true, // Source 0\UserControl1.xaml (Line 12:3) } - .UserControl1_81d855d5b3bba02f594dcda3b149beb2_XamlApply((UserControl1_81d855d5b3bba02f594dcda3b149beb2XamlApplyExtensions.XamlApplyHandler0)(c0 => + .UserControl1_81d855d5b3bba02f594dcda3b149beb2_XamlApply((UserControl1_81d855d5b3bba02f594dcda3b149beb2XamlApplyExtensions.XamlApplyHandler0)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_UserControl1_81d855d5b3bba02f594dcda3b149beb2); - c0.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_UserControl1_81d855d5b3bba02f594dcda3b149beb2); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c1) => + .UserControl1_81d855d5b3bba02f594dcda3b149beb2_XamlApply((UserControl1_81d855d5b3bba02f594dcda3b149beb2XamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Source 0\UserControl1.xaml (Line 1:2) - - // WARNING Property c1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}UserControl, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\UserControl1.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}UserControl, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c2) => + .UserControl1_81d855d5b3bba02f594dcda3b149beb2_XamlApply((UserControl1_81d855d5b3bba02f594dcda3b149beb2XamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Class TestRepro.UserControl1 - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_UserControl1_81d855d5b3bba02f594dcda3b149beb2); - c2.CreationComplete(); + // Class TestRepro.UserControl1 + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_UserControl1_81d855d5b3bba02f594dcda3b149beb2); + __p1.CreationComplete(); } )) ; @@ -94,5 +94,12 @@ static class UserControl1_81d855d5b3bba02f594dcda3b149beb2XamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler1(global::Microsoft.UI.Xaml.Controls.UserControl instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.UserControl UserControl1_81d855d5b3bba02f594dcda3b149beb2_XamlApply(this global::Microsoft.UI.Xaml.Controls.UserControl instance, XamlApplyHandler1 handler) + { + handler(instance); + return instance; + } } } 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 74e5d4ef1a2e..19266e845f3a 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 @@ -46,25 +46,34 @@ public void InitializeComponent() "myTemplate" ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => - new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionarySC0().Build(__owner) - ) ) + { + // var __that = (MyResourceDictionary)__ResourceOwner_1; + return + new global::Microsoft.UI.Xaml.DataTemplate(this, (__owner) => new _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 + private class _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionarySC0 { [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) { _View __rootInstance = null; var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = __rootInstance; __rootInstance = new global::Microsoft.UI.Xaml.Controls.TextBlock { @@ -72,26 +81,26 @@ public _View Build(object __ResourceOwner_1) Name = "tb", // Source 0\MyResourceDictionary.xaml (Line 12:5) } - .MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_XamlApply((MyResourceDictionary_92716e07ff456818f6d4125e055d4d57XamlApplyExtensions.XamlApplyHandler0)(c0 => + .MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_XamlApply((MyResourceDictionary_92716e07ff456818f6d4125e055d4d57XamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:True */ - __that._component_0 = c0; - __nameScope.RegisterName("tb", c0); - __that.tb = c0; - c0.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(c0, __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57); - c0.CreationComplete(); + /* _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(); } )) ; - if (__rootInstance is FrameworkElement __fe) + if (__that.__rootInstance is FrameworkElement __fe) { var owner = this; __fe.Loading += delegate @@ -112,7 +121,7 @@ public _View Build(object __ResourceOwner_1) } 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.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.TextBlock _component_0 { get @@ -185,7 +194,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(this, (__owner) => new __Resources._MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC1().Build(__owner) ) ; private global::Microsoft.UI.Xaml.ResourceDictionary _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_ResourceDictionary; @@ -204,8 +213,13 @@ private object Get_1(object __ResourceOwner_1) => "myTemplate" ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => - new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new __Resources._MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC2().Build(__owner) - ) ) + { + // var __that = (MyResourceDictionaryRD)__ResourceOwner_1; + return + new global::Microsoft.UI.Xaml.DataTemplate(this, (__owner) => new __Resources._MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC2().Build(__owner) + ) ; + } + ) , } ; @@ -227,17 +241,21 @@ 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 + class _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC1 { [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) { _View __rootInstance = null; var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = __rootInstance; __rootInstance = new global::Microsoft.UI.Xaml.Controls.TextBlock { @@ -245,26 +263,26 @@ public _View Build(object __ResourceOwner_1) Name = "tb", // Source 0\MyResourceDictionary.xaml (Line 12:5) } - .MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_XamlApply((MyResourceDictionary_92716e07ff456818f6d4125e055d4d57XamlApplyExtensions.XamlApplyHandler0)(c1 => + .MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_XamlApply((MyResourceDictionary_92716e07ff456818f6d4125e055d4d57XamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:True */ - __that._component_0 = c1; - __nameScope.RegisterName("tb", c1); - __that.tb = c1; - c1.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(c1, __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57); - c1.CreationComplete(); + /* _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) + if (__that.__rootInstance is FrameworkElement __fe) { var owner = this; __fe.Loading += delegate @@ -285,7 +303,7 @@ public _View Build(object __ResourceOwner_1) } 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.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.TextBlock _component_0 { get @@ -319,17 +337,21 @@ private static bool TryGetInstance_xBind_2(global::TestRepro.MyModel ___tctx, ou [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 + class _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC2 { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] private const string __baseUri_prefix_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] private const string __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57 = "ms-appx:///TestProject/"; global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); + global::System.Object __ResourceOwner_1; + _View __rootInstance = null; public _View Build(object __ResourceOwner_1) { _View __rootInstance = null; var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = __rootInstance; __rootInstance = new global::Microsoft.UI.Xaml.Controls.TextBlock { @@ -337,26 +359,26 @@ public _View Build(object __ResourceOwner_1) Name = "tb", // Source 0\MyResourceDictionary.xaml (Line 12:5) } - .MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_XamlApply((MyResourceDictionary_92716e07ff456818f6d4125e055d4d57XamlApplyExtensions.XamlApplyHandler0)(c2 => + .MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_XamlApply((MyResourceDictionary_92716e07ff456818f6d4125e055d4d57XamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:True */ - __that._component_0 = c2; - __nameScope.RegisterName("tb", c2); - __that.tb = c2; - c2.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(c2, __baseUri_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57); - c2.CreationComplete(); + /* _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(); } )) ; - if (__rootInstance is FrameworkElement __fe) + if (__that.__rootInstance is FrameworkElement __fe) { var owner = this; __fe.Loading += delegate @@ -377,7 +399,7 @@ public _View Build(object __ResourceOwner_1) } 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.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.TextBlock _component_0 { get 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 d2c3ad9a4a47..d3fd547b6c12 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 @@ -59,46 +59,46 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 11:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - c0.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBox.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, - } - .BindingApply(___b => /*defaultBindModeOneTime MyFooInterface.Name*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.MyFooInterface.Name)) : (false, default), (___ctx, __value) => { if(___ctx is global::TestRepro.MainPage ___tctx) ___tctx.MyFooInterface.Name = (string)global::Microsoft.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(typeof(string), __value); } , new [] {"MyFooInterface.Name"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBox.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, + } + .BindingApply(___b => /*defaultBindModeOneTime MyFooInterface.Name*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.MyFooInterface.Name)) : (false, default), (___ctx, __value) => { if(___ctx is global::TestRepro.MainPage ___tctx) ___tctx.MyFooInterface.Name = (string)global::Microsoft.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(typeof(string), __value); } , new [] {"MyFooInterface.Name"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c2) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c3) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -113,7 +113,7 @@ private void InitializeComponent() ; } partial void OnInitializeCompleted(); - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 { get @@ -189,5 +189,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } 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 0afbaaaa9257..aba6d7f4b2bc 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 @@ -59,22 +59,22 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 12:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - __that.__0_Click_P1_Button_Click_Builder = (__owner) => + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __that.__0_Click_P1_Button_Click_Builder = (__owner) => + { + var Click_P1_Button_Click_That = (__that as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference; + /* first level targetMethod:TestRepro.C1.Button_Click(object, Microsoft.UI.Xaml.RoutedEventArgs) */ __owner.Click += (_sender,_e) => { - var Click_P1_Button_Click_That = (__that as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference; - /* first level targetMethod:TestRepro.C1.Button_Click(object, Microsoft.UI.Xaml.RoutedEventArgs) */ __owner.Click += (_sender,_e) => - { - (Click_P1_Button_Click_That.Target as global::TestRepro.MainPage)?.P1.Button_Click(_sender,_e); - } - ; + (Click_P1_Button_Click_That.Target as global::TestRepro.MainPage)?.P1.Button_Click(_sender,_e); } ; - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + } + ; + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -83,22 +83,22 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 13:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_1 = c1; - __that.__1_Click_P2_Button_Click_Builder = (__owner) => + /* _isTopLevelDictionary:False */ + __that._component_1 = __p1; + __that.__1_Click_P2_Button_Click_Builder = (__owner) => + { + var Click_P2_Button_Click_That = (__that as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference; + /* first level targetMethod:TestRepro.ImplicitImpl.Button_Click(object, Microsoft.UI.Xaml.RoutedEventArgs) */ __owner.Click += (_sender,_e) => { - var Click_P2_Button_Click_That = (__that as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference; - /* first level targetMethod:TestRepro.ImplicitImpl.Button_Click(object, Microsoft.UI.Xaml.RoutedEventArgs) */ __owner.Click += (_sender,_e) => - { - (Click_P2_Button_Click_That.Target as global::TestRepro.MainPage)?.P2.Button_Click(_sender,_e); - } - ; + (Click_P2_Button_Click_That.Target as global::TestRepro.MainPage)?.P2.Button_Click(_sender,_e); } ; - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + } + ; + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -107,51 +107,51 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 14:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c2 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_2 = c2; - __that.__2_Click_P3_Button_Click_Builder = (__owner) => + /* _isTopLevelDictionary:False */ + __that._component_2 = __p1; + __that.__2_Click_P3_Button_Click_Builder = (__owner) => + { + var Click_P3_Button_Click_That = (__that as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference; + /* first level targetMethod:TestRepro.I.Button_Click(object, Microsoft.UI.Xaml.RoutedEventArgs) */ __owner.Click += (_sender,_e) => { - var Click_P3_Button_Click_That = (__that as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference; - /* first level targetMethod:TestRepro.I.Button_Click(object, Microsoft.UI.Xaml.RoutedEventArgs) */ __owner.Click += (_sender,_e) => - { - (Click_P3_Button_Click_That.Target as global::TestRepro.MainPage)?.P3.Button_Click(_sender,_e); - } - ; + (Click_P3_Button_Click_That.Target as global::TestRepro.MainPage)?.P3.Button_Click(_sender,_e); } ; - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c2.CreationComplete(); + } + ; + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c3 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c4) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c4.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c5) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_3 = c5; - // Class TestRepro.MainPage - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c5, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c5, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c5.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_3 = __p1; + // Class TestRepro.MainPage + global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -169,7 +169,7 @@ private void InitializeComponent() 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; - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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.Button _component_0 { get @@ -181,7 +181,7 @@ private void InitializeComponent() _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.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Button _component_1 { get @@ -193,7 +193,7 @@ private void InitializeComponent() _component_1_Holder.Instance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_2_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_2_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Button _component_2 { get @@ -205,7 +205,7 @@ private void InitializeComponent() _component_2_Holder.Instance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_3_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_3_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Page _component_3 { get @@ -310,5 +310,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } 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 cd548616f8c0..3be428f72e15 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 @@ -50,21 +50,21 @@ private void InitializeComponent() ; this - .GenericApply(((c0) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c0.base does not exist on {using:TestRepro}BasePage, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {using:TestRepro}BasePage, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c1) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c1; - // Class TestRepro.MainPage - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c1, global::TestRepro.BasePage.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + // Class TestRepro.MainPage + global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::TestRepro.BasePage.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -78,7 +78,7 @@ private void InitializeComponent() ; } partial void OnInitializeCompleted(); - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 { get @@ -139,5 +139,12 @@ namespace MyProject { static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions { + public delegate void XamlApplyHandler0(global::TestRepro.BasePage instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::TestRepro.BasePage MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::TestRepro.BasePage instance, XamlApplyHandler0 handler) + { + handler(instance); + return instance; + } } } 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 49e4974989eb..4219c6c9e7b1 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 @@ -51,28 +51,28 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainWindow.xaml (Line 10:3) } - .MainWindow_c93db19a7202d9eb84ddc41d72fcb89b_XamlApply((MainWindow_c93db19a7202d9eb84ddc41d72fcb89bXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainWindow_c93db19a7202d9eb84ddc41d72fcb89b_XamlApply((MainWindow_c93db19a7202d9eb84ddc41d72fcb89bXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c0, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b); - c0.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c1) => + .MainWindow_c93db19a7202d9eb84ddc41d72fcb89b_XamlApply((MainWindow_c93db19a7202d9eb84ddc41d72fcb89bXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Source 0\MainWindow.xaml (Line 1:2) - - // WARNING Property c1.base does not exist on {using:TestRepro}BaseWindow, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainWindow.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {using:TestRepro}BaseWindow, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c2) => + .MainWindow_c93db19a7202d9eb84ddc41d72fcb89b_XamlApply((MainWindow_c93db19a7202d9eb84ddc41d72fcb89bXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Class TestRepro.MainWindow + // Class TestRepro.MainWindow } )) ; @@ -90,7 +90,7 @@ private void InitializeComponent() ; } partial void OnInitializeCompleted(); - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 { get @@ -158,5 +158,12 @@ static class MainWindow_c93db19a7202d9eb84ddc41d72fcb89bXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler1(global::TestRepro.BaseWindow instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::TestRepro.BaseWindow MainWindow_c93db19a7202d9eb84ddc41d72fcb89b_XamlApply(this global::TestRepro.BaseWindow instance, XamlApplyHandler1 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TNMEIAP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TNMEIAP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index a00781b14041..08c34cfcd5cc 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TNMEIAP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TNMEIAP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -59,38 +59,38 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 11:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - global::Microsoft.UI.Xaml.Controls.ToolTipService.SetToolTip(c0, - null ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + global::Microsoft.UI.Xaml.Controls.ToolTipService.SetToolTip(__p1, + null ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c2) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c3) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -118,5 +118,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TNMEIRP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TNMEIRP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index 507c3e1ad5fd..95328b66c38d 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TNMEIRP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TNMEIRP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -60,36 +60,36 @@ private void InitializeComponent() Text = null , // Source 0\MainPage.xaml (Line 11:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c2) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c3) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -117,5 +117,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } 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 f4b6dfb0cfd1..83791a52a433 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 @@ -71,60 +71,60 @@ private void InitializeComponent() Content = "Loaded via x:Load and toggle enable for buttons" , } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - __nameScope.RegisterName("LoadElement", c0); - __that.LoadElement = c0; - // FieldModifier public - /* Skipping x:Load attribute already applied to ElementStub */ - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __nameScope.RegisterName("LoadElement", __p1); + __that.LoadElement = __p1; + // FieldModifier public + /* Skipping x:Load attribute already applied to ElementStub */ + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) - ) .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c1 => + ) .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - c1.Name = "LoadElement"; - _LoadElementSubject.ElementInstance = c1; - c1.SetBinding( - global::Microsoft.UI.Xaml.ElementStub.LoadProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, - Converter = (global::Microsoft.UI.Xaml.Data.IValueConverter)global::Uno.UI.ResourceResolverSingleton.Instance.ResolveResourceStatic("NullableBoolConverter", typeof(global::Microsoft.UI.Xaml.Data.IValueConverter), context: global::MyProject.GlobalStaticResources.__ParseContext_), - } - .BindingApply(___b => /*defaultBindModeOneTime ToggleLoad.IsChecked*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ToggleLoad.IsChecked)) : (false, default), null , new [] {"ToggleLoad.IsChecked"})) - ); - __that._component_1 = c1; - 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) + else { - if (_component_1_update_That.Target is global::TestRepro.MainPage that) - { - if (sender.IsMaterialized) - { - that.Bindings.UpdateResources(); - that.Bindings.NotifyXLoad("LoadElement"); - } - else - { - _LoadElementSubject.ElementInstance = null; - } - } + _LoadElementSubject.ElementInstance = null; + } + __p1.Name = "LoadElement"; + _LoadElementSubject.ElementInstance = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.ElementStub.LoadProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, + Converter = (global::Microsoft.UI.Xaml.Data.IValueConverter)global::Uno.UI.ResourceResolverSingleton.Instance.ResolveResourceStatic("NullableBoolConverter", typeof(global::Microsoft.UI.Xaml.Data.IValueConverter), context: global::MyProject.GlobalStaticResources.__ParseContext_), } - c1.MaterializationChanged += _component_1_update; - var owner = this; - void _component_1_materializing(object sender) + .BindingApply(___b => /*defaultBindModeOneTime ToggleLoad.IsChecked*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ToggleLoad.IsChecked)) : (false, default), null , new [] {"ToggleLoad.IsChecked"})) + ); + __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) { - if (_component_1_update_That.Target is global::TestRepro.MainPage that) + if (sender.IsMaterialized) { - that._component_0.ApplyXBind(); - that._component_0.UpdateResourceBindings(); + that.Bindings.UpdateResources(); + that.Bindings.NotifyXLoad("LoadElement"); } } - c1.Materializing += _component_1_materializing; + } + __p1.MaterializationChanged += _component_1_update; + var owner = this; + void _component_1_materializing(object sender) + { + if (_component_1_update_That.Target is global::TestRepro.MainPage that) + { + that._component_0.ApplyXBind(); + that._component_0.UpdateResourceBindings(); + } + } + __p1.Materializing += _component_1_materializing; } )) , @@ -136,23 +136,23 @@ void _component_1_materializing(object sender) Content = "Button1" , } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(c2 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_2 = c2; - __nameScope.RegisterName("button1", c2); - __that.button1 = c2; - // FieldModifier public - c2.SetBinding( - global::Microsoft.UI.Xaml.Controls.Button.TagProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = BindingMode.OneTime, - } - .BindingApply(___b => /*defaultBindModeOneTime */ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___ctx)) : (false, default), null )) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c2.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_2 = __p1; + __nameScope.RegisterName("button1", __p1); + __that.button1 = __p1; + // FieldModifier public + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.Button.TagProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = BindingMode.OneTime, + } + .BindingApply(___b => /*defaultBindModeOneTime */ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___ctx)) : (false, default), null )) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -165,39 +165,39 @@ void _component_1_materializing(object sender) Content = "Toggle Load" , } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c3 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - __nameScope.RegisterName("ToggleLoad", c3); - __that.ToggleLoad = c3; - // FieldModifier public - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + __nameScope.RegisterName("ToggleLoad", __p1); + __that.ToggleLoad = __p1; + // FieldModifier public + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler3)(c4 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler3)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c4, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c4.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c5) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler4)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c5.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c6) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler4)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c6, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c6.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -248,7 +248,7 @@ void _component_1_materializing(object sender) _ToggleLoadSubject.ElementInstance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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.Primitives.ToggleButton _component_0 { get @@ -260,7 +260,7 @@ void _component_1_materializing(object sender) _component_0_Holder.Instance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: false); + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: false); private global::Microsoft.UI.Xaml.ElementStub _component_1 { get @@ -272,7 +272,7 @@ void _component_1_materializing(object sender) _component_1_Holder.Instance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_2_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_2_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Button _component_2 { get @@ -369,5 +369,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler4(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler4 handler) + { + handler(instance); + return instance; + } } } 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 b353a45113b8..51723c0884fd 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 @@ -60,58 +60,58 @@ private void InitializeComponent() Content = @"Button", // Source 0\MainPage.xaml (Line 12:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - global::TestRepro.MyClass.SetX(c0, - new global::Microsoft.UI.Xaml.ResourceDictionary - { - IsParsing = true, - [ - "PrimaryColor" - ] = - global::Microsoft.UI.Colors.Yellow , - [ - "SecondaryColor" - ] = - global::Microsoft.UI.Colors.Red , - } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c1 => - { - c1.CreationComplete(); - } - )) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + global::TestRepro.MyClass.SetX(__p1, + new global::Microsoft.UI.Xaml.ResourceDictionary + { + IsParsing = true, + [ + "PrimaryColor" + ] = + global::Microsoft.UI.Colors.Yellow , + [ + "SecondaryColor" + ] = + global::Microsoft.UI.Colors.Red , + } + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => + { + __p1.CreationComplete(); + } + )) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(c2 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c2.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c3) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler3)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c3.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c4) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler3)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c4; - // Class TestRepro.MainPage - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c4, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c4, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c4.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + // Class TestRepro.MainPage + global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -125,7 +125,7 @@ private void InitializeComponent() ; } partial void OnInitializeCompleted(); - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 { get @@ -207,5 +207,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler3(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler3 handler) + { + handler(instance); + return instance; + } } } 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 30fc51a7a721..f02d6d5a2f70 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 @@ -75,23 +75,23 @@ private void InitializeComponent() Name = "inner1Button", // Source 0\MainPage.xaml (Line 13:6) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - __nameScope.RegisterName("inner1Button", c0); - __that.inner1Button = c0; - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + __nameScope.RegisterName("inner1Button", __p1); + __that.inner1Button = __p1; + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - __nameScope.RegisterName("inner1", c1); - __that.inner1 = c1; - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + __nameScope.RegisterName("inner1", __p1); + __that.inner1 = __p1; + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -103,12 +103,12 @@ private void InitializeComponent() ) , // Source 0\MainPage.xaml (Line 15:5) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c2 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - __nameScope.RegisterName("inner2", c2); - __that.inner2 = c2; - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c2.CreationComplete(); + __nameScope.RegisterName("inner2", __p1); + __that.inner2 = __p1; + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -125,116 +125,116 @@ private void InitializeComponent() Name = "inner3Button", // Source 0\MainPage.xaml (Line 25:6) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c3 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - __nameScope.RegisterName("inner3Button", c3); - __that.inner3Button = c3; - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + __nameScope.RegisterName("inner3Button", __p1); + __that.inner3Button = __p1; + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c4 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - __nameScope.RegisterName("inner3", c4); - __that.inner3 = c4; - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c4, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c4.CreationComplete(); + __nameScope.RegisterName("inner3", __p1); + __that.inner3 = __p1; + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(c5 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c5; - __nameScope.RegisterName("outerGrid", c5); - __that.outerGrid = c5; - /* Skipping x:Load attribute already applied to ElementStub */ - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c5, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c5.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __nameScope.RegisterName("outerGrid", __p1); + __that.outerGrid = __p1; + /* Skipping x:Load attribute already applied to ElementStub */ + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) - ) .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler3)(c6 => + ) .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler3)(__p1 => { - c6.Name = "outerGrid"; - _outerGridSubject.ElementInstance = c6; - c6.SetBinding( - global::Microsoft.UI.Xaml.ElementStub.LoadProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = BindingMode.OneTime, - } - .BindingApply(___b => /*defaultBindModeOneTime IsLoaded*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? (TryGetInstance_xBind_1(___tctx, out var bindResult1) ? (true, bindResult1) : (false, default)) : (false, default), null )) - ); - __that._component_1 = c6; - 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) + else { - if (_component_1_update_That.Target is global::TestRepro.MainPage that) - { - if (sender.IsMaterialized) - { - that.Bindings.UpdateResources(); - that.Bindings.NotifyXLoad("outerGrid"); - } - 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; - } - } + _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; + } + __p1.Name = "outerGrid"; + _outerGridSubject.ElementInstance = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.ElementStub.LoadProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = BindingMode.OneTime, } - c6.MaterializationChanged += _component_1_update; - var owner = this; - void _component_1_materializing(object sender) + .BindingApply(___b => /*defaultBindModeOneTime IsLoaded*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? (TryGetInstance_xBind_1(___tctx, out var bindResult1) ? (true, bindResult1) : (false, default)) : (false, default), null )) + ); + __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) { - if (_component_1_update_That.Target is global::TestRepro.MainPage that) + if (sender.IsMaterialized) { - that._component_0.ApplyXBind(); - that._component_0.UpdateResourceBindings(); + that.Bindings.UpdateResources(); + that.Bindings.NotifyXLoad("outerGrid"); } } - c6.Materializing += _component_1_materializing; + } + __p1.MaterializationChanged += _component_1_update; + var owner = this; + void _component_1_materializing(object sender) + { + if (_component_1_update_That.Target is global::TestRepro.MainPage that) + { + that._component_0.ApplyXBind(); + that._component_0.UpdateResourceBindings(); + } + } + __p1.Materializing += _component_1_materializing; } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c7 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c7, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c7.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c8) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler4)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c8.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c9) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler4)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c9, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c9.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -324,17 +324,21 @@ void _component_1_materializing(object sender) [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 + private class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 { [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) { _View __rootInstance = null; var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = __rootInstance; __rootInstance = new global::Microsoft.UI.Xaml.Controls.Grid { @@ -349,23 +353,23 @@ public _View Build(object __ResourceOwner_1) Name = "gridInsideGridInsideTemplate", // Source 0\MainPage.xaml (Line 19:9) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(c10 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - __nameScope.RegisterName("gridInsideGridInsideTemplate", c10); - __that.gridInsideGridInsideTemplate = c10; - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c10, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c10.CreationComplete(); + __nameScope.RegisterName("gridInsideGridInsideTemplate", __p1); + __that.gridInsideGridInsideTemplate = __p1; + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(c11 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - __nameScope.RegisterName("gridInsideTemplate", c11); - __that.gridInsideTemplate = c11; - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c11, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c11.CreationComplete(); + __nameScope.RegisterName("gridInsideTemplate", __p1); + __that.gridInsideTemplate = __p1; + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -405,7 +409,7 @@ public _View Build(object __ResourceOwner_1) } } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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.Grid _component_0 { get @@ -417,7 +421,7 @@ public _View Build(object __ResourceOwner_1) _component_0_Holder.Instance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: false); + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: false); private global::Microsoft.UI.Xaml.ElementStub _component_1 { get @@ -518,5 +522,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler4(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler4 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTPWXS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTPWXS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index e68fe6e80e21..d5cd44c387ab 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTPWXS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TTPWXS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -54,27 +54,27 @@ private void InitializeComponent() MyProperty = typeof(string), // Source 0\MainPage.xaml (Line 9:3) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c1) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c2) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c2.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -95,5 +95,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler1(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler1 handler) + { + handler(instance); + return instance; + } } } 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 3e52c509e1d7..e055399428c6 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 @@ -59,49 +59,49 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 12:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - c0.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, - } - .BindingApply(___b => /*defaultBindModeOneTime ViewModel.P*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? (TryGetInstance_xBind_1(___tctx, out var bindResult1) ? (true, bindResult1) : (false, default)) : (false, default), (___ctx, __value) => { if(___ctx is global::TestRepro.MainPage ___tctx) TrySetInstance_xBind_1(___tctx, __value); } , new [] {"ViewModel.P"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, + } + .BindingApply(___b => /*defaultBindModeOneTime ViewModel.P*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? (TryGetInstance_xBind_1(___tctx, out var bindResult1) ? (true, bindResult1) : (false, default)) : (false, default), (___ctx, __value) => { if(___ctx is global::TestRepro.MainPage ___tctx) TrySetInstance_xBind_1(___tctx, __value); } , new [] {"ViewModel.P"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c2) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c3) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_1 = c3; - // Class TestRepro.MainPage - global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c3, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_1 = __p1; + // Class TestRepro.MainPage + global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(__p1, global::Microsoft.UI.Xaml.Controls.Page.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, isHotReloadSupported: false, context: global::MyProject.GlobalStaticResources.__ParseContext_); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -116,7 +116,7 @@ private void InitializeComponent() ; } partial void OnInitializeCompleted(); - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 @@ -128,7 +128,7 @@ private void InitializeComponent() _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.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Page _component_1 { get @@ -220,5 +220,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TVBP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TVBP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index ea6db7c4cd4f..27e5bf405ecf 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TVBP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/TVBP/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -62,37 +62,37 @@ private void InitializeComponent() FontSize = 30d, // Source 0\MainPage.xaml (Line 9:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.Toolkit.VisibleBoundsPadding.SetPaddingMask(c1, global::Uno.UI.Toolkit.VisibleBoundsPadding.PaddingMask.Top); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + global::Uno.UI.Toolkit.VisibleBoundsPadding.SetPaddingMask(__p1, global::Uno.UI.Toolkit.VisibleBoundsPadding.PaddingMask.Top); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c2) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c3) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -120,5 +120,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } 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 412d8268678c..9db562024d38 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 @@ -71,60 +71,60 @@ private void InitializeComponent() Content = "Loaded via x:Load and toggle enable for buttons" , } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - __nameScope.RegisterName("LoadElement", c0); - __that.LoadElement = c0; - // FieldModifier public - /* Skipping x:Load attribute already applied to ElementStub */ - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __nameScope.RegisterName("LoadElement", __p1); + __that.LoadElement = __p1; + // FieldModifier public + /* Skipping x:Load attribute already applied to ElementStub */ + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) - ) .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c1 => + ) .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - c1.Name = "LoadElement"; - _LoadElementSubject.ElementInstance = c1; - c1.SetBinding( - global::Microsoft.UI.Xaml.ElementStub.LoadProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, - Converter = (global::Microsoft.UI.Xaml.Data.IValueConverter)global::Uno.UI.ResourceResolverSingleton.Instance.ResolveResourceStatic("NullableBoolConverter", typeof(global::Microsoft.UI.Xaml.Data.IValueConverter), context: global::MyProject.GlobalStaticResources.__ParseContext_), - } - .BindingApply(___b => /*defaultBindModeOneTime ToggleLoad.IsChecked*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ToggleLoad.IsChecked)) : (false, default), null , new [] {"ToggleLoad.IsChecked"})) - ); - __that._component_1 = c1; - 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) + else { - if (_component_1_update_That.Target is global::TestRepro.MainPage that) - { - if (sender.IsMaterialized) - { - that.Bindings.UpdateResources(); - that.Bindings.NotifyXLoad("LoadElement"); - } - else - { - _LoadElementSubject.ElementInstance = null; - } - } + _LoadElementSubject.ElementInstance = null; + } + __p1.Name = "LoadElement"; + _LoadElementSubject.ElementInstance = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.ElementStub.LoadProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, + Converter = (global::Microsoft.UI.Xaml.Data.IValueConverter)global::Uno.UI.ResourceResolverSingleton.Instance.ResolveResourceStatic("NullableBoolConverter", typeof(global::Microsoft.UI.Xaml.Data.IValueConverter), context: global::MyProject.GlobalStaticResources.__ParseContext_), } - c1.MaterializationChanged += _component_1_update; - var owner = this; - void _component_1_materializing(object sender) + .BindingApply(___b => /*defaultBindModeOneTime ToggleLoad.IsChecked*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ToggleLoad.IsChecked)) : (false, default), null , new [] {"ToggleLoad.IsChecked"})) + ); + __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) { - if (_component_1_update_That.Target is global::TestRepro.MainPage that) + if (sender.IsMaterialized) { - that._component_0.ApplyXBind(); - that._component_0.UpdateResourceBindings(); + that.Bindings.UpdateResources(); + that.Bindings.NotifyXLoad("LoadElement"); } } - c1.Materializing += _component_1_materializing; + } + __p1.MaterializationChanged += _component_1_update; + var owner = this; + void _component_1_materializing(object sender) + { + if (_component_1_update_That.Target is global::TestRepro.MainPage that) + { + that._component_0.ApplyXBind(); + that._component_0.UpdateResourceBindings(); + } + } + __p1.Materializing += _component_1_materializing; } )) , @@ -136,24 +136,24 @@ void _component_1_materializing(object sender) Content = "Button1" , } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(c2 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_2 = c2; - __nameScope.RegisterName("button1", c2); - __that.button1 = c2; - // FieldModifier public - c2.SetBinding( - global::Microsoft.UI.Xaml.Controls.Button.IsEnabledProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, - Converter = (global::Microsoft.UI.Xaml.Data.IValueConverter)global::Uno.UI.ResourceResolverSingleton.Instance.ResolveResourceStatic("NullableBoolConverter", typeof(global::Microsoft.UI.Xaml.Data.IValueConverter), context: global::MyProject.GlobalStaticResources.__ParseContext_), - } - .BindingApply(___b => /*defaultBindModeOneTime LoadElement.IsChecked*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.LoadElement.IsChecked)) : (false, default), null , new [] {"LoadElement.IsChecked"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c2.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_2 = __p1; + __nameScope.RegisterName("button1", __p1); + __that.button1 = __p1; + // FieldModifier public + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.Button.IsEnabledProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, + Converter = (global::Microsoft.UI.Xaml.Data.IValueConverter)global::Uno.UI.ResourceResolverSingleton.Instance.ResolveResourceStatic("NullableBoolConverter", typeof(global::Microsoft.UI.Xaml.Data.IValueConverter), context: global::MyProject.GlobalStaticResources.__ParseContext_), + } + .BindingApply(___b => /*defaultBindModeOneTime LoadElement.IsChecked*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.LoadElement.IsChecked)) : (false, default), null , new [] {"LoadElement.IsChecked"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -166,39 +166,39 @@ void _component_1_materializing(object sender) Content = "Toggle Load" , } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c3 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - __nameScope.RegisterName("ToggleLoad", c3); - __that.ToggleLoad = c3; - // FieldModifier public - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + __nameScope.RegisterName("ToggleLoad", __p1); + __that.ToggleLoad = __p1; + // FieldModifier public + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler3)(c4 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler3)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c4, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c4.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c5) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler4)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c5.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c6) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler4)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c6, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c6.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -249,7 +249,7 @@ void _component_1_materializing(object sender) _ToggleLoadSubject.ElementInstance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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.Primitives.ToggleButton _component_0 { get @@ -261,7 +261,7 @@ void _component_1_materializing(object sender) _component_0_Holder.Instance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: false); + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: false); private global::Microsoft.UI.Xaml.ElementStub _component_1 { get @@ -273,7 +273,7 @@ void _component_1_materializing(object sender) _component_1_Holder.Instance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_2_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_2_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Button _component_2 { get @@ -371,5 +371,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler4(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler4 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WADPIT/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WADPIT/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index ae8d957600b2..4e8fb70a7154 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WADPIT/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WADPIT/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -53,33 +53,33 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 7:3) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - global::TestRepro.MyAttached.SetMyProperty(c0, - new global::TestRepro.TestDisposable - { - // Source 0\MainPage.xaml (Line 9:5) - } - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + global::TestRepro.MyAttached.SetMyProperty(__p1, + new global::TestRepro.TestDisposable + { + // Source 0\MainPage.xaml (Line 9:5) + } + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c1) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c2) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c2.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -100,5 +100,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler1(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler1 handler) + { + handler(instance); + return instance; + } } } 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 4bffbbccc19e..e5468f938cf1 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 @@ -63,39 +63,39 @@ private void InitializeComponent() ) , // Source 0\Binding_ElementName_In_Template.xaml (Line 11:4) } - .Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_XamlApply((Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237ecaXamlApplyExtensions.XamlApplyHandler0)(c0 => + .Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_XamlApply((Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237ecaXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - __nameScope.RegisterName("topLevel", c0); - __that.topLevel = c0; - // FieldModifier public - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca); - c0.CreationComplete(); + __nameScope.RegisterName("topLevel", __p1); + __that.topLevel = __p1; + // FieldModifier public + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca); + __p1.CreationComplete(); } )) , } } - .Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_XamlApply((Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237ecaXamlApplyExtensions.XamlApplyHandler1)(c1 => + .Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_XamlApply((Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237ecaXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca); - c1.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c2) => + .Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_XamlApply((Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237ecaXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\Binding_ElementName_In_Template.xaml (Line 1:2) - - // WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\Binding_ElementName_In_Template.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c3) => + .Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_XamlApply((Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237ecaXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Class Uno.UI.Tests.Windows_UI_Xaml_Data.BindingTests.Controls.Binding_ElementName_In_Template - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca); - c3.CreationComplete(); + // Class Uno.UI.Tests.Windows_UI_Xaml_Data.BindingTests.Controls.Binding_ElementName_In_Template + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca); + __p1.CreationComplete(); } )) ; @@ -118,17 +118,21 @@ private void InitializeComponent() [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026")] [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2111")] - private class _Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_UnoUITestsWindows_UI_Xaml_DataBindingTestsControlsBinding_ElementName_In_TemplateSC0 + private class _Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_UnoUITestsWindows_UI_Xaml_DataBindingTestsControlsBinding_ElementName_In_TemplateSC0 { [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) { _View __rootInstance = null; var __that = this; + this.__ResourceOwner_1 = __ResourceOwner_1; + this.__rootInstance = __rootInstance; __rootInstance = new global::Microsoft.UI.Xaml.Controls.TextBlock { @@ -136,26 +140,26 @@ public _View Build(object __ResourceOwner_1) Name = "innerTextBlock", // Source 0\Binding_ElementName_In_Template.xaml (Line 14:7) } - .Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_XamlApply((Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237ecaXamlApplyExtensions.XamlApplyHandler2)(c4 => + .Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_XamlApply((Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237ecaXamlApplyExtensions.XamlApplyHandler3)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c4; - __nameScope.RegisterName("innerTextBlock", c4); - __that.innerTextBlock = c4; - c4.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Path = @"Tag", - ElementName = _topLevelSubject, - } - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c4, __baseUri_Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca); - c4.CreationComplete(); + /* _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(); } )) ; - if (__rootInstance is FrameworkElement __fe) + if (__that.__rootInstance is FrameworkElement __fe) { var owner = this; __fe.Loading += delegate @@ -175,7 +179,7 @@ public _View Build(object __ResourceOwner_1) } 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.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.TextBlock _component_0 { get @@ -221,9 +225,16 @@ static class Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237ecaXam handler(instance); return instance; } - public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.TextBlock instance); + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } + public delegate void XamlApplyHandler3(global::Microsoft.UI.Xaml.Controls.TextBlock instance); [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] - public static global::Microsoft.UI.Xaml.Controls.TextBlock Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_XamlApply(this global::Microsoft.UI.Xaml.Controls.TextBlock instance, XamlApplyHandler2 handler) + public static global::Microsoft.UI.Xaml.Controls.TextBlock Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_XamlApply(this global::Microsoft.UI.Xaml.Controls.TextBlock instance, XamlApplyHandler3 handler) { handler(instance); return instance; 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 de8c4154b0cb..3addc3837b18 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 @@ -61,46 +61,46 @@ private void InitializeComponent() OffContent = @"Disabled", // Source 0\MainPage.xaml (Line 7:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - c0.SetBinding( - global::Microsoft.UI.Xaml.Controls.ToggleSwitch.IsOnProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, - } - .BindingApply(___b => /*defaultBindModeOneTime ViewModel.IsEnabled*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.IsEnabled)) : (false, default), (___ctx, __value) => { if(___ctx is global::TestRepro.MainPage ___tctx) ___tctx.ViewModel.IsEnabled = (bool)global::Microsoft.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(typeof(bool), __value); } , new [] {"ViewModel.IsEnabled"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.ToggleSwitch.IsOnProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, + } + .BindingApply(___b => /*defaultBindModeOneTime ViewModel.IsEnabled*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.IsEnabled)) : (false, default), (___ctx, __value) => { if(___ctx is global::TestRepro.MainPage ___tctx) ___tctx.ViewModel.IsEnabled = (bool)global::Microsoft.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(typeof(bool), __value); } , new [] {"ViewModel.IsEnabled"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c2) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c3) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -115,7 +115,7 @@ private void InitializeComponent() ; } partial void OnInitializeCompleted(); - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 { get @@ -191,5 +191,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WEOTLNDO/XamlCodeGenerator_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WEOTLNDO/XamlCodeGenerator_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b.cs index 3592ee6ffc62..8b732a87812e 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WEOTLNDO/XamlCodeGenerator_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WEOTLNDO/XamlCodeGenerator_MainWindow_c93db19a7202d9eb84ddc41d72fcb89b.cs @@ -48,18 +48,18 @@ private void InitializeComponent() ; this - .GenericApply(((c0) => + .MainWindow_c93db19a7202d9eb84ddc41d72fcb89b_XamlApply((MainWindow_c93db19a7202d9eb84ddc41d72fcb89bXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - // Source 0\MainWindow.xaml (Line 1:2) - - // WARNING Property c0.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Window, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainWindow.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Window, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c1) => + .MainWindow_c93db19a7202d9eb84ddc41d72fcb89b_XamlApply((MainWindow_c93db19a7202d9eb84ddc41d72fcb89bXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - // Class TestRepro.MainWindow - var Closed_Window_Closed_That = (__that as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference; - /* second level */ c1.Closed += (Window_Closed_sender,Window_Closed_args) => (Closed_Window_Closed_That.Target as global::TestRepro.MainWindow)?.Window_Closed(Window_Closed_sender,Window_Closed_args); + // Class TestRepro.MainWindow + var Closed_Window_Closed_That = (__that as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference; + /* second level */ __p1.Closed += (Window_Closed_sender,Window_Closed_args) => (Closed_Window_Closed_That.Target as global::TestRepro.MainWindow)?.Window_Closed(Window_Closed_sender,Window_Closed_args); } )) ; @@ -77,5 +77,12 @@ namespace MyProject { static class MainWindow_c93db19a7202d9eb84ddc41d72fcb89bXamlApplyExtensions { + public delegate void XamlApplyHandler0(global::Microsoft.UI.Xaml.Window instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Window MainWindow_c93db19a7202d9eb84ddc41d72fcb89b_XamlApply(this global::Microsoft.UI.Xaml.Window instance, XamlApplyHandler0 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUBS/XamlCodeGenerator_Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUBS/XamlCodeGenerator_Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206.cs index dbe76c567640..58f662b05fb6 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUBS/XamlCodeGenerator_Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUBS/XamlCodeGenerator_Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206.cs @@ -180,30 +180,30 @@ private void InitializeComponent() , // Source 0\Grid_Uses_Both_Syntaxes.xaml (Line 11:6) } - .Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206_XamlApply((Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206XamlApplyExtensions.XamlApplyHandler2)(c10 => + .Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206_XamlApply((Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206XamlApplyExtensions.XamlApplyHandler2)(__p1 => { - __nameScope.RegisterName("grid", c10); - __that.grid = c10; - // FieldModifier public - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c10, __baseUri_Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206); - c10.CreationComplete(); + __nameScope.RegisterName("grid", __p1); + __that.grid = __p1; + // FieldModifier public + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c11) => + .Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206_XamlApply((Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206XamlApplyExtensions.XamlApplyHandler3)(__p1 => { - // Source 0\Grid_Uses_Both_Syntaxes.xaml (Line 1:2) - - // WARNING Property c11.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\Grid_Uses_Both_Syntaxes.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c12) => + .Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206_XamlApply((Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206XamlApplyExtensions.XamlApplyHandler3)(__p1 => { - // Class Uno.UI.Tests.Windows_UI_XAML_Controls.GridTests.Controls.Grid_Uses_Both_Syntaxes - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c12, __baseUri_Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206); - c12.CreationComplete(); + // Class Uno.UI.Tests.Windows_UI_XAML_Controls.GridTests.Controls.Grid_Uses_Both_Syntaxes + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206); + __p1.CreationComplete(); } )) ; @@ -250,5 +250,12 @@ static class Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206XamlApplyEx handler(instance); return instance; } + public delegate void XamlApplyHandler3(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page Grid_Uses_Both_Syntaxes_794c1760299b374d12fe38ba3b633206_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler3 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUCS/XamlCodeGenerator_Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUCS/XamlCodeGenerator_Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7.cs index 401376f031eb..78a1c94da9d6 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUCS/XamlCodeGenerator_Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUCS/XamlCodeGenerator_Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7.cs @@ -122,30 +122,30 @@ private void InitializeComponent() , // Source 0\Grid_Uses_Common_Syntax.xaml (Line 10:6) } - .Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7_XamlApply((Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7XamlApplyExtensions.XamlApplyHandler2)(c10 => + .Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7_XamlApply((Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7XamlApplyExtensions.XamlApplyHandler2)(__p1 => { - __nameScope.RegisterName("grid", c10); - __that.grid = c10; - // FieldModifier public - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c10, __baseUri_Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7); - c10.CreationComplete(); + __nameScope.RegisterName("grid", __p1); + __that.grid = __p1; + // FieldModifier public + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c11) => + .Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7_XamlApply((Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7XamlApplyExtensions.XamlApplyHandler3)(__p1 => { - // Source 0\Grid_Uses_Common_Syntax.xaml (Line 1:2) - - // WARNING Property c11.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\Grid_Uses_Common_Syntax.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c12) => + .Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7_XamlApply((Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7XamlApplyExtensions.XamlApplyHandler3)(__p1 => { - // Class Uno.UI.Tests.Windows_UI_XAML_Controls.GridTests.Controls.Grid_Uses_Common_Syntax - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c12, __baseUri_Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7); - c12.CreationComplete(); + // Class Uno.UI.Tests.Windows_UI_XAML_Controls.GridTests.Controls.Grid_Uses_Common_Syntax + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7); + __p1.CreationComplete(); } )) ; @@ -192,5 +192,12 @@ static class Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7XamlApplyEx handler(instance); return instance; } + public delegate void XamlApplyHandler3(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page Grid_Uses_Common_Syntax_8659265dc2cabf0b5a684f0f4b26f8b7_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler3 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUNACPS/XamlCodeGenerator_Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509ef.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUNACPS/XamlCodeGenerator_Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509ef.cs index 754bf1215ac5..c990dccf92a9 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUNACPS/XamlCodeGenerator_Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509ef.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUNACPS/XamlCodeGenerator_Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509ef.cs @@ -122,30 +122,30 @@ private void InitializeComponent() , // Source 0\Grid_Uses_New_Assigned_ContentProperty_Syntax.xaml (Line 10:6) } - .Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509ef_XamlApply((Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509efXamlApplyExtensions.XamlApplyHandler0)(c0 => + .Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509ef_XamlApply((Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509efXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - __nameScope.RegisterName("grid", c0); - __that.grid = c0; - // FieldModifier public - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509ef); - c0.CreationComplete(); + __nameScope.RegisterName("grid", __p1); + __that.grid = __p1; + // FieldModifier public + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509ef); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c1) => + .Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509ef_XamlApply((Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509efXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Source 0\Grid_Uses_New_Assigned_ContentProperty_Syntax.xaml (Line 1:2) - - // WARNING Property c1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\Grid_Uses_New_Assigned_ContentProperty_Syntax.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c2) => + .Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509ef_XamlApply((Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509efXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Class Uno.UI.Tests.Windows_UI_XAML_Controls.GridTests.Controls.Grid_Uses_New_Assigned_ContentProperty_Syntax - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509ef); - c2.CreationComplete(); + // Class Uno.UI.Tests.Windows_UI_XAML_Controls.GridTests.Controls.Grid_Uses_New_Assigned_ContentProperty_Syntax + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509ef); + __p1.CreationComplete(); } )) ; @@ -178,5 +178,12 @@ static class Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15 handler(instance); return instance; } + public delegate void XamlApplyHandler1(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page Grid_Uses_New_Assigned_ContentProperty_Syntax_9f853e56098ff21d39f15479035509ef_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler1 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUNSS/XamlCodeGenerator_Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUNSS/XamlCodeGenerator_Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609.cs index 3838abc3ae60..9e1f23b0b29a 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUNSS/XamlCodeGenerator_Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WGUNSS/XamlCodeGenerator_Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609.cs @@ -112,30 +112,30 @@ private void InitializeComponent() , // Source 0\Grid_Uses_New_Succinct_Syntax.xaml (Line 10:6) } - .Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609_XamlApply((Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609XamlApplyExtensions.XamlApplyHandler0)(c0 => + .Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609_XamlApply((Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609XamlApplyExtensions.XamlApplyHandler0)(__p1 => { - __nameScope.RegisterName("grid", c0); - __that.grid = c0; - // FieldModifier public - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609); - c0.CreationComplete(); + __nameScope.RegisterName("grid", __p1); + __that.grid = __p1; + // FieldModifier public + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c1) => + .Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609_XamlApply((Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609XamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Source 0\Grid_Uses_New_Succinct_Syntax.xaml (Line 1:2) - - // WARNING Property c1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\Grid_Uses_New_Succinct_Syntax.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c2) => + .Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609_XamlApply((Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609XamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Class Uno.UI.Tests.Windows_UI_XAML_Controls.GridTests.Controls.Grid_Uses_New_Succinct_Syntax - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609); - c2.CreationComplete(); + // Class Uno.UI.Tests.Windows_UI_XAML_Controls.GridTests.Controls.Grid_Uses_New_Succinct_Syntax + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609); + __p1.CreationComplete(); } )) ; @@ -168,5 +168,12 @@ static class Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609XamlA handler(instance); return instance; } + public delegate void XamlApplyHandler1(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page Grid_Uses_New_Succinct_Syntax_cc38332c9fd4c0da9c1fa0270bbd3609_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler1 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WI/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WI/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index 1e27d3994324..ee2f09e82b16 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WI/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WI/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -61,36 +61,36 @@ private void InitializeComponent() MyProperty = double.PositiveInfinity, // Source 0\MainPage.xaml (Line 8:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c2) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c3) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -111,5 +111,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler1(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler1 handler) + { + handler(instance); + return instance; + } } } 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 771a3047b3e3..5438152f2298 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 @@ -61,46 +61,46 @@ private void InitializeComponent() OffContent = @"Disabled", // Source 0\MainPage.xaml (Line 7:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - c0.SetBinding( - global::Microsoft.UI.Xaml.Controls.ToggleSwitch.IsOnProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, - } - .BindingApply(___b => /*defaultBindModeOneTime ViewModel.SubModel.IsEnabled*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.SubModel.IsEnabled)) : (false, default), (___ctx, __value) => { if(___ctx is global::TestRepro.MainPage ___tctx) ___tctx.ViewModel.SubModel.IsEnabled = (bool)global::Microsoft.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(typeof(bool), __value); } , new [] {"ViewModel.SubModel.IsEnabled"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.ToggleSwitch.IsOnProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, + } + .BindingApply(___b => /*defaultBindModeOneTime ViewModel.SubModel.IsEnabled*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.SubModel.IsEnabled)) : (false, default), (___ctx, __value) => { if(___ctx is global::TestRepro.MainPage ___tctx) ___tctx.ViewModel.SubModel.IsEnabled = (bool)global::Microsoft.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(typeof(bool), __value); } , new [] {"ViewModel.SubModel.IsEnabled"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c2) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c3) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -115,7 +115,7 @@ private void InitializeComponent() ; } partial void OnInitializeCompleted(); - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 { get @@ -191,5 +191,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNIONE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNIONE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index 5123a84c3951..0dfd917a3b34 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNIONE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNIONE/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -60,36 +60,36 @@ private void InitializeComponent() Source = typeof(global::NamespaceUnderTest.C), // Source 0\MainPage.xaml (Line 9:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c2) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c3) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -117,5 +117,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index c3a0c529f28f..a9b5584e19a2 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -50,51 +50,56 @@ private void InitializeComponent() "MyStyle" ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => - new global::Microsoft.UI.Xaml.Style - { - TargetType = typeof(global::TestRepro.MyGrid), - // Source 0\MainPage.xaml (Line 8:4) - Setters = + { + // var __that = (MainPage)__ResourceOwner_1; + return + new global::Microsoft.UI.Xaml.Style { - new global::Microsoft.UI.Xaml.Setter + TargetType = typeof(global::TestRepro.MyGrid), + // Source 0\MainPage.xaml (Line 8:4) + Setters = { - Property = global::TestRepro.MyGrid.FirstStyleProperty, - Value = new global::Microsoft.UI.Xaml.Style + new global::Microsoft.UI.Xaml.Setter { - TargetType = typeof(global::Microsoft.UI.Xaml.Controls.Button), - // Source 0\MainPage.xaml (Line 11:7) + Property = global::TestRepro.MyGrid.FirstStyleProperty, + Value = new global::Microsoft.UI.Xaml.Style + { + TargetType = typeof(global::Microsoft.UI.Xaml.Controls.Button), + // Source 0\MainPage.xaml (Line 11:7) + } + , + // Source 0\MainPage.xaml (Line 9:5) + } + , + new global::Microsoft.UI.Xaml.Setter + { + Property = global::TestRepro.MyGrid.SecondProperty, + Value = "Hello", + // Source 0\MainPage.xaml (Line 14:5) } , - // Source 0\MainPage.xaml (Line 9:5) - } - , - new global::Microsoft.UI.Xaml.Setter - { - Property = global::TestRepro.MyGrid.SecondProperty, - Value = "Hello", - // Source 0\MainPage.xaml (Line 14:5) } - , } - } + ; + } ) ; // Source 0\MainPage.xaml (Line 1:2) ; this - .GenericApply(((c4) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c4.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c5) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c5, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c5.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -122,5 +127,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } 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 7ff7fc66f88d..b83cc2b638ea 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 @@ -59,20 +59,20 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 7:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - c0.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = BindingMode.OneTime, - } - .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null )) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = BindingMode.OneTime, + } + .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null )) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -81,20 +81,20 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 8:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_1 = c1; - c1.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, - } - .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null , new [] {"ViewModel.Name"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_1 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, + } + .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null , new [] {"ViewModel.Name"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -103,46 +103,46 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 9:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c2 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_2 = c2; - c2.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, - } - .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), (___tctx, __value) => ViewModel.MyBindBack((string)__value) , new [] {"ViewModel.Name"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c2.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_2 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, + } + .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), (___tctx, __value) => ViewModel.MyBindBack((string)__value) , new [] {"ViewModel.Name"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c3 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c4) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c4.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c5) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c5, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c5.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -157,7 +157,7 @@ private void InitializeComponent() ; } partial void OnInitializeCompleted(); - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 @@ -169,7 +169,7 @@ private void InitializeComponent() _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.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.TextBlock _component_1 { get @@ -181,7 +181,7 @@ private void InitializeComponent() _component_1_Holder.Instance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_2_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_2_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.TextBlock _component_2 { get @@ -261,5 +261,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } 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 7ff7fc66f88d..b83cc2b638ea 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 @@ -59,20 +59,20 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 7:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - c0.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = BindingMode.OneTime, - } - .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null )) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = BindingMode.OneTime, + } + .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null )) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -81,20 +81,20 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 8:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_1 = c1; - c1.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, - } - .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null , new [] {"ViewModel.Name"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_1 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, + } + .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null , new [] {"ViewModel.Name"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -103,46 +103,46 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 9:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c2 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_2 = c2; - c2.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, - } - .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), (___tctx, __value) => ViewModel.MyBindBack((string)__value) , new [] {"ViewModel.Name"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c2.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_2 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, + } + .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), (___tctx, __value) => ViewModel.MyBindBack((string)__value) , new [] {"ViewModel.Name"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c3 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c4) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c4.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c5) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c5, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c5.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -157,7 +157,7 @@ private void InitializeComponent() ; } partial void OnInitializeCompleted(); - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 @@ -169,7 +169,7 @@ private void InitializeComponent() _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.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.TextBlock _component_1 { get @@ -181,7 +181,7 @@ private void InitializeComponent() _component_1_Holder.Instance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_2_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_2_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.TextBlock _component_2 { get @@ -261,5 +261,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } 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 7ff7fc66f88d..b83cc2b638ea 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 @@ -59,20 +59,20 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 7:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - c0.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = BindingMode.OneTime, - } - .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null )) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = BindingMode.OneTime, + } + .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null )) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -81,20 +81,20 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 8:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_1 = c1; - c1.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, - } - .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null , new [] {"ViewModel.Name"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_1 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, + } + .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null , new [] {"ViewModel.Name"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -103,46 +103,46 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 9:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c2 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_2 = c2; - c2.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, - } - .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), (___tctx, __value) => ViewModel.MyBindBack((string)__value) , new [] {"ViewModel.Name"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c2.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_2 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, + } + .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), (___tctx, __value) => ViewModel.MyBindBack((string)__value) , new [] {"ViewModel.Name"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c3 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c4) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c4.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c5) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c5, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c5.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -157,7 +157,7 @@ private void InitializeComponent() ; } partial void OnInitializeCompleted(); - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 @@ -169,7 +169,7 @@ private void InitializeComponent() _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.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.TextBlock _component_1 { get @@ -181,7 +181,7 @@ private void InitializeComponent() _component_1_Holder.Instance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_2_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_2_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.TextBlock _component_2 { get @@ -261,5 +261,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } 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 7ff7fc66f88d..b83cc2b638ea 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 @@ -59,20 +59,20 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 7:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - c0.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = BindingMode.OneTime, - } - .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null )) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = BindingMode.OneTime, + } + .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null )) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -81,20 +81,20 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 8:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_1 = c1; - c1.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, - } - .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null , new [] {"ViewModel.Name"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_1 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, + } + .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), null , new [] {"ViewModel.Name"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -103,46 +103,46 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 9:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c2 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_2 = c2; - c2.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, - } - .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), (___tctx, __value) => ViewModel.MyBindBack((string)__value) , new [] {"ViewModel.Name"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c2.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_2 = __p1; + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.TwoWay, + } + .BindingApply(___b => /*defaultBindModeOneTime ViewModel.Name.ToUpper()*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? ((true, ___tctx.ViewModel.Name.ToUpper())) : (false, default), (___tctx, __value) => ViewModel.MyBindBack((string)__value) , new [] {"ViewModel.Name"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c3 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c3.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c4) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c4.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c5) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c5, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c5.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -157,7 +157,7 @@ private void InitializeComponent() ; } partial void OnInitializeCompleted(); - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 @@ -169,7 +169,7 @@ private void InitializeComponent() _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.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.TextBlock _component_1 { get @@ -181,7 +181,7 @@ private void InitializeComponent() _component_1_Holder.Instance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_2_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_2_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.TextBlock _component_2 { get @@ -261,5 +261,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WSXN/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WSXN/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index 978b5658cfea..7005f80dfc2c 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WSXN/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WSXN/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -53,27 +53,27 @@ private void InitializeComponent() IsParsing = true, // Source 0\MainPage.xaml (Line 7:3) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c1) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c2) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c2.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -94,5 +94,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler1(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler1 handler) + { + handler(instance); + return instance; + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXB/XamlCodeGenerator_ContentDialog1_4483f06b3f5899cc3b98f0345eeea8e5.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXB/XamlCodeGenerator_ContentDialog1_4483f06b3f5899cc3b98f0345eeea8e5.cs index ce2a62534f77..f1298c4240a1 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXB/XamlCodeGenerator_ContentDialog1_4483f06b3f5899cc3b98f0345eeea8e5.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WXB/XamlCodeGenerator_ContentDialog1_4483f06b3f5899cc3b98f0345eeea8e5.cs @@ -52,19 +52,19 @@ private void InitializeComponent() PrimaryButtonText = global::Uno.UI.Helpers.MarkupHelper.GetResourceStringForXUid("TestProject/Resources", "XuidGeneratorErrorUid/PrimaryButtonText"); this - .GenericApply(((c0) => + .ContentDialog1_4483f06b3f5899cc3b98f0345eeea8e5_XamlApply((ContentDialog1_4483f06b3f5899cc3b98f0345eeea8e5XamlApplyExtensions.XamlApplyHandler0)(__p1 => { - // Source 0\ContentDialog1.xaml (Line 1:2) - - // WARNING Property c0.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}ContentDialog, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\ContentDialog1.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}ContentDialog, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c1) => + .ContentDialog1_4483f06b3f5899cc3b98f0345eeea8e5_XamlApply((ContentDialog1_4483f06b3f5899cc3b98f0345eeea8e5XamlApplyExtensions.XamlApplyHandler0)(__p1 => { - // Class TestRepro.XuidGeneratorError - global::Uno.UI.Helpers.MarkupHelper.SetXUid(c1, "XuidGeneratorErrorUid"); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_ContentDialog1_4483f06b3f5899cc3b98f0345eeea8e5); - c1.CreationComplete(); + // Class TestRepro.XuidGeneratorError + global::Uno.UI.Helpers.MarkupHelper.SetXUid(__p1, "XuidGeneratorErrorUid"); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_ContentDialog1_4483f06b3f5899cc3b98f0345eeea8e5); + __p1.CreationComplete(); } )) ; @@ -78,5 +78,12 @@ namespace MyProject { static class ContentDialog1_4483f06b3f5899cc3b98f0345eeea8e5XamlApplyExtensions { + public delegate void XamlApplyHandler0(global::Microsoft.UI.Xaml.Controls.ContentDialog instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.ContentDialog ContentDialog1_4483f06b3f5899cc3b98f0345eeea8e5_XamlApply(this global::Microsoft.UI.Xaml.Controls.ContentDialog instance, XamlApplyHandler0 handler) + { + handler(instance); + return instance; + } } } 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 74a748900e00..041619dbe325 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 @@ -69,58 +69,58 @@ private void InitializeComponent() Tag = @"42", // Source 0\Binding_Xaml_Object_With_Common_Properties.xaml (Line 14:10) } - .Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f_XamlApply((Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94fXamlApplyExtensions.XamlApplyHandler0)(c0 => + .Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f_XamlApply((Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94fXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - __nameScope.RegisterName("topLevel", c0); - __that.topLevel = c0; - // FieldModifier public - c0.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Path = @"Tag", - ElementName = _topLevelSubject, - Converter = (global::Microsoft.UI.Xaml.Data.IValueConverter)global::Uno.UI.ResourceResolverSingleton.Instance.ResolveResourceStatic("Binding_Xaml_Object_With_Common_Properties_Return_Value_Converter", typeof(global::Microsoft.UI.Xaml.Data.IValueConverter), context: global::MyProject.GlobalStaticResources.__ParseContext_), - ConverterParameter = @"topLevel", - ConverterLanguage = "topLevel", - UpdateSourceTrigger = global::Microsoft.UI.Xaml.Data.UpdateSourceTrigger.Default, - TargetNullValue = @"TargetNullValue", - FallbackValue = @"FallbackValue", - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, - RelativeSource = new RelativeSource(RelativeSourceMode.None), - Source = @"Source", - } - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f); - c0.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __nameScope.RegisterName("topLevel", __p1); + __that.topLevel = __p1; + // FieldModifier public + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Path = @"Tag", + ElementName = _topLevelSubject, + Converter = (global::Microsoft.UI.Xaml.Data.IValueConverter)global::Uno.UI.ResourceResolverSingleton.Instance.ResolveResourceStatic("Binding_Xaml_Object_With_Common_Properties_Return_Value_Converter", typeof(global::Microsoft.UI.Xaml.Data.IValueConverter), context: global::MyProject.GlobalStaticResources.__ParseContext_), + ConverterParameter = @"topLevel", + ConverterLanguage = "topLevel", + UpdateSourceTrigger = global::Microsoft.UI.Xaml.Data.UpdateSourceTrigger.Default, + TargetNullValue = @"TargetNullValue", + FallbackValue = @"FallbackValue", + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, + RelativeSource = new RelativeSource(RelativeSourceMode.None), + Source = @"Source", + } + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f); + __p1.CreationComplete(); } )) , } } - .Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f_XamlApply((Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94fXamlApplyExtensions.XamlApplyHandler1)(c1 => + .Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f_XamlApply((Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94fXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f); - c1.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c2) => + .Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f_XamlApply((Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94fXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\Binding_Xaml_Object_With_Common_Properties.xaml (Line 1:2) - - // WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\Binding_Xaml_Object_With_Common_Properties.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c3) => + .Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f_XamlApply((Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94fXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Class Uno.UI.Tests.Windows_UI_Xaml_Data.BindingTests.Controls.Binding_Xaml_Object_With_Common_Properties - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f); - c3.CreationComplete(); + // Class Uno.UI.Tests.Windows_UI_Xaml_Data.BindingTests.Controls.Binding_Xaml_Object_With_Common_Properties + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f); + __p1.CreationComplete(); } )) ; @@ -146,7 +146,7 @@ private void InitializeComponent() _topLevelSubject.ElementInstance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 @@ -221,5 +221,12 @@ static class Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page Binding_Xaml_Object_With_Common_Properties_4891310bc693a433ba9a8e9f5113f94f_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } 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 a2fac3b32d81..c9e5ed42f4eb 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 @@ -61,58 +61,58 @@ private void InitializeComponent() Tag = @"42", // Source 0\Binding_Xaml_Object_With_Xaml_Object_Properties.xaml (Line 11:10) } - .Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f_XamlApply((Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476fXamlApplyExtensions.XamlApplyHandler0)(c0 => + .Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f_XamlApply((Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476fXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - __nameScope.RegisterName("topLevel", c0); - __that.topLevel = c0; - // FieldModifier public - c0.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Path = @"Tag", - ElementName = _topLevelSubject, - Converter = new global::Uno.UI.Tests.Windows_UI_Xaml_Data.BindingTests.Controls.Binding_Xaml_Object_With_Xaml_Object_Properties_Return_Value_Converter(), - ConverterParameter = "topLevel", - ConverterLanguage = "topLevel", - UpdateSourceTrigger = global::Microsoft.UI.Xaml.Data.UpdateSourceTrigger.Default, - TargetNullValue = "TargetNullValue", - FallbackValue = "FallbackValue", - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, - RelativeSource = new RelativeSource(RelativeSourceMode.None), - Source = "Source", - } - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f); - c0.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __nameScope.RegisterName("topLevel", __p1); + __that.topLevel = __p1; + // FieldModifier public + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Path = @"Tag", + ElementName = _topLevelSubject, + Converter = new global::Uno.UI.Tests.Windows_UI_Xaml_Data.BindingTests.Controls.Binding_Xaml_Object_With_Xaml_Object_Properties_Return_Value_Converter(), + ConverterParameter = "topLevel", + ConverterLanguage = "topLevel", + UpdateSourceTrigger = global::Microsoft.UI.Xaml.Data.UpdateSourceTrigger.Default, + TargetNullValue = "TargetNullValue", + FallbackValue = "FallbackValue", + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, + RelativeSource = new RelativeSource(RelativeSourceMode.None), + Source = "Source", + } + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f); + __p1.CreationComplete(); } )) , } } - .Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f_XamlApply((Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476fXamlApplyExtensions.XamlApplyHandler1)(c1 => + .Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f_XamlApply((Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476fXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f); - c1.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c2) => + .Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f_XamlApply((Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476fXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Source 0\Binding_Xaml_Object_With_Xaml_Object_Properties.xaml (Line 1:2) - - // WARNING Property c2.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\Binding_Xaml_Object_With_Xaml_Object_Properties.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c3) => + .Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f_XamlApply((Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476fXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - // Class Uno.UI.Tests.Windows_UI_Xaml_Data.BindingTests.Controls.Binding_Xaml_Object_With_Xaml_Object_Properties - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c3, __baseUri_Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f); - c3.CreationComplete(); + // Class Uno.UI.Tests.Windows_UI_Xaml_Data.BindingTests.Controls.Binding_Xaml_Object_With_Xaml_Object_Properties + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f); + __p1.CreationComplete(); } )) ; @@ -138,7 +138,7 @@ private void InitializeComponent() _topLevelSubject.ElementInstance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 @@ -213,5 +213,12 @@ static class Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f8 handler(instance); return instance; } + public delegate void XamlApplyHandler2(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page Binding_Xaml_Object_With_Xaml_Object_Properties_5147419e44d1bc3e3f86860ad528476f_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler2 handler) + { + handler(instance); + return instance; + } } } 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 4423bafb12b3..f7bdadb701f3 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,6 @@ // Uncomment the following line to write expected files to disk // Don't commit this line uncommented. -//#define WRITE_EXPECTED +#define WRITE_EXPECTED using System.Collections.Immutable; using System.Diagnostics; @@ -311,9 +311,9 @@ private static MetadataReference[] BuildUnoReferences() #endif var availableTargets = new[] { - Path.Combine("Uno.UI.Skia", configuration, "net8.0"), - Path.Combine("Uno.UI.Reference", configuration, "net8.0"), - Path.Combine("Uno.UI.Tests", configuration, "net8.0"), + Path.Combine("Uno.UI.Skia", configuration, "net9.0"), + Path.Combine("Uno.UI.Reference", configuration, "net9.0"), + Path.Combine("Uno.UI.Tests", configuration, "net9.0"), }; var unoUIBase = Path.Combine( diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs index cad6ccc5889c..cd650828b7a1 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs @@ -164,7 +164,12 @@ public XamlCodeGeneration(GeneratorExecutionContext context) _isDebug = string.Equals(_configuration, "Debug", StringComparison.OrdinalIgnoreCase); + //Debugger.Launch(); _projectFullPath = context.GetMSBuildPropertyValue("MSBuildProjectFullPath"); + if (Path.GetDirectoryName(_projectFullPath) is null) + { + Debugger.Launch(); + } _projectDirectory = Path.GetDirectoryName(_projectFullPath) ?? throw new InvalidOperationException($"MSBuild property MSBuildProjectFullPath value {_projectFullPath} is not valid"); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGenerator.cs index e0de4c87b13f..e130ada2610b 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGenerator.cs @@ -28,6 +28,8 @@ public void Execute(GeneratorExecutionContext context) // Debugger.Launch(); //} + //Debugger.Launch(); + if (PlatformHelper.IsValidPlatform(context)) { var gen = new XamlCodeGeneration(context); @@ -36,6 +38,7 @@ public void Execute(GeneratorExecutionContext context) foreach (var tree in generatedTrees) { context.AddSource(tree.Key, tree.Value); + File.WriteAllText(Path.Combine("C:\\Src\\_Gen", tree.Key + ".cs"), tree.Value.ToString()); } DumpXamlSourceGeneratorState(context, generatedTrees); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index ca5dc47c5d3d..69861634a1c8 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -914,6 +914,7 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel { writer.AppendLineIndented("global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope();"); writer.AppendLineIndented($"global::System.Object {CurrentResourceOwner};"); + writer.AppendLineIndented($"{kvp.Value.ReturnType} __rootInstance = null;"); #if USE_NEW_TP_CODEGEN using (writer.BlockInvariant($"public {kvp.Value.ReturnType} Build(object {CurrentResourceOwner}, global::Microsoft.UI.Xaml.TemplateMaterializationSettings __settings)")) @@ -924,6 +925,7 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel writer.AppendLineIndented($"{kvp.Value.ReturnType} __rootInstance = null;"); writer.AppendLineIndented($"var __that = this;"); writer.AppendLineIndented($"this.{CurrentResourceOwner} = {CurrentResourceOwner};"); + writer.AppendLineIndented($"this.__rootInstance = __rootInstance;"); writer.AppendLineIndented("__rootInstance = "); // Is never considered in Global Resources because class encapsulation @@ -1044,7 +1046,7 @@ private void BuildCompiledBindingsInitializerForTemplate(IIndentedStringBuilder if (hasResourceExtensions) { - using (writer.BlockInvariant($"if (__rootInstance is FrameworkElement __fe) ")) + using (writer.BlockInvariant($"if (__that.__rootInstance is FrameworkElement __fe) ")) { writer.AppendLineIndented($"var owner = this;"); @@ -2740,7 +2742,11 @@ private IDisposable BuildLazyResourceInitializer(IIndentedStringBuilder writer) var currentScope = CurrentResourceOwnerName; var resourceOwnerScope = ResourceOwnerScope(); - writer.AppendLineIndented($"new global::Uno.UI.Xaml.WeakResourceInitializer({currentScope}, {CurrentResourceOwner} => "); + var bodyDisposable = writer.BlockInvariant($"new global::Uno.UI.Xaml.WeakResourceInitializer({currentScope}, {CurrentResourceOwner} => "); + + writer.AppendLineInvariantIndented($"// var __that = ({CurrentScope.ClassName}){CurrentResourceOwner};"); + + writer.AppendLineInvariantIndented($"return "); var indent = writer.Indent(); @@ -2748,6 +2754,8 @@ private IDisposable BuildLazyResourceInitializer(IIndentedStringBuilder writer) { resourceOwnerScope.Dispose(); indent.Dispose(); + writer.AppendLineInvariantIndented(";"); + bodyDisposable.Dispose(); writer.AppendLineIndented(")"); }); } @@ -2989,6 +2997,8 @@ private void TryExtractAutomationId(XamlMemberDefinition member, string[] target private void BuildExtendedProperties(IIndentedStringBuilder outerwriter, XamlObjectDefinition objectDefinition, bool useGenericApply = false) { + useGenericApply = true; + _generatorContext.CancellationToken.ThrowIfCancellationRequested(); TryAnnotateWithGeneratorSource(outerwriter); @@ -3000,6 +3010,11 @@ private void BuildExtendedProperties(IIndentedStringBuilder outerwriter, XamlObj var isFrameworkElement = IsType(objectDefinitionType, Generation.FrameworkElementSymbol.Value); var hasIsParsing = HasIsParsing(objectDefinitionType); + //if (objectDefinitionType is null) + { + //Debugger.Launch(); + } + if (extendedProperties.Any() || hasChildrenWithPhase || isFrameworkElement || hasIsParsing || !objectUid.IsNullOrEmpty()) { string closureName; @@ -3008,7 +3023,7 @@ private void BuildExtendedProperties(IIndentedStringBuilder outerwriter, XamlObj throw new InvalidOperationException("The type {0} could not be found".InvariantCultureFormat(objectDefinition.Type)); } - using (var writer = CreateApplyBlock(outerwriter, useGenericApply ? null : objectDefinitionType, out closureName)) + using (var writer = CreateApplyBlock(outerwriter, objectDefinitionType, out closureName)) { XamlMemberDefinition? uidMember = null; XamlMemberDefinition? nameMember = null; @@ -3612,7 +3627,7 @@ IMethodSymbol FindTargetMethodSymbol(INamedTypeSymbol? sourceType) // Use of __rootInstance is required to get the top-level DataContext, as it may be changed // in the current visual tree by the user. - $"(__rootInstance as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference", + $"(__that.__rootInstance as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference", FindTargetMethodSymbol(dataTypeSymbol) ); } @@ -3904,6 +3919,10 @@ private XamlLazyApplyBlockIIndentedStringBuilder CreateApplyBlock(IIndentedStrin delegateType = $"{_fileUniqueId}XamlApplyExtensions.XamlApplyHandler{appliedTypeIndex}"; } } + else + { + Debugger.Launch(); + } return new XamlLazyApplyBlockIIndentedStringBuilder( writer, @@ -3912,7 +3931,7 @@ private XamlLazyApplyBlockIIndentedStringBuilder CreateApplyBlock(IIndentedStrin delegateType, !_isTopLevelDictionary, RegisterApplyMethod, - appliedType?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) ?? "global::System.Object", + appliedType?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) ?? "global::System.Object /* oups */", CurrentScope.ClassName, $"ApplyMethod_{(_applyIndex++).ToString(CultureInfo.InvariantCulture)}"); } @@ -4613,6 +4632,10 @@ private string GetCustomMarkupExtensionValue(XamlMemberDefinition member, string .JoinBy(", "); var markupInitializer = !properties.IsNullOrEmpty() ? $" {{ {properties} }}" : "()"; + var thatCurrentResourceOwnerName = CurrentResourceOwnerName == "this" + ? CurrentResourceOwnerName + : "__that." + CurrentResourceOwnerName; + // Build the parser context for ProvideValue(IXamlServiceProvider) var providerDetails = new string[] { @@ -4622,7 +4645,7 @@ private string GetCustomMarkupExtensionValue(XamlMemberDefinition member, string $"\"{member.Member.Name}\"", $"typeof({globalized.PvtpType})", // the ResourceOwner for an ResDict is the RD's singleton instance, not the RD itself - $"({CurrentResourceOwnerName} as object as {DictionaryProviderInterfaceName})?.GetResourceDictionary() ?? (object){CurrentResourceOwnerName}", + $"({thatCurrentResourceOwnerName} as object as {DictionaryProviderInterfaceName})?.GetResourceDictionary() ?? (object){thatCurrentResourceOwnerName}", }; var provider = $"{globalized.MarkupHelper}.CreateParserContext({providerDetails.JoinBy(", ")})"; @@ -6546,6 +6569,8 @@ private void BuildChildThroughSubclass(IIndentedStringBuilder writer, XamlMember var subclassName = $"_{_fileUniqueId}_{subClassPrefix}SC{(_subclassIndex++).ToString(CultureInfo.InvariantCulture)}"; + RegisterChildSubclass(subclassName, contentOwner, returnType); + var activator = $"new {namespacePrefix}{subclassName}()"; #if USE_NEW_TP_CODEGEN @@ -6830,7 +6855,7 @@ private string? CurrentResourceOwner => _resourceOwner != 0 ? $"__ResourceOwner_{_resourceOwner.ToString(CultureInfo.InvariantCulture)}" : null; private string CurrentResourceOwnerName - => CurrentResourceOwner ?? "this"; + => /*CurrentResourceOwner ??*/ "this"; public bool HasImplicitViewPinning => Generation.IOSViewSymbol.Value is not null || Generation.AppKitViewSymbol.Value is not null; diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs index 8ea3561229c4..1e900a4cfe6b 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs @@ -89,7 +89,7 @@ private void TryWriteApply() else if (_exposeContext) { blockDisposable.Dispose(); - _onRegisterApplyMethodBody("/* registration */" + _inner.ToString()); + _onRegisterApplyMethodBody(_inner.ToString()); } _source.AppendLineIndented("))"); diff --git a/src/Uno.UI.RemoteControl.Host/Extensibility/AddIns.cs b/src/Uno.UI.RemoteControl.Host/Extensibility/AddIns.cs index bfb27344276c..0ea2b7de7c06 100644 --- a/src/Uno.UI.RemoteControl.Host/Extensibility/AddIns.cs +++ b/src/Uno.UI.RemoteControl.Host/Extensibility/AddIns.cs @@ -16,6 +16,8 @@ public class AddIns public static IImmutableList Discover(string solutionFile) { + Debugger.Launch(); + var tmp = Path.GetTempFileName(); var wd = Path.GetDirectoryName(solutionFile); var command = $"build \"{solutionFile}\" -t:UnoDumpTargetFrameworks \"-p:UnoDumpTargetFrameworksTargetFile={tmp}\" --verbosity quiet"; diff --git a/src/Uno.UI.Tests/Uno.UI.Unit.Tests.csproj b/src/Uno.UI.Tests/Uno.UI.Unit.Tests.csproj index 005db7a7af2f..b0a774c435a9 100644 --- a/src/Uno.UI.Tests/Uno.UI.Unit.Tests.csproj +++ b/src/Uno.UI.Tests/Uno.UI.Unit.Tests.csproj @@ -12,11 +12,10 @@ - True true - --> true full diff --git a/src/Uno.UI/Uno.UI.Tests.csproj b/src/Uno.UI/Uno.UI.Tests.csproj index bcfb034cfc59..33236d4c28d8 100644 --- a/src/Uno.UI/Uno.UI.Tests.csproj +++ b/src/Uno.UI/Uno.UI.Tests.csproj @@ -6,6 +6,9 @@ + + true + Uno.UI From cbb4d39eeb539606965387b45ecb91a730f73f71 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Dec 2024 10:21:07 -0500 Subject: [PATCH 07/30] chore: Import changes from 1e7006508efe1ff13017a149efc5a379e19a962e --- .../Given_DependencyObjectGenerator.cs | 19 ++++++++++++++----- .../HotReloadWorkspaceProvider.cs | 12 ++++++++---- .../Verifiers/CSGenerator.cs | 10 ++++++++-- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs index d0b5ac652ef3..ffd9579a49b2 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs @@ -26,16 +26,25 @@ public class Given_DependencyObjectGenerator "Release"; #endif - private const string TFM = "net8.0"; + private const string TFMPrevious = "net8.0"; + private const string TFMCurrent = "net9.0"; private static MetadataReference[] BuildUnoReferences(bool isAndroid) { string[] availableTargets = isAndroid - ? [Path.Combine("Uno.UI.netcoremobile", Configuration, $"{TFM}-android")] + ? [ + Path.Combine("Uno.UI.netcoremobile", Configuration, $"{TFMPrevious}-android"), + Path.Combine("Uno.UI.netcoremobile", Configuration, $"{TFMCurrent}-android"), + ] : [ - Path.Combine("Uno.UI.Skia", Configuration, TFM), - Path.Combine("Uno.UI.Reference", Configuration, TFM), - Path.Combine("Uno.UI.Tests", Configuration, TFM), + // On CI the test assemblies set must be first, as it contains all + // dependent assemblies, which the other platforms don't (see DisablePrivateProjectReference). + Path.Combine("Uno.UI.Tests", Configuration, TFMPrevious), + Path.Combine("Uno.UI.Reference", Configuration, TFMPrevious), + Path.Combine("Uno.UI.Skia", Configuration, TFMPrevious), + Path.Combine("Uno.UI.Tests", Configuration, TFMCurrent), + Path.Combine("Uno.UI.Reference", Configuration, TFMCurrent), + Path.Combine("Uno.UI.Skia", Configuration, TFMCurrent), ]; var unoUIBase = Path.Combine( diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs index 33a69a235b9d..a01401cac704 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs @@ -223,9 +223,8 @@ public async Task Initialize(CancellationToken ct) build_property.RootNamespace = {project.Name} build_property.XamlSourceGeneratorTracingFolder = {_baseWorkFolder} build_property.Configuration = {(_isDebugCompilation ? "Debug" : "Release")} - - """); + """); if (_sourceFiles.TryGetValue(projectName, out var sourceFiles)) { foreach (var (fileName, content) in sourceFiles) @@ -310,7 +309,7 @@ public async Task Initialize(CancellationToken ct) // build_property.RootNamespace = {project.Name} // build_property.XamlSourceGeneratorTracingFolder = {_baseWorkFolder} // build_property.Configuration = {(_isDebugCompilation ? "Debug" : "Release")} - + // """); ; // foreach (var (fileName, content) in additionalFiles.Where(k => k.Key.EndsWith(".xaml"))) @@ -452,9 +451,14 @@ private static PortableExecutableReference[] BuildUnoReferences() #endif var availableTargets = new[] { + // On CI the test assemblies set must be first, as it contains all + // dependent assemblies, which the other platforms don't (see DisablePrivateProjectReference). + Path.Combine("Uno.UI.Tests", configuration, "net8.0"), + Path.Combine("Uno.UI.Skia", configuration, "net8.0"), + Path.Combine("Uno.UI.Reference", configuration, "net8.0"), + Path.Combine("Uno.UI.Tests", configuration, "net9.0"), Path.Combine("Uno.UI.Skia", configuration, "net9.0"), Path.Combine("Uno.UI.Reference", configuration, "net9.0"), - Path.Combine("Uno.UI.Tests", configuration, "net9.0"), }; var unoUIBase = Path.Combine( 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 f7bdadb701f3..4443fcc8c5cd 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,6 @@ // Uncomment the following line to write expected files to disk // Don't commit this line uncommented. -#define WRITE_EXPECTED +// #define WRITE_EXPECTED using System.Collections.Immutable; using System.Diagnostics; @@ -125,6 +125,7 @@ protected override async Task RunImplAsync(CancellationToken cancellationToken) } else if (ReferenceAssemblies.Packages.Any(p => p.Id.StartsWith("Microsoft.iOS.Ref", StringComparison.OrdinalIgnoreCase) || + p.Id.StartsWith("Microsoft.tvOS.Ref", StringComparison.OrdinalIgnoreCase) || p.Id.StartsWith("Microsoft.MacCatalyst.Ref", StringComparison.OrdinalIgnoreCase))) { includeXamlNamespaces = "ios,not_android,not_wasm,not_macos,not_skia,not_netstdref"; @@ -311,9 +312,14 @@ private static MetadataReference[] BuildUnoReferences() #endif var availableTargets = new[] { + // On CI the test assemblies set must be first, as it contains all + // dependent assemblies, which the other platforms don't (see DisablePrivateProjectReference). + Path.Combine("Uno.UI.Tests", configuration, "net8.0"), + Path.Combine("Uno.UI.Skia", configuration, "net8.0"), + Path.Combine("Uno.UI.Reference", configuration, "net8.0"), + Path.Combine("Uno.UI.Tests", configuration, "net9.0"), Path.Combine("Uno.UI.Skia", configuration, "net9.0"), Path.Combine("Uno.UI.Reference", configuration, "net9.0"), - Path.Combine("Uno.UI.Tests", configuration, "net9.0"), }; var unoUIBase = Path.Combine( From b6d013833daacfc42d131c2763ffa106ff7a97e7 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Dec 2024 13:51:53 -0500 Subject: [PATCH 08/30] test: All green --- .../Given_DependencyObjectGenerator.cs | 8 +++--- .../Given_DependencyPropertyGenerator.cs | 6 ++-- .../Given_ImplementedRoutedEventsGenerator.cs | 2 +- .../Given_HotReloadEnabledInBuild.cs | 15 ++++------ .../Given_MvvmGeneratedMembers.cs | 6 ++-- .../Given_NoFuzzyMatching.cs | 4 +-- .../XamlCodeGeneratorTests/Given_Parser.cs | 4 +-- .../XamlCodeGeneratorTests/Given_Xuid.cs | 2 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 8 +++--- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 28 +++++++++---------- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 8 +++--- .../Verifiers/CSGenerator.cs | 2 +- .../Uno.UI.SourceGenerators.Tests/_Dotnet.cs | 17 +++++++++++ .../XamlGenerator/XamlCodeGenerator.cs | 6 +++- .../XamlGenerator/XamlFileGenerator.cs | 4 +-- 15 files changed, 69 insertions(+), 51 deletions(-) create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/_Dotnet.cs diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs index ffd9579a49b2..bbe96700c467 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs @@ -16,8 +16,8 @@ namespace Uno.UI.SourceGenerators.Tests.DependencyObjectGeneratorTests; [TestClass] public class Given_DependencyObjectGenerator { - private static readonly ReferenceAssemblies _net80Android = ReferenceAssemblies.Net.Net80Android.AddPackages([new PackageIdentity("Uno.Diagnostics.Eventing", "2.1.0")]); - private static readonly ReferenceAssemblies _net80 = ReferenceAssemblies.Net.Net80.AddPackages([new PackageIdentity("Uno.Diagnostics.Eventing", "2.1.0")]); + private static readonly ReferenceAssemblies _refAsmAndroid = _Dotnet.CurrentAndroid.ReferenceAssemblies.AddPackages([new PackageIdentity("Uno.Diagnostics.Eventing", "2.1.0")]); + private static readonly ReferenceAssemblies _refAsm = _Dotnet.Current.ReferenceAssemblies.AddPackages([new PackageIdentity("Uno.Diagnostics.Eventing", "2.1.0")]); private const string Configuration = #if DEBUG @@ -79,7 +79,7 @@ private async Task TestAndroid(string testCode, params DiagnosticResult[] expect { Sources = { testCode }, }, - ReferenceAssemblies = _net80Android, + ReferenceAssemblies = _refAsmAndroid, }; test.TestState.AdditionalReferences.AddRange(BuildUnoReferences(isAndroid: true)); @@ -350,7 +350,7 @@ public void SuspendBindings() => """, Encoding.UTF8)) } } }, - ReferenceAssemblies = _net80, + ReferenceAssemblies = _refAsm, }; test.TestState.AdditionalReferences.AddRange(BuildUnoReferences(isAndroid: false)); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyPropertyGeneratorTests/Given_DependencyPropertyGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyPropertyGeneratorTests/Given_DependencyPropertyGenerator.cs index 91c6894298cb..117a75dd2674 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyPropertyGeneratorTests/Given_DependencyPropertyGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyPropertyGeneratorTests/Given_DependencyPropertyGenerator.cs @@ -124,7 +124,7 @@ partial class Owner } } }, - ReferenceAssemblies = ReferenceAssemblies.Net.Net80.AddPackages(ImmutableArray.Create(new PackageIdentity("Uno.WinUI", "5.0.118"))), + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage(), }; await test.RunAsync(); @@ -251,7 +251,7 @@ partial class Owner } } }, - ReferenceAssemblies = ReferenceAssemblies.Net.Net80.AddPackages(ImmutableArray.Create(new PackageIdentity("Uno.WinUI", "5.0.118"))), + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage(), }; await test.RunAsync(); @@ -376,7 +376,7 @@ private static void OnMyValueBackingFieldUpdate(object instance, object newValue } } }, - ReferenceAssemblies = ReferenceAssemblies.Net.Net80.AddPackages(ImmutableArray.Create(new PackageIdentity("Uno.WinUI", "5.0.118"))), + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage(), }; test.ExpectedDiagnostics.Add( diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/ImplementedRoutedEventsGeneratorTests/Given_ImplementedRoutedEventsGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/ImplementedRoutedEventsGeneratorTests/Given_ImplementedRoutedEventsGenerator.cs index aa2a31423661..580edb09ab67 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/ImplementedRoutedEventsGeneratorTests/Given_ImplementedRoutedEventsGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/ImplementedRoutedEventsGeneratorTests/Given_ImplementedRoutedEventsGenerator.cs @@ -12,7 +12,7 @@ namespace Uno.UI.SourceGenerators.Tests.ImplementedRoutedEventsGeneratorTests [TestClass] public class Given_ImplementedRoutedEventsGenerator { - private static readonly ReferenceAssemblies s_defaultWithUno = ReferenceAssemblies.Net.Net80.AddPackages( + private static readonly ReferenceAssemblies s_defaultWithUno = _Dotnet.Current.ReferenceAssemblies.AddPackages( ImmutableArray.Create(new PackageIdentity("Uno.WinUI", "5.0.118"))); private async Task TestGeneratorAsync(string inputSource, params GeneratedFile[] generatedFiles) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_HotReloadEnabledInBuild.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_HotReloadEnabledInBuild.cs index f50760033679..8694075a0a51 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_HotReloadEnabledInBuild.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_HotReloadEnabledInBuild.cs @@ -9,9 +9,6 @@ namespace Uno.UI.SourceGenerators.Tests.XamlCodeGeneratorTests; [TestClass] public class Given_HotReloadEnabledInBuild { - // Specify this centrally for all tests that rely on Uno5 or above - private static readonly ReferenceAssemblies _net8Uno5Refs = ReferenceAssemblies.Net.Net80.AddPackages([new PackageIdentity("Uno.WinUI", "5.0.118")]); - [TestMethod] public async Task SetBaseUriIncludedInOutputForFrameworkElements() { @@ -57,7 +54,7 @@ public MainPage() """ } }, - ReferenceAssemblies = _net8Uno5Refs, + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage(), DisableBuildReferences = true, GlobalConfigOverride = configOverride, }.AddGeneratedSources(); @@ -111,7 +108,7 @@ public MainPage() """ } }, - ReferenceAssemblies = _net8Uno5Refs, + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage(), GlobalConfigOverride = configOverride, }.AddGeneratedSources(); @@ -161,7 +158,7 @@ public MainPage() """ } }, - ReferenceAssemblies = _net8Uno5Refs, + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage(), GlobalConfigOverride = configOverride, }.AddGeneratedSources(); @@ -220,7 +217,7 @@ public MainPage() """ } }, - ReferenceAssemblies = _net8Uno5Refs, + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage(), GlobalConfigOverride = configOverride, }.AddGeneratedSources(); @@ -243,7 +240,7 @@ public async Task SetOriginalSourceLocationInOutputForTopLevelResourceDictionari var test = new Verify.Test(xamlFile) { - ReferenceAssemblies = _net8Uno5Refs, + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage(), DisableBuildReferences = true, GlobalConfigOverride = configOverride, }.AddGeneratedSources(); @@ -329,7 +326,7 @@ public MainPage() """ } }, - ReferenceAssemblies = _net8Uno5Refs, + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage(), GlobalConfigOverride = configOverride, }.AddGeneratedSources(); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_MvvmGeneratedMembers.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_MvvmGeneratedMembers.cs index 2749d697dc55..9a7c1af3e9ef 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_MvvmGeneratedMembers.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_MvvmGeneratedMembers.cs @@ -267,11 +267,11 @@ public void MyBindBack(string s) { } test.ExpectedDiagnostics.AddRange(new[] { // Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\MainPage_d6cd66944958ced0c513e0a04797b51d.cs(75,239): error CS1061: 'MyViewModel' does not contain a definition for 'Name' and no accessible extension method 'Name' accepting a first argument of type 'MyViewModel' could be found (are you missing a using directive or an assembly reference?) - DiagnosticResult.CompilerError("CS1061").WithSpan(@"Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\MainPage_d6cd66944958ced0c513e0a04797b51d.cs", 72, 239, 72, 243).WithArguments("TestRepro.MyViewModel", "Name"), + DiagnosticResult.CompilerError("CS1061").WithSpan(@"Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\MainPage_d6cd66944958ced0c513e0a04797b51d.cs", 72, 238, 72, 242).WithArguments("TestRepro.MyViewModel", "Name"), // Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\MainPage_d6cd66944958ced0c513e0a04797b51d.cs(97,239): error CS1061: 'MyViewModel' does not contain a definition for 'Name' and no accessible extension method 'Name' accepting a first argument of type 'MyViewModel' could be found (are you missing a using directive or an assembly reference?) - DiagnosticResult.CompilerError("CS1061").WithSpan(@"Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\MainPage_d6cd66944958ced0c513e0a04797b51d.cs", 94, 239, 94, 243).WithArguments("TestRepro.MyViewModel", "Name"), + DiagnosticResult.CompilerError("CS1061").WithSpan(@"Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\MainPage_d6cd66944958ced0c513e0a04797b51d.cs", 94, 238, 94, 242).WithArguments("TestRepro.MyViewModel", "Name"), // Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\MainPage_d6cd66944958ced0c513e0a04797b51d.cs(119,239): error CS1061: 'MyViewModel' does not contain a definition for 'Name' and no accessible extension method 'Name' accepting a first argument of type 'MyViewModel' could be found (are you missing a using directive or an assembly reference?) - DiagnosticResult.CompilerError("CS1061").WithSpan(@"Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\MainPage_d6cd66944958ced0c513e0a04797b51d.cs", 116, 239, 116, 243).WithArguments("TestRepro.MyViewModel", "Name"), + DiagnosticResult.CompilerError("CS1061").WithSpan(@"Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\MainPage_d6cd66944958ced0c513e0a04797b51d.cs", 116, 238, 116, 242).WithArguments("TestRepro.MyViewModel", "Name"), }); await test.RunAsync(); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_NoFuzzyMatching.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_NoFuzzyMatching.cs index e888a87b7b7d..60a16262df0d 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_NoFuzzyMatching.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_NoFuzzyMatching.cs @@ -52,7 +52,7 @@ public MainPage() """ } }, - ReferenceAssemblies = ReferenceAssemblies.Net.Net80Android.AddPackages(ImmutableArray.Create(new PackageIdentity("Uno.WinUI", "5.0.118"))), + ReferenceAssemblies = _Dotnet.CurrentAndroid.WithUnoPackage(), DisableBuildReferences = true, }.AddGeneratedSources(); @@ -105,7 +105,7 @@ public MainPage() """ } }, - ReferenceAssemblies = ReferenceAssemblies.Net.Net80.AddPackages(ImmutableArray.Create(new PackageIdentity("Uno.WinUI", "5.0.118"))), + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage(), DisableBuildReferences = true, }.AddGeneratedSources(); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_Parser.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_Parser.cs index 564de8ae600e..a56e68a54d9b 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_Parser.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_Parser.cs @@ -363,7 +363,7 @@ public MainPage() } }, DisableBuildReferences = true, - ReferenceAssemblies = ReferenceAssemblies.Net.Net80Android.AddPackages([new PackageIdentity("SkiaSharp.Views.Uno.WinUI", "3.0.0-preview.3.1")]), + ReferenceAssemblies = _Dotnet.CurrentAndroid.ReferenceAssemblies.AddPackages([new PackageIdentity("SkiaSharp.Views.Uno.WinUI", "3.0.0-preview.3.1")]), }.AddGeneratedSources(); await test.RunAsync(); @@ -411,7 +411,7 @@ private void Window_Closed(object sender, WindowEventArgs args) { } } }, DisableBuildReferences = true, - ReferenceAssemblies = ReferenceAssemblies.Net.Net80.AddPackages([new PackageIdentity("Uno.WinUI", "5.3.114")]), + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage("5.3.114"), }.AddGeneratedSources(); await test.RunAsync(); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_Xuid.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_Xuid.cs index c29e7cb11926..c3969001f422 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_Xuid.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_Xuid.cs @@ -51,7 +51,7 @@ public XuidGeneratorError() """ } }, - ReferenceAssemblies = ReferenceAssemblies.Net.Net80Android.AddPackages(ImmutableArray.Create(new PackageIdentity("Uno.WinUI", "5.0.118"))), + ReferenceAssemblies = _Dotnet.CurrentAndroid.WithUnoPackage(), DisableBuildReferences = true, }.AddGeneratedSources(); 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 83791a52a433..67d9eff9d45b 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 @@ -85,10 +85,6 @@ private void InitializeComponent() )) ) .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - else - { - _LoadElementSubject.ElementInstance = null; - } __p1.Name = "LoadElement"; _LoadElementSubject.ElementInstance = __p1; __p1.SetBinding( @@ -112,6 +108,10 @@ void _component_1_update(global::Microsoft.UI.Xaml.ElementStub sender) that.Bindings.UpdateResources(); that.Bindings.NotifyXLoad("LoadElement"); } + else + { + _LoadElementSubject.ElementInstance = null; + } } } __p1.MaterializationChanged += _component_1_update; 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 f02d6d5a2f70..f52c7b5f40c9 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 @@ -160,20 +160,6 @@ private void InitializeComponent() )) ) .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler3)(__p1 => { - 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; - } __p1.Name = "outerGrid"; _outerGridSubject.ElementInstance = __p1; __p1.SetBinding( @@ -196,6 +182,20 @@ void _component_1_update(global::Microsoft.UI.Xaml.ElementStub sender) that.Bindings.UpdateResources(); that.Bindings.NotifyXLoad("outerGrid"); } + 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; + } } } __p1.MaterializationChanged += _component_1_update; 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 9db562024d38..728220287c6d 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 @@ -85,10 +85,6 @@ private void InitializeComponent() )) ) .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - else - { - _LoadElementSubject.ElementInstance = null; - } __p1.Name = "LoadElement"; _LoadElementSubject.ElementInstance = __p1; __p1.SetBinding( @@ -112,6 +108,10 @@ void _component_1_update(global::Microsoft.UI.Xaml.ElementStub sender) that.Bindings.UpdateResources(); that.Bindings.NotifyXLoad("LoadElement"); } + else + { + _LoadElementSubject.ElementInstance = null; + } } } __p1.MaterializationChanged += _component_1_update; 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 4443fcc8c5cd..a7f4fb3b7bd0 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Verifiers/CSGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Verifiers/CSGenerator.cs @@ -107,7 +107,7 @@ protected TestBase(XamlFile[] xamlFiles, ResourceFile[] resourceFiles, string te _testFilePath = testFilePath; _testMethodName = testMethodName; - ReferenceAssemblies = ReferenceAssemblies.Net.Net80; + ReferenceAssemblies = _Dotnet.Current.ReferenceAssemblies; #if WRITE_EXPECTED TestBehaviors |= TestBehaviors.SkipGeneratedSourcesCheck; diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/_Dotnet.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/_Dotnet.cs new file mode 100644 index 000000000000..ba203cc28e8e --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/_Dotnet.cs @@ -0,0 +1,17 @@ +using System; +using System.Linq; +using Microsoft.CodeAnalysis.Testing; + +namespace Uno.UI.SourceGenerators.Tests; + +internal record class _Dotnet(string Moniker, ReferenceAssemblies ReferenceAssemblies) +{ + public ReferenceAssemblies WithUnoPackage(string version = "5.0.118") + => ReferenceAssemblies.AddPackages([new PackageIdentity("Uno.WinUI", version)]); + + public static _Dotnet Previous = new("net8.0", ReferenceAssemblies.Net.Net80); + + public static _Dotnet Current = new("net9.0", ReferenceAssemblies.Net.Net90); + + public static _Dotnet CurrentAndroid = new("net9.0-android", ReferenceAssemblies.Net.Net90); +} diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGenerator.cs index e130ada2610b..79d771effa97 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGenerator.cs @@ -38,7 +38,11 @@ public void Execute(GeneratorExecutionContext context) foreach (var tree in generatedTrees) { context.AddSource(tree.Key, tree.Value); - File.WriteAllText(Path.Combine("C:\\Src\\_Gen", tree.Key + ".cs"), tree.Value.ToString()); + try + { + File.WriteAllText(Path.Combine("C:\\Src\\_Gen", tree.Key + ".cs"), tree.Value.ToString()); + } + catch { } } DumpXamlSourceGeneratorState(context, generatedTrees); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 69861634a1c8..ac4a032203ee 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -6423,12 +6423,12 @@ private IEnumerable EnumerateSubElements(IEnumerable Date: Thu, 5 Dec 2024 14:53:01 -0500 Subject: [PATCH 09/30] fix(reg): Fix invalid code gen --- .../XamlGenerator/XamlCodeGeneration.cs | 5 ----- .../XamlGenerator/XamlCodeGenerator.cs | 7 ------- .../XamlGenerator/XamlFileGenerator.cs | 11 +---------- src/Uno.UI.RemoteControl.Host/Extensibility/AddIns.cs | 2 -- 4 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs index cd650828b7a1..cad6ccc5889c 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs @@ -164,12 +164,7 @@ public XamlCodeGeneration(GeneratorExecutionContext context) _isDebug = string.Equals(_configuration, "Debug", StringComparison.OrdinalIgnoreCase); - //Debugger.Launch(); _projectFullPath = context.GetMSBuildPropertyValue("MSBuildProjectFullPath"); - if (Path.GetDirectoryName(_projectFullPath) is null) - { - Debugger.Launch(); - } _projectDirectory = Path.GetDirectoryName(_projectFullPath) ?? throw new InvalidOperationException($"MSBuild property MSBuildProjectFullPath value {_projectFullPath} is not valid"); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGenerator.cs index 79d771effa97..e0de4c87b13f 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGenerator.cs @@ -28,8 +28,6 @@ public void Execute(GeneratorExecutionContext context) // Debugger.Launch(); //} - //Debugger.Launch(); - if (PlatformHelper.IsValidPlatform(context)) { var gen = new XamlCodeGeneration(context); @@ -38,11 +36,6 @@ public void Execute(GeneratorExecutionContext context) foreach (var tree in generatedTrees) { context.AddSource(tree.Key, tree.Value); - try - { - File.WriteAllText(Path.Combine("C:\\Src\\_Gen", tree.Key + ".cs"), tree.Value.ToString()); - } - catch { } } DumpXamlSourceGeneratorState(context, generatedTrees); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index ac4a032203ee..431ef7e57c89 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -3010,11 +3010,6 @@ private void BuildExtendedProperties(IIndentedStringBuilder outerwriter, XamlObj var isFrameworkElement = IsType(objectDefinitionType, Generation.FrameworkElementSymbol.Value); var hasIsParsing = HasIsParsing(objectDefinitionType); - //if (objectDefinitionType is null) - { - //Debugger.Launch(); - } - if (extendedProperties.Any() || hasChildrenWithPhase || isFrameworkElement || hasIsParsing || !objectUid.IsNullOrEmpty()) { string closureName; @@ -3919,10 +3914,6 @@ private XamlLazyApplyBlockIIndentedStringBuilder CreateApplyBlock(IIndentedStrin delegateType = $"{_fileUniqueId}XamlApplyExtensions.XamlApplyHandler{appliedTypeIndex}"; } } - else - { - Debugger.Launch(); - } return new XamlLazyApplyBlockIIndentedStringBuilder( writer, @@ -4227,7 +4218,7 @@ private string BuildXBindEvalFunction(XamlMemberDefinition member, XamlObjectDef var sourceInstance = CurrentResourceOwner is not null ? CurrentResourceOwnerName : "__that"; var applyBindingParameters = _isHotReloadEnabled - ? $"{sourceInstance}, (___b, {sourceInstance})" + ? $"{sourceInstance}, (___b, __that)" : "___b"; if (isInsideDataTemplate) diff --git a/src/Uno.UI.RemoteControl.Host/Extensibility/AddIns.cs b/src/Uno.UI.RemoteControl.Host/Extensibility/AddIns.cs index 0ea2b7de7c06..bfb27344276c 100644 --- a/src/Uno.UI.RemoteControl.Host/Extensibility/AddIns.cs +++ b/src/Uno.UI.RemoteControl.Host/Extensibility/AddIns.cs @@ -16,8 +16,6 @@ public class AddIns public static IImmutableList Discover(string solutionFile) { - Debugger.Launch(); - var tmp = Path.GetTempFileName(); var wd = Path.GetDirectoryName(solutionFile); var command = $"build \"{solutionFile}\" -t:UnoDumpTargetFrameworks \"-p:UnoDumpTargetFrameworksTargetFile={tmp}\" --verbosity quiet"; From 7aefebe2b1762b352723ebbd61d69aff4008da5d Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Dec 2024 15:05:08 -0500 Subject: [PATCH 10/30] chore: Remove dead code --- .../HotReloadWorkspaceProvider.cs | 61 ------------------- .../XamlGenerator/XamlCodeGeneration.cs | 5 -- 2 files changed, 66 deletions(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs index a01401cac704..714162009c16 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdates/HotReloadWorkspaceProvider.cs @@ -269,67 +269,6 @@ public async Task Initialize(CancellationToken ct) ); workspace.TryApplyChanges(currentSolution); - - //if (_sourceFiles.TryGetValue(projectName, out var sourceFiles)) - //{ - // foreach (var (fileName, content) in sourceFiles) - // { - // var documentId = DocumentId.CreateNewId(project.Id); - - // currentSolution = currentSolution.AddDocument( - // documentId, - // fileName, - // CSharpSyntaxTree.ParseText(content, encoding: Encoding.UTF8).GetText(), - // filePath: Path.Combine(_baseWorkFolder, project.Name, fileName) - // ); - // } - //} - - //if (_additionalFiles.TryGetValue(projectName, out var additionalFiles)) - //{ - // foreach (var (fileName, content) in additionalFiles) - // { - // var documentId = DocumentId.CreateNewId(project.Id); - // currentSolution = currentSolution.AddAdditionalDocument( - // documentId, - // fileName, - // CSharpSyntaxTree.ParseText(content, encoding: Encoding.UTF8).GetText(), - // filePath: Path.Combine(_baseWorkFolder, project.Name, fileName)); - // } - - // if (additionalFiles.Any()) - // { - // // Build the analyzer document additional data information - // var analyzerDocumentId = DocumentId.CreateNewId(project.Id); - - // // For now, there is no need to customize these for each test. - // var globalConfigBuilder = new StringBuilder($""" - // is_global = true - // build_property.MSBuildProjectFullPath = C:\Project\{project.Name}.csproj - // build_property.RootNamespace = {project.Name} - // build_property.XamlSourceGeneratorTracingFolder = {_baseWorkFolder} - // build_property.Configuration = {(_isDebugCompilation ? "Debug" : "Release")} - - // """); ; - - // foreach (var (fileName, content) in additionalFiles.Where(k => k.Key.EndsWith(".xaml"))) - // { - // globalConfigBuilder.Append($""" - // [{Path.Combine(_baseWorkFolder, project.Name, fileName).Replace("\\", "/")}] - // build_metadata.AdditionalFiles.SourceItemGroup = Page - // """); - // } - - // currentSolution = currentSolution.AddAnalyzerConfigDocument( - // analyzerDocumentId, - // name: ".globalconfig", - // filePath: "/.globalconfig", - // text: SourceText.From(globalConfigBuilder.ToString()) - // ); ; - // } - //} - - //workspace.TryApplyChanges(currentSolution); } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs index cad6ccc5889c..b8fa11ba46e4 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs @@ -680,11 +680,6 @@ private SourceText GenerateGlobalResources(IEnumerable files writer.AppendLineIndented("/// Contains all the static resources defined for the application"); writer.AppendLineIndented("/// "); - if (_isDebug) - { - //writer.AppendLineIndented("[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate]"); - } - using (writer.BlockInvariant("public sealed partial class GlobalStaticResources")) { writer.AppendLineIndented("static bool _initialized;"); From 574d4d95785751330a9b3951a426dfca483b115f Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Dec 2024 15:50:31 -0500 Subject: [PATCH 11/30] test(hr): Fix rebase --- .../Given_LazyLoading.cs | 4 +- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 59 ++++---- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 129 +++++++++--------- 3 files changed, 103 insertions(+), 89 deletions(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_LazyLoading.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_LazyLoading.cs index 2d8e360ad10c..c0fc65dcc9f5 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_LazyLoading.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_LazyLoading.cs @@ -55,7 +55,7 @@ public MainPage() """ } }, - ReferenceAssemblies = ReferenceAssemblies.Net.Net70.AddPackages(ImmutableArray.Create(new PackageIdentity("Uno.WinUI", "5.0.118"))), + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage(), DisableBuildReferences = true, }.AddGeneratedSources(); @@ -114,7 +114,7 @@ public string InnerText """ } }, - ReferenceAssemblies = ReferenceAssemblies.Net.Net70.AddPackages(ImmutableArray.Create(new PackageIdentity("Uno.WinUI", "5.0.118"))), + ReferenceAssemblies = _Dotnet.Current.WithUnoPackage(), DisableBuildReferences = true, }.AddGeneratedSources(); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WDLSNVS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WDLSNVS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index 0013d351ffbf..4dbc989946c1 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WDLSNVS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WDLSNVS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -60,10 +60,10 @@ private void InitializeComponent() Text = "Immediate content", // Source 0\MainPage.xaml (Line 10:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , @@ -80,52 +80,52 @@ private void InitializeComponent() Text = "Lazy Content", // Source 0\MainPage.xaml (Line 12:5) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c2 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - __nameScope.RegisterName("LazyLoadedBorder", c2); - __that.LazyLoadedBorder = c2; - // DeferLoadStrategy Lazy - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c2, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c2.CreationComplete(); + __nameScope.RegisterName("LazyLoadedBorder", __p1); + __that.LazyLoadedBorder = __p1; + // DeferLoadStrategy Lazy + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) - ) .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(c3 => + ) .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => { - c3.Name = "LazyLoadedBorder"; - _LazyLoadedBorderSubject.ElementInstance = c3; + __p1.Name = "LazyLoadedBorder"; + _LazyLoadedBorderSubject.ElementInstance = __p1; } )) , } } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler3)(c4 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler3)(__p1 => { - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c4, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c4.CreationComplete(); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; this - .GenericApply(((c5) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler4)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c5.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c6) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler4)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c6, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c6.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -179,5 +179,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler4(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler4 handler) + { + handler(instance); + return instance; + } } } 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 d62b73cfb196..b75b3a0cb20f 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 @@ -61,89 +61,89 @@ private void InitializeComponent() Name = "innerTextBlock", // Source 0\MainPage.xaml (Line 10:4) } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(c0 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler0)(__p1 => { - /* _isTopLevelDictionary:False */ - __that._component_0 = c0; - __nameScope.RegisterName("innerTextBlock", c0); - __that.innerTextBlock = c0; - // FieldModifier public - c0.SetBinding( - global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, - new Microsoft.UI.Xaml.Data.Binding() - { - Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, - } - .BindingApply(___b => /*defaultBindModeOneTime InnerText*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? (TryGetInstance_xBind_1(___tctx, out var bindResult1) ? (true, bindResult1) : (false, default)) : (false, default), null , new [] {"InnerText"})) - ); - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c0, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c0.CreationComplete(); + /* _isTopLevelDictionary:False */ + __that._component_0 = __p1; + __nameScope.RegisterName("innerTextBlock", __p1); + __that.innerTextBlock = __p1; + // FieldModifier public + __p1.SetBinding( + global::Microsoft.UI.Xaml.Controls.TextBlock.TextProperty, + new Microsoft.UI.Xaml.Data.Binding() + { + Mode = global::Microsoft.UI.Xaml.Data.BindingMode.OneWay, + } + .BindingApply(___b => /*defaultBindModeOneTime InnerText*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, __that, ___ctx => ___ctx is global::TestRepro.MainPage ___tctx ? (TryGetInstance_xBind_1(___tctx, out var bindResult1) ? (true, bindResult1) : (false, default)) : (false, default), null , new [] {"InnerText"})) + ); + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) , } - .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(c1 => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler1)(__p1 => { - __nameScope.RegisterName("topLevelContent", c1); - __that.topLevelContent = c1; - // FieldModifier public - // Load false - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c1.CreationComplete(); + __nameScope.RegisterName("topLevelContent", __p1); + __that.topLevelContent = __p1; + // FieldModifier public + // Load false + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) - ) .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(c2 => + ) .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler2)(__p1 => + { + __p1.Name = "topLevelContent"; + _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) { - c2.Name = "topLevelContent"; - _topLevelContentSubject.ElementInstance = c2; - __that._component_1 = c2; - 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) { - if (_component_1_update_That.Target is global::TestRepro.MainPage that) + if (sender.IsMaterialized) { - if (sender.IsMaterialized) - { - that.Bindings.UpdateResources(); - that.Bindings.NotifyXLoad("topLevelContent"); - } - else - { - _topLevelContentSubject.ElementInstance = null; - _innerTextBlockSubject.ElementInstance = null; - _innerTextBlockSubject.ElementInstance = null; - } + that.Bindings.UpdateResources(); + that.Bindings.NotifyXLoad("topLevelContent"); } - } - c2.MaterializationChanged += _component_1_update; - var owner = this; - void _component_1_materializing(object sender) - { - if (_component_1_update_That.Target is global::TestRepro.MainPage that) + else { - that._component_0.ApplyXBind(); - that._component_0.UpdateResourceBindings(); + _topLevelContentSubject.ElementInstance = null; + _innerTextBlockSubject.ElementInstance = null; + _innerTextBlockSubject.ElementInstance = null; } } - c2.Materializing += _component_1_materializing; + } + __p1.MaterializationChanged += _component_1_update; + var owner = this; + void _component_1_materializing(object sender) + { + if (_component_1_update_That.Target is global::TestRepro.MainPage that) + { + that._component_0.ApplyXBind(); + that._component_0.UpdateResourceBindings(); + } + } + __p1.Materializing += _component_1_materializing; } )) ; this - .GenericApply(((c3) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler3)(__p1 => { - // Source 0\MainPage.xaml (Line 1:2) - - // WARNING Property c3.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator + // Source 0\MainPage.xaml (Line 1:2) + + // WARNING Property __p1.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator } )) - .GenericApply(((c4) => + .MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply((MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions.XamlApplyHandler3)(__p1 => { - // Class TestRepro.MainPage - global::Uno.UI.FrameworkElementHelper.SetBaseUri(c4, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); - c4.CreationComplete(); + // Class TestRepro.MainPage + global::Uno.UI.FrameworkElementHelper.SetBaseUri(__p1, __baseUri_MainPage_d6cd66944958ced0c513e0a04797b51d); + __p1.CreationComplete(); } )) ; @@ -182,7 +182,7 @@ void _component_1_materializing(object sender) _topLevelContentSubject.ElementInstance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_0_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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 @@ -194,7 +194,7 @@ void _component_1_materializing(object sender) _component_0_Holder.Instance = value; } } - private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: false); + private global::Microsoft.UI.Xaml.Markup.ComponentHolder _component_1_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: false); private global::Microsoft.UI.Xaml.ElementStub _component_1 { get @@ -284,5 +284,12 @@ static class MainPage_d6cd66944958ced0c513e0a04797b51dXamlApplyExtensions handler(instance); return instance; } + public delegate void XamlApplyHandler3(global::Microsoft.UI.Xaml.Controls.Page instance); + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static global::Microsoft.UI.Xaml.Controls.Page MainPage_d6cd66944958ced0c513e0a04797b51d_XamlApply(this global::Microsoft.UI.Xaml.Controls.Page instance, XamlApplyHandler3 handler) + { + handler(instance); + return instance; + } } } From 361d014e718b7a11718fc19c9dcf4871744f36ac Mon Sep 17 00:00:00 2001 From: David Date: Fri, 6 Dec 2024 11:49:25 -0500 Subject: [PATCH 12/30] fix: Fix invalid code gen --- ...deGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 2 +- ...deGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 2 +- ...MyResourceDictionary_92716e07ff456818f6d4125e055d4d57.cs | 6 +++--- .../XamlGenerator/XamlFileGenerator.cs | 2 +- src/Uno.UI/Helpers/MarkupHelper.cs | 4 ++-- 5 files changed, 8 insertions(+), 8 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 196730c23d18..62b4f5099eb0 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 @@ -107,7 +107,7 @@ private void InitializeComponent() { // var __that = (MainPage)__ResourceOwner_1; return - new global::Microsoft.UI.Xaml.DataTemplate(this, (__owner) => new _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0().Build(__owner) + new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0().Build(__owner) ) .GenericApply(__that, __nameScope, (ApplyMethod_6 )) ; } 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 ffc70c3e580c..a08bcc1d47a7 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 @@ -107,7 +107,7 @@ private void InitializeComponent() { // var __that = (MainPage)__ResourceOwner_1; return - new global::Microsoft.UI.Xaml.DataTemplate(this, (__owner) => new _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0().Build(__owner) + new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0().Build(__owner) ) .GenericApply(__that, __nameScope, (ApplyMethod_6 )) ; } 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 19266e845f3a..d14455ff77d5 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 @@ -49,7 +49,7 @@ public void InitializeComponent() { // var __that = (MyResourceDictionary)__ResourceOwner_1; return - new global::Microsoft.UI.Xaml.DataTemplate(this, (__owner) => new _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionarySC0().Build(__owner) + new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionarySC0().Build(__owner) ) ; } ) @@ -194,7 +194,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(this, (__owner) => new __Resources._MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC1().Build(__owner) + new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new __Resources._MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC1().Build(__owner) ) ; private global::Microsoft.UI.Xaml.ResourceDictionary _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_ResourceDictionary; @@ -216,7 +216,7 @@ private object Get_1(object __ResourceOwner_1) => { // var __that = (MyResourceDictionaryRD)__ResourceOwner_1; return - new global::Microsoft.UI.Xaml.DataTemplate(this, (__owner) => new __Resources._MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC2().Build(__owner) + new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new __Resources._MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC2().Build(__owner) ) ; } ) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 431ef7e57c89..2ba4580c05cb 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -6846,7 +6846,7 @@ private string? CurrentResourceOwner => _resourceOwner != 0 ? $"__ResourceOwner_{_resourceOwner.ToString(CultureInfo.InvariantCulture)}" : null; private string CurrentResourceOwnerName - => /*CurrentResourceOwner ??*/ "this"; + => CurrentResourceOwner ?? "this"; public bool HasImplicitViewPinning => Generation.IOSViewSymbol.Value is not null || Generation.AppKitViewSymbol.Value is not null; diff --git a/src/Uno.UI/Helpers/MarkupHelper.cs b/src/Uno.UI/Helpers/MarkupHelper.cs index 4f3e060edd0e..4b7a7a3b393c 100644 --- a/src/Uno.UI/Helpers/MarkupHelper.cs +++ b/src/Uno.UI/Helpers/MarkupHelper.cs @@ -80,8 +80,8 @@ public static void SetVisualTransitionLazy(VisualTransition target, Action build target.FromLegacyTemplate = TemplatedParentScope.GetCurrentTemplate() is { IsLegacyTemplate: true }; } - public static IXamlServiceProvider CreateParserContext(object? target, Type propertyDeclaringType, string propertyName, Type propertyType) => - CreateParserContext(target, propertyDeclaringType, propertyName, propertyType, null); + public static IXamlServiceProvider CreateParserContext(object? target, Type propertyDeclaringType, string propertyName, Type propertyType) + => CreateParserContext(target, propertyDeclaringType, propertyName, propertyType, null); public static IXamlServiceProvider CreateParserContext(object? target, Type propertyDeclaringType, string propertyName, Type propertyType, object? rootObject) => new XamlServiceProviderContext From 79ed849aedf9d5a637d991de378fe150df91f8ef Mon Sep 17 00:00:00 2001 From: David Date: Mon, 9 Dec 2024 10:52:46 -0500 Subject: [PATCH 13/30] fix: Fix x:Bind not applied properly --- ...deGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 2 +- ...deGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 2 +- ...MyResourceDictionary_92716e07ff456818f6d4125e055d4d57.cs | 6 +++--- ...mentName_In_Template_66bf0a54f1801c397a6fa4930a237eca.cs | 2 +- .../XamlGenerator/XamlFileGenerator.cs | 2 +- 5 files changed, 7 insertions(+), 7 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 62b4f5099eb0..0aa5b3fecebb 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 @@ -369,7 +369,7 @@ public _View Build(object __ResourceOwner_1) } .GenericApply(__that, __nameScope, (ApplyMethod_19 )) ; - if (__that.__rootInstance is FrameworkElement __fe) + if (__rootInstance is FrameworkElement __fe) { var owner = this; __fe.Loading += delegate 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 a08bcc1d47a7..1e1d2f7ee5d7 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 @@ -219,7 +219,7 @@ public _View Build(object __ResourceOwner_1) } .GenericApply(__that, __nameScope, (ApplyMethod_12 )) ; - if (__that.__rootInstance is FrameworkElement __fe) + if (__rootInstance is FrameworkElement __fe) { var owner = this; __fe.Loading += delegate 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 d14455ff77d5..53e898d96a60 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 @@ -100,7 +100,7 @@ public _View Build(object __ResourceOwner_1) } )) ; - if (__that.__rootInstance is FrameworkElement __fe) + if (__rootInstance is FrameworkElement __fe) { var owner = this; __fe.Loading += delegate @@ -282,7 +282,7 @@ public _View Build(object __ResourceOwner_1) } )) ; - if (__that.__rootInstance is FrameworkElement __fe) + if (__rootInstance is FrameworkElement __fe) { var owner = this; __fe.Loading += delegate @@ -378,7 +378,7 @@ public _View Build(object __ResourceOwner_1) } )) ; - if (__that.__rootInstance is FrameworkElement __fe) + if (__rootInstance is FrameworkElement __fe) { var owner = this; __fe.Loading += delegate 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 e5468f938cf1..d0a13ccd4a8f 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 @@ -159,7 +159,7 @@ public _View Build(object __ResourceOwner_1) } )) ; - if (__that.__rootInstance is FrameworkElement __fe) + if (__rootInstance is FrameworkElement __fe) { var owner = this; __fe.Loading += delegate diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 2ba4580c05cb..e3caf3339369 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -1046,7 +1046,7 @@ private void BuildCompiledBindingsInitializerForTemplate(IIndentedStringBuilder if (hasResourceExtensions) { - using (writer.BlockInvariant($"if (__that.__rootInstance is FrameworkElement __fe) ")) + using (writer.BlockInvariant($"if (__rootInstance is FrameworkElement __fe) ")) { writer.AppendLineIndented($"var owner = this;"); From 9613875886aa59fb6c3e2ebca1f30190aa2e439f Mon Sep 17 00:00:00 2001 From: David Date: Mon, 9 Dec 2024 17:04:11 -0500 Subject: [PATCH 14/30] fix(hr): Fix invalid code gen for custom markup extensions --- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 7 ++---- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 5 +--- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 2 -- ...ionary_92716e07ff456818f6d4125e055d4d57.cs | 2 -- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 1 - .../XamlGenerator/XamlFileGenerator.cs | 23 +++++++++---------- ...amlLazyApplyBlockIIndentedStringBuilder.cs | 11 +++++---- 7 files changed, 20 insertions(+), 31 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 0aa5b3fecebb..6bc913cfa5aa 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 @@ -51,7 +51,6 @@ private void InitializeComponent() ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { - // var __that = (MainPage)__ResourceOwner_1; return new global::Microsoft.UI.Xaml.Style { @@ -78,7 +77,6 @@ private void InitializeComponent() ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { - // var __that = (MainPage)__ResourceOwner_1; return new global::Microsoft.UI.Xaml.Style { @@ -105,7 +103,6 @@ private void InitializeComponent() ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { - // var __that = (MainPage)__ResourceOwner_1; return new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0().Build(__owner) ) .GenericApply(__that, __nameScope, (ApplyMethod_6 )) @@ -151,12 +148,12 @@ private void ApplyMethod_4(global::Microsoft.UI.Xaml.Style __p1, MainPage __that global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__p1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L10:6"); } - private void ApplyMethod_6(global::System.Object /* oups */ __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + private void ApplyMethod_6(global::System.Object __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) { global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__p1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L13:6"); } - private void ApplyMethod_7(global::System.Object /* oups */ __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + private void ApplyMethod_7(global::System.Object __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) { global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__p1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L42:8"); } 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 1e1d2f7ee5d7..68d67fb070c5 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 @@ -51,7 +51,6 @@ private void InitializeComponent() ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { - // var __that = (MainPage)__ResourceOwner_1; return new global::Microsoft.UI.Xaml.Style { @@ -78,7 +77,6 @@ private void InitializeComponent() ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { - // var __that = (MainPage)__ResourceOwner_1; return new global::Microsoft.UI.Xaml.Style { @@ -105,7 +103,6 @@ private void InitializeComponent() ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { - // var __that = (MainPage)__ResourceOwner_1; return new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0().Build(__owner) ) .GenericApply(__that, __nameScope, (ApplyMethod_6 )) @@ -147,7 +144,7 @@ private void ApplyMethod_4(global::Microsoft.UI.Xaml.Style __p1, MainPage __that global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__p1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L10:6"); } - private void ApplyMethod_6(global::System.Object /* oups */ __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) + private void ApplyMethod_6(global::System.Object __p1, MainPage __that, global::Microsoft.UI.Xaml.NameScope __nameScope) { global::Uno.UI.Helpers.MarkupHelper.SetElementProperty(__p1, "OriginalSourceLocation", "file:///C:/Project/0/MainPage.xaml#L13:6"); } 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 492f1a139bb5..2f9dba5656e8 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 @@ -51,7 +51,6 @@ private void InitializeComponent() ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { - // var __that = (MainPage)__ResourceOwner_1; return new global::Microsoft.UI.Xaml.Style { @@ -78,7 +77,6 @@ private void InitializeComponent() ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { - // var __that = (MainPage)__ResourceOwner_1; return new global::Microsoft.UI.Xaml.Style { 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 53e898d96a60..69fa763557c8 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 @@ -47,7 +47,6 @@ public void InitializeComponent() ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { - // var __that = (MyResourceDictionary)__ResourceOwner_1; return new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMyResourceDictionarySC0().Build(__owner) ) ; @@ -214,7 +213,6 @@ private object Get_1(object __ResourceOwner_1) => ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { - // var __that = (MyResourceDictionaryRD)__ResourceOwner_1; return new global::Microsoft.UI.Xaml.DataTemplate(__ResourceOwner_1, (__owner) => new __Resources._MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionaryRDSC2().Build(__owner) ) ; diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs index a9b5584e19a2..142a79638ad3 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/WNS/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs @@ -51,7 +51,6 @@ private void InitializeComponent() ] = new global::Uno.UI.Xaml.WeakResourceInitializer(this, __ResourceOwner_1 => { - // var __that = (MainPage)__ResourceOwner_1; return new global::Microsoft.UI.Xaml.Style { diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index e3caf3339369..e1d5d4dcf467 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -2744,8 +2744,6 @@ private IDisposable BuildLazyResourceInitializer(IIndentedStringBuilder writer) var bodyDisposable = writer.BlockInvariant($"new global::Uno.UI.Xaml.WeakResourceInitializer({currentScope}, {CurrentResourceOwner} => "); - writer.AppendLineInvariantIndented($"// var __that = ({CurrentScope.ClassName}){CurrentResourceOwner};"); - writer.AppendLineInvariantIndented($"return "); var indent = writer.Indent(); @@ -2997,8 +2995,6 @@ private void TryExtractAutomationId(XamlMemberDefinition member, string[] target private void BuildExtendedProperties(IIndentedStringBuilder outerwriter, XamlObjectDefinition objectDefinition, bool useGenericApply = false) { - useGenericApply = true; - _generatorContext.CancellationToken.ThrowIfCancellationRequested(); TryAnnotateWithGeneratorSource(outerwriter); @@ -3117,7 +3113,7 @@ private void BuildExtendedProperties(IIndentedStringBuilder outerwriter, XamlObj } else { - BuildCustomMarkupExtensionPropertyValue(writer, member, closureName); + BuildCustomMarkupExtensionPropertyValue(writer, member, closureName, $"(({CurrentScope.ClassName})__that)"); } } else if (member.Objects.Count > 0) @@ -3479,9 +3475,9 @@ private void BuildExtendedProperties(IIndentedStringBuilder outerwriter, XamlObj } // Local function used to build a property/value for any custom MarkupExtensions - void BuildCustomMarkupExtensionPropertyValue(IIndentedStringBuilder writer, XamlMemberDefinition member, string closure) + void BuildCustomMarkupExtensionPropertyValue(IIndentedStringBuilder writer, XamlMemberDefinition member, string closure, string resourceOwner) { - var propertyValue = GetCustomMarkupExtensionValue(member, closure); + var propertyValue = GetCustomMarkupExtensionValue(member, closure, resourceOwner); if (!propertyValue.IsNullOrEmpty()) { writer.AppendIndented($"{closure}.{member.Member.Name} = {propertyValue};\r\n"); @@ -3922,7 +3918,7 @@ private XamlLazyApplyBlockIIndentedStringBuilder CreateApplyBlock(IIndentedStrin delegateType, !_isTopLevelDictionary, RegisterApplyMethod, - appliedType?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) ?? "global::System.Object /* oups */", + appliedType?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) ?? "global::System.Object", CurrentScope.ClassName, $"ApplyMethod_{(_applyIndex++).ToString(CultureInfo.InvariantCulture)}"); } @@ -4577,7 +4573,7 @@ private string BuildMemberPropertyValue(XamlMemberDefinition m, bool isTemplateB } } - private string GetCustomMarkupExtensionValue(XamlMemberDefinition member, string? target = null) + private string GetCustomMarkupExtensionValue(XamlMemberDefinition member, string? target = null, string? resourceOwner = null) { // Get the type of the custom markup extension var markup = member @@ -4623,9 +4619,12 @@ private string GetCustomMarkupExtensionValue(XamlMemberDefinition member, string .JoinBy(", "); var markupInitializer = !properties.IsNullOrEmpty() ? $" {{ {properties} }}" : "()"; - var thatCurrentResourceOwnerName = CurrentResourceOwnerName == "this" - ? CurrentResourceOwnerName - : "__that." + CurrentResourceOwnerName; + var thatCurrentResourceOwnerName = resourceOwner switch + { + not null => resourceOwner, + null when CurrentResourceOwner is { } owner => "__that." + owner, + _ => "this" + }; // Build the parser context for ProvideValue(IXamlServiceProvider) var providerDetails = new string[] diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs index 1e900a4cfe6b..567fc42a3624 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlLazyApplyBlockIIndentedStringBuilder.cs @@ -25,17 +25,18 @@ internal class XamlLazyApplyBlockIIndentedStringBuilder : IIndentedStringBuilder private readonly bool _exposeContext; private readonly Action _onRegisterApplyMethodBody; private readonly string? _exposeContextMethod; - private readonly string? _appliedType; - private readonly string? _topLevelType; + private readonly string _appliedType; + private readonly string _topLevelType; public XamlLazyApplyBlockIIndentedStringBuilder( IIndentedStringBuilder source, - string closureName, string? applyPrefix, + string closureName, + string? applyPrefix, string? delegateType, bool exposeContext, Action onRegisterApplyMethodBody, - string? appliedType, - string? topLevelType, + string appliedType, + string topLevelType, string? exposeContextMethod, IDisposable? parentDisposable = null) { From 55822b38aaff449da8dd3aee2fefc43305bddeb9 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 9 Dec 2024 22:41:53 -0500 Subject: [PATCH 15/30] fix(hr): Fix invalid gen for top level dic --- .../XamlGenerator/XamlFileGenerator.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index e1d5d4dcf467..3476a94be03e 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -3113,7 +3113,7 @@ private void BuildExtendedProperties(IIndentedStringBuilder outerwriter, XamlObj } else { - BuildCustomMarkupExtensionPropertyValue(writer, member, closureName, $"(({CurrentScope.ClassName})__that)"); + BuildCustomMarkupExtensionPropertyValue(writer, member, closureName, _isTopLevelDictionary ? null : $"(({CurrentScope.ClassName})__that)"); } } else if (member.Objects.Count > 0) @@ -3475,7 +3475,7 @@ private void BuildExtendedProperties(IIndentedStringBuilder outerwriter, XamlObj } // Local function used to build a property/value for any custom MarkupExtensions - void BuildCustomMarkupExtensionPropertyValue(IIndentedStringBuilder writer, XamlMemberDefinition member, string closure, string resourceOwner) + void BuildCustomMarkupExtensionPropertyValue(IIndentedStringBuilder writer, XamlMemberDefinition member, string closure, string? resourceOwner) { var propertyValue = GetCustomMarkupExtensionValue(member, closure, resourceOwner); if (!propertyValue.IsNullOrEmpty()) From 69b6aa106e591ff2243d24cc1dc4e57204489682 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 10 Dec 2024 08:13:23 -0500 Subject: [PATCH 16/30] fix(reg): Fix _rootInstance field is always null --- ...ator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 8 ++------ ...ator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 4 +--- ...rceDictionary_92716e07ff456818f6d4125e055d4d57.cs | 12 +++--------- ...ator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 4 +--- ...e_In_Template_66bf0a54f1801c397a6fa4930a237eca.cs | 4 +--- .../XamlGenerator/XamlFileGenerator.cs | 4 +--- 6 files changed, 9 insertions(+), 27 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 6bc913cfa5aa..34f30d3c9fe0 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 @@ -336,11 +336,9 @@ private class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 _View __rootInstance = null; public _View Build(object __ResourceOwner_1) { - _View __rootInstance = null; var __that = this; this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = __rootInstance; - __rootInstance = + this.__rootInstance = new global::Microsoft.UI.Xaml.Controls.StackPanel { IsParsing = true, @@ -441,11 +439,9 @@ private class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC1 _View __rootInstance = null; public _View Build(object __ResourceOwner_1) { - _View __rootInstance = null; var __that = this; this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = __rootInstance; - __rootInstance = + this.__rootInstance = new global::Microsoft.UI.Xaml.Controls.TextBlock { IsParsing = 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 68d67fb070c5..92c8d4125bb1 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 @@ -186,11 +186,9 @@ private class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 _View __rootInstance = null; public _View Build(object __ResourceOwner_1) { - _View __rootInstance = null; var __that = this; this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = __rootInstance; - __rootInstance = + this.__rootInstance = new global::Microsoft.UI.Xaml.Controls.StackPanel { IsParsing = true, 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 69fa763557c8..bbcd4288b325 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 @@ -69,11 +69,9 @@ private class _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_TestReproMy _View __rootInstance = null; public _View Build(object __ResourceOwner_1) { - _View __rootInstance = null; var __that = this; this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = __rootInstance; - __rootInstance = + this.__rootInstance = new global::Microsoft.UI.Xaml.Controls.TextBlock { IsParsing = true, @@ -250,11 +248,9 @@ class _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionar _View __rootInstance = null; public _View Build(object __ResourceOwner_1) { - _View __rootInstance = null; var __that = this; this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = __rootInstance; - __rootInstance = + this.__rootInstance = new global::Microsoft.UI.Xaml.Controls.TextBlock { IsParsing = true, @@ -346,11 +342,9 @@ class _MyResourceDictionary_92716e07ff456818f6d4125e055d4d57_MyResourceDictionar _View __rootInstance = null; public _View Build(object __ResourceOwner_1) { - _View __rootInstance = null; var __that = this; this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = __rootInstance; - __rootInstance = + this.__rootInstance = new global::Microsoft.UI.Xaml.Controls.TextBlock { IsParsing = true, 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 f52c7b5f40c9..81834e675e7c 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 @@ -335,11 +335,9 @@ private class _MainPage_d6cd66944958ced0c513e0a04797b51d_TestReproMainPageSC0 _View __rootInstance = null; public _View Build(object __ResourceOwner_1) { - _View __rootInstance = null; var __that = this; this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = __rootInstance; - __rootInstance = + this.__rootInstance = new global::Microsoft.UI.Xaml.Controls.Grid { IsParsing = true, 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 d0a13ccd4a8f..319f3672239f 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 @@ -129,11 +129,9 @@ private class _Binding_ElementName_In_Template_66bf0a54f1801c397a6fa4930a237eca_ _View __rootInstance = null; public _View Build(object __ResourceOwner_1) { - _View __rootInstance = null; var __that = this; this.__ResourceOwner_1 = __ResourceOwner_1; - this.__rootInstance = __rootInstance; - __rootInstance = + this.__rootInstance = new global::Microsoft.UI.Xaml.Controls.TextBlock { IsParsing = true, diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 3476a94be03e..5659bd726acc 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -922,11 +922,9 @@ private void BuildChildSubclasses(IIndentedStringBuilder writer, bool isTopLevel using (writer.BlockInvariant($"public {kvp.Value.ReturnType} Build(object {CurrentResourceOwner})")) #endif { - writer.AppendLineIndented($"{kvp.Value.ReturnType} __rootInstance = null;"); writer.AppendLineIndented($"var __that = this;"); writer.AppendLineIndented($"this.{CurrentResourceOwner} = {CurrentResourceOwner};"); - writer.AppendLineIndented($"this.__rootInstance = __rootInstance;"); - writer.AppendLineIndented("__rootInstance = "); + writer.AppendLineIndented("this.__rootInstance = "); // Is never considered in Global Resources because class encapsulation BuildChild(writer, contentOwner, contentOwner.Objects.First()); From beb33aa80452164b0f10db3cf403850fc392d5f8 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 10 Dec 2024 08:22:10 -0500 Subject: [PATCH 17/30] fix(hr): Avoid rude edit --- ...deGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 6 +++--- ...deGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 4 ++-- ...deGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 2 +- ...deGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 2 +- .../XamlGenerator/XamlFileGenerator.cs | 4 ++-- 5 files changed, 9 insertions(+), 9 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 34f30d3c9fe0..a57796277fa3 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 @@ -384,7 +384,7 @@ public _View Build(object __ResourceOwner_1) } 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.Markup.ComponentHolder _component_0_Holder { get; set; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Button _component_0 { get @@ -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 = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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.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 = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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.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 92c8d4125bb1..07029301e0c7 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 @@ -234,7 +234,7 @@ public _View Build(object __ResourceOwner_1) } 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.Markup.ComponentHolder _component_0_Holder { get; set; } = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); private global::Microsoft.UI.Xaml.Controls.Button _component_0 { get @@ -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 = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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.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 2f9dba5656e8..4a56a1cc951e 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,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 = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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.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 1011f6c8dba4..419110c4f838 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,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 = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: true); + 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.Controls.Page _component_0 { get diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 5659bd726acc..683718cd9927 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -1108,8 +1108,8 @@ private void BuildComponentFields(IIndentedStringBuilder writer) var typeName = GetType(current.XamlObject.Type).GetFullyQualifiedTypeIncludingGlobal(); var isWeak = current.IsWeakReference ? "true" : "false"; - - writer.AppendLineIndented($"private global::Microsoft.UI.Xaml.Markup.ComponentHolder {componentName}_Holder = new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: {isWeak});"); + var accessors = _isHotReloadEnabled ? "{ get; set; } " : ""; // 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}")) { From 4867046067931da2c63e92d1bc816ce611270c16 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 10 Dec 2024 10:41:44 -0500 Subject: [PATCH 18/30] fix(hr): Use properties for subjects --- ...ator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | 6 +++--- .../XamlGenerator/XamlFileGenerator.cs | 12 +++++++----- 2 files changed, 10 insertions(+), 8 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 a57796277fa3..ce510446357b 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 @@ -286,7 +286,7 @@ private void ApplyMethod_10(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPa __p1.CreationComplete(); } - private global::Microsoft.UI.Xaml.Data.ElementNameSubject _TheListViewSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); + private global::Microsoft.UI.Xaml.Data.ElementNameSubject _TheListViewSubject { get; set; } = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); private global::Microsoft.UI.Xaml.Controls.ListView TheListView { get @@ -298,7 +298,7 @@ private void ApplyMethod_10(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPa _TheListViewSubject.ElementInstance = value; } } - private global::Microsoft.UI.Xaml.Data.ElementNameSubject _WideStateSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); + private global::Microsoft.UI.Xaml.Data.ElementNameSubject _WideStateSubject { get; set; } = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); private global::Microsoft.UI.Xaml.VisualState WideState { get @@ -310,7 +310,7 @@ private void ApplyMethod_10(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPa _WideStateSubject.ElementInstance = value; } } - private global::Microsoft.UI.Xaml.Data.ElementNameSubject _NarrowStateSubject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); + private global::Microsoft.UI.Xaml.Data.ElementNameSubject _NarrowStateSubject { get; set; } = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(); private global::Microsoft.UI.Xaml.VisualState NarrowState { get diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 683718cd9927..11cc825c0a94 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -828,6 +828,8 @@ private void BuildXBindTryGetDeclarations(IIndentedStringBuilder 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. + TryAnnotateWithGeneratorSource(writer); foreach (var backingFieldDefinition in CurrentScope.BackingFields.Distinct()) { @@ -838,7 +840,7 @@ private void BuildBackingFields(IIndentedStringBuilder writer) CurrentScope.ReferencedElementNames.Remove(sanitizedFieldName); } - writer.AppendLineIndented($"private global::Microsoft.UI.Xaml.Data.ElementNameSubject _{sanitizedFieldName}Subject = new global::Microsoft.UI.Xaml.Data.ElementNameSubject();"); + writer.AppendLineIndented($"private global::Microsoft.UI.Xaml.Data.ElementNameSubject _{sanitizedFieldName}Subject{accessors} = new global::Microsoft.UI.Xaml.Data.ElementNameSubject();"); using (writer.BlockInvariant($"{FormatAccessibility(backingFieldDefinition.Accessibility)} {backingFieldDefinition.GlobalizedTypeName} {sanitizedFieldName}")) @@ -858,13 +860,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};"); + writer.AppendLineIndented($"{FormatAccessibility(xBindEventHandler.Accessibility)} {xBindEventHandler.GlobalizedTypeName} {xBindEventHandler.Name}{accessors ?? ";"}"); } 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 = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(isRuntimeBound: true, name: \"{remainingReference}\");"); + writer.AppendLineIndented($"private global::Microsoft.UI.Xaml.Data.ElementNameSubject _{remainingReference}Subject{accessors} = new global::Microsoft.UI.Xaml.Data.ElementNameSubject(isRuntimeBound: true, name: \"{remainingReference}\");"); } } @@ -1108,8 +1110,8 @@ 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. - writer.AppendLineIndented($"private global::Microsoft.UI.Xaml.Markup.ComponentHolder {componentName}_Holder {accessors}= new global::Microsoft.UI.Xaml.Markup.ComponentHolder(isWeak: {isWeak});"); + var accessors = _isHotReloadEnabled ? " { get; set; }" : ""; // 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}")) { From 4ea7bce37189b31e5a468a506cd1e19a887e3a22 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 10 Dec 2024 11:30:07 -0500 Subject: [PATCH 19/30] fix(hr): Always generate the Bindings class when HR is enabled --- ...inPage_d6cd66944958ced0c513e0a04797b51d.cs | 42 +++++++++++++++++++ .../XamlGenerator/XamlFileGenerator.cs | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) 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 2105fd316c32..aea9e14cc033 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,5 +104,47 @@ private void ApplyMethod_3(global::Microsoft.UI.Xaml.Controls.Page __p1, MainPag __p1.CreationComplete(); } + private interface IMainPage_Bindings + { + void Initialize(); + void Update(); + void UpdateResources(); + void StopTracking(); + void NotifyXLoad(string name); + } + #pragma warning disable 0169 // Suppress unused field warning in case Bindings is not used. + private IMainPage_Bindings Bindings; + #pragma warning restore 0169 + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private class MainPage_Bindings : IMainPage_Bindings + { + #if UNO_HAS_UIELEMENT_IMPLICIT_PINNING + private global::System.WeakReference _ownerReference; + private global::TestRepro.MainPage Owner { get => (global::TestRepro.MainPage)_ownerReference?.Target; set => _ownerReference = new global::System.WeakReference(value); } + #else + private global::TestRepro.MainPage Owner { get; set; } + #endif + public MainPage_Bindings(global::TestRepro.MainPage owner) + { + Owner = owner; + } + void IMainPage_Bindings.NotifyXLoad(string name) + { + } + void IMainPage_Bindings.Initialize() + { + } + void IMainPage_Bindings.Update() + { + var owner = Owner; + } + void IMainPage_Bindings.UpdateResources() + { + var owner = Owner; + } + void IMainPage_Bindings.StopTracking() + { + } + } } } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 11cc825c0a94..34100209e809 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -1135,7 +1135,7 @@ private void BuildCompiledBindings(IndentedStringBuilder writer) var hasXBindExpressions = CurrentScope.XBindExpressions.Count != 0; var hasResourceExtensions = CurrentScope.Components.Any(c => HasMarkupExtensionNeedingComponent(c.XamlObject)); - if (hasXBindExpressions || hasResourceExtensions) + if (hasXBindExpressions || hasResourceExtensions || _isHotReloadEnabled) // We forcefully generate the bindings class for HR to avoids rude edit { var (bindingsInterfaceName, bindingsClassName) = GetBindingsTypeNames(_xClassName.ClassName); From 7a8536ad625611036918966dd898f3ca0818e88e Mon Sep 17 00:00:00 2001 From: David Date: Tue, 10 Dec 2024 17:51:43 -0500 Subject: [PATCH 20/30] fix(hr): Restore udage of cnomua for resource dictionnaries --- .../XamlCodeGenerator_GlobalStaticResources.cs | 1 + .../XamlCodeGenerator_GlobalStaticResources.cs | 1 + .../XamlCodeGenerator_GlobalStaticResources.cs | 1 + .../XamlCodeGenerator_GlobalStaticResources.cs | 1 + .../XamlCodeGenerator_GlobalStaticResources.cs | 1 + .../XamlCodeGenerator_GlobalStaticResources.cs | 1 + ...Dictionary_b7707bcf1e73425b710b6a5d04177088.cs | 4 ++++ .../XamlGenerator/XamlCodeGeneration.cs | 5 +++++ .../XamlGenerator/XamlFileGenerator.cs | 15 +++++++++++++++ .../ClientHotReloadProcessor.Common.Status.cs | 10 +++++++++- 10 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SBUIIOFFE/XamlCodeGenerator_GlobalStaticResources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SBUIIOFFE/XamlCodeGenerator_GlobalStaticResources.cs index 0dc326678c53..b22252d3f926 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SBUIIOFFE/XamlCodeGenerator_GlobalStaticResources.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SBUIIOFFE/XamlCodeGenerator_GlobalStaticResources.cs @@ -4,6 +4,7 @@ namespace MyProject /// /// Contains all the static resources defined for the application /// + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] public sealed partial class GlobalStaticResources { static bool _initialized; diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFDOTAFE/XamlCodeGenerator_GlobalStaticResources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFDOTAFE/XamlCodeGenerator_GlobalStaticResources.cs index 1efc369d512c..c3128646b018 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFDOTAFE/XamlCodeGenerator_GlobalStaticResources.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIIOFDOTAFE/XamlCodeGenerator_GlobalStaticResources.cs @@ -4,6 +4,7 @@ namespace MyProject /// /// Contains all the static resources defined for the application /// + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] public sealed partial class GlobalStaticResources { static bool _initialized; diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLR/XamlCodeGenerator_GlobalStaticResources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLR/XamlCodeGenerator_GlobalStaticResources.cs index 1efc369d512c..c3128646b018 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLR/XamlCodeGenerator_GlobalStaticResources.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLR/XamlCodeGenerator_GlobalStaticResources.cs @@ -4,6 +4,7 @@ namespace MyProject /// /// Contains all the static resources defined for the application /// + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] public sealed partial class GlobalStaticResources { static bool _initialized; diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLS/XamlCodeGenerator_GlobalStaticResources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLS/XamlCodeGenerator_GlobalStaticResources.cs index 1efc369d512c..c3128646b018 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLS/XamlCodeGenerator_GlobalStaticResources.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFPLS/XamlCodeGenerator_GlobalStaticResources.cs @@ -4,6 +4,7 @@ namespace MyProject /// /// Contains all the static resources defined for the application /// + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] public sealed partial class GlobalStaticResources { static bool _initialized; diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFRT/XamlCodeGenerator_GlobalStaticResources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFRT/XamlCodeGenerator_GlobalStaticResources.cs index 1efc369d512c..c3128646b018 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFRT/XamlCodeGenerator_GlobalStaticResources.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFRT/XamlCodeGenerator_GlobalStaticResources.cs @@ -4,6 +4,7 @@ namespace MyProject /// /// Contains all the static resources defined for the application /// + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] public sealed partial class GlobalStaticResources { static bool _initialized; diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFTLRD/XamlCodeGenerator_GlobalStaticResources.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFTLRD/XamlCodeGenerator_GlobalStaticResources.cs index 15ab9e0d8660..2742f4391268 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFTLRD/XamlCodeGenerator_GlobalStaticResources.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/SOSLIOFTLRD/XamlCodeGenerator_GlobalStaticResources.cs @@ -4,6 +4,7 @@ namespace MyProject /// /// Contains all the static resources defined for the application /// + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] public sealed partial class GlobalStaticResources { static bool _initialized; 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 7ea52c3b2fda..609b3797756e 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 @@ -34,6 +34,7 @@ namespace TestNamespace { + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] public sealed partial class TestClass : global::Microsoft.UI.Xaml.ResourceDictionary { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] @@ -58,6 +59,9 @@ public sealed partial class GlobalStaticResources [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] private const string __baseUri_MyDictionary_b7707bcf1e73425b710b6a5d04177088 = "ms-appx:///TestProject/"; // This non-static inner class is a means of reducing size of AOT compilations by avoiding many accesses to static members from a static callsite, which adds costly class initializer checks each time. + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + internal string __MyDictionary_b7707bcf1e73425b710b6a5d04177088_checksum() => "0006bfa967d7b0e0bdb0aa951326268f007434d5"; + [global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate] internal sealed class ResourceDictionarySingleton__MyDictionary_b7707bcf1e73425b710b6a5d04177088 : global::Uno.UI.IXamlResourceDictionaryProvider { private static global::Microsoft.UI.Xaml.NameScope __nameScope = new global::Microsoft.UI.Xaml.NameScope(); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs index b8fa11ba46e4..8d67fdc9b457 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs @@ -680,6 +680,11 @@ private SourceText GenerateGlobalResources(IEnumerable files writer.AppendLineIndented("/// Contains all the static resources defined for the application"); writer.AppendLineIndented("/// "); + if (_isHotReloadEnabled) + { + writer.AppendLineIndented("[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate]"); + } + using (writer.BlockInvariant("public sealed partial class GlobalStaticResources")) { writer.AppendLineIndented("static bool _initialized;"); diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 34100209e809..6c37e9ddf5a8 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -1294,6 +1294,16 @@ IDisposable WrapSingleton() { writer.AppendLineIndented("// This non-static inner class is a means of reducing size of AOT compilations by avoiding many accesses to static members from a static callsite, which adds costly class initializer checks each time."); + if (_isHotReloadEnabled) + { + // Create a public member to avoid having to remove all unused member warnings + // The member is a method to avoid this error: error ENC0011: Updating the initializer of const field requires restarting the application. + writer.AppendLineIndented("[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]"); + writer.AppendLineIndented($"internal string __{_fileDefinition.UniqueID}_checksum() => \"{_fileDefinition.Checksum}\";"); + + writer.AppendLineIndented("[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate]"); + } + var block = writer.BlockInvariant("internal sealed class {0} : {1}", SingletonClassName, DictionaryProviderInterfaceName); _isInSingletonInstance = true; return new DisposableAction(() => @@ -1694,6 +1704,11 @@ private void BuildResourceDictionaryBackingClass(IIndentedStringBuilder writer, using (writer.BlockInvariant("namespace {0}", className.Namespace)) { + if (_isHotReloadEnabled) + { + writer.AppendLineIndented("[global::System.Runtime.CompilerServices.CreateNewOnMetadataUpdate]"); + } + using (writer.BlockInvariant("public sealed partial class {0} : {1}", className.ClassName, controlBaseType.GetFullyQualifiedTypeIncludingGlobal())) { BuildBaseUri(writer); diff --git a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.Common.Status.cs b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.Common.Status.cs index 16791f6d6d1b..829603ad3e5e 100644 --- a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.Common.Status.cs +++ b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.Common.Status.cs @@ -8,6 +8,7 @@ using System.Reflection; using System.Threading; using Uno.Diagnostics.UI; +using Uno.Foundation.Logging; #if HAS_UNO_WINUI using Uno.UI.RemoteControl.HotReload.Messages; @@ -138,7 +139,14 @@ private void NotifyStatusChanged() var status = BuildStatus(); Current = status; - owner.StatusChanged?.Invoke(this, status); + try + { + owner.StatusChanged?.Invoke(this, status); + } + catch (Exception error) + { + this.Log().Error("Failed to notify the status changed.", error); + } } private Status BuildStatus() From 3db1f2cb80b00967cc437869adffcc8b8b18d881 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 11 Dec 2024 11:38:30 -0500 Subject: [PATCH 21/30] fix(reg): Fix ANdroid test not passing --- .../Given_DependencyObjectGenerator.cs | 13 ++++++++----- .../Uno.UI.SourceGenerators.Tests/_Dotnet.cs | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs index bbe96700c467..0f29ef6dbd5a 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/DependencyObjectGeneratorTests/Given_DependencyObjectGenerator.cs @@ -90,7 +90,7 @@ private async Task TestAndroid(string testCode, params DiagnosticResult[] expect [TestMethod] public async Task TestAndroidViewImplementingDependencyObject() { - await TestAndroid(""" + var source = """ using Android.Content; using Windows.UI.Core; using Microsoft.UI.Dispatching; @@ -101,7 +101,7 @@ public class C : Android.Views.View, DependencyObject public C(Context context) : base(context) { } - + public CoreDispatcher Dispatcher { get; } public DispatcherQueue DispatcherQueue { get; } public object GetValue(DependencyProperty dp) => null; @@ -112,9 +112,12 @@ public void ClearValue(DependencyProperty dp) { } public long RegisterPropertyChangedCallback(DependencyProperty dp, DependencyPropertyChangedCallback callback) => 0; public void UnregisterPropertyChangedCallback(DependencyProperty dp, long token) { } } - """, - // /0/Test0.cs(5,14): error Uno0003: 'Android.Views.View' shouldn't implement 'DependencyObject'. Inherit 'FrameworkElement' instead. - DiagnosticResult.CompilerError("Uno0003").WithSpan(6, 14, 6, 15).WithArguments("Android.Views.View")); + """; + + await TestAndroid( + source, + // /0/Test0.cs(5,14): error Uno0003: 'Android.Views.View' shouldn't implement 'DependencyObject'. Inherit 'FrameworkElement' instead. + DiagnosticResult.CompilerError("Uno0003").WithSpan(6, 14, 6, 15).WithArguments("Android.Views.View")); } [TestMethod] diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/_Dotnet.cs b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/_Dotnet.cs index ba203cc28e8e..85fef5b499a0 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/_Dotnet.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/_Dotnet.cs @@ -13,5 +13,5 @@ public ReferenceAssemblies WithUnoPackage(string version = "5.0.118") public static _Dotnet Current = new("net9.0", ReferenceAssemblies.Net.Net90); - public static _Dotnet CurrentAndroid = new("net9.0-android", ReferenceAssemblies.Net.Net90); + public static _Dotnet CurrentAndroid = new("net9.0-android", ReferenceAssemblies.Net.Net90Android); } From ac83205698c2a0998c2077181c4b05dd0c7b7d19 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 11 Dec 2024 14:50:48 -0500 Subject: [PATCH 22/30] test(hr): Remove invalid clss from UWP tests --- .../Uno.UI.SourceGenerators.Tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Uno.UI.SourceGenerators.Tests.csproj b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Uno.UI.SourceGenerators.Tests.csproj index 83645ba5bdfb..604138751e1e 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Uno.UI.SourceGenerators.Tests.csproj +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Uno.UI.SourceGenerators.Tests.csproj @@ -286,6 +286,7 @@ + From 00f4a15d65df516baeb5d348fd3f30d547d299ae Mon Sep 17 00:00:00 2001 From: David Date: Wed, 11 Dec 2024 16:02:21 -0500 Subject: [PATCH 23/30] fix(hr): Disable partial reload on compatible targets --- .../Content/Uno.UI.SourceGenerators.props | 1 + .../RemoteControl/RemoteControlGenerator.cs | 1 + .../HotReload/ClientHotReloadProcessor.PartialReload.cs | 2 ++ 3 files changed, 4 insertions(+) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props b/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props index cea123ca4cf3..0f02c73d1526 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/Content/Uno.UI.SourceGenerators.props @@ -64,6 +64,7 @@ + diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/RemoteControl/RemoteControlGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/RemoteControl/RemoteControlGenerator.cs index 79f4c8b1df25..e579923b8ae7 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/RemoteControl/RemoteControlGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/RemoteControl/RemoteControlGenerator.cs @@ -46,6 +46,7 @@ public class RemoteControlGenerator : ISourceGenerator "SolutionName", "VSIDEResolvedNonMSBuildProjectOutputs", "DevEnvDir", + "MSBuildVersion", }; public void Initialize(GeneratorInitializationContext context) diff --git a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.PartialReload.cs b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.PartialReload.cs index b2cd8b1af0c0..1b674d6773c4 100644 --- a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.PartialReload.cs +++ b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.PartialReload.cs @@ -29,10 +29,12 @@ private void InitializePartialReload() var unoRuntimeIdentifier = GetMSBuildProperty("UnoRuntimeIdentifier"); var targetFramework = GetMSBuildProperty("TargetFramework"); var buildingInsideVisualStudio = GetMSBuildProperty("BuildingInsideVisualStudio"); + var msBuildVersion = GetMSBuildProperty("MSBuildVersion"); _supportsPartialHotReload = buildingInsideVisualStudio.Equals("true", StringComparison.OrdinalIgnoreCase) && _forcedHotReloadMode is null or HotReloadMode.Partial + && (Version.TryParse(msBuildVersion, out var v) is false || v is not { Major: >= 17, Minor: >= 12 }) && ( // As of VS 17.8, when the debugger is attached, mobile targets don't invoke MetadataUpdateHandlers // and both targets are not providing updated types. We simulate parts of this process From e15e96738578c918067bb3b5c89b71ccfc2754c2 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 11 Dec 2024 21:45:49 -0500 Subject: [PATCH 24/30] fix(hr): Do not restore MSBuild properties in HR workspace --- .../HotReload/ServerHotReloadProcessor.MetadataUpdate.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.MetadataUpdate.cs b/src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.MetadataUpdate.cs index 1d4b9ea3bb7c..48f9ac106ad1 100644 --- a/src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.MetadataUpdate.cs +++ b/src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.MetadataUpdate.cs @@ -65,7 +65,7 @@ private void InitializeInner(ConfigureServer configureServer) => _initializeTask configureServer.ProjectPath, _reporter, configureServer.MetadataUpdateCapabilities, - configureServer.MSBuildProperties, + configureServer.MSBuildProperties.Where(kvp => !kvp.Key.StartsWith("MSBuild", StringComparison.OrdinalIgnoreCase)).ToDictionary(), CancellationToken.None); ObserveSolutionPaths(result.Item1); From c9d39da185c2b5b6eb27651347556c7863a8b9ca Mon Sep 17 00:00:00 2001 From: David Date: Thu, 12 Dec 2024 11:39:23 -0500 Subject: [PATCH 25/30] test(hr): Fix invalid space chars --- .../HotReload/Frame/HRApp/Tests/Pages/HR_Frame_Pages_Page2.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Pages/HR_Frame_Pages_Page2.xaml b/src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Pages/HR_Frame_Pages_Page2.xaml index ba7171230556..6512ad40c2f8 100644 --- a/src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Pages/HR_Frame_Pages_Page2.xaml +++ b/src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Pages/HR_Frame_Pages_Page2.xaml @@ -7,7 +7,7 @@ mc:Ignorable="d"> - From 5aeb92be1879bed62697ccca7b3569d066b542c5 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 12 Dec 2024 11:43:20 -0500 Subject: [PATCH 26/30] test(hr): Prevent cross-tests impacts --- .../HotReload/Frame/HRApp/Tests/Given_TextBlock.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Given_TextBlock.cs b/src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Given_TextBlock.cs index c87b9915f418..c99eec807d83 100644 --- a/src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Given_TextBlock.cs +++ b/src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Given_TextBlock.cs @@ -121,7 +121,15 @@ public async Task When_Changing_TextBlock_UsingHRClient_NoChanges() true) .WithExtendedTimeouts(); // Required for CI - await hr.UpdateFileAsync(req, ct); + try + { + await hr.UpdateFileAsync(req, ct); + } + finally + { + // Make sure to undo to not impact other tests! + await hr.UpdateFileAsync(req.Undo(waitForHotReload: false), CancellationToken.None); + } } // Another version of the test above, but pausing the TypeMapping before calling the file update From 797c16838984979532c64eaf2f79b3206fc0dcbe Mon Sep 17 00:00:00 2001 From: David Date: Thu, 12 Dec 2024 13:10:44 -0500 Subject: [PATCH 27/30] test(hr): Update test scenario --- .../Tests/HotReload/Frame/HRApp/Tests/Given_TypeReplacement.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Given_TypeReplacement.cs b/src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Given_TypeReplacement.cs index 68131528f487..1b893f6aa66c 100644 --- a/src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Given_TypeReplacement.cs +++ b/src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Given_TypeReplacement.cs @@ -34,7 +34,6 @@ await HotReloadHelper.UpdateServerFileAndRevert( var grid = (Grid)page.Content; var component = (UserControl)grid.Children.Single(); Assert.AreNotEqual(oldComponent, component); - Assert.IsTrue(component.GetType().Name.Contains("#")); Assert.AreEqual(1, Grid.GetRow(component)); Assert.AreEqual("Hello tag", component.Tag as string); Assert.AreEqual(Microsoft.UI.Colors.Orange, ((SolidColorBrush)((Grid)component.Content).Background).Color); @@ -60,8 +59,6 @@ await HotReloadHelper.UpdateServerFileAndRevert( { var component = (UserControl)page.Content; Assert.AreNotEqual(oldComponent, component); - Assert.IsTrue(component.GetType().Name.Contains("#")); - Assert.IsNotNull(component.GetBindingExpression(FrameworkElement.TagProperty)); page.Tag2 = "Updated tag"; From 7aae564996528686acbc8671dcc732480a7df157 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 13 Dec 2024 16:55:42 -0500 Subject: [PATCH 28/30] 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 Date: Fri, 13 Dec 2024 16:57:23 -0500 Subject: [PATCH 29/30] test(HR): Add several test scenario --- .../Given_HotReloadService.cs | 10 +++- .../0/p1/MainPage.xaml | 19 ++++++++ .../0/p1/MainPage.xaml.cs | 0 .../1/p1/MainPage.xaml | 19 ++++++++ .../1/p1/MainPage.xaml.cs | 28 +++++++++++ .../Scenario.json | 0 .../0/p1/MainPage.xaml | 19 ++++++++ .../0/p1/MainPage.xaml.cs | 24 ++++++++++ .../1/p1/MainPage.xaml | 19 ++++++++ .../1/p1/MainPage.xaml.cs | 28 +++++++++++ .../2/p1/MainPage.xaml | 19 ++++++++ .../2/p1/MainPage.xaml.cs | 24 ++++++++++ .../Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 19 ++++++++ .../0/p1/MainPage.xaml.cs | 28 +++++++++++ .../1/p1/MainPage.xaml | 19 ++++++++ .../1/p1/MainPage.xaml.cs | 24 ++++++++++ .../Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 19 ++++++++ .../0/p1/MainPage.xaml.cs | 28 +++++++++++ .../1/p1/MainPage.xaml | 19 ++++++++ .../1/p1/MainPage.xaml.cs | 28 +++++++++++ .../Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 19 ++++++++ .../0/p1/MainPage.xaml.cs | 24 ++++++++++ .../1/p1/MainPage.xaml | 19 ++++++++ .../1/p1/MainPage.xaml.cs | 26 +++++++++++ .../Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 19 ++++++++ .../0/p1/MainPage.xaml.cs | 24 ++++++++++ .../1/p1/MainPage.xaml | 19 ++++++++ .../1/p1/MainPage.xaml.cs | 26 +++++++++++ .../2/p1/MainPage.xaml | 19 ++++++++ .../2/p1/MainPage.xaml.cs | 24 ++++++++++ .../Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 19 ++++++++ .../0/p1/MainPage.xaml.cs | 26 +++++++++++ .../1/p1/MainPage.xaml | 19 ++++++++ .../1/p1/MainPage.xaml.cs | 24 ++++++++++ .../Scenario.json | 26 +++++++++++ .../0/p1/MainPage.xaml | 19 ++++++++ .../0/p1/MainPage.xaml.cs | 26 +++++++++++ .../1/p1/MainPage.xaml | 19 ++++++++ .../1/p1/MainPage.xaml.cs | 26 +++++++++++ .../Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 4 +- .../0/p1/MainPage.xaml.cs | 24 ++++++++++ .../1/p1/MainPage.xaml | 13 ++++++ .../1/p1/MainPage.xaml.cs | 26 +++++++++++ .../2/p1/MainPage.xaml | 13 ++++++ .../2/p1/MainPage.xaml.cs | 24 ++++++++++ .../Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 13 ++++++ .../0}/p1/MainPage.xaml.cs | 0 .../1/p1/MainPage.xaml | 13 ++++++ .../1/p1/MainPage.xaml.cs | 24 ++++++++++ .../Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 13 ++++++ .../0/p1/MainPage.xaml.cs | 24 ++++++++++ .../1/p1/MainPage.xaml | 13 ++++++ .../1/p1/MainPage.xaml.cs | 28 +++++++++++ .../2/p1/MainPage.xaml | 13 ++++++ .../2/p1/MainPage.xaml.cs | 24 ++++++++++ .../Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 13 ++++++ .../0/p1/MainPage.xaml.cs | 28 +++++++++++ .../1/p1/MainPage.xaml | 13 ++++++ .../1/p1/MainPage.xaml.cs | 24 ++++++++++ .../Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 13 ++++++ .../0/p1/MainPage.xaml.cs | 26 +++++++++++ .../1/p1/MainPage.xaml | 13 ++++++ .../1/p1/MainPage.xaml.cs | 28 +++++++++++ .../2/p1/MainPage.xaml | 13 ++++++ .../2/p1/MainPage.xaml.cs | 26 +++++++++++ .../Scenario.json | 46 +++++++++++++++++++ .../0/p1/MainPage.xaml | 13 ++++++ .../0/p1/MainPage.xaml.cs | 28 +++++++++++ .../1/p1/MainPage.xaml | 13 ++++++ .../1/p1/MainPage.xaml.cs | 26 +++++++++++ .../Scenario.json | 46 +++++++++++++++++++ .../0/p1/MainPage.xaml | 14 ++++++ .../0/p1/MainPage.xaml.cs | 24 ++++++++++ .../1/p1/MainPage.xaml | 0 .../1/p1/MainPage.xaml.cs | 26 +++++++++++ .../When_Simple_Xaml_xLoad_Add/Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 14 ++++++ .../0/p1/MainPage.xaml.cs | 24 ++++++++++ .../1/p1/MainPage.xaml | 14 ++++++ .../1/p1/MainPage.xaml.cs | 26 +++++++++++ .../2/p1/MainPage.xaml | 14 ++++++ .../2/p1/MainPage.xaml.cs | 24 ++++++++++ .../Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 14 ++++++ .../0/p1/MainPage.xaml.cs | 24 ++++++++++ .../1/p1/MainPage.xaml | 14 ++++++ .../1/p1/MainPage.xaml.cs | 26 +++++++++++ .../Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 14 ++++++ .../0/p1/MainPage.xaml.cs | 24 ++++++++++ .../1/p1/MainPage.xaml | 14 ++++++ .../1/p1/MainPage.xaml.cs | 26 +++++++++++ .../Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 14 ++++++ .../0/p1/MainPage.xaml.cs | 24 ++++++++++ .../1/p1/MainPage.xaml | 14 ++++++ .../1/p1/MainPage.xaml.cs | 28 +++++++++++ .../Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 14 ++++++ .../0/p1/MainPage.xaml.cs | 24 ++++++++++ .../1/p1/MainPage.xaml | 14 ++++++ .../1/p1/MainPage.xaml.cs | 28 +++++++++++ .../2/p1/MainPage.xaml | 14 ++++++ .../2/p1/MainPage.xaml.cs | 24 ++++++++++ .../Scenario.json | 24 ++++++++++ .../0/p1/MainPage.xaml | 14 ++++++ .../0/p1/MainPage.xaml.cs | 28 +++++++++++ .../1/p1/MainPage.xaml | 14 ++++++ .../1/p1/MainPage.xaml.cs | 24 ++++++++++ .../Scenario.json | 26 +++++++++++ .../0/p1/MainPage.xaml | 14 ++++++ .../0/p1/MainPage.xaml.cs | 28 +++++++++++ .../1/p1/MainPage.xaml | 14 ++++++ .../1/p1/MainPage.xaml.cs | 26 +++++++++++ .../Scenario.json | 24 ++++++++++ 125 files changed, 2580 insertions(+), 4 deletions(-) create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add/0/p1/MainPage.xaml rename src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/{When_Simple_Xaml_Add_xLoad => When_DataTemplate_xBind_Event_Add}/0/p1/MainPage.xaml.cs (100%) create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add/1/p1/MainPage.xaml.cs rename src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/{When_Simple_Xaml_Add_xLoad => When_DataTemplate_xBind_Event_Add}/Scenario.json (100%) create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add_Remove/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add_Remove/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add_Remove/2/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add_Remove/2/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Remove/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Remove/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Update/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Update/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Update/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Update/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Update/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Add/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Add/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Add/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Add/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Add/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Add_Remove/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Add_Remove/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Add_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Add_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Add_Remove/2/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Add_Remove/2/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Add_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Remove/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Remove/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Update/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Update/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Update/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Update/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xLoad_xBind_Update/Scenario.json rename src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/{When_Simple_Xaml_Add_xLoad => When_Simple_Xaml_Single_xName_Add_Remove}/0/p1/MainPage.xaml (93%) create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add_Remove/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add_Remove/2/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add_Remove/2/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Add_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Remove/0/p1/MainPage.xaml rename src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/{When_Simple_Xaml_Add_xLoad/1 => When_Simple_Xaml_Single_xName_Remove/0}/p1/MainPage.xaml.cs (100%) create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_Single_xName_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Add_Remove/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Add_Remove/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Add_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Add_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Add_Remove/2/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Add_Remove/2/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Add_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Remove/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Remove/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Event_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Function_Property_Add_Remove/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Function_Property_Add_Remove/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Function_Property_Add_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Function_Property_Add_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Function_Property_Add_Remove/2/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Function_Property_Add_Remove/2/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Function_Property_Add_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Function_Property_Remove/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Function_Property_Remove/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Function_Property_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Function_Property_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xBind_Function_Property_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Add/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Add/0/p1/MainPage.xaml.cs rename src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/{When_Simple_Xaml_Add_xLoad => When_Simple_Xaml_xLoad_Add}/1/p1/MainPage.xaml (100%) create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Add/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Add/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Add_Remove/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Add_Remove/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Add_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Add_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Add_Remove/2/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Add_Remove/2/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Add_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Remove/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Remove/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Update/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Update/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Update/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Update/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_Update/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Add/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Add/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Add/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Add/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Add/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Add_Remove/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Add_Remove/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Add_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Add_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Add_Remove/2/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Add_Remove/2/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Add_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Remove/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Remove/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Remove/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Remove/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Remove/Scenario.json create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Update/0/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Update/0/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Update/1/p1/MainPage.xaml create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_Update/1/p1/MainPage.xaml.cs create mode 100644 src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_Simple_Xaml_xLoad_xBind_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 992ac2bae031..bb5ba0926b45 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Given_HotReloadService.cs @@ -14,6 +14,12 @@ public async Task HR(string name, Scenario? scenario, Project[]? projects) { if (scenario != null) { + if (scenario.IsCrashingRoslyn) + { + Assert.Inconclusive("Case is known to crash roslyn."); + return; + } + var results = await ApplyScenario(projects, scenario.IsDebug, scenario.IsMono, scenario.UseXamlReaderReload, name); for (var i = 0; i < scenario.PassResults.Length; i++) @@ -36,7 +42,7 @@ public record ScenariosDescriptor( public record Project(string Name, ProjectReference[]? ProjectReferences); public record ProjectReference(string Name); - public record Scenario(bool IsDebug, bool IsMono, bool UseXamlReaderReload, params PassResult[] PassResults) + public record Scenario(bool IsDebug, bool IsMono, bool IsCrashingRoslyn, bool UseXamlReaderReload, params PassResult[] PassResults) { public override string ToString() => $"{(IsDebug ? "Debug" : "Release")},{(IsMono ? "MonoVM" : "NetCore")},XR:{UseXamlReaderReload}"; @@ -53,7 +59,7 @@ public record DiagnosticsResult(string Id); var path = Path.Combine(scenarioFolder, "Scenario.json"); #if DEBUG && false - if (!path.Contains("When_Simple_Xaml_Add_xBind_Function_Property_Add")) + if (!path.Contains("When_DataTemplate_xLoad_xBind_Remove")) { continue; } diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add/0/p1/MainPage.xaml b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add/0/p1/MainPage.xaml new file mode 100644 index 000000000000..f8d477b0e53d --- /dev/null +++ b/src/SourceGenerators/Uno.UI.SourceGenerators.Tests/MetadataUpdateTests/Scenarios/When_DataTemplate_xBind_Event_Add/0/p1/MainPage.xaml @@ -0,0 +1,19 @@ + + + + +