From 9c9d5a3ae5c1b6b52e51676f19ad718c8a4a3bf7 Mon Sep 17 00:00:00 2001 From: Al Dyachkov Date: Mon, 15 Nov 2021 20:21:04 +0300 Subject: [PATCH 1/6] Fixed missing XA_WM_NAME remove on empty window Title --- src/Avalonia.X11/X11Window.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Avalonia.X11/X11Window.cs b/src/Avalonia.X11/X11Window.cs index 7bc8872fa7..b2bc9d1a35 100644 --- a/src/Avalonia.X11/X11Window.cs +++ b/src/Avalonia.X11/X11Window.cs @@ -1026,6 +1026,7 @@ namespace Avalonia.X11 if (string.IsNullOrEmpty(title)) { XDeleteProperty(_x11.Display, _handle, _x11.Atoms._NET_WM_NAME); + XDeleteProperty(_x11.Display, _handle, _x11.Atoms.XA_WM_NAME); } else { From 69126a7967ecc208a0b3572686f5a89a6cfa2ad5 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Tue, 16 Nov 2021 10:58:20 +0100 Subject: [PATCH 2/6] fixes(DevTools): Null Annotations --- .../ViewModels/ControlDetailsViewModel.cs | 25 ++++++++++--------- .../ViewModels/TreePageViewModel.cs | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs index 7b32e21fbd..9905aa4afc 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs +++ b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs @@ -17,16 +17,16 @@ namespace Avalonia.Diagnostics.ViewModels internal class ControlDetailsViewModel : ViewModelBase, IDisposable { private readonly IVisual _control; - private IDictionary> _propertyIndex; + private IDictionary>? _propertyIndex; private PropertyViewModel? _selectedProperty; - private DataGridCollectionView _propertiesView; + private DataGridCollectionView? _propertiesView; private bool _snapshotStyles; private bool _showInactiveStyles; private string? _styleStatus; - private object _selectedEntity; + private object? _selectedEntity; private readonly Stack<(string Name,object Entry)> _selectedEntitiesStack = new(); - private string _selectedEntityName; - private string _selectedEntityType; + private string? _selectedEntityName; + private string? _selectedEntityType; public ControlDetailsViewModel(TreePageViewModel treePage, IVisual control) { @@ -117,7 +117,7 @@ namespace Avalonia.Diagnostics.ViewModels public TreePageViewModel TreePage { get; } - public DataGridCollectionView PropertiesView + public DataGridCollectionView? PropertiesView { get => _propertiesView; private set => RaiseAndSetIfChanged(ref _propertiesView, value); @@ -127,7 +127,7 @@ namespace Avalonia.Diagnostics.ViewModels public ObservableCollection PseudoClasses { get; } - public object SelectedEntity + public object? SelectedEntity { get => _selectedEntity; set @@ -137,7 +137,7 @@ namespace Avalonia.Diagnostics.ViewModels } } - public string SelectedEntityName + public string? SelectedEntityName { get => _selectedEntityName; set @@ -147,7 +147,7 @@ namespace Avalonia.Diagnostics.ViewModels } } - public string SelectedEntityType + public string? SelectedEntityType { get => _selectedEntityType; set @@ -270,7 +270,7 @@ namespace Avalonia.Diagnostics.ViewModels private void ControlPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) { - if (_propertyIndex.TryGetValue(e.Property, out var properties)) + if (_propertyIndex is { } && _propertyIndex.TryGetValue(e.Property, out var properties)) { foreach (var property in properties) { @@ -284,6 +284,7 @@ namespace Avalonia.Diagnostics.ViewModels private void ControlPropertyChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName != null + && _propertyIndex is { } && _propertyIndex.TryGetValue(e.PropertyName, out var properties)) { foreach (var property in properties) @@ -402,7 +403,7 @@ namespace Avalonia.Diagnostics.ViewModels var selectedProperty = SelectedProperty; var selectedEntity = SelectedEntity; var selectedEntityName = SelectedEntityName; - if (selectedProperty == null) + if (selectedEntity == null || selectedProperty == null) return; object? property; @@ -419,7 +420,7 @@ namespace Avalonia.Diagnostics.ViewModels ?.GetValue(selectedEntity); } if (property == null) return; - _selectedEntitiesStack.Push((Name:selectedEntityName,Entry:selectedEntity)); + _selectedEntitiesStack.Push((Name:selectedEntityName!,Entry:selectedEntity)); NavigateToProperty(property, selectedProperty.Name); } diff --git a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/TreePageViewModel.cs b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/TreePageViewModel.cs index 4b18cf414a..27b28f35fc 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/TreePageViewModel.cs +++ b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/TreePageViewModel.cs @@ -15,7 +15,7 @@ namespace Avalonia.Diagnostics.ViewModels Nodes = nodes; PropertiesFilter = new FilterViewModel(); - PropertiesFilter.RefreshFilter += (s, e) => Details?.PropertiesView.Refresh(); + PropertiesFilter.RefreshFilter += (s, e) => Details?.PropertiesView?.Refresh(); SettersFilter = new FilterViewModel(); SettersFilter.RefreshFilter += (s, e) => Details?.UpdateStyleFilters(); From de8f9155dc6622ca889c4384dc18c5d4bc5e9732 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Thu, 18 Nov 2021 15:44:48 +0200 Subject: [PATCH 3/6] add unittest for issue #6969 animator crashes because of invalid keyframe value --- .../AnimatableTests.cs | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/tests/Avalonia.Animation.UnitTests/AnimatableTests.cs b/tests/Avalonia.Animation.UnitTests/AnimatableTests.cs index b01fb70f58..26d8059eec 100644 --- a/tests/Avalonia.Animation.UnitTests/AnimatableTests.cs +++ b/tests/Avalonia.Animation.UnitTests/AnimatableTests.cs @@ -1,5 +1,7 @@ using System; +using Avalonia.Animation.Animators; using Avalonia.Controls; +using Avalonia.Controls.Shapes; using Avalonia.Data; using Avalonia.Layout; using Avalonia.Media; @@ -100,6 +102,71 @@ namespace Avalonia.Animation.UnitTests Times.Never); } + + [Theory] + [InlineData(null)] //null value + [InlineData("stringValue")] //string value + public void Invalid_Values_In_Animation_Should_Not_Crash_Animations(object invalidValue) + { + var keyframe1 = new KeyFrame() + { + Setters = + { + new Setter(Layoutable.WidthProperty, 1d), + }, + KeyTime = TimeSpan.FromSeconds(0) + }; + + var keyframe2 = new KeyFrame() + { + Setters = + { + new Setter(Layoutable.WidthProperty, 2d), + }, + KeyTime = TimeSpan.FromSeconds(2), + }; + + var keyframe3 = new KeyFrame() + { + Setters = + { + new Setter(Layoutable.WidthProperty, invalidValue), + }, + KeyTime = TimeSpan.FromSeconds(3), + }; + + var animation = new Animation() + { + Duration = TimeSpan.FromSeconds(3), + Children = + { + keyframe1, + keyframe2, + keyframe3 + }, + IterationCount = new IterationCount(5), + PlaybackDirection = PlaybackDirection.Alternate, + }; + + var rect = new Rectangle() + { + Width = 11, + }; + + var originalValue = rect.Width; + + var clock = new TestClock(); + var animationRun = animation.RunAsync(rect, clock); + + clock.Step(TimeSpan.Zero); + Assert.Equal(rect.Width, 1); + clock.Step(TimeSpan.FromSeconds(2)); + Assert.Equal(rect.Width, 2); + clock.Step(TimeSpan.FromSeconds(3)); + //here we have invalid value so value should be expected and set to initial original value + Assert.Equal(rect.Width, originalValue); + } + [Fact] public void Transition_Is_Not_Applied_When_StyleTrigger_Changes_With_LocalValue_Present() { From fd0816b3700c643316701f272a4d02058c1fe573 Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Thu, 18 Nov 2021 16:53:18 +0200 Subject: [PATCH 4/6] fix #6969 animation errors when a value is invalid, so animation system works predictable even one animation is invalid --- src/Avalonia.Animation/Animators/Animator`1.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Animation/Animators/Animator`1.cs b/src/Avalonia.Animation/Animators/Animator`1.cs index d784227620..23afa76bf6 100644 --- a/src/Avalonia.Animation/Animators/Animator`1.cs +++ b/src/Avalonia.Animation/Animators/Animator`1.cs @@ -79,15 +79,15 @@ namespace Avalonia.Animation.Animators T oldValue, newValue; - if (firstKeyframe.isNeutral) - oldValue = neutralValue; + if (!firstKeyframe.isNeutral && firstKeyframe.Value is T firstKeyframeValue) + oldValue = firstKeyframeValue; else - oldValue = (T)firstKeyframe.Value; + oldValue = neutralValue; - if (lastKeyframe.isNeutral) - newValue = neutralValue; + if (!lastKeyframe.isNeutral && lastKeyframe.Value is T lastKeyframeValue) + newValue = lastKeyframeValue; else - newValue = (T)lastKeyframe.Value; + newValue = neutralValue; if (lastKeyframe.KeySpline != null) progress = lastKeyframe.KeySpline.GetSplineProgress(progress); From d18ffdad370a68d2ee50ba36408979d36f0510a2 Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 18 Nov 2021 18:45:08 +0100 Subject: [PATCH 5/6] Expander properties to all directions Fixed Expander Border properties not applied to all directions --- src/Avalonia.Themes.Default/Expander.xaml | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Themes.Default/Expander.xaml b/src/Avalonia.Themes.Default/Expander.xaml index 7df65677b6..e72ddea163 100644 --- a/src/Avalonia.Themes.Default/Expander.xaml +++ b/src/Avalonia.Themes.Default/Expander.xaml @@ -15,7 +15,7 @@ BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}"> - + - + - + - + - + - + - + Date: Fri, 19 Nov 2021 19:05:48 +0800 Subject: [PATCH 6/6] Fix debugging in Rider after we merged .NET 6 Since we merged #6902 our debugging infra for this repo is not working with Rider. This PR fixes it. --- build/SourceLink.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/SourceLink.props b/build/SourceLink.props index 1e007e01eb..0f77c2a613 100644 --- a/build/SourceLink.props +++ b/build/SourceLink.props @@ -3,7 +3,7 @@ true false true - embedded + full $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb