Skip to content

Commit

Permalink
Modernized accessor syntax in several places (#13044)
Browse files Browse the repository at this point in the history
* Modernized accessor syntax in several places

* Toned down the getter modernization

* Block body for properties with code

---------

Co-authored-by: Lehonti Ramos <lehonti@ramos>
  • Loading branch information
Lehonti and Lehonti Ramos authored Oct 6, 2023
1 parent 54c573c commit d1444b4
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 57 deletions.
22 changes: 11 additions & 11 deletions tests/Avalonia.Markup.UnitTests/Data/BindingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,10 @@ private class StyledPropertyClass : AvaloniaObject

public double DoubleValue
{
get { return GetValue(DoubleValueProperty); }
set { SetValue(DoubleValueProperty, value); }
get => GetValue(DoubleValueProperty);
set => SetValue(DoubleValueProperty, value);
}

public static StyledProperty<double?> NullableDoubleProperty =
AvaloniaProperty.Register<StyledPropertyClass, double?>(nameof(NullableDoubleProperty), -1);

Expand All @@ -724,8 +724,8 @@ private class DirectPropertyClass : AvaloniaObject
private double _doubleValue;
public double DoubleValue
{
get { return _doubleValue; }
set { SetAndRaise(DoubleValueProperty, ref _doubleValue, value); }
get => _doubleValue;
set => SetAndRaise(DoubleValueProperty, ref _doubleValue, value);
}
}

Expand Down Expand Up @@ -756,7 +756,7 @@ private class TestStackOverflowViewModel : INotifyPropertyChanged

