ronantakizawa/codereview-bench huggingface dataset:
Repository: unoplatform/uno
File: src/Uno.UI.RuntimeTests/Tests/Windows_UI_Composition/Given_RedirectVisual.cs (C#)

Code before:
		{
			Width = 200,
			Height = 200
		};

		var redirectVisual = compositor.CreateRedirectVisual(ElementCompositionPreview.GetElementVisual(expected));
		redirectVisual.Size = new(200, 200);

		ElementCompositionPreview.SetElementChildVisual(sut, redirectVisual);

		await UITestHelper.Load(new Grid
		{
			ColumnDefinitions =
			{
				new ColumnDefinition(),
				new ColumnDefinition()
			},
			Children =
			{
				expected.Apply(e => Grid.SetColumn(e, 0)),
				sut.Apply(e => Grid.SetColumn(e, 1))
			}
		});

		await TestServices.WindowHelper.WaitFor(() => opened);

		var (expectedScreenshot, actualScreenshot) = (await UITestHelper.ScreenShot(expected), await UITestHelper.ScreenShot(sut));

		await ImageAssert.AreEqualAsync(actualScreenshot, expectedScreenshot);
	}
}


Review comment (suggestion):
i know you tested for "opened", but just for sanity, 
should we also add an assertion for the `expectedScreenshot` pixels to be not all 0s?
```
public static async Task<bool> ImageAssert::IsBlankCanvas(RenderTargetBitmap bitmap)
{
	var buffer = await bitmap.GetPixelsAsync();
	using var render = DataReader.FromBuffer(buffer);

	while (render.UnconsumedBufferLength > 0)
	{
		if (render.ReadByte() != 0)
		{
			return false;
		}
	}

	return true;
}
```

Code after:
		var sut = new ContentControl
		{
			Width = 200,
			Height = 200
		};

		var redirectVisual = compositor.CreateRedirectVisual(ElementCompositionPreview.GetElementVisual(expected));
		redirectVisual.Size = new(200, 200);

		ElementCompositionPreview.SetElementChildVisual(sut, redirectVisual);

		await UITestHelper.Load(new Grid
		{
			ColumnDefinitions =
			{
				new ColumnDefinition(),
				new ColumnDefinition()
			},
			Children =
			{
				expected.Apply(e => Grid.SetColumn(e, 0)),
				sut.Apply(e => Grid.SetColumn(e, 1))
			}
		});

		await TestServices.WindowHelper.WaitFor(() => opened);

		var (expectedScreenshot, actualScreenshot) = (await UITestHelper.ScreenShot(expected), await UITestHelper.ScreenShot(sut));

		await ImageAssert.AreEqualAsync(actualScreenshot, expectedScreenshot);
	}
#endif
}
Repository: unoplatform/uno
File: src/Uno.UI/UI/Xaml/Application.skia.cs (C#)

Code before:
			InitializeSystemTheme();

			using (WritePhaseEventTrace(TraceProvider.LauchedStart, TraceProvider.LauchedStop))
			{
				InitializationCompleted();
				PreloadFonts();

				// OnLaunched should execute only for full apps, not for individual islands.
				if (CoreApplication.IsFullFledgedApp)
				{
					OnLaunched(new LaunchActivatedEventArgs(ActivationKind.Launch, GetCommandLineArgsWithoutExecutable()));
				}
			}
		}

		internal void ForceSetRequestedTheme(ApplicationTheme theme) => _requestedTheme = theme;

		private static void PreloadFonts()
		{
			if (OperatingSystem.IsBrowser())
			{
				// WASM does the font preloading before removing the splash via PrefetchFonts.
				return;
			}

			var _ = FontFamilyHelper.PreloadAsync(new FontFamily(FeatureConfiguration.Font.SymbolsFont), FontWeights.Normal, FontStretch.Normal, FontStyle.Normal);
			_ = FontFamilyHelper.PreloadAllFontsInManifest(new Uri(FeatureConfiguration.Font.DefaultTextFontFamily));
		}
	}

	internal interface IApplicationEvents
	{
	}
}


Review comment (refactor):
```suggestion
			_ = FontFamilyHelper.PreloadAsync(new FontFamily(FeatureConfiguration.Font.SymbolsFont), FontWeights.Normal, FontStretch.Normal, FontStyle.Normal);
```

NOTE: That's a fire-and-forget operation. Usually a thing to avoid as it may lead to unobserved exceptions

Code after:
			InitializeSystemTheme();

			using (WritePhaseEventTrace(TraceProvider.LauchedStart, TraceProvider.LauchedStop))
			{
				InitializationCompleted();
				PreloadFonts();

				// OnLaunched should execute only for full apps, not for individual islands.
				if (CoreApplication.IsFullFledgedApp)
				{
					OnLaunched(new LaunchActivatedEventArgs(ActivationKind.Launch, GetCommandLineArgsWithoutExecutable()));
				}
			}
		}

		internal void ForceSetRequestedTheme(ApplicationTheme theme) => _requestedTheme = theme;

		private static void PreloadFonts()
		{
			if (OperatingSystem.IsBrowser())
			{
				// WASM does the font preloading before removing the splash via PrefetchFonts.
				return;
			}

			_ = FontFamilyHelper.PreloadAsync(new FontFamily(FeatureConfiguration.Font.SymbolsFont), FontWeights.Normal, FontStretch.Normal, FontStyle.Normal);
			if (Uri.TryCreate(FeatureConfiguration.Font.DefaultTextFontFamily, UriKind.RelativeOrAbsolute, out var uri))
			{
				_ = FontFamilyHelper.PreloadAllFontsInManifest(uri);
			}
			else
			{
				_ = FontFamilyHelper.PreloadAsync(new FontFamily(FeatureConfiguration.Font.DefaultTextFontFamily), FontWeights.Normal, FontStretch.Normal, FontStyle.Normal);
			}
		}
	}

	internal interface IApplicationEvents
	{
	}
}
Repository: unoplatform/uno
File: src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/TabView/TabViewTests.Uno.cs (C#)

Code before:
			tabView.TabItems.Add(tabItem2);
			tabView.TabItems.Add(tabItem3);

			var tabToSelectAndClose = tabView.TabItems[tabToClose];
			var expectedSelectedTabAfterClose = (TabViewItem)tabView.TabItems[expectedSelectedTab];
			var expectedColor = ((SolidColorBrush)((Border)expectedSelectedTabAfterClose.Content).Background).Color;

			TestServices.WindowHelper.WindowContent = tabView;
			await TestServices.WindowHelper.WaitForLoaded(tabView);

			// Select the tab that will be closed
			tabView.SelectedItem = tabToSelectAndClose;
			await TestServices.WindowHelper.WaitForIdle();

			// Close the tab
			tabView.TabItems.Remove(tabToSelectAndClose);
			await TestServices.WindowHelper.WaitForIdle();

			// Verify that the last tab is closed and the second last tab is selected
			Assert.IsFalse(tabView.TabItems.Contains(tabToSelectAndClose), "Expected the tab to be removed from the TabItems collection.");
			Assert.AreEqual(expectedSelectedTabAfterClose, tabView.SelectedItem, "Expected different tab to be selected after closing the selected tab.");

#if HAS_RENDER_TARGET_BITMAP
			var contentScreenshot = await UITestHelper.ScreenShot(tabView);
			ImageAssert.HasColorAt(contentScreenshot, contentScreenshot.Width / 2, contentScreenshot.Height / 2, expectedColor);
#endif
		}
	}
}


Review comment (suggestion):
could use something that doesnt depends on image assert
```suggestion
			var presenter = tabView.FindFirstDescendant<ContentPresenter>("TabContentPresenter");
			Assert.AreEqual(presenter.Content, expectedSelectedTabAfterClose.Content);
```

Code after:

			tabView.TabItems.Add(tabItem1);
			tabView.TabItems.Add(tabItem2);
			tabView.TabItems.Add(tabItem3);

			var tabToSelectAndClose = tabView.TabItems[tabToClose];
			var expectedSelectedTabAfterClose = (TabViewItem)tabView.TabItems[expectedSelectedTab];
			var expectedColor = ((SolidColorBrush)((Border)expectedSelectedTabAfterClose.Content).Background).Color;

			TestServices.WindowHelper.WindowContent = tabView;
			await TestServices.WindowHelper.WaitForLoaded(tabView);

			// Select the tab that will be closed
			tabView.SelectedItem = tabToSelectAndClose;
			await TestServices.WindowHelper.WaitForIdle();

			// Close the tab
			tabView.TabItems.Remove(tabToSelectAndClose);
			await TestServices.WindowHelper.WaitForIdle();

			// Verify that the last tab is closed and the second last tab is selected
			Assert.IsFalse(tabView.TabItems.Contains(tabToSelectAndClose), "Expected the tab to be removed from the TabItems collection.");
			Assert.AreEqual(expectedSelectedTabAfterClose, tabView.SelectedItem, "Expected different tab to be selected after closing the selected tab.");
			Assert.IsTrue(expectedSelectedTabAfterClose.IsSelected, "Expected tab is not selected.");

#if HAS_UNO
			var presenter = tabView.FindFirstDescendant<ContentPresenter>("TabContentPresenter");
			Assert.AreEqual(presenter.Content, expectedSelectedTabAfterClose.Content);
