Browse Source

Merge branch 'master' into restore-RaisePropertyChanged

pull/9905/head
Jumar Macato 3 years ago
committed by GitHub
parent
commit
16165fc8df
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      Directory.Build.props
  2. 1
      build/SharedVersion.props
  3. 2
      global.json
  4. 2
      samples/ControlCatalog.Desktop/Program.cs
  5. 2
      samples/ControlCatalog/Pages/PointerCanvas.cs
  6. 58
      samples/ControlCatalog/Pages/ScreenPage.cs
  7. 2
      samples/ControlCatalog/Pages/TabControlPage.xaml.cs
  8. 2
      samples/ControlCatalog/Pages/TextBoxPage.xaml
  9. 7
      samples/ControlCatalog/ViewModels/ContextPageViewModel.cs
  10. 2
      samples/ControlCatalog/ViewModels/CursorPageViewModel.cs
  11. 2
      samples/ControlCatalog/ViewModels/TransitioningContentControlPageViewModel.cs
  12. 5
      samples/Directory.Build.props
  13. 21
      src/Avalonia.Base/Controls/NameScopeExtensions.cs
  14. 2
      src/Avalonia.Base/Data/Converters/FuncMultiValueConverter.cs
  15. 3
      src/Avalonia.Base/Input/Cursor.cs
  16. 2
      src/Avalonia.Base/Layout/WrapLayout/UvMeasure.cs
  17. 2
      src/Avalonia.Base/Media/DrawingContext.cs
  18. 4
      src/Avalonia.Base/Media/DrawingGroup.cs
  19. 5
      src/Avalonia.Base/Media/FontManager.cs
  20. 2
      src/Avalonia.Base/Media/ImmediateDrawingContext.cs
  21. 27
      src/Avalonia.Base/Media/TextFormatting/CharacterBufferRange.cs
  22. 2
      src/Avalonia.Base/Media/TextFormatting/FormattedTextSource.cs
  23. 2
      src/Avalonia.Base/Media/TextFormatting/InterWordJustification.cs
  24. 12
      src/Avalonia.Base/Media/TextFormatting/ShapedTextRun.cs
  25. 22
      src/Avalonia.Base/Media/TextFormatting/TextCharacters.cs
  26. 2
      src/Avalonia.Base/Media/TextFormatting/TextEllipsisHelper.cs
  27. 28
      src/Avalonia.Base/Media/TextFormatting/TextFormatterImpl.cs
  28. 4
      src/Avalonia.Base/Media/TextFormatting/TextLeadingPrefixCharacterEllipsis.cs
  29. 40
      src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs
  30. 7
      src/Avalonia.Base/Media/TextFormatting/TextParagraphProperties.cs
  31. 2
      src/Avalonia.Base/Media/TextFormatting/TextRun.cs
  32. 5
      src/Avalonia.Base/Media/TextFormatting/TextShaper.cs
  33. 68
      src/Avalonia.Base/Media/TextFormatting/Unicode/Codepoint.cs
  34. 14
      src/Avalonia.Base/Media/TextFormatting/Unicode/Grapheme.cs
  35. 4
      src/Avalonia.Base/Media/TextFormatting/Unicode/GraphemeEnumerator.cs
  36. 16
      src/Avalonia.Base/Media/TextFormatting/UnshapedTextRun.cs
  37. 2
      src/Avalonia.Base/Rendering/Composition/Expressions/ExpressionVariant.cs
  38. 6
      src/Avalonia.Base/Rendering/ImmediateRenderer.cs
  39. 3
      src/Avalonia.Base/Rendering/RenderLoop.cs
  40. 2
      src/Avalonia.Base/Rendering/Utilities/TileBrushCalculator.cs
  41. 8
      src/Avalonia.Base/Threading/DispatcherTimer.cs
  42. 2
      src/Avalonia.Base/Utilities/SingleOrDictionary.cs
  43. 4
      src/Avalonia.Base/Utilities/StringTokenizer.cs
  44. 1
      src/Avalonia.Base/Visual.cs
  45. 4
      src/Avalonia.Build.Tasks/ComInteropHelper.cs
  46. 5
      src/Avalonia.Controls.DataGrid/DataGrid.cs
  47. 11
      src/Avalonia.Controls.DataGrid/DataGridColumn.cs
  48. 16
      src/Avalonia.Controls.DataGrid/DataGridTemplateColumn.cs
  49. 2
      src/Avalonia.Controls.DataGrid/IndexToValueTable.cs
  50. 1
      src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs
  51. 8
      src/Avalonia.Controls/Control.cs
  52. 2
      src/Avalonia.Controls/Platform/InProcessDragSource.cs
  53. 11
      src/Avalonia.Controls/Platform/PlatformManager.cs
  54. 5
      src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs
  55. 4
      src/Avalonia.Controls/PullToRefresh/ScrollViewerIRefreshInfoProviderAdapter.cs
  56. 16
      src/Avalonia.Controls/Repeater/ViewportManager.cs
  57. 4
      src/Avalonia.Controls/Templates/FuncTreeDataTemplate`1.cs
  58. 2
      src/Avalonia.Controls/TextBox.cs
  59. 2
      src/Avalonia.Controls/Utils/UndoRedoHelper.cs
  60. 5
      src/Avalonia.DesignerSupport/DesignWindowLoader.cs
  61. 8
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs
  62. 2
      src/Avalonia.Dialogs/Internal/ManagedFileChooserViewModel.cs
  63. 8
      src/Avalonia.FreeDesktop/DBusMenu.cs
  64. 2
      src/Avalonia.OpenGL/Egl/EglInterface.cs
  65. 2
      src/Avalonia.X11/X11Framebuffer.cs
  66. 2
      src/Avalonia.X11/X11Platform.cs
  67. 1
      src/Browser/Avalonia.Browser/Avalonia.Browser.csproj
  68. 2
      src/Browser/Avalonia.Browser/AvaloniaView.cs
  69. 2
      src/Browser/Avalonia.Browser/Interop/StorageHelper.cs
  70. 2
      src/Linux/Avalonia.LinuxFramebuffer/FramebufferToplevelImpl.cs
  71. 2
      src/Markup/Avalonia.Markup.Xaml/Converters/BitmapTypeConverter.cs
  72. 2
      src/Markup/Avalonia.Markup.Xaml/Converters/IconTypeConverter.cs
  73. 12
      src/Markup/Avalonia.Markup/Markup/Parsers/SelectorGrammar.cs
  74. 4
      src/Skia/Avalonia.Skia/DrawingContextImpl.cs
  75. 2
      src/Skia/Avalonia.Skia/GeometryImpl.cs
  76. 2
      src/Skia/Avalonia.Skia/SKTypefaceCollectionCache.cs
  77. 6
      src/Skia/Avalonia.Skia/WriteableBitmapImpl.cs
  78. 2
      src/Windows/Avalonia.Direct2D1/Media/DWriteResourceFontLoader.cs
  79. 2
      src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs
  80. 6
      src/Windows/Avalonia.Win32.Interop/Wpf/Direct2DImageSurface.cs
  81. 2
      src/Windows/Avalonia.Win32.Interop/Wpf/IntSize.cs
  82. 2
      src/Windows/Avalonia.Win32/DataObject.cs
  83. 2
      src/Windows/Avalonia.Win32/OleDropTarget.cs
  84. 2
      src/Windows/Avalonia.Win32/WindowImpl.CustomCaptionProc.cs
  85. 1
      src/tools/DevAnalyzers/DevAnalyzers.csproj
  86. 1
      src/tools/DevGenerators/DevGenerators.csproj
  87. 1
      tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj
  88. 2
      tests/Avalonia.Base.UnitTests/Media/Fonts/FontFamilyLoaderTests.cs
  89. 4
      tests/Avalonia.Base.UnitTests/Media/TextFormatting/GraphemeBreakClassTrieGeneratorTests.cs
  90. 62
      tests/Avalonia.Benchmarks/Text/HugeTextLayout.cs
  91. 1
      tests/Avalonia.Controls.DataGrid.UnitTests/Avalonia.Controls.DataGrid.UnitTests.csproj
  92. 1
      tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj
  93. 2
      tests/Avalonia.Controls.UnitTests/ContextMenuTests.cs
  94. 2
      tests/Avalonia.Controls.UnitTests/FlyoutTests.cs
  95. 2
      tests/Avalonia.Controls.UnitTests/MaskedTextBoxTests.cs
  96. 2
      tests/Avalonia.Controls.UnitTests/Presenters/ItemsPresenterTests_Virtualization_Simple.cs
  97. 2
      tests/Avalonia.Controls.UnitTests/Primitives/PopupTests.cs
  98. 4
      tests/Avalonia.Controls.UnitTests/TextBoxTests.cs
  99. 9
      tests/Avalonia.Controls.UnitTests/TreeViewTests.cs
  100. 1
      tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj

1
Directory.Build.props

@ -7,5 +7,6 @@
<AddSyntheticProjectReferencesForSolutionDependencies>false</AddSyntheticProjectReferencesForSolutionDependencies>
<MSBuildEnableWorkloadResolver>false</MSBuildEnableWorkloadResolver>
<RunApiCompat>False</RunApiCompat>
<LangVersion>11</LangVersion>
</PropertyGroup>
</Project>

1
build/SharedVersion.props

@ -8,7 +8,6 @@
<RepositoryUrl>https://github.com/AvaloniaUI/Avalonia/</RepositoryUrl>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<LangVersion>preview</LangVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>Icon.png</PackageIcon>
<PackageDescription>Avalonia is a cross-platform UI framework for .NET providing a flexible styling system and supporting a wide range of Operating Systems such as Windows, Linux, macOS and with experimental support for Android, iOS and WebAssembly.</PackageDescription>

2
global.json

@ -4,6 +4,6 @@
"rollForward": "latestFeature"
},
"msbuild-sdks": {
"Microsoft.Build.Traversal": "1.0.43"
"Microsoft.Build.Traversal": "3.2.0"
}
}

2
samples/ControlCatalog.Desktop/Program.cs

@ -23,7 +23,7 @@ namespace ControlCatalog
private static void ConfigureAssetAssembly(AppBuilder builder)
{
AvaloniaLocator.CurrentMutable
.GetService<IAssetLoader>()
.GetRequiredService<IAssetLoader>()
.SetDefaultAssembly(typeof(App).Assembly);
}
}

2
samples/ControlCatalog/Pages/PointerCanvas.cs

@ -24,7 +24,7 @@ public class PointerCanvas : Control
{
struct CanvasPoint
{
public IBrush Brush;
public IBrush? Brush;
public Point Point;
public double Radius;
public double? Pressure;

58
samples/ControlCatalog/Pages/ScreenPage.cs

@ -36,44 +36,44 @@ namespace ControlCatalog.Pages
var drawBrush = Brushes.Black;
Pen p = new Pen(drawBrush);
if (screens != null)
foreach (Screen screen in screens)
foreach (Screen screen in screens)
{
if (screen.Bounds.X / 10f < _leftMost)
{
if (screen.Bounds.X / 10f < _leftMost)
{
_leftMost = screen.Bounds.X / 10f;
Dispatcher.UIThread.Post(InvalidateVisual, DispatcherPriority.Background);
return;
}
_leftMost = screen.Bounds.X / 10f;
Dispatcher.UIThread.Post(InvalidateVisual, DispatcherPriority.Background);
return;
}
Rect boundsRect = new Rect(screen.Bounds.X / 10f + Math.Abs(_leftMost), screen.Bounds.Y / 10f, screen.Bounds.Width / 10f,
screen.Bounds.Height / 10f);
Rect workingAreaRect = new Rect(screen.WorkingArea.X / 10f + Math.Abs(_leftMost), screen.WorkingArea.Y / 10f, screen.WorkingArea.Width / 10f,
screen.WorkingArea.Height / 10f);
context.DrawRectangle(p, boundsRect);
context.DrawRectangle(p, workingAreaRect);
Rect boundsRect = new Rect(screen.Bounds.X / 10f + Math.Abs(_leftMost), screen.Bounds.Y / 10f, screen.Bounds.Width / 10f,
screen.Bounds.Height / 10f);
Rect workingAreaRect = new Rect(screen.WorkingArea.X / 10f + Math.Abs(_leftMost), screen.WorkingArea.Y / 10f, screen.WorkingArea.Width / 10f,
screen.WorkingArea.Height / 10f);
context.DrawRectangle(p, boundsRect);
context.DrawRectangle(p, workingAreaRect);
var formattedText = CreateFormattedText($"Bounds: {screen.Bounds.Width}:{screen.Bounds.Height}");
context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height));
formattedText =
CreateFormattedText($"WorkArea: {screen.WorkingArea.Width}:{screen.WorkingArea.Height}");
context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 20));
var formattedText = CreateFormattedText($"Bounds: {screen.Bounds.Width}:{screen.Bounds.Height}");
context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height));
formattedText = CreateFormattedText($"Scaling: {screen.Scaling * 100}%");
context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 40));
formattedText =
CreateFormattedText($"WorkArea: {screen.WorkingArea.Width}:{screen.WorkingArea.Height}");
context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 20));
formattedText = CreateFormattedText($"IsPrimary: {screen.IsPrimary}");
formattedText = CreateFormattedText($"Scaling: {screen.Scaling * 100}%");
context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 40));
context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 60));
formattedText = CreateFormattedText($"IsPrimary: {screen.IsPrimary}");
formattedText =
CreateFormattedText(
$"Current: {screen.Equals(w.Screens.ScreenFromBounds(new PixelRect(w.Position, PixelSize.FromSize(w.Bounds.Size, scaling))))}");
context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 80));
}
context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 60));
formattedText =
CreateFormattedText(
$"Current: {screen.Equals(w.Screens.ScreenFromBounds(new PixelRect(w.Position, PixelSize.FromSize(w.Bounds.Size, scaling))))}");
context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 80));
}
context.DrawRectangle(p, new Rect(w.Position.X / 10f + Math.Abs(_leftMost), w.Position.Y / 10f, w.Bounds.Width / 10, w.Bounds.Height / 10));
}

2
samples/ControlCatalog/Pages/TabControlPage.xaml.cs

@ -51,7 +51,7 @@ namespace ControlCatalog.Pages
private static IBitmap LoadBitmap(string uri)
{
var assets = AvaloniaLocator.Current!.GetService<IAssetLoader>()!;
var assets = AvaloniaLocator.Current.GetRequiredService<IAssetLoader>();
return new Bitmap(assets.Open(new Uri(uri)));
}
}

2
samples/ControlCatalog/Pages/TextBoxPage.xaml

@ -38,7 +38,7 @@
UseFloatingWatermark="True"
PasswordChar="*"
Text="Password" />
<TextBox Width="200" Text="Left aligned text" TextAlignment="Left" />
<TextBox Width="200" Text="Left aligned text" TextAlignment="Left" AcceptsTab="True" />
<TextBox Width="200" Text="Center aligned text" TextAlignment="Center" />
<TextBox Width="200" Text="Right aligned text" TextAlignment="Right" />
<TextBox Width="200" Text="Custom selection brush"

7
samples/ControlCatalog/ViewModels/ContextPageViewModel.cs

@ -56,12 +56,9 @@ namespace ControlCatalog.ViewModels
var result = await window.StorageProvider.OpenFilePickerAsync(new Avalonia.Platform.Storage.FilePickerOpenOptions() { AllowMultiple = true });
if (result != null)
foreach (var file in result)
{
foreach (var file in result)
{
System.Diagnostics.Debug.WriteLine($"Opened: {file.Name}");
}
System.Diagnostics.Debug.WriteLine($"Opened: {file.Name}");
}
}

2
samples/ControlCatalog/ViewModels/CursorPageViewModel.cs

@ -18,7 +18,7 @@ namespace ControlCatalog.ViewModels
.Select(x => new StandardCursorModel(x))
.ToList();
var loader = AvaloniaLocator.Current!.GetService<IAssetLoader>()!;
var loader = AvaloniaLocator.Current.GetRequiredService<IAssetLoader>();
var s = loader.Open(new Uri("avares://ControlCatalog/Assets/avalonia-32.png"));
var bitmap = new Bitmap(s);
CustomCursor = new Cursor(bitmap, new PixelPoint(16, 16));

2
samples/ControlCatalog/ViewModels/TransitioningContentControlPageViewModel.cs

@ -19,7 +19,7 @@ namespace ControlCatalog.ViewModels
{
public TransitioningContentControlPageViewModel()
{
var assetLoader = AvaloniaLocator.Current?.GetService<IAssetLoader>()!;
var assetLoader = AvaloniaLocator.Current.GetRequiredService<IAssetLoader>();
var images = new string[]
{

5
samples/Directory.Build.props

@ -2,9 +2,8 @@
<PropertyGroup>
<IsPackable>false</IsPackable>
<AvaloniaPreviewerNetCoreToolPath>$(MSBuildThisFileDirectory)..\src\tools\Avalonia.Designer.HostApp\bin\Debug\netcoreapp2.0\Avalonia.Designer.HostApp.dll</AvaloniaPreviewerNetCoreToolPath>
<EnableNETAnalyzers>false</EnableNETAnalyzers>
<LangVersion>11</LangVersion>
</PropertyGroup>
<Import Project="..\build\SharedVersion.props" />
<PropertyGroup>
<EnableNETAnalyzers>false</EnableNETAnalyzers>
</PropertyGroup>
</Project>

21
src/Avalonia.Base/Controls/NameScopeExtensions.cs

@ -25,13 +25,18 @@ namespace Avalonia.Controls
var result = nameScope.Find(name);
if (result != null && !(result is T))
if (result == null)
{
throw new InvalidOperationException(
$"Expected control '{name}' to be '{typeof(T)} but it was '{result.GetType()}'.");
return null;
}
return (T?)result;
if (result is T typed)
{
return typed;
}
throw new InvalidOperationException(
$"Expected control '{name}' to be '{typeof(T)} but it was '{result.GetType()}'.");
}
/// <summary>
@ -74,13 +79,13 @@ namespace Avalonia.Controls
throw new KeyNotFoundException($"Could not find control '{name}'.");
}
if (!(result is T))
if (result is T typed)
{
throw new InvalidOperationException(
$"Expected control '{name}' to be '{typeof(T)} but it was '{result.GetType()}'.");
return typed;
}
return (T)result;
throw new InvalidOperationException(
$"Expected control '{name}' to be '{typeof(T)} but it was '{result.GetType()}'.");
}
/// <summary>

2
src/Avalonia.Base/Data/Converters/FuncMultiValueConverter.cs

@ -38,7 +38,7 @@ namespace Avalonia.Data.Converters
}
else if (Equals(obj, default(TIn)))
{
yield return default(TIn);
yield return default;
}
}
}

3
src/Avalonia.Base/Input/Cursor.cs

@ -71,8 +71,7 @@ namespace Avalonia.Input
private static ICursorFactory GetCursorFactory()
{
return AvaloniaLocator.Current.GetService<ICursorFactory>() ??
throw new Exception("Could not create Cursor: ICursorFactory not registered.");
return AvaloniaLocator.Current.GetRequiredService<ICursorFactory>();
}
}
}

2
src/Avalonia.Base/Layout/WrapLayout/UvMeasure.cs

@ -7,7 +7,7 @@ namespace Avalonia.Layout
{
internal struct UvMeasure
{
internal static readonly UvMeasure Zero = default(UvMeasure);
internal static readonly UvMeasure Zero = default;
internal double U { get; set; }

2
src/Avalonia.Base/Media/DrawingContext.cs

@ -279,7 +279,7 @@ namespace Avalonia.Media
OpacityMask,
}
public PushedState(DrawingContext context, PushedStateType type, Matrix matrix = default(Matrix))
public PushedState(DrawingContext context, PushedStateType type, Matrix matrix = default)
{
if (context._states is null)
throw new ObjectDisposedException(nameof(DrawingContext));

4
src/Avalonia.Base/Media/DrawingGroup.cs

@ -76,8 +76,8 @@ namespace Avalonia.Media
{
using (context.PushPreTransform(Transform?.Value ?? Matrix.Identity))
using (context.PushOpacity(Opacity))
using (ClipGeometry != null ? context.PushGeometryClip(ClipGeometry) : default(DrawingContext.PushedState))
using (OpacityMask != null ? context.PushOpacityMask(OpacityMask, GetBounds()) : default(DrawingContext.PushedState))
using (ClipGeometry != null ? context.PushGeometryClip(ClipGeometry) : default)
using (OpacityMask != null ? context.PushOpacityMask(OpacityMask, GetBounds()) : default)
{
foreach (var drawing in Children)
{

5
src/Avalonia.Base/Media/FontManager.cs

@ -47,10 +47,7 @@ namespace Avalonia.Media
return current;
}
var fontManagerImpl = AvaloniaLocator.Current.GetService<IFontManagerImpl>();
if (fontManagerImpl == null)
throw new InvalidOperationException("No font manager implementation was registered.");
var fontManagerImpl = AvaloniaLocator.Current.GetRequiredService<IFontManagerImpl>();
current = new FontManager(fontManagerImpl);

2
src/Avalonia.Base/Media/ImmediateDrawingContext.cs

@ -218,7 +218,7 @@ namespace Avalonia.Media
OpacityMask,
}
internal PushedState(ImmediateDrawingContext context, PushedStateType type, Matrix matrix = default(Matrix))
internal PushedState(ImmediateDrawingContext context, PushedStateType type, Matrix matrix = default)
{
if (context._states is null)
throw new ObjectDisposedException(nameof(ImmediateDrawingContext));

27
src/Avalonia.Base/Media/TextFormatting/CharacterBufferRange.cs

@ -140,7 +140,7 @@ namespace Avalonia.Media.TextFormatting
throw new ArgumentOutOfRangeException(nameof(index));
}
#endif
return Span[index];
return CharacterBufferReference.CharacterBuffer.Span[CharacterBufferReference.OffsetToFirstChar + index];
}
}
@ -163,27 +163,18 @@ namespace Avalonia.Media.TextFormatting
/// <summary>
/// Gets the character memory buffer
/// </summary>
internal ReadOnlyMemory<char> CharacterBuffer
{
get { return CharacterBufferReference.CharacterBuffer; }
}
internal ReadOnlyMemory<char> CharacterBuffer => CharacterBufferReference.CharacterBuffer;
/// <summary>
/// Gets the character offset relative to the beginning of buffer to
/// the first character of the run
/// </summary>
internal int OffsetToFirstChar
{
get { return CharacterBufferReference.OffsetToFirstChar; }
}
internal int OffsetToFirstChar => CharacterBufferReference.OffsetToFirstChar;
/// <summary>
/// Indicate whether the character buffer range is empty
/// </summary>
internal bool IsEmpty
{
get { return CharacterBufferReference.CharacterBuffer.Length == 0 || Length <= 0; }
}
internal bool IsEmpty => CharacterBufferReference.CharacterBuffer.Length == 0 || Length <= 0;
internal CharacterBufferRange Take(int length)
{
@ -280,14 +271,8 @@ namespace Avalonia.Media.TextFormatting
int IReadOnlyCollection<char>.Count => Length;
public IEnumerator<char> GetEnumerator()
{
return new ImmutableReadOnlyListStructEnumerator<char>(this);
}
public IEnumerator<char> GetEnumerator() => new ImmutableReadOnlyListStructEnumerator<char>(this);
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}

2
src/Avalonia.Base/Media/TextFormatting/FormattedTextSource.cs

@ -132,7 +132,7 @@ namespace Avalonia.Media.TextFormatting
{
var grapheme = graphemeEnumerator.Current;
finalLength += grapheme.Text.Length;
finalLength += grapheme.Length;
if (finalLength >= length)
{

2
src/Avalonia.Base/Media/TextFormatting/InterWordJustification.cs

@ -91,7 +91,7 @@ namespace Avalonia.Media.TextFormatting
continue;
}
if (textRun is ShapedTextCharacters shapedText)
if (textRun is ShapedTextRun shapedText)
{
var glyphRun = shapedText.GlyphRun;
var shapedBuffer = shapedText.ShapedBuffer;

12
src/Avalonia.Base/Media/TextFormatting/ShapedTextCharacters.cs → src/Avalonia.Base/Media/TextFormatting/ShapedTextRun.cs

@ -6,11 +6,11 @@ namespace Avalonia.Media.TextFormatting
/// <summary>
/// A text run that holds shaped characters.
/// </summary>
public sealed class ShapedTextCharacters : DrawableTextRun
public sealed class ShapedTextRun : DrawableTextRun
{
private GlyphRun? _glyphRun;
public ShapedTextCharacters(ShapedBuffer shapedBuffer, TextRunProperties properties)
public ShapedTextRun(ShapedBuffer shapedBuffer, TextRunProperties properties)
{
ShapedBuffer = shapedBuffer;
CharacterBufferReference = shapedBuffer.CharacterBufferRange.CharacterBufferReference;
@ -155,7 +155,7 @@ namespace Avalonia.Media.TextFormatting
return length > 0;
}
internal SplitResult<ShapedTextCharacters> Split(int length)
internal SplitResult<ShapedTextRun> Split(int length)
{
if (IsReversed)
{
@ -171,7 +171,7 @@ namespace Avalonia.Media.TextFormatting
var splitBuffer = ShapedBuffer.Split(length);
var first = new ShapedTextCharacters(splitBuffer.First, Properties);
var first = new ShapedTextRun(splitBuffer.First, Properties);
#if DEBUG
@ -182,9 +182,9 @@ namespace Avalonia.Media.TextFormatting
#endif
var second = new ShapedTextCharacters(splitBuffer.Second!, Properties);
var second = new ShapedTextRun(splitBuffer.Second!, Properties);
return new SplitResult<ShapedTextCharacters>(first, second);
return new SplitResult<ShapedTextRun>(first, second);
}
internal GlyphRun CreateGlyphRun()

22
src/Avalonia.Base/Media/TextFormatting/TextCharacters.cs

@ -91,12 +91,12 @@ namespace Avalonia.Media.TextFormatting
public override TextRunProperties Properties { get; }
/// <summary>
/// Gets a list of <see cref="ShapeableTextCharacters"/>.
/// Gets a list of <see cref="UnshapedTextRun"/>.
/// </summary>
/// <returns>The shapeable text characters.</returns>
internal IReadOnlyList<ShapeableTextCharacters> GetShapeableCharacters(CharacterBufferRange characterBufferRange, sbyte biDiLevel, ref TextRunProperties? previousProperties)
internal IReadOnlyList<UnshapedTextRun> GetShapeableCharacters(CharacterBufferRange characterBufferRange, sbyte biDiLevel, ref TextRunProperties? previousProperties)
{
var shapeableCharacters = new List<ShapeableTextCharacters>(2);
var shapeableCharacters = new List<UnshapedTextRun>(2);
while (characterBufferRange.Length > 0)
{
@ -120,7 +120,7 @@ namespace Avalonia.Media.TextFormatting
/// <param name="biDiLevel">The bidi level of the run.</param>
/// <param name="previousProperties"></param>
/// <returns>A list of shapeable text runs.</returns>
private static ShapeableTextCharacters CreateShapeableRun(CharacterBufferRange characterBufferRange,
private static UnshapedTextRun CreateShapeableRun(CharacterBufferRange characterBufferRange,
TextRunProperties defaultProperties, sbyte biDiLevel, ref TextRunProperties? previousProperties)
{
var defaultTypeface = defaultProperties.Typeface;
@ -133,12 +133,12 @@ namespace Avalonia.Media.TextFormatting
{
if (TryGetShapeableLength(characterBufferRange, previousTypeface.Value, null, out var fallbackCount, out _))
{
return new ShapeableTextCharacters(characterBufferRange.CharacterBufferReference, fallbackCount,
return new UnshapedTextRun(characterBufferRange.CharacterBufferReference, fallbackCount,
defaultProperties.WithTypeface(previousTypeface.Value), biDiLevel);
}
}
return new ShapeableTextCharacters(characterBufferRange.CharacterBufferReference, count, defaultProperties.WithTypeface(currentTypeface),
return new UnshapedTextRun(characterBufferRange.CharacterBufferReference, count, defaultProperties.WithTypeface(currentTypeface),
biDiLevel);
}
@ -146,7 +146,7 @@ namespace Avalonia.Media.TextFormatting
{
if (TryGetShapeableLength(characterBufferRange, previousTypeface.Value, defaultTypeface, out count, out _))
{
return new ShapeableTextCharacters(characterBufferRange.CharacterBufferReference, count,
return new UnshapedTextRun(characterBufferRange.CharacterBufferReference, count,
defaultProperties.WithTypeface(previousTypeface.Value), biDiLevel);
}
}
@ -176,7 +176,7 @@ namespace Avalonia.Media.TextFormatting
if (matchFound && TryGetShapeableLength(characterBufferRange, currentTypeface, defaultTypeface, out count, out _))
{
//Fallback found
return new ShapeableTextCharacters(characterBufferRange.CharacterBufferReference, count, defaultProperties.WithTypeface(currentTypeface),
return new UnshapedTextRun(characterBufferRange.CharacterBufferReference, count, defaultProperties.WithTypeface(currentTypeface),
biDiLevel);
}
@ -196,10 +196,10 @@ namespace Avalonia.Media.TextFormatting
break;
}
count += grapheme.Text.Length;
count += grapheme.Length;
}
return new ShapeableTextCharacters(characterBufferRange.CharacterBufferReference, count, defaultProperties, biDiLevel);
return new UnshapedTextRun(characterBufferRange.CharacterBufferReference, count, defaultProperties, biDiLevel);
}
/// <summary>
@ -264,7 +264,7 @@ namespace Avalonia.Media.TextFormatting
}
}
length += currentGrapheme.Text.Length;
length += currentGrapheme.Length;
}
return length > 0;

2
src/Avalonia.Base/Media/TextFormatting/TextEllipsisHelper.cs

@ -31,7 +31,7 @@ namespace Avalonia.Media.TextFormatting
switch (currentRun)
{
case ShapedTextCharacters shapedRun:
case ShapedTextRun shapedRun:
{
currentWidth += shapedRun.Size.Width;

28
src/Avalonia.Base/Media/TextFormatting/TextFormatterImpl.cs

@ -124,7 +124,7 @@ namespace Avalonia.Media.TextFormatting
var second = new List<DrawableTextRun>(secondCount);
if (currentRun is ShapedTextCharacters shapedTextCharacters)
if (currentRun is ShapedTextRun shapedTextCharacters)
{
var split = shapedTextCharacters.Split(length - currentLength);
@ -206,16 +206,16 @@ namespace Avalonia.Media.TextFormatting
break;
}
case ShapeableTextCharacters shapeableRun:
case UnshapedTextRun shapeableRun:
{
var groupedRuns = new List<ShapeableTextCharacters>(2) { shapeableRun };
var groupedRuns = new List<UnshapedTextRun>(2) { shapeableRun };
var characterBufferReference = currentRun.CharacterBufferReference;
var length = currentRun.Length;
var offsetToFirstCharacter = characterBufferReference.OffsetToFirstChar;
while (index + 1 < processedRuns.Count)
{
if (processedRuns[index + 1] is not ShapeableTextCharacters nextRun)
if (processedRuns[index + 1] is not UnshapedTextRun nextRun)
{
break;
}
@ -258,10 +258,10 @@ namespace Avalonia.Media.TextFormatting
return drawableTextRuns;
}
private static IReadOnlyList<ShapedTextCharacters> ShapeTogether(
IReadOnlyList<ShapeableTextCharacters> textRuns, CharacterBufferReference text, int length, TextShaperOptions options)
private static IReadOnlyList<ShapedTextRun> ShapeTogether(
IReadOnlyList<UnshapedTextRun> textRuns, CharacterBufferReference text, int length, TextShaperOptions options)
{
var shapedRuns = new List<ShapedTextCharacters>(textRuns.Count);
var shapedRuns = new List<ShapedTextRun>(textRuns.Count);
var shapedBuffer = TextShaper.Current.ShapeText(text, length, options);
@ -271,7 +271,7 @@ namespace Avalonia.Media.TextFormatting
var splitResult = shapedBuffer.Split(currentRun.Length);
shapedRuns.Add(new ShapedTextCharacters(splitResult.First, currentRun.Properties));
shapedRuns.Add(new ShapedTextRun(splitResult.First, currentRun.Properties));
shapedBuffer = splitResult.Second!;
}
@ -280,9 +280,9 @@ namespace Avalonia.Media.TextFormatting
}
/// <summary>
/// Coalesces ranges of the same bidi level to form <see cref="ShapeableTextCharacters"/>
/// Coalesces ranges of the same bidi level to form <see cref="UnshapedTextRun"/>
/// </summary>
/// <param name="textCharacters">The text characters to form <see cref="ShapeableTextCharacters"/> from.</param>
/// <param name="textCharacters">The text characters to form <see cref="UnshapedTextRun"/> from.</param>
/// <param name="levels">The bidi levels.</param>
/// <returns></returns>
private static IEnumerable<IReadOnlyList<TextRun>> CoalesceLevels(IReadOnlyList<TextRun> textCharacters, ArraySlice<sbyte> levels)
@ -474,7 +474,7 @@ namespace Avalonia.Media.TextFormatting
{
switch (currentRun)
{
case ShapedTextCharacters shapedTextCharacters:
case ShapedTextRun shapedTextCharacters:
{
if(shapedTextCharacters.ShapedBuffer.Length > 0)
{
@ -538,7 +538,7 @@ namespace Avalonia.Media.TextFormatting
var shapedBuffer = new ShapedBuffer(characterBufferRange, glyphInfos, glyphTypeface, properties.FontRenderingEmSize,
(sbyte)flowDirection);
var textRuns = new List<DrawableTextRun> { new ShapedTextCharacters(shapedBuffer, properties) };
var textRuns = new List<DrawableTextRun> { new ShapedTextRun(shapedBuffer, properties) };
return new TextLineImpl(textRuns, firstTextSourceIndex, 0, paragraphWidth, paragraphProperties, flowDirection).FinalizeLine();
}
@ -744,7 +744,7 @@ namespace Avalonia.Media.TextFormatting
/// <returns>
/// The shaped symbol.
/// </returns>
internal static ShapedTextCharacters CreateSymbol(TextRun textRun, FlowDirection flowDirection)
internal static ShapedTextRun CreateSymbol(TextRun textRun, FlowDirection flowDirection)
{
var textShaper = TextShaper.Current;
@ -760,7 +760,7 @@ namespace Avalonia.Media.TextFormatting
var shapedBuffer = textShaper.ShapeText(characterBuffer, textRun.Length, shaperOptions);
return new ShapedTextCharacters(shapedBuffer, textRun.Properties);
return new ShapedTextRun(shapedBuffer, textRun.Properties);
}
}
}

4
src/Avalonia.Base/Media/TextFormatting/TextLeadingPrefixCharacterEllipsis.cs

@ -65,7 +65,7 @@ namespace Avalonia.Media.TextFormatting
switch (currentRun)
{
case ShapedTextCharacters shapedRun:
case ShapedTextRun shapedRun:
{
currentWidth += currentRun.Size.Width;
@ -118,7 +118,7 @@ namespace Avalonia.Media.TextFormatting
switch (run)
{
case ShapedTextCharacters endShapedRun:
case ShapedTextRun endShapedRun:
{
if (endShapedRun.TryMeasureCharactersBackwards(availableSuffixWidth,
out var suffixCount, out var suffixWidth))

40
src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs

@ -192,14 +192,14 @@ namespace Avalonia.Media.TextFormatting
{
var currentRun = _textRuns[i];
if (currentRun is ShapedTextCharacters shapedRun && !shapedRun.ShapedBuffer.IsLeftToRight)
if (currentRun is ShapedTextRun shapedRun && !shapedRun.ShapedBuffer.IsLeftToRight)
{
var rightToLeftIndex = i;
currentPosition += currentRun.Length;
while (rightToLeftIndex + 1 <= _textRuns.Count - 1)
{
var nextShaped = _textRuns[++rightToLeftIndex] as ShapedTextCharacters;
var nextShaped = _textRuns[++rightToLeftIndex] as ShapedTextRun;
if (nextShaped == null || nextShaped.ShapedBuffer.IsLeftToRight)
{
@ -255,7 +255,7 @@ namespace Avalonia.Media.TextFormatting
switch (run)
{
case ShapedTextCharacters shapedRun:
case ShapedTextRun shapedRun:
{
characterHit = shapedRun.GlyphRun.GetCharacterHitFromDistance(distance, out _);
@ -303,7 +303,7 @@ namespace Avalonia.Media.TextFormatting
{
var currentRun = _textRuns[index];
if (currentRun is ShapedTextCharacters shapedRun && !shapedRun.ShapedBuffer.IsLeftToRight)
if (currentRun is ShapedTextRun shapedRun && !shapedRun.ShapedBuffer.IsLeftToRight)
{
var i = index;
@ -313,7 +313,7 @@ namespace Avalonia.Media.TextFormatting
{
var nextRun = _textRuns[i + 1];
if (nextRun is ShapedTextCharacters nextShapedRun && !nextShapedRun.ShapedBuffer.IsLeftToRight)
if (nextRun is ShapedTextRun nextShapedRun && !nextShapedRun.ShapedBuffer.IsLeftToRight)
{
i++;
@ -407,7 +407,7 @@ namespace Avalonia.Media.TextFormatting
switch (currentRun)
{
case ShapedTextCharacters shapedTextCharacters:
case ShapedTextRun shapedTextCharacters:
{
currentGlyphRun = shapedTextCharacters.GlyphRun;
@ -476,7 +476,7 @@ namespace Avalonia.Media.TextFormatting
switch (currentRun)
{
case ShapedTextCharacters shapedRun:
case ShapedTextRun shapedRun:
{
nextCharacterHit = shapedRun.GlyphRun.GetNextCaretCharacterHit(characterHit);
break;
@ -550,7 +550,7 @@ namespace Avalonia.Media.TextFormatting
double combinedWidth;
if (currentRun is ShapedTextCharacters currentShapedRun)
if (currentRun is ShapedTextRun currentShapedRun)
{
var firstCluster = currentShapedRun.GlyphRun.Metrics.FirstCluster;
@ -592,7 +592,7 @@ namespace Avalonia.Media.TextFormatting
var rightToLeftIndex = index;
var rightToLeftWidth = currentShapedRun.Size.Width;
while (rightToLeftIndex + 1 <= _textRuns.Count - 1 && _textRuns[rightToLeftIndex + 1] is ShapedTextCharacters nextShapedRun)
while (rightToLeftIndex + 1 <= _textRuns.Count - 1 && _textRuns[rightToLeftIndex + 1] is ShapedTextRun nextShapedRun)
{
if (nextShapedRun == null || nextShapedRun.ShapedBuffer.IsLeftToRight)
{
@ -624,12 +624,12 @@ namespace Avalonia.Media.TextFormatting
for (int i = rightToLeftIndex - 1; i >= index; i--)
{
if (TextRuns[i] is not ShapedTextCharacters)
if (TextRuns[i] is not ShapedTextRun)
{
continue;
}
currentShapedRun = (ShapedTextCharacters)TextRuns[i];
currentShapedRun = (ShapedTextRun)TextRuns[i];
currentRunBounds = GetRightToLeftTextRunBounds(currentShapedRun, startX, firstTextSourceIndex, characterIndex, currentPosition, remainingLength);
@ -769,7 +769,7 @@ namespace Avalonia.Media.TextFormatting
var characterLength = 0;
var endX = startX;
if (currentRun is ShapedTextCharacters currentShapedRun)
if (currentRun is ShapedTextRun currentShapedRun)
{
var offset = Math.Max(0, firstTextSourceIndex - currentPosition);
@ -883,7 +883,7 @@ namespace Avalonia.Media.TextFormatting
return result;
}
private TextRunBounds GetRightToLeftTextRunBounds(ShapedTextCharacters currentRun, double endX, int firstTextSourceIndex, int characterIndex, int currentPosition, int remainingLength)
private TextRunBounds GetRightToLeftTextRunBounds(ShapedTextRun currentRun, double endX, int firstTextSourceIndex, int characterIndex, int currentPosition, int remainingLength)
{
var startX = endX;
@ -945,7 +945,7 @@ namespace Avalonia.Media.TextFormatting
private static sbyte GetRunBidiLevel(DrawableTextRun run, FlowDirection flowDirection)
{
if (run is ShapedTextCharacters shapedTextCharacters)
if (run is ShapedTextRun shapedTextCharacters)
{
return shapedTextCharacters.BidiLevel;
}
@ -1027,7 +1027,7 @@ namespace Avalonia.Media.TextFormatting
{
if (current.Level >= minLevelToReverse && current.Level % 2 != 0)
{
if (current.Run is ShapedTextCharacters { IsReversed: false } shapedTextCharacters)
if (current.Run is ShapedTextRun { IsReversed: false } shapedTextCharacters)
{
shapedTextCharacters.Reverse();
}
@ -1145,7 +1145,7 @@ namespace Avalonia.Media.TextFormatting
switch (currentRun)
{
case ShapedTextCharacters shapedRun:
case ShapedTextRun shapedRun:
{
var foundCharacterHit = shapedRun.GlyphRun.FindNearestCharacterHit(characterHit.FirstCharacterIndex + characterHit.TrailingLength, out _);
@ -1230,7 +1230,7 @@ namespace Avalonia.Media.TextFormatting
switch (currentRun)
{
case ShapedTextCharacters shapedRun:
case ShapedTextRun shapedRun:
{
var foundCharacterHit = shapedRun.GlyphRun.FindNearestCharacterHit(characterHit.FirstCharacterIndex - 1, out _);
@ -1294,7 +1294,7 @@ namespace Avalonia.Media.TextFormatting
switch (currentRun)
{
case ShapedTextCharacters shapedRun:
case ShapedTextRun shapedRun:
{
var firstCluster = shapedRun.GlyphRun.Metrics.FirstCluster;
@ -1303,7 +1303,7 @@ namespace Avalonia.Media.TextFormatting
break;
}
if (previousRun is ShapedTextCharacters previousShaped && !previousShaped.ShapedBuffer.IsLeftToRight)
if (previousRun is ShapedTextRun previousShaped && !previousShaped.ShapedBuffer.IsLeftToRight)
{
if (shapedRun.ShapedBuffer.IsLeftToRight)
{
@ -1394,7 +1394,7 @@ namespace Avalonia.Media.TextFormatting
{
switch (_textRuns[index])
{
case ShapedTextCharacters textRun:
case ShapedTextRun textRun:
{
var textMetrics =
new TextMetrics(textRun.Properties.Typeface.GlyphTypeface, textRun.Properties.FontRenderingEmSize);

7
src/Avalonia.Base/Media/TextFormatting/TextParagraphProperties.cs

@ -63,14 +63,11 @@
{
get { return 0; }
}
/// <summary>
/// Gets the default incremental tab width.
/// </summary>
public virtual double DefaultIncrementalTab
{
get { return 4 * DefaultTextRunProperties.FontRenderingEmSize; }
}
public virtual double DefaultIncrementalTab => 0;
/// <summary>
/// Gets the letter spacing.

2
src/Avalonia.Base/Media/TextFormatting/TextRun.cs

@ -44,7 +44,7 @@ namespace Avalonia.Media.TextFormatting
fixed (char* charsPtr = characterBuffer.Span)
{
return new string(charsPtr, 0, characterBuffer.Span.Length);
return new string(charsPtr, _textRun.CharacterBufferReference.OffsetToFirstChar, _textRun.Length);
}
}
}

5
src/Avalonia.Base/Media/TextFormatting/TextShaper.cs

@ -29,10 +29,7 @@ namespace Avalonia.Media.TextFormatting
return current;
}
var textShaperImpl = AvaloniaLocator.Current.GetService<ITextShaperImpl>();
if (textShaperImpl == null)
throw new InvalidOperationException("No text shaper implementation was registered.");
var textShaperImpl = AvaloniaLocator.Current.GetRequiredService<ITextShaperImpl>();
current = new TextShaper(textShaperImpl);

68
src/Avalonia.Base/Media/TextFormatting/Unicode/Codepoint.cs

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace Avalonia.Media.TextFormatting.Unicode
@ -222,6 +223,71 @@ namespace Avalonia.Media.TextFormatting.Unicode
return new Codepoint(code);
}
/// <summary>
/// Reads the <see cref="Codepoint"/> at specified position.
/// </summary>
/// <param name="text">The buffer to read from.</param>
/// <param name="index">The index to read at.</param>
/// <param name="count">The count of character that were read.</param>
/// <returns></returns>
public static Codepoint ReadAt(CharacterBufferRange text, int index, out int count)
{
count = 1;
if (index >= text.Length)
{
return ReplacementCodepoint;
}
var code = text[index];
ushort hi, low;
//# High surrogate
if (0xD800 <= code && code <= 0xDBFF)
{
hi = code;
if (index + 1 == text.Length)
{
return ReplacementCodepoint;
}
low = text[index + 1];
if (0xDC00 <= low && low <= 0xDFFF)
{
count = 2;
return new Codepoint((uint)((hi - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000));
}
return ReplacementCodepoint;
}
//# Low surrogate
if (0xDC00 <= code && code <= 0xDFFF)
{
if (index == 0)
{
return ReplacementCodepoint;
}
hi = text[index - 1];
low = code;
if (0xD800 <= hi && hi <= 0xDBFF)
{
count = 2;
return new Codepoint((uint)((hi - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000));
}
return ReplacementCodepoint;
}
return new Codepoint(code);
}
/// <summary>
/// Returns <see langword="true"/> if <paramref name="cp"/> is between

14
src/Avalonia.Base/Media/TextFormatting/Unicode/Grapheme.cs

@ -7,10 +7,11 @@ namespace Avalonia.Media.TextFormatting.Unicode
/// </summary>
public readonly ref struct Grapheme
{
public Grapheme(Codepoint firstCodepoint, ReadOnlySpan<char> text)
public Grapheme(Codepoint firstCodepoint, int offset, int length)
{
FirstCodepoint = firstCodepoint;
Text = text;
Offset = offset;
Length = length;
}
/// <summary>
@ -19,8 +20,13 @@ namespace Avalonia.Media.TextFormatting.Unicode
public Codepoint FirstCodepoint { get; }
/// <summary>
/// The text that is representing the <see cref="Grapheme"/>.
/// The Offset to the FirstCodepoint
/// </summary>
public ReadOnlySpan<char> Text { get; }
public int Offset { get; }
/// <summary>
/// The length of the grapheme cluster
/// </summary>
public int Length { get; }
}
}

4
src/Avalonia.Base/Media/TextFormatting/Unicode/GraphemeEnumerator.cs

@ -185,9 +185,7 @@ namespace Avalonia.Media.TextFormatting.Unicode
Return:
var text = _text.Take(processor.CurrentCodeUnitOffset);
Current = new Grapheme(firstCodepoint, text.Span);
Current = new Grapheme(firstCodepoint, _text.OffsetToFirstChar, processor.CurrentCodeUnitOffset);
_text = _text.Skip(processor.CurrentCodeUnitOffset);

16
src/Avalonia.Base/Media/TextFormatting/ShapeableTextCharacters.cs → src/Avalonia.Base/Media/TextFormatting/UnshapedTextRun.cs

@ -5,9 +5,9 @@ namespace Avalonia.Media.TextFormatting
/// <summary>
/// A group of characters that can be shaped.
/// </summary>
public sealed class ShapeableTextCharacters : TextRun
public sealed class UnshapedTextRun : TextRun
{
public ShapeableTextCharacters(CharacterBufferReference characterBufferReference, int length,
public UnshapedTextRun(CharacterBufferReference characterBufferReference, int length,
TextRunProperties properties, sbyte biDiLevel)
{
CharacterBufferReference = characterBufferReference;
@ -24,30 +24,30 @@ namespace Avalonia.Media.TextFormatting
public sbyte BidiLevel { get; }
public bool CanShapeTogether(ShapeableTextCharacters shapeableTextCharacters)
public bool CanShapeTogether(UnshapedTextRun unshapedTextRun)
{
if (!CharacterBufferReference.Equals(shapeableTextCharacters.CharacterBufferReference))
if (!CharacterBufferReference.Equals(unshapedTextRun.CharacterBufferReference))
{
return false;
}
if (BidiLevel != shapeableTextCharacters.BidiLevel)
if (BidiLevel != unshapedTextRun.BidiLevel)
{
return false;
}
if (!MathUtilities.AreClose(Properties.FontRenderingEmSize,
shapeableTextCharacters.Properties.FontRenderingEmSize))
unshapedTextRun.Properties.FontRenderingEmSize))
{
return false;
}
if (Properties.Typeface != shapeableTextCharacters.Properties.Typeface)
if (Properties.Typeface != unshapedTextRun.Properties.Typeface)
{
return false;
}
if (Properties.BaselineAlignment != shapeableTextCharacters.Properties.BaselineAlignment)
if (Properties.BaselineAlignment != unshapedTextRun.Properties.BaselineAlignment)
{
return false;
}

2
src/Avalonia.Base/Rendering/Composition/Expressions/ExpressionVariant.cs

@ -654,7 +654,7 @@ namespace Avalonia.Rendering.Composition.Expressions
}
}
res = default(T);
res = default;
return false;
}

6
src/Avalonia.Base/Rendering/ImmediateRenderer.cs

@ -330,11 +330,11 @@ namespace Avalonia.Rendering
? visual is IVisualWithRoundRectClip roundClipVisual
? context.PushClip(new RoundedRect(bounds, roundClipVisual.ClipToBoundsRadius))
: context.PushClip(bounds)
: default(DrawingContext.PushedState))
: default)
#pragma warning restore CS0618 // Type or member is obsolete
using (visual.Clip != null ? context.PushGeometryClip(visual.Clip) : default(DrawingContext.PushedState))
using (visual.OpacityMask != null ? context.PushOpacityMask(visual.OpacityMask, bounds) : default(DrawingContext.PushedState))
using (visual.Clip != null ? context.PushGeometryClip(visual.Clip) : default)
using (visual.OpacityMask != null ? context.PushOpacityMask(visual.OpacityMask, bounds) : default)
using (context.PushTransformContainer())
{
visual.Render(context);

3
src/Avalonia.Base/Rendering/RenderLoop.cs

@ -50,8 +50,7 @@ namespace Avalonia.Rendering
{
get
{
return _timer ??= AvaloniaLocator.Current.GetService<IRenderTimer>() ??
throw new InvalidOperationException("Cannot locate IRenderTimer.");
return _timer ??= AvaloniaLocator.Current.GetRequiredService<IRenderTimer>();
}
}

2
src/Avalonia.Base/Rendering/Utilities/TileBrushCalculator.cs

@ -109,7 +109,7 @@ namespace Avalonia.Rendering.Utilities
{
if (IntermediateTransform != Matrix.Identity)
return true;
if (SourceRect.Position != default(Point))
if (SourceRect.Position != default)
return true;
if (SourceRect.Size.AspectRatio == _imageSize.AspectRatio)
return false;

8
src/Avalonia.Base/Threading/DispatcherTimer.cs

@ -176,13 +176,7 @@ namespace Avalonia.Threading
{
if (!IsEnabled)
{
var threading = AvaloniaLocator.Current.GetService<IPlatformThreadingInterface>();
if (threading == null)
{
throw new Exception("Could not start timer: IPlatformThreadingInterface is not registered.");
}
var threading = AvaloniaLocator.Current.GetRequiredService<IPlatformThreadingInterface>();
_timer = threading.StartTimer(_priority, Interval, InternalTick);
}
}

2
src/Avalonia.Base/Utilities/SingleOrDictionary.cs

@ -42,7 +42,7 @@ namespace Avalonia.Utilities
{
if (!_singleValue.HasValue || !EqualityComparer<TKey>.Default.Equals(_singleValue.Value.Key, key))
{
value = default(TValue);
value = default;
return false;
}
else

4
src/Avalonia.Base/Utilities/StringTokenizer.cs

@ -63,7 +63,7 @@ namespace Avalonia.Utilities
}
else
{
result = default(Int32);
result = default;
return false;
}
}
@ -87,7 +87,7 @@ namespace Avalonia.Utilities
}
else
{
result = default(double);
result = default;
return false;
}
}

1
src/Avalonia.Base/Visual.cs

@ -480,6 +480,7 @@ namespace Avalonia
{
AttachToCompositor(compositingRenderer.Compositor);
}
InvalidateMirrorTransform();
OnAttachedToVisualTree(e);
AttachedToVisualTree?.Invoke(this, e);
InvalidateVisual();

4
src/Avalonia.Build.Tasks/ComInteropHelper.cs

@ -65,10 +65,8 @@ namespace Avalonia.Build.Tasks
{
Instruction instruction = instructions[i];
if (instruction.OpCode == OpCodes.Call && instruction.Operand is MethodReference)
if (instruction.OpCode == OpCodes.Call && instruction.Operand is MethodReference methodDescription)
{
var methodDescription = (MethodReference)instruction.Operand;
if (methodDescription.Name.StartsWith("Calli") && methodDescription.DeclaringType.Name == "LocalInterop")
{
var callSite = new CallSite(methodDescription.ReturnType) { CallingConvention = MethodCallingConvention.StdCall };

5
src/Avalonia.Controls.DataGrid/DataGrid.cs

@ -1118,7 +1118,7 @@ namespace Avalonia.Controls
EnsureColumnHeadersVisibility();
if (!newValueCols)
{
_columnHeadersPresenter.Measure(default(Size));
_columnHeadersPresenter.Measure(default);
}
else
{
@ -1159,7 +1159,7 @@ namespace Avalonia.Controls
_topLeftCornerHeader.IsVisible = newValueRows && newValueCols;
if (_topLeftCornerHeader.IsVisible)
{
_topLeftCornerHeader.Measure(default(Size));
_topLeftCornerHeader.Measure(default);
}
}
@ -4152,6 +4152,7 @@ namespace Avalonia.Controls
if (exitEditingMode)
{
CurrentColumn.EndCellEditInternal();
_editingColumnIndex = -1;
editingCell.UpdatePseudoClasses();

11
src/Avalonia.Controls.DataGrid/DataGridColumn.cs

@ -800,11 +800,22 @@ namespace Avalonia.Controls
protected internal virtual void RefreshCellContent(Control element, string propertyName)
{ }
/// <summary>
/// When overridden in a derived class, called when a cell in the column exits editing mode.
/// </summary>
protected virtual void EndCellEdit()
{ }
internal void CancelCellEditInternal(Control editingElement, object uneditedValue)
{
CancelCellEdit(editingElement, uneditedValue);
}
internal void EndCellEditInternal()
{
EndCellEdit();
}
/// <summary>
/// Coerces a DataGridLength to a valid value. If any value components are double.NaN, this method
/// coerces them to a proper initial value. For star columns, the desired width is calculated based

16
src/Avalonia.Controls.DataGrid/DataGridTemplateColumn.cs

@ -55,17 +55,25 @@ namespace Avalonia.Controls
get => _cellEditingCellTemplate;
set => SetAndRaise(CellEditingTemplateProperty, ref _cellEditingCellTemplate, value);
}
private static void OnCellTemplateChanged(AvaloniaPropertyChangedEventArgs e)
private bool _forceGenerateCellFromTemplate;
protected override void EndCellEdit()
{
var oldValue = (IDataTemplate)e.OldValue;
var value = (IDataTemplate)e.NewValue;
//the next call to generate element should not resuse the current content as we need to exit edit mode
_forceGenerateCellFromTemplate = true;
base.EndCellEdit();
}
protected override Control GenerateElement(DataGridCell cell, object dataItem)
{
if (CellTemplate != null)
{
if (_forceGenerateCellFromTemplate)
{
_forceGenerateCellFromTemplate = false;
return CellTemplate.Build(dataItem);
}
return (CellTemplate is IRecyclingDataTemplate recyclingDataTemplate)
? recyclingDataTemplate.Build(dataItem, cell.Content as Control)
: CellTemplate.Build(dataItem);

2
src/Avalonia.Controls.DataGrid/IndexToValueTable.cs

@ -422,7 +422,7 @@ namespace Avalonia.Controls
else
{
found = false;
return default(T);
return default;
}
}

1
src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs

@ -474,6 +474,7 @@ namespace Avalonia.Controls
FilterModeProperty.Changed.AddClassHandler<AutoCompleteBox>((x,e) => x.OnFilterModePropertyChanged(e));
ItemFilterProperty.Changed.AddClassHandler<AutoCompleteBox>((x,e) => x.OnItemFilterPropertyChanged(e));
ItemsProperty.Changed.AddClassHandler<AutoCompleteBox>((x,e) => x.OnItemsPropertyChanged(e));
ItemTemplateProperty.Changed.AddClassHandler<AutoCompleteBox>((x,e) => x.OnItemTemplatePropertyChanged(e));
IsEnabledProperty.Changed.AddClassHandler<AutoCompleteBox>((x,e) => x.OnControlIsEnabledChanged(e));
}

8
src/Avalonia.Controls/Control.cs

@ -392,14 +392,6 @@ namespace Avalonia.Controls
OnUnloadedCore();
}
/// <inheritdoc/>
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnAttachedToVisualTree(e);
InvalidateMirrorTransform();
}
/// <inheritdoc/>
protected override void OnGotFocus(GotFocusEventArgs e)
{

2
src/Avalonia.Controls/Platform/InProcessDragSource.cs

@ -41,7 +41,7 @@ namespace Avalonia.Platform
{
_draggedData = data;
_lastRoot = null;
_lastPosition = default(Point);
_lastPosition = default;
_allowedEffects = allowedEffects;
using (_inputManager.PreProcess.OfType<RawPointerEventArgs>().Subscribe(ProcessMouseEvents))

11
src/Avalonia.Controls/Platform/PlatformManager.cs

@ -26,21 +26,14 @@ namespace Avalonia.Controls.Platform
public static IWindowImpl CreateWindow()
{
var platform = AvaloniaLocator.Current.GetService<IWindowingPlatform>();
if (platform == null)
{
throw new Exception("Could not CreateWindow(): IWindowingPlatform is not registered.");
}
var platform = AvaloniaLocator.Current.GetRequiredService<IWindowingPlatform>();
return s_designerMode ? platform.CreateEmbeddableWindow() : platform.CreateWindow();
}
public static IWindowImpl CreateEmbeddableWindow()
{
var platform = AvaloniaLocator.Current.GetService<IWindowingPlatform>();
if (platform == null)
throw new Exception("Could not CreateEmbeddableWindow(): IWindowingPlatform is not registered.");
var platform = AvaloniaLocator.Current.GetRequiredService<IWindowingPlatform>();
return platform.CreateEmbeddableWindow();
}
}

5
src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs

@ -94,6 +94,7 @@ namespace Avalonia.Controls.Presenters
{
AddHandler(RequestBringIntoViewEvent, BringIntoViewRequested);
AddHandler(Gestures.ScrollGestureEvent, OnScrollGesture);
AddHandler(Gestures.ScrollGestureEndedEvent, OnScrollGestureEnded);
this.GetObservable(ChildProperty).Subscribe(UpdateScrollableSubscription);
}
@ -500,7 +501,7 @@ namespace Avalonia.Controls.Presenters
if (e.OldValue != null)
{
Offset = default(Vector);
Offset = default;
}
}
@ -542,7 +543,7 @@ namespace Avalonia.Controls.Presenters
if (logicalScroll != scrollable.IsLogicalScrollEnabled)
{
UpdateScrollableSubscription(Child);
Offset = default(Vector);
Offset = default;
InvalidateMeasure();
}
else if (scrollable.IsLogicalScrollEnabled)

4
src/Avalonia.Controls/PullToRefresh/ScrollViewerIRefreshInfoProviderAdapter.cs

@ -197,12 +197,12 @@ namespace Avalonia.Controls.PullToRefresh
throw new ArgumentException(nameof(_scrollViewer), "Adaptee's content property must be a Visual");
}
if (content.Parent is not InputElement)
if (content.Parent is not InputElement parent)
{
throw new ArgumentException(nameof(_scrollViewer), "Adaptee's content parent must be an InputElement");
}
MakeInteractionSource(content.Parent as InputElement);
MakeInteractionSource(parent);
if (_scrollViewer != null)
{

16
src/Avalonia.Controls/Repeater/ViewportManager.cs

@ -124,22 +124,6 @@ namespace Avalonia.Controls
}
}
}
private Rect GetLayoutVisibleWindowDiscardAnchor()
{
var visibleWindow = _visibleWindow;
if (HasScroller)
{
visibleWindow = new Rect(
visibleWindow.X + _layoutExtent.X + _expectedViewportShift.X + _unshiftableShift.X,
visibleWindow.Y + _layoutExtent.Y + _expectedViewportShift.Y + _unshiftableShift.Y,
visibleWindow.Width,
visibleWindow.Height);
}
return visibleWindow;
}
public Rect GetLayoutVisibleWindow()
{

4
src/Avalonia.Controls/Templates/FuncTreeDataTemplate`1.cs

