Browse Source

Merge branch 'master' into consistent-LangVersion

pull/9862/head
Max Katz 3 years ago
committed by GitHub
parent
commit
629b1cad1b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      samples/ControlCatalog.Desktop/Program.cs
  2. 2
      samples/ControlCatalog/Pages/TabControlPage.xaml.cs
  3. 2
      samples/ControlCatalog/Pages/TextBoxPage.xaml
  4. 2
      samples/ControlCatalog/ViewModels/CursorPageViewModel.cs
  5. 2
      samples/ControlCatalog/ViewModels/TransitioningContentControlPageViewModel.cs
  6. 2
      src/Avalonia.Base/Data/Converters/FuncMultiValueConverter.cs
  7. 3
      src/Avalonia.Base/Input/Cursor.cs
  8. 2
      src/Avalonia.Base/Layout/WrapLayout/UvMeasure.cs
  9. 2
      src/Avalonia.Base/Media/DrawingContext.cs
  10. 4
      src/Avalonia.Base/Media/DrawingGroup.cs
  11. 5
      src/Avalonia.Base/Media/FontManager.cs
  12. 2
      src/Avalonia.Base/Media/ImmediateDrawingContext.cs
  13. 2
      src/Avalonia.Base/Media/TextFormatting/InterWordJustification.cs
  14. 12
      src/Avalonia.Base/Media/TextFormatting/ShapedTextRun.cs
  15. 18
      src/Avalonia.Base/Media/TextFormatting/TextCharacters.cs
  16. 2
      src/Avalonia.Base/Media/TextFormatting/TextEllipsisHelper.cs
  17. 28
      src/Avalonia.Base/Media/TextFormatting/TextFormatterImpl.cs
  18. 4
      src/Avalonia.Base/Media/TextFormatting/TextLeadingPrefixCharacterEllipsis.cs
  19. 40
      src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs
  20. 7
      src/Avalonia.Base/Media/TextFormatting/TextParagraphProperties.cs
  21. 2
      src/Avalonia.Base/Media/TextFormatting/TextRun.cs
  22. 5
      src/Avalonia.Base/Media/TextFormatting/TextShaper.cs
  23. 16
      src/Avalonia.Base/Media/TextFormatting/UnshapedTextRun.cs
  24. 2
      src/Avalonia.Base/Rendering/Composition/Expressions/ExpressionVariant.cs
  25. 6
      src/Avalonia.Base/Rendering/ImmediateRenderer.cs
  26. 3
      src/Avalonia.Base/Rendering/RenderLoop.cs
  27. 2
      src/Avalonia.Base/Rendering/Utilities/TileBrushCalculator.cs
  28. 8
      src/Avalonia.Base/Threading/DispatcherTimer.cs
  29. 2
      src/Avalonia.Base/Utilities/SingleOrDictionary.cs
  30. 4
      src/Avalonia.Base/Utilities/StringTokenizer.cs
  31. 1
      src/Avalonia.Base/Visual.cs
  32. 4
      src/Avalonia.Controls.DataGrid/DataGrid.cs
  33. 2
      src/Avalonia.Controls.DataGrid/IndexToValueTable.cs
  34. 8
      src/Avalonia.Controls/Control.cs
  35. 2
      src/Avalonia.Controls/Platform/InProcessDragSource.cs
  36. 11
      src/Avalonia.Controls/Platform/PlatformManager.cs
  37. 4
      src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs
  38. 2
      src/Avalonia.Controls/Utils/UndoRedoHelper.cs
  39. 5
      src/Avalonia.DesignerSupport/DesignWindowLoader.cs
  40. 2
      src/Avalonia.Dialogs/Internal/ManagedFileChooserViewModel.cs
  41. 8
      src/Avalonia.FreeDesktop/DBusMenu.cs
  42. 2
      src/Avalonia.OpenGL/Egl/EglInterface.cs
  43. 2
      src/Avalonia.X11/X11Framebuffer.cs
  44. 2
      src/Avalonia.X11/X11Platform.cs
  45. 2
      src/Browser/Avalonia.Browser/AvaloniaView.cs
  46. 2
      src/Linux/Avalonia.LinuxFramebuffer/FramebufferToplevelImpl.cs
  47. 2
      src/Markup/Avalonia.Markup.Xaml/Converters/BitmapTypeConverter.cs
  48. 2
      src/Markup/Avalonia.Markup.Xaml/Converters/IconTypeConverter.cs
  49. 4
      src/Skia/Avalonia.Skia/DrawingContextImpl.cs
  50. 2
      src/Skia/Avalonia.Skia/GeometryImpl.cs
  51. 2
      src/Skia/Avalonia.Skia/SKTypefaceCollectionCache.cs
  52. 6
      src/Skia/Avalonia.Skia/WriteableBitmapImpl.cs
  53. 2
      src/Windows/Avalonia.Direct2D1/Media/DWriteResourceFontLoader.cs
  54. 2
      src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs
  55. 6
      src/Windows/Avalonia.Win32.Interop/Wpf/Direct2DImageSurface.cs
  56. 2
      src/Windows/Avalonia.Win32/DataObject.cs
  57. 2
      src/Windows/Avalonia.Win32/OleDropTarget.cs
  58. 2
      tests/Avalonia.Base.UnitTests/Media/Fonts/FontFamilyLoaderTests.cs
  59. 2
      tests/Avalonia.Controls.UnitTests/ContextMenuTests.cs
  60. 2
      tests/Avalonia.Controls.UnitTests/FlyoutTests.cs
  61. 2
      tests/Avalonia.Controls.UnitTests/MaskedTextBoxTests.cs
  62. 2
      tests/Avalonia.Controls.UnitTests/Presenters/ItemsPresenterTests_Virtualization_Simple.cs
  63. 2
      tests/Avalonia.Controls.UnitTests/Primitives/PopupTests.cs
  64. 4
      tests/Avalonia.Controls.UnitTests/TextBoxTests.cs
  65. 9
      tests/Avalonia.Controls.UnitTests/TreeViewTests.cs
  66. 6
      tests/Avalonia.ReactiveUI.UnitTests/AutoSuspendHelperTest.cs
  67. 2
      tests/Avalonia.RenderTests/TestBase.cs
  68. 4
      tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextFormatterTests.cs
  69. 28
      tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLayoutTests.cs
  70. 30
      tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLineTests.cs
  71. 7
      tests/Avalonia.UnitTests/HarfBuzzFontManagerImpl.cs

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/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"

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[]
{

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));

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()

