Repository: unoplatform/uno
File: src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.skia.cs (C#)

Code before:
	{
		private readonly TextVisual _textVisual;
		private Action? _selectionHighlightColorChanged;
		private MenuFlyout? _contextMenu;
		private IDisposable? _selectionHighlightBrushChangedSubscription;
		private readonly Dictionary<ContextMenuItem, MenuFlyoutItem> _flyoutItems = new();
		private readonly VirtualKeyModifiers _platformCtrlKey = OperatingSystem.IsMacOS() ? VirtualKeyModifiers.Windows : VirtualKeyModifiers.Control;

		public TextBlock()
		{
			UpdateLastUsedTheme();
			_textVisual = new TextVisual(Visual.Compositor, this);

			Visual.Children.InsertAtBottom(_textVisual);

			_hyperlinks.CollectionChanged += HyperlinksOnCollectionChanged;

			DoubleTapped += (s, e) => ((TextBlock)s).OnDoubleTapped(e);
			RightTapped += (s, e) => ((TextBlock)s).OnRightTapped(e);
			KeyDown += (s, e) => ((TextBlock)s).OnKeyDown(e);

			GotFocus += (_, _) => UpdateSelectionRendering();
			LostFocus += (_, _) => UpdateSelectionRendering();
		}

		internal bool IsTextBoxDisplay { get; set; }

#if DEBUG
		private protected override void OnLoaded()
		{
			base.OnLoaded();
			_textVisual.Comment = $"{Visual.Comment}#text";
		}
#endif

		protected override Size MeasureOverride(Size availableSize)
		{
			var padding = Padding;
			var availableSizeWithoutPadding = availableSize.Subtract(padding).AtLeastZero();
			var defaultLineHeight = GetComputedLineHeight();
			var desiredSize = Inlines.Measure(availableSizeWithoutPadding, defaultLineHeight);

			desiredSize = desiredSize.Add(padding);

			if (GetUseLayoutRounding())
			{
				// In order to prevent text clipping as a result of layout rounding at
				// scales other than 1.0x, the ceiling of the rescaled size is used.
				var plateauScale = RootScale.GetRasterizationScaleForElement(this);
				Size pageNodeSize = desiredSize;
				desiredSize.Width = ((int)Math.Ceiling(pageNodeSize.Width * plateauScale)) / plateauScale;

Review comment (suggestion):
Would there be any benefit in marking this property setter as `init` as I see we only initialize it once?

```suggestion
		internal bool IsTextBoxDisplay { get; init; }
```

Code after:
	{
		private readonly TextVisual _textVisual;
		private Action? _selectionHighlightColorChanged;
		private MenuFlyout? _contextMenu;
		private IDisposable? _selectionHighlightBrushChangedSubscription;
		private readonly Dictionary<ContextMenuItem, MenuFlyoutItem> _flyoutItems = new();
		private readonly VirtualKeyModifiers _platformCtrlKey = OperatingSystem.IsMacOS() ? VirtualKeyModifiers.Windows : VirtualKeyModifiers.Control;

		public TextBlock()
		{
			UpdateLastUsedTheme();
			_textVisual = new TextVisual(Visual.Compositor, this);

			Visual.Children.InsertAtBottom(_textVisual);

			_hyperlinks.CollectionChanged += HyperlinksOnCollectionChanged;

			DoubleTapped += (s, e) => ((TextBlock)s).OnDoubleTapped(e);
			RightTapped += (s, e) => ((TextBlock)s).OnRightTapped(e);
			KeyDown += (s, e) => ((TextBlock)s).OnKeyDown(e);

			GotFocus += (_, _) => UpdateSelectionRendering();
			LostFocus += (_, _) => UpdateSelectionRendering();
		}

		internal bool IsTextBoxDisplay { get; init; }

#if DEBUG
		private protected override void OnLoaded()
		{
			base.OnLoaded();
			_textVisual.Comment = $"{Visual.Comment}#text";
		}
#endif

		protected override Size MeasureOverride(Size availableSize)
		{
			var padding = Padding;
			var availableSizeWithoutPadding = availableSize.Subtract(padding).AtLeastZero();
			var defaultLineHeight = GetComputedLineHeight();
			var desiredSize = Inlines.Measure(availableSizeWithoutPadding, defaultLineHeight);

			desiredSize = desiredSize.Add(padding);

			if (GetUseLayoutRounding())
			{
				// In order to prevent text clipping as a result of layout rounding at
				// scales other than 1.0x, the ceiling of the rescaled size is used.
				var plateauScale = RootScale.GetRasterizationScaleForElement(this);
				Size pageNodeSize = desiredSize;
				desiredSize.Width = ((int)Math.Ceiling(pageNodeSize.Width * plateauScale)) / plateauScale;