@ -59,7 +59,7 @@ namespace Avalonia.Controls.Templates
/// <returns>The untyped function.</returns>
private static Func<object?, bool> CastMatch(Func<T, bool> f)
{
return o => (o is T) && f((T)o);
return o => o is T arg && f(arg);
}
/// <summary>
@ -72,7 +72,7 @@ namespace Avalonia.Controls.Templates
{
return (o, s) => f((T)o!, s);
}
/// <summary>
/// Casts a function with a typed parameter to an untyped function.
/// </summary>

2
src/Avalonia.Controls/TextBox.cs

@ -981,7 +981,7 @@ namespace Avalonia.Controls
}
}
length += grapheme.Text.Length;
length += grapheme.Length;
}
if (length < input.Length)

2
src/Avalonia.Controls/Utils/UndoRedoHelper.cs

@ -49,7 +49,7 @@ namespace Avalonia.Controls.Utils
public bool TryGetLastState(out TState? _state)
{
_state = default(TState);
_state = default;
if (!IsLastState)
return false;

5
src/Avalonia.DesignerSupport/DesignWindowLoader.cs

@ -18,12 +18,9 @@ namespace Avalonia.DesignerSupport
Control control;
using (PlatformManager.DesignerMode())
{
var loader = AvaloniaLocator.Current.GetService<AvaloniaXamlLoader.IRuntimeXamlLoader>();
var loader = AvaloniaLocator.Current.GetRequiredService<AvaloniaXamlLoader.IRuntimeXamlLoader>();
var stream = new MemoryStream(Encoding.UTF8.GetBytes(xaml));
if (loader == null)
throw new XamlLoadException("Runtime XAML loader is not registered");
Uri baseUri = null;
if (assemblyPath != null)
{

8
src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs

@ -33,12 +33,12 @@ namespace Avalonia.Diagnostics.ViewModels
{
_avaloniaObject = avaloniaObject;
TreePage = treePage;
Layout = avaloniaObject is Visual
? new ControlLayoutViewModel((Visual)avaloniaObject)
TreePage = treePage;
Layout = avaloniaObject is Visual visual
? new ControlLayoutViewModel(visual)
: default;
NavigateToProperty(_avaloniaObject, (_avaloniaObject as Control)?.Name ?? _avaloniaObject.ToString());
NavigateToProperty(_avaloniaObject, (_avaloniaObject as Control)?.Name ?? _avaloniaObject.ToString());
AppliedStyles = new ObservableCollection<StyleViewModel>();
PseudoClasses = new ObservableCollection<PseudoClassViewModel>();

2
src/Avalonia.Dialogs/Internal/ManagedFileChooserViewModel.cs

@ -117,7 +117,7 @@ namespace Avalonia.Dialogs.Internal
?? new ManagedFileChooserSources();
var sub1 = AvaloniaLocator.Current
.GetService<IMountedVolumeInfoProvider>()
.GetRequiredService<IMountedVolumeInfoProvider>()
.Listen(ManagedFileChooserSources.MountedVolumes);
var sub2 = Observable.FromEventPattern(ManagedFileChooserSources.MountedVolumes,

8
src/Avalonia.FreeDesktop/DBusMenu.cs

@ -36,10 +36,10 @@ namespace Avalonia.FreeDesktop.DBusMenu
[Dictionary]
class DBusMenuProperties
{
public uint Version { get; set; } = default (uint);
public string? TextDirection { get; set; } = default (string);
public string? Status { get; set; } = default (string);
public string[]? IconThemePath { get; set; } = default (string[]);
public uint Version { get; set; } = default;
public string? TextDirection { get; set; } = default;
public string? Status { get; set; } = default;
public string[]? IconThemePath { get; set; } = default;
}

2
src/Avalonia.OpenGL/Egl/EglInterface.cs

@ -35,7 +35,7 @@ namespace Avalonia.OpenGL.Egl
static Func<string, IntPtr> Load(string library)
{
var dyn = AvaloniaLocator.Current.GetService<IDynamicLibraryLoader>();
var dyn = AvaloniaLocator.Current.GetRequiredService<IDynamicLibraryLoader>();
var lib = dyn.LoadLibrary(library);
return (s) => dyn.GetProcAddress(lib, s, true);
}

2
src/Avalonia.X11/X11Framebuffer.cs

@ -25,7 +25,7 @@ namespace Avalonia.X11
RowBytes = width * 4;
Dpi = new Vector(96, 96) * factor;
Format = PixelFormat.Bgra8888;
_blob = AvaloniaLocator.Current.GetService<IRuntimePlatform>().AllocBlob(RowBytes * height);
_blob = AvaloniaLocator.Current.GetRequiredService<IRuntimePlatform>().AllocBlob(RowBytes * height);
Address = _blob.Address;
}

2
src/Avalonia.X11/X11Platform.cs

@ -105,7 +105,7 @@ namespace Avalonia.X11
var gl = AvaloniaLocator.Current.GetService<IPlatformGraphics>();
if (options.UseCompositor)
Compositor = new Compositor(AvaloniaLocator.Current.GetService<IRenderLoop>()!, gl);
Compositor = new Compositor(AvaloniaLocator.Current.GetRequiredService<IRenderLoop>(), gl);
else
RenderInterface = new(gl);

1
src/Browser/Avalonia.Browser/Avalonia.Browser.csproj

@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

2
src/Browser/Avalonia.Browser/AvaloniaView.cs

@ -106,7 +106,7 @@ namespace Avalonia.Browser
_dpi = DomHelper.ObserveDpi(OnDpiChanged);
_useGL = AvaloniaLocator.Current.GetRequiredService<IPlatformGraphics>() != null;
_useGL = AvaloniaLocator.Current.GetService<IPlatformGraphics>() != null;
if (_useGL)
{

2
src/Browser/Avalonia.Browser/Interop/StorageHelper.cs

@ -45,7 +45,7 @@ internal static partial class StorageHelper
[JSImport("StorageItem.getItems", AvaloniaModule.StorageModuleName)]
[return: JSMarshalAs<JSType.Promise<JSType.Object>>]
public static partial Task<JSObject> GetItems(JSObject item);
public static partial Task<JSObject?> GetItems(JSObject item);
[JSImport("StorageItems.itemsArray", AvaloniaModule.StorageModuleName)]
public static partial JSObject[] ItemsArray(JSObject item);

2
src/Linux/Avalonia.LinuxFramebuffer/FramebufferToplevelImpl.cs

@ -25,7 +25,7 @@ namespace Avalonia.LinuxFramebuffer
Surfaces = new object[] { _outputBackend };
Invalidate(default(Rect));
Invalidate(default);
_inputBackend.Initialize(this, e => Input?.Invoke(e));
}

2
src/Markup/Avalonia.Markup.Xaml/Converters/BitmapTypeConverter.cs

@ -24,7 +24,7 @@ namespace Avalonia.Markup.Xaml.Converters
if(uri.IsAbsoluteUri && uri.IsFile)
return new Bitmap(uri.LocalPath);
var assets = AvaloniaLocator.Current.GetService<IAssetLoader>();
var assets = AvaloniaLocator.Current.GetRequiredService<IAssetLoader>();
return new Bitmap(assets.Open(uri, context.GetContextBaseUri()));
}
}

2
src/Markup/Avalonia.Markup.Xaml/Converters/IconTypeConverter.cs

@ -40,7 +40,7 @@ namespace Avalonia.Markup.Xaml.Converters
if(uri.IsAbsoluteUri && uri.IsFile)
return new WindowIcon(uri.LocalPath);
var assets = AvaloniaLocator.Current.GetService<IAssetLoader>();
var assets = AvaloniaLocator.Current.GetRequiredService<IAssetLoader>();
return new WindowIcon(assets.Open(uri, context.GetContextBaseUri()));
}
}