public double Value
{
get { return _value; }
get => _value;
set
{
if (_value != value)
Expand Down Expand Up @@ -788,8 +788,8 @@ private class TwoWayBindingTest : Control

public string TwoWay
{
get { return GetValue(TwoWayProperty); }
set { SetValue(TwoWayProperty, value); }
get => GetValue(TwoWayProperty);
set => SetValue(TwoWayProperty, value);
}
}

Expand All @@ -800,7 +800,7 @@ public class Source : INotifyPropertyChanged

public string Foo
{
get { return _foo; }
get => _foo;
set
{
_foo = value;
Expand Down Expand Up @@ -911,8 +911,8 @@ private class InheritanceTest : Decorator

public int Baz
{
get { return GetValue(BazProperty); }
set { SetValue(BazProperty, value); }
get => GetValue(BazProperty);
set => SetValue(BazProperty, value);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Source : INotifyPropertyChanged

public string Foo
{
get { return _foo; }
get => _foo;
set
{
_foo = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ private class Class1 : AvaloniaObject

public Class1 Next
{
get { return GetValue(NextProperty); }
set { SetValue(NextProperty, value); }
get => GetValue(NextProperty);
set => SetValue(NextProperty, value);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,7 @@ private class NonIntegerIndexer : NotifyingBase

public string this[string key]
{
get
{
return _storage[key];
}
get => _storage[key];
set
{
_storage[key] = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ private class Class1 : StyledElement
public static readonly StyledProperty<string> FooProperty =
AvaloniaProperty.Register<Class1, string>("Foo");

public ThemeVariant ThemeVariant
public ThemeVariant ThemeVariant
{
get { throw new NotImplementedException(); }
get => throw new NotImplementedException();
}

public event EventHandler ThemeVariantChanged;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,7 @@ private class ViewModel : INotifyPropertyChanged
object _parameter;
public object Parameter
{
get
{
return _parameter;
}
get => _parameter;
set
{
if (_parameter == value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1949,10 +1949,7 @@ public class NonIntegerIndexer : NotifyingBase, INonIntegerIndexerDerived

public string this[string key]
{
get
{
return _storage[key];
}
get => _storage[key];
set
{
_storage[key] = value;
Expand Down Expand Up @@ -1991,10 +1988,7 @@ public class MethodAsCommandDataContext : INotifyPropertyChanged
object _parameter;
public object Parameter
{
get
{
return _parameter;
}
get => _parameter;
set
{
if (_parameter == value)
Expand Down Expand Up @@ -2050,8 +2044,8 @@ public class DataGridLikeControl : Control
private IEnumerable _items;
public IEnumerable Items
{
get { return _items; }
set { SetAndRaise(ItemsProperty, ref _items, value); }
get => _items;
set => SetAndRaise(ItemsProperty, ref _items, value);
}

public AvaloniaList<DataGridLikeColumn> Columns { get; } = new();
Expand Down
10 changes: 5 additions & 5 deletions tests/Avalonia.Markup.Xaml.UnitTests/SampleAvaloniaObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ internal class SampleAvaloniaObject : AvaloniaObject

public int Int
{
get { return GetValue(IntProperty); }
set { SetValue(IntProperty, value); }
get => GetValue(IntProperty);
set => SetValue(IntProperty, value);
}

public string String
{
get { return GetValue(StringProperty); }
set { SetValue(StringProperty, value); }
get => GetValue(StringProperty);
set => SetValue(StringProperty, value);
}
}
}
}
6 changes: 3 additions & 3 deletions tests/Avalonia.Markup.Xaml.UnitTests/TestViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class TestViewModel : NotifyingBase

public int Integer
{
get { return _integer; }
get => _integer;
set
{
_integer = value;
Expand All @@ -20,7 +20,7 @@ public int Integer

public string String
{
get { return _string; }
get => _string;
set
{
_string = value;
Expand All @@ -30,7 +30,7 @@ public string String

public TestViewModel Child
{
get { return _child; }
get => _child;
set
{
_child = value;
Expand Down
2 changes: 1 addition & 1 deletion tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ private class SelectedItemsViewModel : INotifyPropertyChanged

public IList SelectedItems
{
get { return _selectedItems; }
get => _selectedItems;
set
{
_selectedItems = value;
Expand Down
13 changes: 5 additions & 8 deletions tests/Avalonia.Markup.Xaml.UnitTests/Xaml/NonControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,16 @@ public class NonControl : AvaloniaObject

public Control Control
{
get { return GetValue(ControlProperty); }
set { SetValue(ControlProperty, value); }
get => GetValue(ControlProperty);
set => SetValue(ControlProperty, value);
}

public string String
{
get { return GetValue(StringProperty); }
set { SetValue(StringProperty, value); }
get => GetValue(StringProperty);
set => SetValue(StringProperty, value);
}

public string Bar
{
get { return GetValue(BarProperty); }
}
public string Bar => GetValue(BarProperty);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ private class Class1 : AvaloniaObject

public string Foo
{
get { return GetValue(FooProperty); }
set { SetValue(FooProperty, value); }
get => GetValue(FooProperty);
set => SetValue(FooProperty, value);
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions tests/Avalonia.RenderTests/Media/ImageBrushTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ public ImageBrushTests()

private string BitmapPath
{
get { return System.IO.Path.Combine(OutputPath, "github_icon.png"); }
get
{
return System.IO.Path.Combine(OutputPath, "github_icon.png");
}
}

private string SmallBitmapPath
{
get { return System.IO.Path.Combine(OutputPath, "github_icon_small.png"); }
get
{
return System.IO.Path.Combine(OutputPath, "github_icon_small.png");
}
}

[Fact]
Expand Down
5 changes: 4 additions & 1 deletion tests/Avalonia.RenderTests/Media/ImageDrawingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ public ImageDrawingTests()

private string BitmapPath
{
get { return System.IO.Path.Combine(OutputPath, "github_icon.png"); }
get
{
return System.IO.Path.Combine(OutputPath, "github_icon.png");
}
}

[Fact]
Expand Down
5 changes: 4 additions & 1 deletion tests/Avalonia.RenderTests/Media/VisualBrushTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public VisualBrushTests()

private string BitmapPath
{
get { return System.IO.Path.Combine(OutputPath, "github_icon.png"); }
get
{
return System.IO.Path.Combine(OutputPath, "github_icon.png");
}
}

private Control Visual
Expand Down

0 comments on commit d1444b4

Please sign in to comment.