18
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);
}
@ -199,7 +199,7 @@ namespace Avalonia.Media.TextFormatting
count += grapheme.Text.Length;
}
return new ShapeableTextCharacters(characterBufferRange.CharacterBufferReference, count, defaultProperties, biDiLevel);
return new UnshapedTextRun(characterBufferRange.CharacterBufferReference, count, defaultProperties, biDiLevel);
}
/// <summary>

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);

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.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);
}
}

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

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

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();
}
}

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

@ -501,7 +501,7 @@ namespace Avalonia.Controls.Presenters
if (e.OldValue != null)
{
Offset = default(Vector);
Offset = default;
}
}
@ -543,7 +543,7 @@ namespace Avalonia.Controls.Presenters
if (logicalScroll != scrollable.IsLogicalScrollEnabled)
{
UpdateScrollableSubscription(Child);
Offset = default(Vector);
Offset = default;
InvalidateMeasure();
}
else if (scrollable.IsLogicalScrollEnabled)

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)
{

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);

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/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()));
}
}

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/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
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");

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

6
tests/Avalonia.ReactiveUI.UnitTests/AutoSuspendHelperTest.cs

@ -47,7 +47,7 @@ namespace Avalonia.ReactiveUI.UnitTests
using (var lifetime = new ClassicDesktopStyleApplicationLifetime())
{
var isLaunchingReceived = false;
var application = AvaloniaLocator.Current.GetService<Application>();
var application = AvaloniaLocator.Current.GetRequiredService<Application>();
application.ApplicationLifetime = lifetime;
// Initialize ReactiveUI Suspension as in real-world scenario.
@ -65,7 +65,7 @@ namespace Avalonia.ReactiveUI.UnitTests
using (UnitTestApplication.Start(TestServices.MockWindowingPlatform))
using (var lifetime = new ExoticApplicationLifetimeWithoutLifecycleEvents())
{
var application = AvaloniaLocator.Current.GetService<Application>();
var application = AvaloniaLocator.Current.GetRequiredService<Application>();
application.ApplicationLifetime = lifetime;
Assert.Throws<NotSupportedException>(() => new AutoSuspendHelper(application.ApplicationLifetime));
}
@ -88,7 +88,7 @@ namespace Avalonia.ReactiveUI.UnitTests
using (var lifetime = new ClassicDesktopStyleApplicationLifetime())
{
var shouldPersistReceived = false;
var application = AvaloniaLocator.Current.GetService<Application>();
var application = AvaloniaLocator.Current.GetRequiredService<Application>();
application.ApplicationLifetime = lifetime;
// Initialize ReactiveUI Suspension as in real-world scenario.

2
tests/Avalonia.RenderTests/TestBase.cs

@ -91,7 +91,7 @@ namespace Avalonia.Direct2D1.RenderTests
var immediatePath = Path.Combine(OutputPath, testName + ".immediate.out.png");
var deferredPath = Path.Combine(OutputPath, testName + ".deferred.out.png");
var compositedPath = Path.Combine(OutputPath, testName + ".composited.out.png");
var factory = AvaloniaLocator.Current.GetService<IPlatformRenderInterface>();
var factory = AvaloniaLocator.Current.GetRequiredService<IPlatformRenderInterface>();
var pixelSize = new PixelSize((int)target.Width, (int)target.Height);
var size = new Size(target.Width, target.Height);
var dpiVector = new Vector(dpi, dpi);

4
tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextFormatterTests.cs

@ -520,7 +520,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
var expectedTextLine = formatter.FormatLine(new SingleBufferTextSource(text, defaultProperties),
0, double.PositiveInfinity, paragraphProperties);
var expectedRuns = expectedTextLine.TextRuns.Cast<ShapedTextCharacters>().ToList();
var expectedRuns = expectedTextLine.TextRuns.Cast<ShapedTextRun>().ToList();
var expectedGlyphs = expectedRuns.SelectMany(x => x.GlyphRun.GlyphIndices).ToList();
@ -539,7 +539,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
var textLine =
formatter.FormatLine(textSource, 0, double.PositiveInfinity, paragraphProperties);
var shapedRuns = textLine.TextRuns.Cast<ShapedTextCharacters>().ToList();
var shapedRuns = textLine.TextRuns.Cast<ShapedTextRun>().ToList();
var actualGlyphs = shapedRuns.SelectMany(x => x.GlyphRun.GlyphIndices).ToList();

28
tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLayoutTests.cs

@ -141,7 +141,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
black,
textWrapping: TextWrapping.Wrap);
var expectedGlyphs = expected.TextLines.Select(x => string.Join('|', x.TextRuns.Cast<ShapedTextCharacters>()
var expectedGlyphs = expected.TextLines.Select(x => string.Join('|', x.TextRuns.Cast<ShapedTextRun>()
.SelectMany(x => x.ShapedBuffer.GlyphIndices))).ToList();
var outer = new GraphemeEnumerator(new CharacterBufferRange(text));
@ -174,7 +174,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
textWrapping: TextWrapping.Wrap,
textStyleOverrides: spans);
var actualGlyphs = actual.TextLines.Select(x => string.Join('|', x.TextRuns.Cast<ShapedTextCharacters>()
var actualGlyphs = actual.TextLines.Select(x => string.Join('|', x.TextRuns.Cast<ShapedTextRun>()
.SelectMany(x => x.ShapedBuffer.GlyphIndices))).ToList();
Assert.Equal(expectedGlyphs.Count, actualGlyphs.Count);
@ -447,7 +447,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
12.0f,
Brushes.Black.ToImmutable());
var shapedRun = (ShapedTextCharacters)layout.TextLines[0].TextRuns[0];
var shapedRun = (ShapedTextRun)layout.TextLines[0].TextRuns[0];
var glyphRun = shapedRun.GlyphRun;
@ -481,7 +481,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
foreach (var textRun in textLine.TextRuns)
{
var shapedRun = (ShapedTextCharacters)textRun;
var shapedRun = (ShapedTextRun)textRun;
var glyphClusters = shapedRun.ShapedBuffer.GlyphClusters;
@ -514,13 +514,13 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
Assert.Equal(1, layout.TextLines[0].TextRuns.Count);
Assert.Equal(expectedLength, ((ShapedTextCharacters)layout.TextLines[0].TextRuns[0]).GlyphRun.GlyphClusters.Count);
Assert.Equal(expectedLength, ((ShapedTextRun)layout.TextLines[0].TextRuns[0]).GlyphRun.GlyphClusters.Count);
Assert.Equal(5, ((ShapedTextCharacters)layout.TextLines[0].TextRuns[0]).ShapedBuffer.GlyphClusters[5]);
Assert.Equal(5, ((ShapedTextRun)layout.TextLines[0].TextRuns[0]).ShapedBuffer.GlyphClusters[5]);
if (expectedLength == 7)
{
Assert.Equal(5, ((ShapedTextCharacters)layout.TextLines[0].TextRuns[0]).ShapedBuffer.GlyphClusters[6]);
Assert.Equal(5, ((ShapedTextRun)layout.TextLines[0].TextRuns[0]).ShapedBuffer.GlyphClusters[6]);
}
}
}
@ -555,7 +555,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
var textLine = layout.TextLines[0];
var textRun = (ShapedTextCharacters)textLine.TextRuns[0];
var textRun = (ShapedTextRun)textLine.TextRuns[0];
Assert.Equal(7, textRun.Length);
@ -775,7 +775,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
Assert.Equal(textLine.WidthIncludingTrailingWhitespace, rect.Width);
}
var rects = layout.TextLines.SelectMany(x => x.TextRuns.Cast<ShapedTextCharacters>())
var rects = layout.TextLines.SelectMany(x => x.TextRuns.Cast<ShapedTextRun>())
.SelectMany(x => x.ShapedBuffer.GlyphAdvances).ToArray();
for (var i = 0; i < SingleLineText.Length; i++)
@ -814,7 +814,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
{
Assert.True(textLine.Width <= maxWidth);
var actual = new string(textLine.TextRuns.Cast<ShapedTextCharacters>()
var actual = new string(textLine.TextRuns.Cast<ShapedTextRun>()
.OrderBy(x => x.CharacterBufferReference.OffsetToFirstChar)
.SelectMany(x => new CharacterBufferRange(x.CharacterBufferReference, x.Length)).ToArray());
@ -855,7 +855,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
Brushes.Black,
flowDirection: FlowDirection.RightToLeft);
var firstRun = layout.TextLines[0].TextRuns[0] as ShapedTextCharacters;
var firstRun = layout.TextLines[0].TextRuns[0] as ShapedTextRun;
var hit = layout.HitTestPoint(new Point());
@ -881,7 +881,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
currentX += advance;
}
var secondRun = layout.TextLines[0].TextRuns[1] as ShapedTextCharacters;
var secondRun = layout.TextLines[0].TextRuns[1] as ShapedTextRun;
hit = layout.HitTestPoint(new Point(firstRun.Size.Width, 0));
@ -928,7 +928,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
var textLine = layout.TextLines[0];
var firstRun = (ShapedTextCharacters)textLine.TextRuns[0];
var firstRun = (ShapedTextRun)textLine.TextRuns[0];
var firstCluster = firstRun.ShapedBuffer.GlyphClusters[0];
@ -987,7 +987,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
var textLine = layout.TextLines[0];
var shapedRuns = textLine.TextRuns.Cast<ShapedTextCharacters>().ToList();
var shapedRuns = textLine.TextRuns.Cast<ShapedTextRun>().ToList();
var clusters = shapedRuns.SelectMany(x => x.ShapedBuffer.GlyphClusters).ToList();

30
tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLineTests.cs

@ -92,7 +92,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
foreach (var textRun in textLine.TextRuns.OrderBy(x => x.CharacterBufferReference.OffsetToFirstChar))
{
var shapedRun = (ShapedTextCharacters)textRun;
var shapedRun = (ShapedTextRun)textRun;
clusters.AddRange(shapedRun.IsReversed ?
shapedRun.ShapedBuffer.GlyphClusters.Reverse() :
@ -139,7 +139,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
foreach (var textRun in textLine.TextRuns.OrderBy(x => x.CharacterBufferReference.OffsetToFirstChar))
{
var shapedRun = (ShapedTextCharacters)textRun;
var shapedRun = (ShapedTextRun)textRun;
clusters.AddRange(shapedRun.IsReversed ?
shapedRun.ShapedBuffer.GlyphClusters.Reverse() :
@ -246,7 +246,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
formatter.FormatLine(textSource, 0, double.PositiveInfinity,
new GenericTextParagraphProperties(defaultProperties));
var clusters = textLine.TextRuns.Cast<ShapedTextCharacters>().SelectMany(x => x.ShapedBuffer.GlyphClusters)
var clusters = textLine.TextRuns.Cast<ShapedTextRun>().SelectMany(x => x.ShapedBuffer.GlyphClusters)
.ToArray();
var previousCharacterHit = new CharacterHit(text.Length);
@ -308,7 +308,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
foreach (var run in textLine.TextRuns)
{
var textRun = (ShapedTextCharacters)run;
var textRun = (ShapedTextRun)run;
var glyphRun = textRun.GlyphRun;
@ -634,7 +634,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
formatter.FormatLine(textSource, 0, double.PositiveInfinity,
new GenericTextParagraphProperties(defaultProperties));
var textRuns = textLine.TextRuns.Cast<ShapedTextCharacters>().ToList();
var textRuns = textLine.TextRuns.Cast<ShapedTextRun>().ToList();
var lineWidth = textLine.WidthIncludingTrailingWhitespace;
@ -732,14 +732,14 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
private static bool IsRightToLeft(TextLine textLine)
{
return textLine.TextRuns.Cast<ShapedTextCharacters>().Any(x => !x.ShapedBuffer.IsLeftToRight);
return textLine.TextRuns.Cast<ShapedTextRun>().Any(x => !x.ShapedBuffer.IsLeftToRight);
}
private static List<int> BuildGlyphClusters(TextLine textLine)
{
var glyphClusters = new List<int>();
var shapedTextRuns = textLine.TextRuns.Cast<ShapedTextCharacters>().ToList();
var shapedTextRuns = textLine.TextRuns.Cast<ShapedTextRun>().ToList();
var lastCluster = -1;
@ -774,7 +774,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
var lastCluster = -1;
var shapedTextRuns = textLine.TextRuns.Cast<ShapedTextCharacters>().ToList();
var shapedTextRuns = textLine.TextRuns.Cast<ShapedTextRun>().ToList();
foreach (var textRun in shapedTextRuns)
{
@ -820,16 +820,16 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
var text = "0123";
var shaperOption = new TextShaperOptions(Typeface.Default.GlyphTypeface, 10, 0, CultureInfo.CurrentCulture);
var firstRun = new ShapedTextCharacters(TextShaper.Current.ShapeText(text, shaperOption), defaultProperties);
var firstRun = new ShapedTextRun(TextShaper.Current.ShapeText(text, shaperOption), defaultProperties);
var textRuns = new List<TextRun>
{
new CustomDrawableRun(),
firstRun,
new CustomDrawableRun(),
new ShapedTextCharacters(TextShaper.Current.ShapeText(text, shaperOption), defaultProperties),
new ShapedTextRun(TextShaper.Current.ShapeText(text, shaperOption), defaultProperties),
new CustomDrawableRun(),
new ShapedTextCharacters(TextShaper.Current.ShapeText(text, shaperOption), defaultProperties)
new ShapedTextRun(TextShaper.Current.ShapeText(text, shaperOption), defaultProperties)
};
var textSource = new FixedRunsTextSource(textRuns);
@ -885,14 +885,14 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
var textBounds = textLine.GetTextBounds(0, 3);
var firstRun = textLine.TextRuns[0] as ShapedTextCharacters;
var firstRun = textLine.TextRuns[0] as ShapedTextRun;
Assert.Equal(1, textBounds.Count);
Assert.Equal(firstRun.Size.Width, textBounds.Sum(x => x.Rectangle.Width));
textBounds = textLine.GetTextBounds(3, 4);
var secondRun = textLine.TextRuns[1] as ShapedTextCharacters;
var secondRun = textLine.TextRuns[1] as ShapedTextRun;
Assert.Equal(1, textBounds.Count);
Assert.Equal(secondRun.Size.Width, textBounds.Sum(x => x.Rectangle.Width));
@ -932,14 +932,14 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
var textBounds = textLine.GetTextBounds(0, 4);
var secondRun = textLine.TextRuns[1] as ShapedTextCharacters;
var secondRun = textLine.TextRuns[1] as ShapedTextRun;
Assert.Equal(1, textBounds.Count);
Assert.Equal(secondRun.Size.Width, textBounds.Sum(x => x.Rectangle.Width));
textBounds = textLine.GetTextBounds(4, 3);
var firstRun = textLine.TextRuns[0] as ShapedTextCharacters;
var firstRun = textLine.TextRuns[0] as ShapedTextRun;
Assert.Equal(1, textBounds.Count);

7
tests/Avalonia.UnitTests/HarfBuzzFontManagerImpl.cs

@ -76,13 +76,8 @@ namespace Avalonia.UnitTests
var asset = fontAssets.First();
var assetLoader = AvaloniaLocator.Current.GetService<IAssetLoader>();
var assetLoader = AvaloniaLocator.Current.GetRequiredService<IAssetLoader>();
if (assetLoader == null)
{
throw new NotSupportedException("IAssetLoader is not registered.");
}
var stream = assetLoader.Open(asset);
return new HarfBuzzGlyphTypefaceImpl(stream);

Loading…
Cancel
Save