12
src/Markup/Avalonia.Markup/Markup/Parsers/SelectorGrammar.cs

@ -552,7 +552,8 @@ namespace Avalonia.Markup.Parsers
public override bool Equals(object? obj)
{
return obj is ClassSyntax && ((ClassSyntax)obj).Class == Class;
return obj is ClassSyntax syntax &&
syntax.Class == Class;
}
}
@ -562,7 +563,8 @@ namespace Avalonia.Markup.Parsers
public override bool Equals(object? obj)
{
return obj is NameSyntax && ((NameSyntax)obj).Name == Name;
return obj is NameSyntax syntax &&
syntax.Name == Name;
}
}
@ -574,9 +576,9 @@ namespace Avalonia.Markup.Parsers
public override bool Equals(object? obj)
{
return obj is PropertySyntax &&
((PropertySyntax)obj).Property == Property &&
((PropertySyntax)obj).Value == Value;
return obj is PropertySyntax syntax &&
syntax.Property == Property &&
syntax.Value == Value;
}
}

4
src/Skia/Avalonia.Skia/DrawingContextImpl.cs

@ -224,9 +224,9 @@ namespace Avalonia.Skia
var impl = (GeometryImpl) geometry;
var size = geometry.Bounds.Size;
using (var fill = brush != null ? CreatePaint(_fillPaint, brush, size) : default(PaintWrapper))
using (var fill = brush != null ? CreatePaint(_fillPaint, brush, size) : default)
using (var stroke = pen?.Brush != null ? CreatePaint(_strokePaint, pen,
size.Inflate(new Thickness(pen?.Thickness / 2 ?? 0))) : default(PaintWrapper))
size.Inflate(new Thickness(pen?.Thickness / 2 ?? 0))) : default)
{
if (fill.Paint != null)
{

2
src/Skia/Avalonia.Skia/GeometryImpl.cs

@ -245,7 +245,7 @@ namespace Avalonia.Skia
{
CachedStrokePath?.Dispose();
CachedGeometryRenderBounds = default;
_cachedStrokeWidth = default(float);
_cachedStrokeWidth = default;
}
}
}

