diff --git a/Directory.Build.props b/Directory.Build.props index 4034ddaf..7ec64a73 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ latest true - 11.0.999-cibuild0031007-beta + 11.0.0-preview6 1.0.50 13.0.1 beta diff --git a/src/AvaloniaEdit.Demo/MainWindow.xaml.cs b/src/AvaloniaEdit.Demo/MainWindow.xaml.cs index f05e94bf..01ce49bc 100644 --- a/src/AvaloniaEdit.Demo/MainWindow.xaml.cs +++ b/src/AvaloniaEdit.Demo/MainWindow.xaml.cs @@ -49,7 +49,7 @@ public MainWindow() _textEditor.ShowLineNumbers = true; _textEditor.ContextMenu = new ContextMenu { - Items = new List + ItemsSource = new List { new MenuItem { Header = "Copy", InputGesture = new KeyGesture(Key.C, KeyModifiers.Control) }, new MenuItem { Header = "Paste", InputGesture = new KeyGesture(Key.V, KeyModifiers.Control) }, @@ -84,7 +84,7 @@ public MainWindow() Language csharpLanguage = _registryOptions.GetLanguageByExtension(".cs"); _syntaxModeCombo = this.FindControl("syntaxModeCombo"); - _syntaxModeCombo.Items = _registryOptions.GetAvailableLanguages(); + _syntaxModeCombo.ItemsSource = _registryOptions.GetAvailableLanguages(); _syntaxModeCombo.SelectedItem = csharpLanguage; _syntaxModeCombo.SelectionChanged += SyntaxModeCombo_SelectionChanged; diff --git a/src/AvaloniaEdit/CodeCompletion/CompletionList.cs b/src/AvaloniaEdit/CodeCompletion/CompletionList.cs index c1f45bf1..53ba1e4d 100644 --- a/src/AvaloniaEdit/CodeCompletion/CompletionList.cs +++ b/src/AvaloniaEdit/CodeCompletion/CompletionList.cs @@ -86,7 +86,7 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e) _listBox = e.NameScope.Find("PART_ListBox") as CompletionListBox; if (_listBox != null) { - _listBox.Items = _completionData; + _listBox.ItemsSource = _completionData; } } @@ -294,7 +294,7 @@ where quality > 0 _currentList = listBoxItems; //_listBox.Items = null; Makes no sense? Tooltip disappeared because of this - _listBox.Items = listBoxItems; + _listBox.ItemsSource = listBoxItems; SelectIndexCentered(bestIndex); } diff --git a/src/AvaloniaEdit/CodeCompletion/CompletionWindow.cs b/src/AvaloniaEdit/CodeCompletion/CompletionWindow.cs index b5d8ed73..139aebdb 100644 --- a/src/AvaloniaEdit/CodeCompletion/CompletionWindow.cs +++ b/src/AvaloniaEdit/CodeCompletion/CompletionWindow.cs @@ -62,7 +62,7 @@ public CompletionWindow(TextArea textArea) : base(textArea) { IsLightDismissEnabled = true, PlacementTarget = this, - PlacementMode = PlacementMode.Right, + Placement = PlacementMode.Right, Child = _toolTipContent, }; diff --git a/src/AvaloniaEdit/CodeCompletion/CompletionWindowBase.cs b/src/AvaloniaEdit/CodeCompletion/CompletionWindowBase.cs index b635dea6..ea7725f6 100644 --- a/src/AvaloniaEdit/CodeCompletion/CompletionWindowBase.cs +++ b/src/AvaloniaEdit/CodeCompletion/CompletionWindowBase.cs @@ -86,7 +86,7 @@ public CompletionWindowBase(TextArea textArea) : base() StartOffset = EndOffset = TextArea.Caret.Offset; PlacementTarget = TextArea.TextView; - PlacementMode = PlacementMode.AnchorAndGravity; + Placement = PlacementMode.AnchorAndGravity; PlacementAnchor = Avalonia.Controls.Primitives.PopupPositioning.PopupAnchor.TopLeft; PlacementGravity = Avalonia.Controls.Primitives.PopupPositioning.PopupGravity.BottomRight; diff --git a/src/AvaloniaEdit/Editing/Caret.cs b/src/AvaloniaEdit/Editing/Caret.cs index 7148845e..ecc779ff 100644 --- a/src/AvaloniaEdit/Editing/Caret.cs +++ b/src/AvaloniaEdit/Editing/Caret.cs @@ -446,7 +446,7 @@ public Rect CalculateCaretRectangle() var visualLine = _textView.GetOrConstructVisualLine(_textView.Document.GetLineByNumber(_position.Line)); return _textArea.OverstrikeMode ? CalcCaretOverstrikeRectangle(visualLine) : CalcCaretRectangle(visualLine); } - return Rect.Empty; + return default; } /// @@ -465,7 +465,7 @@ public void BringCaretToView() public void BringCaretToView(double border) { var caretRectangle = CalculateCaretRectangle(); - if (!caretRectangle.IsEmpty) + if (caretRectangle != default) { caretRectangle = caretRectangle.Inflate(border); _textView.MakeVisible(caretRectangle); diff --git a/src/AvaloniaEdit/Editing/TextArea.cs b/src/AvaloniaEdit/Editing/TextArea.cs index 666b60ab..3f68dc27 100644 --- a/src/AvaloniaEdit/Editing/TextArea.cs +++ b/src/AvaloniaEdit/Editing/TextArea.cs @@ -1154,7 +1154,7 @@ public Rect CursorRectangle { if(_textArea == null) { - return Rect.Empty; + return default; } var transform = _textArea.TextView.TransformToVisual(_textArea); diff --git a/src/AvaloniaEdit/Rendering/BackgroundGeometryBuilder.cs b/src/AvaloniaEdit/Rendering/BackgroundGeometryBuilder.cs index 6b373387..8591d6e0 100644 --- a/src/AvaloniaEdit/Rendering/BackgroundGeometryBuilder.cs +++ b/src/AvaloniaEdit/Rendering/BackgroundGeometryBuilder.cs @@ -210,7 +210,7 @@ private static IEnumerable ProcessTextLines(TextView textView, VisualLine int segmentStartVcInLine = Math.Max(segmentStartVc, visualStartCol); int segmentEndVcInLine = Math.Min(segmentEndVc, visualEndCol); y -= scrollOffset.Y; - Rect lastRect = Rect.Empty; + Rect lastRect = default; if (segmentStartVcInLine == segmentEndVcInLine) { // GetTextBounds crashes for length=0, so we'll handle this case with GetDistanceFromCharacterHit // We need to return a rectangle to ensure empty lines are still visible @@ -229,7 +229,7 @@ private static IEnumerable ProcessTextLines(TextView textView, VisualLine foreach (var b in line.GetTextBounds(segmentStartVcInLine, segmentEndVcInLine - segmentStartVcInLine)) { double left = b.Rectangle.Left - scrollOffset.X; double right = b.Rectangle.Right - scrollOffset.X; - if (!lastRect.IsEmpty) + if (lastRect != default) yield return lastRect; // left>right is possible in RTL languages lastRect = new Rect(Math.Min(left, right), y, Math.Abs(right - left), line.Height); @@ -261,7 +261,7 @@ private static IEnumerable ProcessTextLines(TextView textView, VisualLine right = visualLine.GetTextLineVisualXPosition(lastTextLine, segmentEndVc); } Rect extendSelection = new Rect(Math.Min(left, right), y, Math.Abs(right - left), line.Height); - if (!lastRect.IsEmpty) { + if (lastRect != default) { if (extendSelection.Intersects(lastRect)) { lastRect.Union(extendSelection); yield return lastRect; diff --git a/src/AvaloniaEdit/Rendering/SingleCharacterElementGenerator.cs b/src/AvaloniaEdit/Rendering/SingleCharacterElementGenerator.cs index 4274bb33..f64fee8a 100644 --- a/src/AvaloniaEdit/Rendering/SingleCharacterElementGenerator.cs +++ b/src/AvaloniaEdit/Rendering/SingleCharacterElementGenerator.cs @@ -202,7 +202,7 @@ public TabGlyphRun(TabTextElement element, TextRunProperties properties) public override double Baseline => _element.Text.Baseline; - public override Size Size => Size.Empty; + public override Size Size => default; public override void Draw(DrawingContext drawingContext, Point origin) { diff --git a/src/AvaloniaEdit/Rendering/TextView.cs b/src/AvaloniaEdit/Rendering/TextView.cs index fd2e55e1..bf781661 100644 --- a/src/AvaloniaEdit/Rendering/TextView.cs +++ b/src/AvaloniaEdit/Rendering/TextView.cs @@ -1952,7 +1952,7 @@ private static ImmutablePen CreateFrozenPen(IBrush brush) bool ILogicalScrollable.BringIntoView(Control target, Rect rectangle) { - if (rectangle.IsEmpty || target == null || target == this || !this.IsVisualAncestorOf(target)) + if (rectangle == default || target == null || target == this || !this.IsVisualAncestorOf(target)) { return false; } diff --git a/test/AvaloniaEdit.Tests/AvaloniaMocks/MockFontManagerImpl.cs b/test/AvaloniaEdit.Tests/AvaloniaMocks/MockFontManagerImpl.cs index 77965fc5..deae986e 100644 --- a/test/AvaloniaEdit.Tests/AvaloniaMocks/MockFontManagerImpl.cs +++ b/test/AvaloniaEdit.Tests/AvaloniaMocks/MockFontManagerImpl.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Globalization; +using System.IO; #nullable enable @@ -24,7 +25,7 @@ public string GetDefaultFontFamilyName() return _defaultFamilyName; } - public IEnumerable GetInstalledFontFamilyNames(bool checkForUpdates = false) + public string[] GetInstalledFontFamilyNames(bool checkForUpdates = false) { return new[] { _defaultFamilyName }; } @@ -37,9 +38,17 @@ public bool TryMatchCharacter(int codepoint, FontStyle fontStyle, FontWeight fon return true; } - public IGlyphTypeface CreateGlyphTypeface(Typeface typeface) + public bool TryCreateGlyphTypeface(string familyName, FontStyle style, FontWeight weight, + FontStretch stretch, out IGlyphTypeface glyphTypeface) { - return new MockGlyphTypeface(); + glyphTypeface = new MockGlyphTypeface(); + return true; + } + + public bool TryCreateGlyphTypeface(Stream stream, out IGlyphTypeface glyphTypeface) + { + glyphTypeface = new MockGlyphTypeface(); + return true; } } } diff --git a/test/AvaloniaEdit.Tests/AvaloniaMocks/MockGlyphRun.cs b/test/AvaloniaEdit.Tests/AvaloniaMocks/MockGlyphRun.cs index f3bb0bad..377c6e31 100644 --- a/test/AvaloniaEdit.Tests/AvaloniaMocks/MockGlyphRun.cs +++ b/test/AvaloniaEdit.Tests/AvaloniaMocks/MockGlyphRun.cs @@ -16,10 +16,10 @@ public MockGlyphRun(IReadOnlyList glyphInfos) width += glyphInfos[i].GlyphAdvance; } - Size = new Size(width, 10); + Bounds = new Rect(new Size(width, 10)); } - public Size Size { get; } + public Rect Bounds { get; } public Point BaselineOrigin => new Point(0, 8); diff --git a/test/AvaloniaEdit.Tests/AvaloniaMocks/MockGlyphTypeface.cs b/test/AvaloniaEdit.Tests/AvaloniaMocks/MockGlyphTypeface.cs index 436068df..279aed08 100644 --- a/test/AvaloniaEdit.Tests/AvaloniaMocks/MockGlyphTypeface.cs +++ b/test/AvaloniaEdit.Tests/AvaloniaMocks/MockGlyphTypeface.cs @@ -14,6 +14,7 @@ public class MockGlyphTypeface : IGlyphTypeface IsFixedPitch = true }; + public FontStretch Stretch { get; } public int GlyphCount => 1337; public FontSimulations FontSimulations => throw new NotImplementedException(); @@ -62,6 +63,10 @@ public bool TryGetTable(uint tag, out byte[] table) return false; } + public string FamilyName => ""; + public FontWeight Weight => FontWeight.Normal; + public FontStyle Style => FontStyle.Normal; + public bool TryGetGlyphMetrics(ushort glyph, out GlyphMetrics metrics) { metrics = new GlyphMetrics