From 3b6d95e87c1e2a79096855bada7a90f6972a60d2 Mon Sep 17 00:00:00 2001
From: MartyIX <203266+MartyIX@users.noreply.github.com>
Date: Tue, 27 Feb 2024 14:54:52 +0100
Subject: [PATCH 1/5] Just .NET 8
---
global.json | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/global.json b/global.json
index 84aa9e607a1f..26a71eeb1bb8 100644
--- a/global.json
+++ b/global.json
@@ -5,5 +5,12 @@
"msbuild-sdks": {
"MSBuild.Sdk.Extras": "3.0.44",
"Microsoft.Build.NoTargets": "3.3.0"
+ },
+ "sdk": {
+ "version": "8.0.0",
+ "rollForward": "latestFeature",
+ "allowPrerelease": true
}
}
+
+
From 85d7cc4be0be004a095ed4fbaa09cf7d51c9ffc9 Mon Sep 17 00:00:00 2001
From: MartyIX <203266+MartyIX@users.noreply.github.com>
Date: Thu, 11 Apr 2024 22:03:27 +0200
Subject: [PATCH 2/5] Generate grid
---
.../Controls.Sample.Sandbox/MainPage.xaml | 12 +++++-
.../Controls.Sample.Sandbox/MainPage.xaml.cs | 43 +++++++++++++++----
2 files changed, 46 insertions(+), 9 deletions(-)
diff --git a/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml b/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml
index e1762ab92d18..43e38a464766 100644
--- a/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml
+++ b/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml
@@ -1,6 +1,16 @@
+ x:DataType="local:MainPage">
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml.cs b/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml.cs
index effdbcdb46d7..c7ff5eb1a9d6 100644
--- a/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml.cs
+++ b/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml.cs
@@ -1,18 +1,45 @@
using System;
-using System.Collections.ObjectModel;
using System.Diagnostics;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Maui;
using Microsoft.Maui.Controls;
-using Microsoft.Maui.Graphics;
-namespace Maui.Controls.Sample
+namespace Maui.Controls.Sample;
+
+public partial class MainPage : ContentPage
{
- public partial class MainPage : ContentPage
+ public MainPage()
+ {
+ InitializeComponent();
+ }
+
+ private void ClearGrid_Clicked(object sender, EventArgs e)
{
- public MainPage()
+ Stopwatch sw = Stopwatch.StartNew();
+
+ contentGrid.Clear();
+
+ sw.Stop();
+
+ info.Text = $"Clearing grid took: {sw.ElapsedMilliseconds} ms";
+ }
+
+ private void Button_Clicked(object sender, EventArgs e)
+ {
+ const int rowCount = 30;
+ const int columnCount = 30;
+
+ Stopwatch sw = Stopwatch.StartNew();
+ contentGrid.Clear();
+
+ for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
{
- InitializeComponent();
+ for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
+ {
+ Label label = new Label() { Text = $"[{columnIndex}x{rowIndex}]" };
+ contentGrid.Add(label, column: columnIndex, row: rowIndex);
+ }
}
+
+ sw.Stop();
+ info.Text = $"Clearing grid took: {sw.ElapsedMilliseconds} ms";
}
}
\ No newline at end of file
From d45625562ab1408575dddb0450dafefb16c01afe Mon Sep 17 00:00:00 2001
From: MartyIX <203266+MartyIX@users.noreply.github.com>
Date: Fri, 12 Apr 2024 14:42:14 +0200
Subject: [PATCH 3/5] Add batch generate
---
.../Controls.Sample.Sandbox/MainPage.xaml | 2 ++
.../Controls.Sample.Sandbox/MainPage.xaml.cs | 31 +++++++++++++++++--
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml b/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml
index 43e38a464766..aeb74084b579 100644
--- a/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml
+++ b/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml
@@ -8,6 +8,8 @@
+
+
diff --git a/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml.cs b/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml.cs
index c7ff5eb1a9d6..8ae3891a5f54 100644
--- a/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml.cs
+++ b/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml.cs
@@ -6,6 +6,9 @@ namespace Maui.Controls.Sample;
public partial class MainPage : ContentPage
{
+ const int rowCount = 30;
+ const int columnCount = 30;
+
public MainPage()
{
InitializeComponent();
@@ -24,9 +27,6 @@ private void ClearGrid_Clicked(object sender, EventArgs e)
private void Button_Clicked(object sender, EventArgs e)
{
- const int rowCount = 30;
- const int columnCount = 30;
-
Stopwatch sw = Stopwatch.StartNew();
contentGrid.Clear();
@@ -42,4 +42,29 @@ private void Button_Clicked(object sender, EventArgs e)
sw.Stop();
info.Text = $"Clearing grid took: {sw.ElapsedMilliseconds} ms";
}
+
+ private void BatchGenerate_Clicked(object sender, EventArgs e)
+ {
+ Stopwatch sw = Stopwatch.StartNew();
+
+ int batchSize = int.Parse(BatchSize.Text);
+
+ for (int i = 0; i < batchSize; i++)
+ {
+ contentGrid.Clear();
+
+ for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
+ {
+ for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
+ {
+ Label label = new Label() { Text = $"[{columnIndex}x{rowIndex}]" };
+ contentGrid.Add(label, column: columnIndex, row: rowIndex);
+ }
+ }
+ }
+
+ sw.Stop();
+ info.Text = $"Grid was created {batchSize} times and it took {sw.ElapsedMilliseconds} ms in total. Avg run took {Math.Round(sw.ElapsedMilliseconds / (double)batchSize, 2)} ms";
+ }
+
}
\ No newline at end of file
From dab7968c58f97f7ddf57677f4f04624d179d2002 Mon Sep 17 00:00:00 2001
From: MartyIX <203266+MartyIX@users.noreply.github.com>
Date: Fri, 12 Apr 2024 14:35:07 +0200
Subject: [PATCH 4/5] Add `WindowsBatchPropertyMapper`
---
src/Core/src/Handlers/View/ViewHandler.cs | 3 ++
.../View/WindowsBatchPropertyMapper.cs | 50 +++++++++++++++++++
2 files changed, 53 insertions(+)
create mode 100644 src/Core/src/Handlers/View/WindowsBatchPropertyMapper.cs
diff --git a/src/Core/src/Handlers/View/ViewHandler.cs b/src/Core/src/Handlers/View/ViewHandler.cs
index eb3ac9b6eaaf..f4c7f60fe605 100644
--- a/src/Core/src/Handlers/View/ViewHandler.cs
+++ b/src/Core/src/Handlers/View/ViewHandler.cs
@@ -27,6 +27,9 @@ public abstract partial class ViewHandler : ElementHandler, IViewHandler
#if ANDROID
// Use a custom mapper for Android which knows how to batch the initial property sets
new AndroidBatchPropertyMapper(ElementMapper)
+#elif WINDOWS
+ // Use a custom mapper for Windows which knows how to batch the initial property sets
+ new WindowsBatchPropertyMapper(ElementMapper)
#else
new PropertyMapper(ElementHandler.ElementMapper)
#endif
diff --git a/src/Core/src/Handlers/View/WindowsBatchPropertyMapper.cs b/src/Core/src/Handlers/View/WindowsBatchPropertyMapper.cs
new file mode 100644
index 000000000000..1668373bfad5
--- /dev/null
+++ b/src/Core/src/Handlers/View/WindowsBatchPropertyMapper.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+
+namespace Microsoft.Maui.Handlers;
+
+#if WINDOWS
+class WindowsBatchPropertyMapper : PropertyMapper
+ where TVirtualView : IElement
+ where TViewHandler : IElementHandler
+{
+ // During mass property updates, this list of properties will be skipped
+ public static HashSet SkipList = new(StringComparer.Ordinal)
+ {
+ // TranslationX does the work that is necessary to make other properties work.
+ nameof(IView.TranslationY),
+ nameof(IView.Scale),
+ nameof(IView.ScaleX),
+ nameof(IView.ScaleY),
+ nameof(IView.Rotation),
+ nameof(IView.RotationX),
+ nameof(IView.RotationY),
+ nameof(IView.AnchorX),
+ nameof(IView.AnchorY),
+ };
+
+ public WindowsBatchPropertyMapper(params IPropertyMapper[] chained) : base(chained) { }
+
+ public override IEnumerable GetKeys()
+ {
+ foreach (var key in _mapper.Keys)
+ {
+ // When reporting the key list for mass updates up the chain, ignore properties in SkipList.
+ // These will be handled by ViewHandler.SetVirtualView() instead.
+ if (SkipList.Contains(key))
+ {
+ continue;
+ }
+
+ yield return key;
+ }
+
+ if (Chained is not null)
+ {
+ foreach (var chain in Chained)
+ foreach (var key in chain.GetKeys())
+ yield return key;
+ }
+ }
+}
+#endif
\ No newline at end of file
From bc1b884d5cebffc89934fb6a8c312f0cd0cff733 Mon Sep 17 00:00:00 2001
From: MartyIX <203266+MartyIX@users.noreply.github.com>
Date: Sat, 13 Apr 2024 21:14:41 +0200
Subject: [PATCH 5/5] Revert "Just .NET 8"
This reverts commit 3b6d95e87c1e2a79096855bada7a90f6972a60d2.
---
global.json | 7 -------
1 file changed, 7 deletions(-)
diff --git a/global.json b/global.json
index 26a71eeb1bb8..84aa9e607a1f 100644
--- a/global.json
+++ b/global.json
@@ -5,12 +5,5 @@
"msbuild-sdks": {
"MSBuild.Sdk.Extras": "3.0.44",
"Microsoft.Build.NoTargets": "3.3.0"
- },
- "sdk": {
- "version": "8.0.0",
- "rollForward": "latestFeature",
- "allowPrerelease": true
}
}
-
-