2
src/Skia/Avalonia.Skia/SKTypefaceCollectionCache.cs

@ -37,7 +37,7 @@ namespace Avalonia.Skia
var typeFaceCollection = new SKTypefaceCollection();
var assetLoader = AvaloniaLocator.Current.GetService<IAssetLoader>();
var assetLoader = AvaloniaLocator.Current.GetRequiredService<IAssetLoader>();
foreach (var asset in fontAssets)
{

6
src/Skia/Avalonia.Skia/WriteableBitmapImpl.cs

@ -96,9 +96,9 @@ namespace Avalonia.Skia
SKColorType colorType = format.ToSkColorType();
SKAlphaType alphaType = alphaFormat.ToSkAlphaType();
var runtimePlatform = AvaloniaLocator.Current?.GetService<IRuntimePlatform>();
var runtimePlatform = AvaloniaLocator.Current.GetService<IRuntimePlatform>();
if (runtimePlatform != null)
{
_bitmap = new SKBitmap();

2
src/Windows/Avalonia.Direct2D1/Media/DWriteResourceFontLoader.cs

@ -22,7 +22,7 @@ namespace Avalonia.Direct2D1.Media
{
var factory1 = factory;
var assetLoader = AvaloniaLocator.Current.GetService<IAssetLoader>();
var assetLoader = AvaloniaLocator.Current.GetRequiredService<IAssetLoader>();
foreach (var asset in fontAssets)
{

2
src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs

@ -409,7 +409,7 @@ namespace Avalonia.Direct2D1.Media
}
else
{
var platform = AvaloniaLocator.Current.GetService<IPlatformRenderInterface>();
var platform = AvaloniaLocator.Current.GetRequiredService<IPlatformRenderInterface>();
var dpi = new Vector(_deviceContext.DotsPerInch.Width, _deviceContext.DotsPerInch.Height);
var pixelSize = PixelSize.FromSizeWithDpi(size, dpi);
return (IDrawingContextLayerImpl)platform.CreateRenderTargetBitmap(pixelSize, dpi);

6
src/Windows/Avalonia.Win32.Interop/Wpf/Direct2DImageSurface.cs

@ -127,7 +127,7 @@ namespace Avalonia.Win32.Interop.Wpf
DeviceWindowHandle = GetDesktopWindow(),
PresentationInterval = PresentInterval.Default
};
s_dxDevice = s_dxDevice ?? AvaloniaLocator.Current.GetService<SharpDX.DXGI.Device>()
s_dxDevice = s_dxDevice ?? AvaloniaLocator.Current.GetRequiredService<SharpDX.DXGI.Device>()
.QueryInterface<SharpDX.Direct3D11.Device>();
s_d3DDevice = new DeviceEx(s_d3DContext, 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.HardwareVertexProcessing | CreateFlags.Multithreaded | CreateFlags.FpuPreserve, presentparams);
@ -156,7 +156,7 @@ namespace Avalonia.Win32.Interop.Wpf
_impl.ImageSource = _image;
RemoveAndDispose(ref _backBuffer);
if (size == default(IntSize))
if (size == default)
{
_image.Lock();
_image.SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero);
@ -171,7 +171,7 @@ namespace Avalonia.Win32.Interop.Wpf
static void RemoveAndDispose<T>(ref T d) where T : IDisposable
{
d?.Dispose();
d = default(T);
d = default;
}
void Swap()

2
src/Windows/Avalonia.Win32.Interop/Wpf/IntSize.cs

@ -28,7 +28,7 @@ namespace Avalonia.Win32.Interop.Wpf
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is IntSize && Equals((IntSize) obj);
return obj is IntSize size && Equals(size);
}
public override int GetHashCode()

2
src/Windows/Avalonia.Win32/DataObject.cs

@ -205,7 +205,7 @@ namespace Avalonia.Win32
if (string.IsNullOrEmpty(fmt) || !_wrapped.Contains(fmt))
return DV_E_FORMATETC;
* medium = default(Interop.STGMEDIUM);
* medium = default;
medium->tymed = TYMED.TYMED_HGLOBAL;
return WriteDataToHGlobal(fmt, ref medium->unionmember);
}

2
src/Windows/Avalonia.Win32/OleDropTarget.cs

@ -121,7 +121,7 @@ namespace Avalonia.Win32
_dragDevice,
RawDragEventType.DragLeave,
_target,
default(Point),
default,
null,
DragDropEffects.None,
RawInputModifiers.None

2
src/Windows/Avalonia.Win32/WindowImpl.CustomCaptionProc.cs

@ -109,7 +109,7 @@ namespace Avalonia.Win32
if (_owner is Window window)
{
var visual = window.Renderer.HitTestFirst(position, (Visual)_owner, x =>
var visual = window.Renderer.HitTestFirst(position, window, x =>
{
if (x is IInputElement ie && (!ie.IsHitTestVisible || !ie.IsEffectivelyVisible))
{

1
src/tools/DevAnalyzers/DevAnalyzers.csproj

@ -2,7 +2,6 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>10</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

1
src/tools/DevGenerators/DevGenerators.csproj

@ -4,7 +4,6 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<LangVersion>10</LangVersion>
</PropertyGroup>
<ItemGroup>

1
tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj

@ -3,7 +3,6 @@
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<IsTestProject>true</IsTestProject>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<Import Project="..\..\build\UnitTests.NetCore.targets" />
<Import Project="..\..\build\UnitTests.NetFX.props" />

2
tests/Avalonia.Base.UnitTests/Media/Fonts/FontFamilyLoaderTests.cs

@ -97,7 +97,7 @@ namespace Avalonia.Base.UnitTests.Media.Fonts
{
using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface))
{
var assetLoader = AvaloniaLocator.Current.GetService<IAssetLoader>();
var assetLoader = AvaloniaLocator.Current.GetRequiredService<IAssetLoader>();
var fontFamily = new FontFamily("resm:Avalonia.Base.UnitTests.Assets?assembly=Avalonia.Base.UnitTests#Noto Mono");

4
tests/Avalonia.Base.UnitTests/Media/TextFormatting/GraphemeBreakClassTrieGeneratorTests.cs

@ -42,7 +42,7 @@ namespace Avalonia.Base.UnitTests.Media.TextFormatting
enumerator.MoveNext();
var actual = enumerator.Current.Text;
var actual = text.AsSpan(enumerator.Current.Offset, enumerator.Current.Length);
var pass = true;
@ -93,7 +93,7 @@ namespace Avalonia.Base.UnitTests.Media.TextFormatting
while (enumerator.MoveNext())
{
Assert.Equal(1, enumerator.Current.Text.Length);
Assert.Equal(1, enumerator.Current.Length);
count++;
}

62
tests/Avalonia.Benchmarks/Text/HugeTextLayout.cs

@ -0,0 +1,62 @@
using System;
using Avalonia.Media;
using Avalonia.Media.TextFormatting;
using Avalonia.UnitTests;
using BenchmarkDotNet.Attributes;
namespace Avalonia.Benchmarks.Text;
[MemoryDiagnoser]
public class HugeTextLayout : IDisposable
{
private readonly IDisposable _app;
public HugeTextLayout()
{
_app = UnitTestApplication.Start(
TestServices.StyledWindow.With(
renderInterface: new NullRenderingPlatform(),
threadingInterface: new NullThreadingPlatform(),
standardCursorFactory: new NullCursorFactory()));
}
private const string Text = @"Though, the objectives of the development of the prominent landmarks can be neglected in most cases, it should be realized that after the completion of the strategic decision gives rise to The Expertise of Regular Program (Carlton Cartwright in The Book of the Key Factor)
A number of key issues arise from the belief that the explicit examination of strategic management should correlate with the conceptual design.
By all means, the unification of the reliably developed techniques indicates the importance of the ultimate advantage of episodic skill over alternate practices.
Let's consider, that the portion of the continuing support can be regarded as relentlessly insignificant. The hardware maintenance focuses our attention on the structure absorption. The real reason of the permanent growth drastically the preliminary action plan the ultimate advantage of useful probability over alternate practices.
Let it not be said that a section of the essential component discards the principle of the more interconnection of critical thinking with productivity boosting of the referential arguments.
One should, however, not forget that concentration of violations of the strategic management requires urgent actions to be taken towards the comprehensive set of policy statements. Therefore, the concept of the design aspects can be treated as the only solution.
In a loose sense concentration of the center of the critical thinking provides a deep insight into the emergency planning. The comparison is quite a powerful matter.
Resulting from review or analysis of threats and opportunities, we can presume that either significant improvement or basics of planning and scheduling reveals the patterns of the final draft. Therefore, the concept of the crucial component can be treated as the only solution.
One should, nevertheless, consider that the exceptional results of the diverse sources of information gives an overview of the production cycle. It should rather be regarded as an integral part of the direct access to key resources.
Admitting that the possibility of achieving the results of the constructive criticism, as far as the strategic management is questionable, cannot rely only on the critical thinking. It may reveal how the systems approach partially the comprehensive project management. We must be ready for outline design stage and network development investigation of every contradiction between the effective time management and the efficient decision the network development. Everyone understands what it takes to the draft analysis and prior decisions and early design solutions. In any case, we can systematically change the mechanism of the sources and influences of the continuing financing doctrine. This could exceedingly be a result of a task analysis the hardware maintenance. The real reason of the strategic planning seemingly the influence on eventual productivity. Everyone understands what it takes to the well-known practice. Therefore, the concept of the productivity boost can be treated as the only solution the driving factor. It may reveal how the matters of peculiar interest slowly the goals and objectives or the diverse sources of information the positive influence of any major outcomes complete failure of the supposed theory.
In respect that the structure of the sufficient amount poses problems and challenges for both the set of related commands and controls and the ability bias.";
[Benchmark]
public TextLayout BuildTextLayout() => new TextLayout(Text, Typeface.Default, 12d, Brushes.Black);
private const string Emojis = @"😀 😁 😂 🤣 😃 😄 😅 😆 😉 😊 😋 😎 😍 😘 🥰 😗 😙 😚 ☺️ 🙂 🤗 🤩 🤔 🤨 😐 😑 😶 🙄 😏 😣 😥 😮 🤐 😯 😪 😫 😴 😌 😛 😜 😝 🤤 😒 😓 😔 😕 🙃 🤑 😲 ☹️ 🙁 😖 😞 😟 😤 😢 😭 😦 😧 😨 😩 🤯 😬 😰 😱 🥵 🥶 😳 🤪 😵 😡 😠 🤬 😷 🤒 🤕 🤢 🤮 🤧 😇 🤠 🤡 🥳 🥴 🥺 🤥 🤫 🤭 🧐 🤓 😈 👿 👹 👺 💀 👻 👽 🤖 💩 😺 😸 😹 😻 😼 😽 🙀 😿 😾
👶 👧 🧒 👦 👩 🧑 👨 👵 🧓 👴 👲 👳 👳 🧕 🧔 👱 👱 👨🦰 👩🦰 👨🦱 👩🦱 👨🦲 👩🦲 👨🦳 👩🦳 🦸 🦸 🦹 🦹 👮 👮 👷 👷 💂 💂 🕵 🕵 👩 👨 👩🌾 👨🌾 👩🍳 👨🍳 👩🎓 👨🎓 👩🎤 👨🎤 👩🏫 👨🏫 👩🏭 👨🏭 👩💻 👨💻 👩💼 👨💼 👩🔧 👨🔧 👩🔬 👨🔬 👩🎨 👨🎨 👩🚒 👨🚒 👩 👨 👩🚀 👨🚀 👩 👨 👰 🤵 👸 🤴 🤶 🎅 🧙 🧙 🧝 🧝 🧛 🧛 🧟 🧟 🧞 🧞 🧜 🧜 🧚 🧚 👼 🤰 🤱 🙇 🙇 💁 💁 🙅 🙅 🙆 🙆 🙋 🙋 🤦 🤦 🤷 🤷 🙎 🙎 🙍 🙍 💇 💇 💆 💆 🧖 🧖 💅 🤳 💃 🕺 👯 👯 🕴 🚶 🚶 🏃 🏃 👫 👭 👬 💑 👩👩 👨👨 💏 👩💋👩 👨💋👨 👪 👨👩👧 👨👩👧👦 👨👩👦👦 👨👩👧👧 👩👩👦 👩👩👧 👩👩👧👦 👩👩👦👦 👩👩👧👧 👨👨👦 👨👨👧 👨👨👧👦 👨👨👦👦 👨👨👧👧 👩👦 👩👧 👩👧👦 👩👦👦 👩👧👧 👨👦 👨👧 👨👧👦 👨👦👦 👨👧👧 🤲 👐 🙌 👏 🤝 👍 👎 👊 🤛 🤜 🤞 🤟 🤘 👌 👈 👉 👆 👇 🤚 🖐 🖖 👋 🤙 💪 🦵 🦶 🖕 🙏 💍 💄 💋 👄 👅 👂 👃 👣 👁 👀 🧠 🦴 🦷 🗣 👤 👥
🧥 👚 👕 👖 👔 👗 👙 👘 👠 👡 👢 👞 👟 🥾 🥿 🧦 🧤 🧣 🎩 🧢 👒 🎓 👑 👝 👛 👜 💼 🎒 👓 🕶 🥽 🥼 🌂 🧵 🧶
👶🏻 👦🏻 👧🏻 👨🏻 👩🏻 👱🏻 👱🏻 👴🏻 👵🏻 👲🏻 👳🏻 👳🏻 👮🏻 👮🏻 👷🏻 👷🏻 💂🏻 💂🏻 🕵🏻 🕵🏻 👩🏻 👨🏻 👩🏻🌾 👨🏻🌾 👩🏻🍳 👨🏻🍳 👩🏻🎓 👨🏻🎓 👩🏻🎤 👨🏻🎤 👩🏻🏫 👨🏻🏫 👩🏻🏭 👨🏻🏭 👩🏻💻 👨🏻💻 👩🏻💼 👨🏻💼 👩🏻🔧 👨🏻🔧 👩🏻🔬 👨🏻🔬 👩🏻🎨 👨🏻🎨 👩🏻🚒 👨🏻🚒 👩🏻 👨🏻 👩🏻🚀 👨🏻🚀 👩🏻 👨🏻 🤶🏻 🎅🏻 👸🏻 🤴🏻 👰🏻 🤵🏻 👼🏻 🤰🏻 🙇🏻 🙇🏻 💁🏻 💁🏻 🙅🏻 🙅🏻 🙆🏻 🙆🏻 🙋🏻 🙋🏻 🤦🏻 🤦🏻 🤷🏻 🤷🏻 🙎🏻 🙎🏻 🙍🏻 🙍🏻 💇🏻 💇🏻 💆🏻 💆🏻 🕴🏻 💃🏻 🕺🏻 🚶🏻 🚶🏻 🏃🏻 🏃🏻 🤲🏻 👐🏻 🙌🏻 👏🏻 🙏🏻 👍🏻 👎🏻 👊🏻 🏻 🤛🏻 🤜🏻 🤞🏻 🏻 🤟🏻 🤘🏻 👌🏻 👈🏻 👉🏻 👆🏻 👇🏻 🏻 🏻 🤚🏻 🖐🏻 🖖🏻 👋🏻 🤙🏻 💪🏻 🖕🏻 🏻 🤳🏻 💅🏻 👂🏻 👃🏻
👶🏼 👦🏼 👧🏼 👨🏼 👩🏼 👱🏼 👱🏼 👴🏼 👵🏼 👲🏼 👳🏼 👳🏼 👮🏼 👮🏼 👷🏼 👷🏼 💂🏼 💂🏼 🕵🏼 🕵🏼 👩🏼 👨🏼 👩🏼🌾 👨🏼🌾 👩🏼🍳 👨🏼🍳 👩🏼🎓 👨🏼🎓 👩🏼🎤 👨🏼🎤 👩🏼🏫 👨🏼🏫 👩🏼🏭 👨🏼🏭 👩🏼💻 👨🏼💻 👩🏼💼 👨🏼💼 👩🏼🔧 👨🏼🔧 👩🏼🔬 👨🏼🔬 👩🏼🎨 👨🏼🎨 👩🏼🚒 👨🏼🚒 👩🏼 👨🏼 👩🏼🚀 👨🏼🚀 👩🏼 👨🏼 🤶🏼 🎅🏼 👸🏼 🤴🏼 👰🏼 🤵🏼 👼🏼 🤰🏼 🙇🏼 🙇🏼 💁🏼 💁🏼 🙅🏼 🙅🏼 🙆🏼 🙆🏼 🙋🏼 🙋🏼 🤦🏼 🤦🏼 🤷🏼 🤷🏼 🙎🏼 🙎🏼 🙍🏼 🙍🏼 💇🏼 💇🏼 💆🏼 💆🏼 🕴🏼 💃🏼 🕺🏼 🚶🏼 🚶🏼 🏃🏼 🏃🏼 🤲🏼 👐🏼 🙌🏼 👏🏼 🙏🏼 👍🏼 👎🏼 👊🏼 🏼 🤛🏼 🤜🏼 🤞🏼 🏼 🤟🏼 🤘🏼 👌🏼 👈🏼 👉🏼 👆🏼 👇🏼 🏼 🏼 🤚🏼 🖐🏼 🖖🏼 👋🏼 🤙🏼 💪🏼 🖕🏼 🏼 🤳🏼 💅🏼 👂🏼 👃🏼
👶🏽 👦🏽 👧🏽 👨🏽 👩🏽 👱🏽 👱🏽 👴🏽 👵🏽 👲🏽 👳🏽 👳🏽 👮🏽 👮🏽 👷🏽 👷🏽 💂🏽 💂🏽 🕵🏽 🕵🏽 👩🏽 👨🏽 👩🏽🌾 👨🏽🌾 👩🏽🍳 👨🏽🍳 👩🏽🎓 👨🏽🎓 👩🏽🎤 👨🏽🎤 👩🏽🏫 👨🏽🏫 👩🏽🏭 👨🏽🏭 👩🏽💻 👨🏽💻 👩🏽💼 👨🏽💼 👩🏽🔧 👨🏽🔧 👩🏽🔬 👨🏽🔬 👩🏽🎨 👨🏽🎨 👩🏽🚒 👨🏽🚒 👩🏽 👨🏽 👩🏽🚀 👨🏽🚀 👩🏽 👨🏽 🤶🏽 🎅🏽 👸🏽 🤴🏽 👰🏽 🤵🏽 👼🏽 🤰🏽 🙇🏽 🙇🏽 💁🏽 💁🏽 🙅🏽 🙅🏽 🙆🏽 🙆🏽 🙋🏽 🙋🏽 🤦🏽 🤦🏽 🤷🏽 🤷🏽 🙎🏽 🙎🏽 🙍🏽 🙍🏽 💇🏽 💇🏽 💆🏽 💆🏽 🕴🏼 💃🏽 🕺🏽 🚶🏽 🚶🏽 🏃🏽 🏃🏽 🤲🏽 👐🏽 🙌🏽 👏🏽 🙏🏽 👍🏽 👎🏽 👊🏽 🏽 🤛🏽 🤜🏽 🤞🏽 🏽 🤟🏽 🤘🏽 👌🏽 👈🏽 👉🏽 👆🏽 👇🏽 🏽 🏽 🤚🏽 🖐🏽 🖖🏽 👋🏽 🤙🏽 💪🏽 🖕🏽 🏽 🤳🏽 💅🏽 👂🏽 👃🏽
👶🏾 👦🏾 👧🏾 👨🏾 👩🏾 👱🏾 👱🏾 👴🏾 👵🏾 👲🏾 👳🏾 👳🏾 👮🏾 👮🏾 👷🏾 👷🏾 💂🏾 💂🏾 🕵🏾 🕵🏾 👩🏾 👨🏾 👩🏾🌾 👨🏾🌾 👩🏾🍳 👨🏾🍳 👩🏾🎓 👨🏾🎓 👩🏾🎤 👨🏾🎤 👩🏾🏫 👨🏾🏫 👩🏾🏭 👨🏾🏭 👩🏾💻 👨🏾💻 👩🏾💼 👨🏾💼 👩🏾🔧 👨🏾🔧 👩🏾🔬 👨🏾🔬 👩🏾🎨 👨🏾🎨 👩🏾🚒 👨🏾🚒 👩🏾 👨🏾 👩🏾🚀 👨🏾🚀 👩🏾 👨🏾 🤶🏾 🎅🏾 👸🏾 🤴🏾 👰🏾 🤵🏾 👼🏾 🤰🏾 🙇🏾 🙇🏾 💁🏾 💁🏾 🙅🏾 🙅🏾 🙆🏾 🙆🏾 🙋🏾 🙋🏾 🤦🏾 🤦🏾 🤷🏾 🤷🏾 🙎🏾 🙎🏾 🙍🏾 🙍🏾 💇🏾 💇🏾 💆🏾 💆🏾 🕴🏾 💃🏾 🕺🏾 🚶🏾 🚶🏾 🏃🏾 🏃🏾 🤲🏾 👐🏾 🙌🏾 👏🏾 🙏🏾 👍🏾 👎🏾 👊🏾 🏾 🤛🏾 🤜🏾 🤞🏾 🏾 🤟🏾 🤘🏾 👌🏾 👈🏾 👉🏾 👆🏾 👇🏾 🏾 🏾 🤚🏾 🖐🏾 🖖🏾 👋🏾 🤙🏾 💪🏾 🖕🏾 🏾 🤳🏾 💅🏾 👂🏾 👃🏾
👶🏿 👦🏿 👧🏿 👨🏿 👩🏿 👱🏿 👱🏿 👴🏿 👵🏿 👲🏿 👳🏿 👳🏿 👮🏿 👮🏿 👷🏿 👷🏿 💂🏿 💂🏿 🕵🏿 🕵🏿 👩🏿 👨🏿 👩🏿🌾 👨🏿🌾 👩🏿🍳 👨🏿🍳 👩🏿🎓 👨🏿🎓 👩🏿🎤 👨🏿🎤 👩🏿🏫 👨🏿🏫 👩🏿🏭 👨🏿🏭 👩🏿💻 👨🏿💻 👩🏿💼 👨🏿💼 👩🏿🔧 👨🏿🔧 👩🏿🔬 👨🏿🔬 👩🏿🎨 👨🏿🎨 👩🏿🚒 👨🏿🚒 👩🏿 👨🏿 👩🏿🚀 👨🏿🚀 👩🏿 👨🏿 🤶🏿 🎅🏿 👸🏿 🤴🏿 👰🏿 🤵🏿 👼🏿 🤰🏿 🙇🏿 🙇🏿 💁🏿 💁🏿 🙅🏿 🙅🏿 🙆🏿 🙆🏿 🙋🏿 🙋🏿 🤦🏿 🤦🏿 🤷🏿 🤷🏿 🙎🏿 🙎🏿 🙍🏿 🙍🏿 💇🏿 💇🏿 💆🏿 💆🏿 🕴🏿 💃🏿 🕺🏿 🚶🏿 🚶🏿 🏃🏿 🏃🏿 🤲🏿 👐🏿 🙌🏿 👏🏿 🙏🏿 👍🏿 👎🏿 👊🏿 🏿 🤛🏿 🤜🏿 🤞🏿 🏿 🤟🏿 🤘🏿 👌🏿 👈🏿 👉🏿 👆🏿 👇🏿 🏿 🏿 🤚🏿 🖐🏿 🖖🏿 👋🏿 🤙🏿 💪🏿 🖕🏿 🏿 🤳🏿 💅🏿 👂🏿 👃🏿
🐶 🐱 🐭 🐹 🐰 🦊 🦝 🐻 🐼 🦘 🦡 🐨 🐯 🦁 🐮 🐷 🐽 🐸 🐵 🙈 🙉 🙊 🐒 🐔 🐧 🐦 🐤 🐣 🐥 🦆 🦢 🦅 🦉 🦚 🦜 🦇 🐺 🐗 🐴 🦄 🐝 🐛 🦋 🐌 🐚 🐞 🐜 🦗 🕷 🕸 🦂 🦟 🦠 🐢 🐍 🦎 🦖 🦕 🐙 🦑 🦐 🦀 🐡 🐠 🐟 🐬 🐳 🐋 🦈 🐊 🐅 🐆 🦓 🦍 🐘 🦏 🦛 🐪 🐫 🦙 🦒 🐃 🐂 🐄 🐎 🐖 🐏 🐑 🐐 🦌 🐕 🐩 🐈 🐓 🦃 🕊 🐇 🐁 🐀 🐿 🦔 🐾 🐉 🐲 🌵 🎄 🌲 🌳 🌴 🌱 🌿 🍀 🎍 🎋 🍃 🍂 🍁 🍄 🌾 💐 🌷 🌹 🥀 🌺 🌸 🌼 🌻 🌞 🌝 🌛 🌜 🌚 🌕 🌖 🌗 🌘 🌑 🌒 🌓 🌔 🌙 🌎 🌍 🌏 💫 🌟 💥 🔥 🌪 🌈 🌤 🌥 🌦 🌧 🌩 🌨 🌬 💨 💧 💦 🌊 🌫
🍏 🍎 🍐 🍊 🍋 🍌 🍉 🍇 🍓 🍈 🍒 🍑 🍍 🥭 🥥 🥝 🍅 🍆 🥑 🥦 🥒 🥬 🌶 🌽 🥕 🥔 🍠 🥐 🍞 🥖 🥨 🥯 🧀 🥚 🍳 🥞 🥓 🥩 🍗 🍖 🌭 🍔 🍟 🍕 🥪 🥙 🌮 🌯 🥗 🥘 🥫 🍝 🍜 🍲 🍛 🍣 🍱 🥟 🍤 🍙 🍚 🍘 🍥 🥮 🥠 🍢 🍡 🍧 🍨 🍦 🥧 🍰 🎂 🍮 🍭 🍬 🍫 🍿 🧂 🍩 🍪 🌰 🥜 🍯 🥛 🍼 🍵 🥤 🍶 🍺 🍻 🥂 🍷 🥃 🍸 🍹 🍾 🥄 🍴 🍽 🥣 🥡 🥢
🏀 🏈 🥎 🏐 🏉 🎾 🥏 🎱 🏓 🏸 🥅 🏒 🏑 🥍 🏏 🏹 🎣 🥊 🥋 🎽 🥌 🛷 🛹 🎿 🏂 🏋 🏋🏻 🏋🏼 🏋🏽 🏋🏾 🏋🏿 🏋 🏋🏻 🏋🏼 🏋🏽 🏋🏾 🏋🏿 🤼 🤼 🤸 🤸🏻 🤸🏼 🤸🏽 🤸🏾 🤸🏿 🤸 🤸🏻 🤸🏼 🤸🏽 🤸🏾 🤸🏿 🏻 🏼 🏽 🏾 🏿 🏻 🏼 🏽 🏾 🏿 🤺 🤾 🤾🏻 🤾🏼 🤾🏾 🤾🏾 🤾🏿 🤾 🤾🏻 🤾🏼 🤾🏽 🤾🏾 🤾🏿 🏌 🏌🏻 🏌🏼 🏌🏽 🏌🏾 🏌🏿 🏌 🏌🏻 🏌🏼 🏌🏽 🏌🏾 🏌🏿 🏇 🏇🏻 🏇🏼 🏇🏽 🏇🏾 🏇🏿 🧘 🧘🏻 🧘🏼 🧘🏽 🧘🏾 🧘🏿 🧘 🧘🏻 🧘🏼 🧘🏽 🧘🏾 🧘🏿 🏄 🏄🏻 🏄🏼 🏄🏽 🏄🏾 🏄🏿 🏄 🏄🏻 🏄🏼 🏄🏽 🏄🏾 🏄🏿 🏊 🏊🏻 🏊🏼 🏊🏽 🏊🏾 🏊🏿 🏊 🏊🏻 🏊🏼 🏊🏽 🏊🏾 🏊🏿 🤽 🤽🏻 🤽🏼 🤽🏽 🤽🏾 🤽🏿 🤽 🤽🏻 🤽🏼 🤽🏽 🤽🏾 🤽🏿 🚣 🚣🏻 🚣🏼 🚣🏽 🚣🏾 🚣🏿 🚣 🚣🏻 🚣🏼 🚣🏽 🚣🏾 🚣🏿 🧗 🧗🏻 🧗🏼 🧗🏽 🧗🏾 🧗🏿 🧗 🧗🏻 🧗🏼 🧗🏽 🧗🏾 🧗🏿 🚵 🚵🏻 🚵🏼 🚵🏽 🚵🏾 🚵🏿 🚵 🚵🏻 🚵🏼 🚵🏽 🚵🏾 🚵🏿 🚴 🚴🏻 🚴🏼 🚴🏽 🚴🏾 🚴🏿 🚴 🚴🏻 🚴🏼 🚴🏽 🚴🏾 🚴🏿 🏆 🥇 🥈 🥉 🏅 🎖 🏵 🎗 🎫 🎟 🎪 🤹 🤹🏻 🤹🏼 🤹🏽 🤹🏾 🤹🏿 🤹 🤹🏻 🤹🏼 🤹🏽 🤹🏾 🤹🏿 🎭 🎨 🎬 🎤 🎧 🎼 🎹 🥁 🎷 🎺 🎸 🎻 🎲 🧩 🎯 🎳 🎮 🎰
🚗 🚕 🚙 🚌 🚎 🏎 🚓 🚑 🚒 🚐 🚚 🚛 🚜 🛴 🚲 🛵 🏍 🚨 🚔 🚍 🚘 🚖 🚡 🚠 🚟 🚃 🚋 🚞 🚝 🚄 🚅 🚈 🚂 🚆 🚇 🚊 🚉 🛫 🛬 🛩 💺 🛰 🚀 🛸 🚁 🛶 🚤 🛥 🛳 🚢 🚧 🚦 🚥 🚏 🗺 🗿 🗽 🗼 🏰 🏯 🏟 🎡 🎢 🎠 🏖 🏝 🏜 🌋 🏔 🗻 🏕 🏠 🏡 🏘 🏚 🏗 🏭 🏢 🏬 🏣 🏤 🏥 🏦 🏨 🏪 🏫 🏩 💒 🏛 🕌 🕍 🕋 🛤 🛣 🗾 🎑 🏞 🌅 🌄 🌠 🎇 🎆 🌇 🌆 🏙 🌃 🌌 🌉 🌁
📱 📲 💻 🖥 🖨 🖱 🖲 🕹 🗜 💽 💾 💿 📀 📼 📷 📸 📹 🎥 📽 🎞 📞 📟 📠 📺 📻 🎙 🎚 🎛 🕰 📡 🔋 🔌 💡 🔦 🕯 🗑 🛢 💸 💵 💴 💶 💷 💰 💳 🧾 💎 🔧 🔨 🛠 🔩 🔫 💣 🔪 🗡 🛡 🚬 🏺 🧭 🧱 🔮 🧿 🧸 📿 💈 🔭 🧰 🧲 🧪 🧫 🧬 🧯 🔬 🕳 💊 💉 🌡 🚽 🚰 🚿 🛁 🛀 🛀🏻 🛀🏼 🛀🏽 🛀🏾 🛀🏿 🧴 🧵 🧶 🧷 🧹 🧺 🧻 🧼 🧽 🛎 🔑 🗝 🚪 🛋 🛏 🛌 🖼 🛍 🧳 🛒 🎁 🎈 🎏 🎀 🎊 🎉 🧨 🎎 🏮 🎐 🧧 📩 📨 📧 💌 📥 📤 📦 🏷 📪 📫 📬 📭 📮 📯 📜 📃 📄 📑 📊 📈 📉 🗒 🗓 📆 📅 📇 🗃 🗳 🗄 📋 📁 📂 🗂 🗞 📰 📓 📔 📒 📕 📗 📘 📙 📚 📖 🔖 🔗 📎 🖇 📐 📏 📌 📍 🖊 🖋 🖌 🖍 📝 🔍 🔎 🔏 🔐 🔒 🔓
🧡 💛 💚 💙 💜 🖤 💔 💕 💞 💓 💗 💖 💘 💝 💟 🕉 🔯 🕎 🛐 🆔 🉑 📴 📳 🈶 🈚 🈸 🈺 🈷 🆚 💮 🉐 🈴 🈵 🈹 🈲 🅰 🅱 🆎 🆑 🅾 🆘 🛑 📛 🚫 💯 💢 🚷 🚯 🚳 🚱 🔞 📵 🚭 🔅 🔆 🚸 🔱 🔰 🈯 💹 🌐 💠 🌀 💤 🏧 🚾 🅿 🈳 🈂 🛂 🛃 🛄 🛅 🚹 🚺 🚼 🚻 🚮 🎦 📶 🈁 🔣 🔤 🔡 🔠 🆖 🆗 🆙 🆒 🆕 🆓 0 1 2 3 4 5 6 7 8 9 🔟 🔢 # * 🔼 🔽 🔀 🔁 🔂 🔄 🔃 🎵 🎶 💲 💱 © ® 🔚 🔙 🔛 🔝 🔜 🔘 🔴 🔵 🔺 🔻 🔸 🔹 🔶 🔷 🔳 🔲 🔈 🔇 🔉 🔊 🔔 🔕 📣 📢 👁🗨 💬 💭 🗯 🃏 🎴 🀄 🕐 🕑 🕒 🕓 🕔 🕕 🕖 🕗 🕘 🕙 🕚 🕛 🕜 🕝 🕞 🕟 🕠 🕡 🕢 🕣 🕤 🕥 🕦 🕧
🏳 🏴 🏁 🚩 🏳🌈 🏴 🇦🇫 🇦🇽 🇦🇱 🇩🇿 🇦🇸 🇦🇩 🇦🇴 🇦🇮 🇦🇶 🇦🇬 🇦🇷 🇦🇲 🇦🇼 🇦🇺 🇦🇹 🇦🇿 🇧🇸 🇧🇭 🇧🇩 🇧🇧 🇧🇾 🇧🇪 🇧🇿 🇧🇯 🇧🇲 🇧🇹 🇧🇴 🇧🇦 🇧🇼 🇧🇷 🇮🇴 🇻🇬 🇧🇳 🇧🇬 🇧🇫 🇧🇮 🇰🇭 🇨🇲 🇨🇦 🇮🇨 🇨🇻 🇧🇶 🇰🇾 🇨🇫 🇹🇩 🇨🇱 🇨🇳 🇨🇽 🇨🇨 🇨🇴 🇰🇲 🇨🇬 🇨🇩 🇨🇰 🇨🇷 🇨🇮 🇭🇷 🇨🇺 🇨🇼 🇨🇾 🇨🇿 🇩🇰 🇩🇯 🇩🇲 🇩🇴 🇪🇨 🇪🇬 🇸🇻 🇬🇶 🇪🇷 🇪🇪 🇪🇹 🇪🇺 🇫🇰 🇫🇴 🇫🇯 🇫🇮 🇫🇷 🇬🇫 🇵🇫 🇹🇫 🇬🇦 🇬🇲 🇬🇪 🇩🇪 🇬🇭 🇬🇮 🇬🇷 🇬🇱 🇬🇩 🇬🇵 🇬🇺 🇬🇹 🇬🇬 🇬🇳 🇬🇼 🇬🇾 🇭🇹 🇭🇳 🇭🇰 🇭🇺 🇮🇸 🇮🇳 🇮🇩 🇮🇷 🇮🇶 🇮🇪 🇮🇲 🇮🇱 🇮🇹 🇯🇲 🇯🇵 🎌 🇯🇪 🇯🇴 🇰🇿 🇰🇪 🇰🇮 🇽🇰 🇰🇼 🇰🇬 🇱🇦 🇱🇻 🇱🇧 🇱🇸 🇱🇷 🇱🇾 🇱🇮 🇱🇹 🇱🇺 🇲🇴 🇲🇰 🇲🇬 🇲🇼 🇲🇾 🇲🇻 🇲🇱 🇲🇹 🇲🇭 🇲🇶 🇲🇷 🇲🇺 🇾🇹 🇲🇽 🇫🇲 🇲🇩 🇲🇨 🇲🇳 🇲🇪 🇲🇸 🇲🇦 🇲🇿 🇲🇲 🇳🇦 🇳🇷 🇳🇵 🇳🇱 🇳🇨 🇳🇿 🇳🇮 🇳🇪 🇳🇬 🇳🇺 🇳🇫 🇰🇵 🇲🇵 🇳🇴 🇴🇲 🇵🇰 🇵🇼 🇵🇸 🇵🇦 🇵🇬 🇵🇾 🇵🇪 🇵🇭 🇵🇳 🇵🇱 🇵🇹 🇵🇷 🇶🇦 🇷🇪 🇷🇴 🇷🇺 🇷🇼 🇼🇸 🇸🇲 🇸🇦 🇸🇳 🇷🇸 🇸🇨 🇸🇱 🇸🇬 🇸🇽 🇸🇰 🇸🇮 🇬🇸 🇸🇧 🇸🇴 🇿🇦 🇰🇷 🇸🇸 🇪🇸 🇱🇰 🇧🇱 🇸🇭 🇰🇳 🇱🇨 🇵🇲 🇻🇨 🇸🇩 🇸🇷 🇸🇿 🇸🇪 🇨🇭 🇸🇾 🇹🇼 🇹🇯 🇹🇿 🇹🇭 🇹🇱 🇹🇬 🇹🇰 🇹🇴 🇹🇹 🇹🇳 🇹🇷 🇹🇲 🇹🇨 🇹🇻 🇻🇮 🇺🇬 🇺🇦 🇦🇪 🇬🇧 🏴󠁧󠁢󠁥󠁮󠁧󠁿 🏴󠁧󠁢󠁳󠁣󠁴󠁿 🏴󠁧󠁢󠁷󠁬󠁳󠁿 🇺🇳 🇺🇸 🇺🇾 🇺🇿 🇻🇺 🇻🇦 🇻🇪 🇻🇳 🇼🇫 🇪🇭 🇾🇪 🇿🇲 🇿🇼
🥱 🤏 🦾 🦿 🦻 🧏 🧏 🧏 🧍 🧍 🧍 🧎 🧎 🧎 👨🦯 👩🦯 👨🦼 👩🦼 👨🦽 👩🦽 🦧 🦮 🐕🦺 🦥 🦦 🦨 🦩 🧄 🧅 🧇 🧆 🧈 🦪 🧃 🧉 🧊 🛕 🦽 🦼 🛺 🪂 🪐 🤿 🪀 🪁 🦺 🥻 🩱 🩲 🩳 🩰 🪕 🪔 🪓 🦯 🩸 🩹 🩺 🪑 🪒 🤎 🤍 🟠 🟡 🟢 🟣 🟤 🟥 🟧 🟨 🟩 🟦 🟪 🟫";
[Benchmark]
public TextLayout BuildEmojisTextLayout() => new TextLayout(Emojis, Typeface.Default, 12d, Brushes.Black);
public void Dispose()
{
_app?.Dispose();
}
}

1
tests/Avalonia.Controls.DataGrid.UnitTests/Avalonia.Controls.DataGrid.UnitTests.csproj

@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<OutputType>Library</OutputType>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

1
tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj

@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<OutputType>Library</OutputType>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

2
tests/Avalonia.Controls.UnitTests/ContextMenuTests.cs

@ -596,7 +596,7 @@ namespace Avalonia.Controls.UnitTests
private static Window PreparedWindow(object content = null)
{
var renderer = new Mock<IRenderer>();
var platform = AvaloniaLocator.Current.GetService<IWindowingPlatform>();
var platform = AvaloniaLocator.Current.GetRequiredService<IWindowingPlatform>();
var windowImpl = Mock.Get(platform.CreateWindow());
windowImpl.Setup(x => x.CreateRenderer(It.IsAny<IRenderRoot>())).Returns(renderer.Object);

2
tests/Avalonia.Controls.UnitTests/FlyoutTests.cs

@ -570,7 +570,7 @@ namespace Avalonia.Controls.UnitTests
private static Window PreparedWindow(object content = null)
{
var renderer = new Mock<IRenderer>();
var platform = AvaloniaLocator.Current.GetService<IWindowingPlatform>();
var platform = AvaloniaLocator.Current.GetRequiredService<IWindowingPlatform>();
var windowImpl = Mock.Get(platform.CreateWindow());
windowImpl.Setup(x => x.CreateRenderer(It.IsAny<IRenderRoot>())).Returns(renderer.Object);

2
tests/Avalonia.Controls.UnitTests/MaskedTextBoxTests.cs

@ -827,7 +827,7 @@ namespace Avalonia.Controls.UnitTests
{
AvaloniaLocator.CurrentMutable.Bind<IClipboard>().ToSingleton<ClipboardStub>();
var clipboard = AvaloniaLocator.CurrentMutable.GetService<IClipboard>();
var clipboard = AvaloniaLocator.CurrentMutable.GetRequiredService<IClipboard>();
clipboard.SetTextAsync(textInput).GetAwaiter().GetResult();
RaiseKeyEvent(target, Key.V, KeyModifiers.Control);

2
tests/Avalonia.Controls.UnitTests/Presenters/ItemsPresenterTests_Virtualization_Simple.cs

@ -569,7 +569,7 @@ namespace Avalonia.Controls.UnitTests.Presenters
var target = CreateTarget(itemCount: 10);
var items = (IList<string>)target.Items;
target.ApplyTemplate();
target.Measure(default(Size));
target.Measure(default);
target.Arrange(default);
// Check for issue #591: this should not throw.

2
tests/Avalonia.Controls.UnitTests/Primitives/PopupTests.cs

@ -564,7 +564,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
using (CreateServices())
{
var renderer = new Mock<IRenderer>();
var platform = AvaloniaLocator.Current.GetService<IWindowingPlatform>();
var platform = AvaloniaLocator.Current.GetRequiredService<IWindowingPlatform>();
var windowImpl = Mock.Get(platform.CreateWindow());
windowImpl.Setup(x => x.CreateRenderer(It.IsAny<IRenderRoot>())).Returns(renderer.Object);

4
tests/Avalonia.Controls.UnitTests/TextBoxTests.cs

@ -767,7 +767,7 @@ namespace Avalonia.Controls.UnitTests
{
AvaloniaLocator.CurrentMutable.Bind<IClipboard>().ToSingleton<ClipboardStub>();
var clipboard = AvaloniaLocator.CurrentMutable.GetService<IClipboard>();
var clipboard = AvaloniaLocator.CurrentMutable.GetRequiredService<IClipboard>();
clipboard.SetTextAsync(textInput).GetAwaiter().GetResult();
RaiseKeyEvent(target, Key.V, KeyModifiers.Control);
@ -876,7 +876,7 @@ namespace Avalonia.Controls.UnitTests
AvaloniaLocator.CurrentMutable.Bind<IClipboard>().ToSingleton<ClipboardStub>();
var clipboard = AvaloniaLocator.CurrentMutable.GetService<IClipboard>();
var clipboard = AvaloniaLocator.CurrentMutable.GetRequiredService<IClipboard>();
clipboard.SetTextAsync(Environment.NewLine).GetAwaiter().GetResult();
RaiseKeyEvent(target, Key.V, KeyModifiers.Control);

9
tests/Avalonia.Controls.UnitTests/TreeViewTests.cs

@ -1248,7 +1248,7 @@ namespace Avalonia.Controls.UnitTests
using (Application())
{
var focus = FocusManager.Instance;
var navigation = AvaloniaLocator.Current.GetService<IKeyboardNavigationHandler>();
var navigation = AvaloniaLocator.Current.GetRequiredService<IKeyboardNavigationHandler>();
var data = CreateTestTreeData();
var target = new TreeView
@ -1293,7 +1293,6 @@ namespace Avalonia.Controls.UnitTests
using (Application())
{
var focus = FocusManager.Instance;
var navigation = AvaloniaLocator.Current.GetService<IKeyboardNavigationHandler>();
var data = CreateTestTreeData();
var selectedNode = new Node { Value = "Out of Tree Selected Item" };
@ -1353,7 +1352,7 @@ namespace Avalonia.Controls.UnitTests
var rootNode = tree[0];
var keymap = AvaloniaLocator.Current.GetService<PlatformHotkeyConfiguration>();
var keymap = AvaloniaLocator.Current.GetRequiredService<PlatformHotkeyConfiguration>();
var selectAllGesture = keymap.SelectAll.First();
var keyEvent = new KeyEventArgs
@ -1400,7 +1399,7 @@ namespace Avalonia.Controls.UnitTests
ClickContainer(fromContainer, KeyModifiers.None);
ClickContainer(toContainer, KeyModifiers.Shift);
var keymap = AvaloniaLocator.Current.GetService<PlatformHotkeyConfiguration>();
var keymap = AvaloniaLocator.Current.GetRequiredService<PlatformHotkeyConfiguration>();
var selectAllGesture = keymap.SelectAll.First();
var keyEvent = new KeyEventArgs
@ -1447,7 +1446,7 @@ namespace Avalonia.Controls.UnitTests
ClickContainer(fromContainer, KeyModifiers.None);
ClickContainer(toContainer, KeyModifiers.Shift);
var keymap = AvaloniaLocator.Current.GetService<PlatformHotkeyConfiguration>();
var keymap = AvaloniaLocator.Current.GetRequiredService<PlatformHotkeyConfiguration>();
var selectAllGesture = keymap.SelectAll.First();
var keyEvent = new KeyEventArgs

1
tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj

@ -3,7 +3,6 @@
<TargetFrameworks>net6.0;net47</TargetFrameworks>
<OutputType>Library</OutputType>
<IsTestProject>true</IsTestProject>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<Import Project="..\..\build\UnitTests.NetCore.targets" />
<Import Project="..\..\build\UnitTests.NetFX.props" />

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save