#endif
		}
	}
}
Repository: unoplatform/uno
File: src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/TextBox/PasswordBox_PasswordChar.xaml.cs (C#)

Code before:
﻿using System;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

namespace UITests.Shared.Windows_UI_Xaml_Controls.TextBox
{
	public sealed partial class PasswordBox_PasswordChar : Page
	{
		public PasswordBox_PasswordChar()
		{
			this.InitializeComponent();
			this.Loaded += OnLoaded;
		}

		private void OnLoaded(object sender, RoutedEventArgs e)
		{
			UpdateValueDisplays();
		}

		private void SetDefaultChar_Click(object sender, RoutedEventArgs e)
		{
			DynamicPasswordBox.PasswordChar = "●";
			UpdateValueDisplays();
		}

		private void SetAsterisk_Click(object sender, RoutedEventArgs e)
		{
			DynamicPasswordBox.PasswordChar = "*";
			UpdateValueDisplays();
		}

Review comment (suggestion):
@copilot rename the namespace to avoid TextBox_BeforeTextChanging.xaml.cs(14,49): error CS0118: 'TextBox' is a namespace but is used like a type [D:\a\1\s\src\SamplesApp\UnoIslandsSamplesApp.Skia\UnoIslandsSamplesApp.Skia.csproj::TargetFramework=net9.0]

Code after:
﻿using System;
using Uno.UI.Samples.Controls;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

namespace Uno.UI.Samples.Content.UITests.TextBoxControl
{
	[SampleControlInfo("TextBox", "PasswordBox_PasswordChar", IsManualTest = true, Description = "PasswordChar is supported on Skia targets. Setting its value should change the password char accordingly.")]
	public sealed partial class PasswordBox_PasswordChar : UserControl
	{
		public PasswordBox_PasswordChar()
		{
			this.InitializeComponent();
			this.Loaded += OnLoaded;
		}

		private void OnLoaded(object sender, RoutedEventArgs e)
		{
			UpdateValueDisplays();
		}

		private void SetDefaultChar_Click(object sender, RoutedEventArgs e)
		{
			DynamicPasswordBox.PasswordChar = DefaultPasswordBox.PasswordChar;
			UpdateValueDisplays();
		}

		private void SetAsterisk_Click(object sender, RoutedEventArgs e)
		{
			DynamicPasswordBox.PasswordChar = "*";
Repository: unoplatform/uno
File: src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2.cs (C#)

Code before:
				CoreDispatcherPriority.Normal,
				() => WebMessageReceived?.Invoke(this, new(message)));
		}
	}

	internal void RaiseUnsupportedUriSchemeIdentified(Uri targetUri, out bool handled)
	{
		var args = new Microsoft.UI.Xaml.Controls.WebViewUnsupportedUriSchemeIdentifiedEventArgs(targetUri);
		UnsupportedUriSchemeIdentified?.Invoke(this, args);

		handled = args.Handled;
	}

	private TaskCompletionSource<bool>? _nativeWebViewInitializedTcs;
	internal Task EnsureNativeWebViewAsync()
	{
		if (_nativeWebView != null)
		{
			return Task.CompletedTask;
		}

		_nativeWebViewInitializedTcs ??= new TaskCompletionSource<bool>();

		return _nativeWebViewInitializedTcs.Task;
	}

	internal static bool GetIsHistoryEntryValid(string url) =>
		!url.IsNullOrWhiteSpace() &&
		!url.Equals(BlankUrl, StringComparison.OrdinalIgnoreCase);

	[MemberNotNullWhen(true, nameof(_nativeWebView))]
	private bool VerifyWebViewAvailability()
	{
		if (_nativeWebView == null)
		{
			if (_owner.IsLoaded)
			{
				_owner.Log().Warn(
					"This WebView control instance does not have a native WebView child, " +
					"the control template may be missing.");
			}

			return false;
		}

		return true;
	}

	private void UpdateFromInternalSource()
	{
		if (!VerifyWebViewAvailability())

Review comment (suggestion):
```suggestion
	private TaskCompletionSource<bool> _nativeWebViewInitializedTcs = new TaskCompletionSource<bool>();
	internal Task EnsureNativeWebViewAsync() => _nativeWebViewInitializedTcs.Task;
```

Code after:
				CoreDispatcherPriority.Normal,
				() => WebMessageReceived?.Invoke(this, new(message)));
		}
	}

	internal void RaiseUnsupportedUriSchemeIdentified(Uri targetUri, out bool handled)
	{
		var args = new Microsoft.UI.Xaml.Controls.WebViewUnsupportedUriSchemeIdentifiedEventArgs(targetUri);
		UnsupportedUriSchemeIdentified?.Invoke(this, args);

		handled = args.Handled;
	}

	private TaskCompletionSource<bool> _nativeWebViewInitializedTcs = new TaskCompletionSource<bool>();
	internal Task EnsureNativeWebViewAsync() => _nativeWebViewInitializedTcs.Task;
	internal static bool GetIsHistoryEntryValid(string url) =>
		!url.IsNullOrWhiteSpace() &&
		!url.Equals(BlankUrl, StringComparison.OrdinalIgnoreCase);

	[MemberNotNullWhen(true, nameof(_nativeWebView))]
	private bool VerifyWebViewAvailability()
	{
		if (_nativeWebView == null)
		{
			if (_owner.IsLoaded)
			{
				_owner.Log().Warn(
					"This WebView control instance does not have a native WebView child, " +
					"the control template may be missing.");
			}

			return false;
		}

		return true;
	}

	private void UpdateFromInternalSource()
	{
		if (!VerifyWebViewAvailability())
		{
			return;
		}

		if (_processedSource is Uri uri)
		{
			_nativeWebView.ProcessNavigation(uri);
		}
		else if (_processedSource is string html)
		{
			_nativeWebView.ProcessNavigation(html);
Repository: unoplatform/uno
File: src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2.cs (C#)

Code before:
		AsyncOperation.FromTask(ct =>
		{
			if (_nativeWebView is null)
			{
				return Task.FromResult<string?>(null);
			}

			return _nativeWebView.ExecuteScriptAsync(javaScript, ct);
		});

	internal async Task<string?> InvokeScriptAsync(string script, string[]? arguments, CancellationToken ct)
	{
		if (_nativeWebView is null)
		{
			return null;
		}

		return await _nativeWebView.InvokeScriptAsync(script, arguments, ct);
	}

	internal void OnOwnerApplyTemplate()
	{
		_nativeWebView = GetNativeWebViewFromTemplate();

		// Signal that native WebView is now initialized
		_nativeWebViewInitializedTcs?.TrySetResult(true);

		//The native WebView already navigate to a blank page if no source is set.
		//Avoid a bug where invoke GoBack() on WebView do nothing in Android 4.4
		UpdateFromInternalSource();
		OnScrollEnabledChanged(_scrollEnabled);
	}

	internal void OnScrollEnabledChanged(bool newValue)
	{
		_scrollEnabled = newValue;
		_nativeWebView?.SetScrollingEnabled(newValue);
	}

	internal void OnDocumentTitleChanged()
	{
		DocumentTitleChanged?.Invoke(this, null);
	}

	internal void RaiseNavigationStarting(object? navigationData, out bool cancel)
	{
		string? uriString = null;
		if (navigationData is Uri uri)
		{
			uriString = uri.ToString();
		}

Review comment (suggestion):
```suggestion
		_nativeWebViewInitializedTcs.TrySetResult(true);
```
See https://github.com/unoplatform/uno/pull/21626/files#r2446481410

Code after:
		AsyncOperation.FromTask(ct =>
		{
			if (_nativeWebView is null)
			{
				return Task.FromResult<string?>(null);
			}

			return _nativeWebView.ExecuteScriptAsync(javaScript, ct);
		});

	internal async Task<string?> InvokeScriptAsync(string script, string[]? arguments, CancellationToken ct)
	{
		if (_nativeWebView is null)
		{
			return null;
		}

		return await _nativeWebView.InvokeScriptAsync(script, arguments, ct);
	}

	internal void OnOwnerApplyTemplate()
	{
		_nativeWebView = GetNativeWebViewFromTemplate();

		// Signal that native WebView is now initialized
		_nativeWebViewInitializedTcs.TrySetResult(true);

		//The native WebView already navigate to a blank page if no source is set.
		//Avoid a bug where invoke GoBack() on WebView do nothing in Android 4.4
		UpdateFromInternalSource();
		OnScrollEnabledChanged(_scrollEnabled);
	}

	internal void OnScrollEnabledChanged(bool newValue)
	{
		_scrollEnabled = newValue;
		_nativeWebView?.SetScrollingEnabled(newValue);
	}

	internal void OnDocumentTitleChanged()
	{
		DocumentTitleChanged?.Invoke(this, null);
	}

	internal void RaiseNavigationStarting(object? navigationData, out bool cancel)
	{
		string? uriString = null;
		if (navigationData is Uri uri)
		{
			uriString = uri.ToString();
		}
Repository: unoplatform/uno
File: src/Uno.UI.Composition/Composition/Visual.skia.cs (C#)

Code before:
				}

				var rotation = RotationAngle;
				if (rotation is not 0)
				{
					transform *= Matrix4x4.CreateTranslation(-CenterPoint);
					transform *= Matrix4x4.CreateFromAxisAngle(RotationAxis, rotation);
					transform *= Matrix4x4.CreateTranslation(CenterPoint);
				}

				return transform;
			}
		}
	}

#if DEBUG
	internal string TotalMatrixString => $"{((_flags & VisualFlags.MatrixDirty) != 0 ? "-dirty-" : "")}{_totalMatrix}";
#endif

	/// <remarks>
	/// This should only be called from <see cref="Compositor.InvalidateRenderPartial"/>
	/// </remarks>
	internal void InvalidatePaint()
	{
		if (_picture != IntPtr.Zero)
		{
			UnoSkiaApi.sk_refcnt_safe_unref(_picture);
			_picture = IntPtr.Zero;
		}
		_flags |= VisualFlags.PaintDirty;
		InvalidateParentChildrenPicture(false);
	}

	internal void InvalidateParentChildrenPicture(bool includeSelf)
	{
		var parent = includeSelf ? this : Parent;
		while (parent is not null && (parent._flags & VisualFlags.ChildrenSKPictureInvalid) == 0)
		{
			if (parent._childrenPicture != IntPtr.Zero)
			{
				UnoSkiaApi.sk_refcnt_safe_unref(parent._childrenPicture);
				parent._childrenPicture = IntPtr.Zero;
			}
			parent._flags |= VisualFlags.ChildrenSKPictureInvalid;
			parent = parent.Parent;
		}
	}

	public CompositionClip? Clip
	{
		get => _clip;

Review comment (bug):
Definitely optional, but whenever we swap out SkiaSharp calls for direct P/Invoke'd skia calls, it would be great if we could keep the equivalent SkiaSharp calls that got removed in a comment so that we can restore them back easily to check if there's something wrong with the changes.

Code after:
				if (rotation is not 0)
				{
					transform *= Matrix4x4.CreateTranslation(-CenterPoint);
					transform *= Matrix4x4.CreateFromAxisAngle(RotationAxis, rotation);
					transform *= Matrix4x4.CreateTranslation(CenterPoint);
				}

				return transform;
			}
		}
	}

#if DEBUG
	internal string TotalMatrixString => $"{((_flags & VisualFlags.MatrixDirty) != 0 ? "-dirty-" : "")}{_totalMatrix}";
#endif

	/// <remarks>
	/// This should only be called from <see cref="Compositor.InvalidateRenderPartial"/>
	/// </remarks>
	internal void InvalidatePaint()
	{
		if (_picture != IntPtr.Zero)
		{
			UnoSkiaApi.sk_refcnt_safe_unref(_picture);
			_picture = IntPtr.Zero;
		}
		_flags |= VisualFlags.PaintDirty;
		InvalidateParentChildrenPicture(false);
	}

	internal void InvalidateParentChildrenPicture(bool includeSelf)
	{
		var parent = includeSelf ? this : Parent;
		while (parent is not null && (parent._flags & VisualFlags.ChildrenSKPictureInvalid) == 0)
		{
			if (parent._childrenPicture != IntPtr.Zero)
			{
				UnoSkiaApi.sk_refcnt_safe_unref(parent._childrenPicture);
				parent._childrenPicture = IntPtr.Zero;
			}
			parent._flags |= VisualFlags.ChildrenSKPictureInvalid;
			parent = parent.Parent;
		}
	}

	public CompositionClip? Clip
	{
		get => _clip;
		set => SetProperty(ref _clip, value);
	}
Repository: unoplatform/uno
File: src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_CalendarView.cs (C#)

Code before:

	[TestMethod]
	public async Task When_Spanish_Language()
	{
		var calendarView = new CalendarView();
		TestServices.WindowHelper.WindowContent = calendarView;
		await TestServices.WindowHelper.WaitForLoaded(calendarView);
		calendarView.Language = "es-ES";
		await TestServices.WindowHelper.WaitForIdle();
		calendarView.SetDisplayDate(new DateTimeOffset(new DateTime(2024, 1, 1)));
		await TestServices.WindowHelper.WaitForIdle();
		Assert.AreEqual("enero de 2024", calendarView.TemplateSettings.HeaderText);
	}

	[TestMethod]
	public async Task When_English_Language()
	{
		var calendarView = new CalendarView();
		TestServices.WindowHelper.WindowContent = calendarView;
		await TestServices.WindowHelper.WaitForLoaded(calendarView);
		calendarView.Language = "en"; //default culture usually is en
		await TestServices.WindowHelper.WaitForIdle();
		calendarView.SetDisplayDate(new DateTimeOffset(new DateTime(2024, 1, 1)));
		await TestServices.WindowHelper.WaitForIdle();
		Assert.AreEqual("January 2024", calendarView.TemplateSettings.HeaderText);
	}
}
#endif


Review comment (refactor):
wouldnt it better to setup everything, and then wait:
```suggestion
	public async Task When_Spanish_Language()
	{
		var calendarView = new CalendarView();
		calendarView.Language = "es-ES";
		calendarView.SetDisplayDate(new DateTimeOffset(new DateTime(2024, 1, 1)));
		
		TestServices.WindowHelper.WindowContent = calendarView;
		await TestServices.WindowHelper.WaitForLoaded(calendarView);

		Assert.AreEqual("enero de 2024", calendarView.TemplateSettings.HeaderText);
	}

	[TestMethod]
	public async Task When_English_Language()
	{
		var calendarView = new CalendarView();
		calendarView.Language = "en"; // default culture usually is en
		calendarView.SetDisplayDate(new DateTimeOffset(new DateTime(2024, 1, 1)));

		TestServices.WindowHelper.WindowContent = calendarView;
		await TestServices.WindowHelper.WaitForLoaded(calendarView);
		
		Assert.AreEqual("January 2024", calendarView.TemplateSettings.HeaderText);
	}
```

Code after:

	[TestMethod]
	public async Task When_Spanish_Language()
	{
		var calendarView = new CalendarView()
		{
			Language = "es-ES"
		};
		calendarView.SetDisplayDate(new DateTimeOffset(new DateTime(2024, 1, 1)));
		TestServices.WindowHelper.WindowContent = calendarView;
		await TestServices.WindowHelper.WaitForLoaded(calendarView);
		Assert.AreEqual("enero de 2024", calendarView.TemplateSettings.HeaderText);
	}

	[TestMethod]
	public async Task When_English_Language()
	{
		var calendarView = new CalendarView()
		{
			Language = "en-US"
		};
		calendarView.SetDisplayDate(new DateTimeOffset(new DateTime(2024, 1, 1)));
		TestServices.WindowHelper.WindowContent = calendarView;
		await TestServices.WindowHelper.WaitForLoaded(calendarView);
		Assert.AreEqual("January 2024", calendarView.TemplateSettings.HeaderText);
	}
}
#endif
Repository: unoplatform/uno
File: src/Uno.UWP/Globalization/DateTimeFormatting/DateTimeFormatter.cs (C#)

Code before:
						builder.Append("{timezone.abbreviated(2)}");
						count -= 2;
					}

					while (count >= 1)
					{
						builder.Append("{timezone.abbreviated(1)}");
						count -= 1;
					}

					break;

				default:
					builder.Append(lastChar, count);
					break;
			}
		}

		string ConstructPattern(string str)
		{
			if (string.IsNullOrEmpty(str))
			{
				return string.Empty;
			}

			char singleQuoteChar = '\'';
			var builder = new StringBuilder();
			int i = 0;
			int len = str.Length;

			while (i < len)
			{
				char currentChar = str[i];

				// Handle quoted section (literals) "MMMM 'de' yyyy"
				if (currentChar == singleQuoteChar)
				{
					i++;
					var literal = new StringBuilder();

					while (i < len)
					{
						if (str[i] == singleQuoteChar)
						{
							if (i + 1 < len && str[i + 1] == singleQuoteChar)
							{
								literal.Append(singleQuoteChar);
								i += 2;
							}
							else
							{

Review comment (suggestion):
```suggestion
			const char SingleQuoteChar = '\'';
```

Code after:
						builder.Append("{timezone.abbreviated(2)}");
						count -= 2;
					}

					while (count >= 1)
					{
						builder.Append("{timezone.abbreviated(1)}");
						count -= 1;
					}

					break;

				default:
					builder.Append(lastChar, count);
					break;
			}
		}

		string ConstructPattern(string str)
		{
			if (string.IsNullOrEmpty(str))
			{
				return string.Empty;
			}

			var builder = new StringBuilder();

			foreach (var part in StringLiteralRegex().Split(str))
			{
				// skip empty block
				if (part.Length == 0)
				{
					continue;
				}
				// add quoted literal as is, without the quotes
				else if (part.StartsWith('\''))
				{
					if (part.Length > 2)
					{
						builder.Append(part[1..^1]);
					}
				}
				// for non-quoted parts, further segment them by grouping repeated character(s)
				else
				{
					foreach (var segment in RepeatedCharactersRegex().EnumerateMatches(part))
					{
						AddToBuilder(builder, part[segment.Index], segment.Length);
					}
				}
			}