From f3c55f83e443c70f4eb5407a2ac2982413f302c2 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Fri, 30 Aug 2024 17:27:01 +0300 Subject: [PATCH 1/3] fix: Consider init-only properties as not settable in bindable type generator --- .../BindableTypeProvidersGenerationTask.cs | 2 +- .../BindableNullableValueTypeTestPage.xaml.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/BindableTypeProviders/BindableTypeProvidersGenerationTask.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/BindableTypeProviders/BindableTypeProvidersGenerationTask.cs index 82eb829238fb..e7729393205e 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/BindableTypeProviders/BindableTypeProvidersGenerationTask.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/BindableTypeProviders/BindableTypeProvidersGenerationTask.cs @@ -364,7 +364,7 @@ where field.IsStatic if ( property.SetMethod != null - && property.SetMethod != null + && !property.SetMethod.IsInitOnly && property.SetMethod.IsLocallyPublic(_currentModule!) ) { diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/BindableNullableValueTypeTestPage.xaml.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/BindableNullableValueTypeTestPage.xaml.cs index 60bc58fdc2bb..2b06b78d5428 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/BindableNullableValueTypeTestPage.xaml.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/BindableNullableValueTypeTestPage.xaml.cs @@ -30,4 +30,6 @@ public int? MyProperty } } } + + public int MyInitOnlyProperty { get; init; } } From 4f6e3ce44d1abcb7d00ad3b9d2a39ed07f3bdb83 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Fri, 30 Aug 2024 19:40:16 +0300 Subject: [PATCH 2/3] chore: Skip for WinAppSDK --- .../BindableNullableValueTypeTestPage.xaml.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/BindableNullableValueTypeTestPage.xaml.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/BindableNullableValueTypeTestPage.xaml.cs index 2b06b78d5428..bd78af6d397a 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/BindableNullableValueTypeTestPage.xaml.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/BindableNullableValueTypeTestPage.xaml.cs @@ -31,5 +31,7 @@ public int? MyProperty } } +#if !WINAPPSDK // https://github.com/microsoft/microsoft-ui-xaml/issues/5315 public int MyInitOnlyProperty { get; init; } + #endif } From 46e75e286f6dc3175b78471be7551c1ff21dea3a Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Fri, 30 Aug 2024 20:46:19 +0300 Subject: [PATCH 3/3] chore: Fix formatting --- .../BindableNullableValueTypeTestPage.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/BindableNullableValueTypeTestPage.xaml.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/BindableNullableValueTypeTestPage.xaml.cs index bd78af6d397a..3dd38d68be88 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/BindableNullableValueTypeTestPage.xaml.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/BindableNullableValueTypeTestPage.xaml.cs @@ -33,5 +33,5 @@ public int? MyProperty #if !WINAPPSDK // https://github.com/microsoft/microsoft-ui-xaml/issues/5315 public int MyInitOnlyProperty { get; init; } - #endif +#endif }