Skip to content

Commit d1444b4

Browse files
LehontiLehonti Ramos
andauthored
Modernized accessor syntax in several places (#13044)
* Modernized accessor syntax in several places * Toned down the getter modernization * Block body for properties with code --------- Co-authored-by: Lehonti Ramos <lehonti@ramos>
1 parent 54c573c commit d1444b4

File tree

15 files changed

+54
-57
lines changed

15 files changed

+54
-57
lines changed

tests/Avalonia.Markup.UnitTests/Data/BindingTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,10 @@ private class StyledPropertyClass : AvaloniaObject
699699

700700
public double DoubleValue
701701
{
702-
get { return GetValue(DoubleValueProperty); }
703-
set { SetValue(DoubleValueProperty, value); }
702+
get => GetValue(DoubleValueProperty);
703+
set => SetValue(DoubleValueProperty, value);
704704
}
705-
705+
706706
public static StyledProperty<double?> NullableDoubleProperty =
707707
AvaloniaProperty.Register<StyledPropertyClass, double?>(nameof(NullableDoubleProperty), -1);
708708

@@ -724,8 +724,8 @@ private class DirectPropertyClass : AvaloniaObject
724724
private double _doubleValue;
725725
public double DoubleValue
726726
{
727-
get { return _doubleValue; }
728-
set { SetAndRaise(DoubleValueProperty, ref _doubleValue, value); }
727+
get => _doubleValue;
728+
set => SetAndRaise(DoubleValueProperty, ref _doubleValue, value);
729729
}
730730
}
731731

@@ -756,7 +756,7 @@ private class TestStackOverflowViewModel : INotifyPropertyChanged
756756

757757
public double Value
758758
{
759-
get { return _value; }
759+
get => _value;
760760
set
761761
{
762762
if (_value != value)
@@ -788,8 +788,8 @@ private class TwoWayBindingTest : Control
788788

789789
public string TwoWay
790790
{
791-
get { return GetValue(TwoWayProperty); }
792-
set { SetValue(TwoWayProperty, value); }
791+
get => GetValue(TwoWayProperty);
792+
set => SetValue(TwoWayProperty, value);
793793
}
794794
}
795795

@@ -800,7 +800,7 @@ public class Source : INotifyPropertyChanged
800800

801801
public string Foo
802802
{
803-
get { return _foo; }
803+
get => _foo;
804804
set
805805
{
806806
_foo = value;
@@ -911,8 +911,8 @@ private class InheritanceTest : Decorator
911911

912912
public int Baz
913913
{
914-
get { return GetValue(BazProperty); }
915-
set { SetValue(BazProperty, value); }
914+
get => GetValue(BazProperty);
915+
set => SetValue(BazProperty, value);
916916
}
917917
}
918918
}

tests/Avalonia.Markup.UnitTests/Data/BindingTests_Source.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class Source : INotifyPropertyChanged
2828

2929
public string Foo
3030
{
31-
get { return _foo; }
31+
get => _foo;
3232
set
3333
{
3434
_foo = value;

tests/Avalonia.Markup.UnitTests/Parsers/ExpressionObserverBuilderTests_AttachedProperty.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ private class Class1 : AvaloniaObject
158158

159159
public Class1 Next
160160
{
161-
get { return GetValue(NextProperty); }
162-
set { SetValue(NextProperty, value); }
161+
get => GetValue(NextProperty);
162+
set => SetValue(NextProperty, value);
163163
}
164164
}
165165
}

tests/Avalonia.Markup.UnitTests/Parsers/ExpressionObserverBuilderTests_Indexer.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,7 @@ private class NonIntegerIndexer : NotifyingBase
369369

370370
public string this[string key]
371371
{
372-
get
373-
{
374-
return _storage[key];
375-
}
372+
get => _storage[key];
376373
set
377374
{
378375
_storage[key] = value;

tests/Avalonia.Markup.Xaml.UnitTests/Converters/AvaloniaPropertyConverterTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ private class Class1 : StyledElement
115115
public static readonly StyledProperty<string> FooProperty =
116116
AvaloniaProperty.Register<Class1, string>("Foo");
117117

118-
public ThemeVariant ThemeVariant
118+
public ThemeVariant ThemeVariant
119119
{
120-
get { throw new NotImplementedException(); }
120+
get => throw new NotImplementedException();
121121
}
122122

123123
public event EventHandler ThemeVariantChanged;

tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests_Method.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,7 @@ private class ViewModel : INotifyPropertyChanged
231231
object _parameter;
232232
public object Parameter
233233
{
234-
get
235-
{
236-
return _parameter;
237-
}
234+
get => _parameter;
238235
set
239236
{
240237
if (_parameter == value)

tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,10 +1949,7 @@ public class NonIntegerIndexer : NotifyingBase, INonIntegerIndexerDerived
19491949

19501950
public string this[string key]
19511951
{
1952-
get
1953-
{
1954-
return _storage[key];
1955-
}
1952+
get => _storage[key];
19561953
set
19571954
{
19581955
_storage[key] = value;
@@ -1991,10 +1988,7 @@ public class MethodAsCommandDataContext : INotifyPropertyChanged
19911988
object _parameter;
19921989
public object Parameter
19931990
{
1994-
get
1995-
{
1996-
return _parameter;
1997-
}
1991+
get => _parameter;
19981992
set
19991993
{
20001994
if (_parameter == value)
@@ -2050,8 +2044,8 @@ public class DataGridLikeControl : Control
20502044
private IEnumerable _items;
20512045
public IEnumerable Items
20522046
{
2053-
get { return _items; }
2054-
set { SetAndRaise(ItemsProperty, ref _items, value); }
2047+
get => _items;
2048+
set => SetAndRaise(ItemsProperty, ref _items, value);
20552049
}
20562050

20572051
public AvaloniaList<DataGridLikeColumn> Columns { get; } = new();

tests/Avalonia.Markup.Xaml.UnitTests/SampleAvaloniaObject.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ internal class SampleAvaloniaObject : AvaloniaObject
1212

1313
public int Int
1414
{
15-
get { return GetValue(IntProperty); }
16-
set { SetValue(IntProperty, value); }
15+
get => GetValue(IntProperty);
16+
set => SetValue(IntProperty, value);
1717
}
1818

1919
public string String
2020
{
21-
get { return GetValue(StringProperty); }
22-
set { SetValue(StringProperty, value); }
21+
get => GetValue(StringProperty);
22+
set => SetValue(StringProperty, value);
2323
}
2424
}
25-
}
25+
}

tests/Avalonia.Markup.Xaml.UnitTests/TestViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class TestViewModel : NotifyingBase
1010

1111
public int Integer
1212
{
13-
get { return _integer; }
13+
get => _integer;
1414
set
1515
{
1616
_integer = value;
@@ -20,7 +20,7 @@ public int Integer
2020

2121
public string String
2222
{
23-
get { return _string; }
23+
get => _string;
2424
set
2525
{
2626
_string = value;
@@ -30,7 +30,7 @@ public string String
3030

3131
public TestViewModel Child
3232
{
33-
get { return _child; }
33+
get => _child;
3434
set
3535
{
3636
_child = value;

tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BasicTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ private class SelectedItemsViewModel : INotifyPropertyChanged
990990

991991
public IList SelectedItems
992992
{
993-
get { return _selectedItems; }
993+
get => _selectedItems;
994994
set
995995
{
996996
_selectedItems = value;

tests/Avalonia.Markup.Xaml.UnitTests/Xaml/NonControl.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,16 @@ public class NonControl : AvaloniaObject
2020

2121
public Control Control
2222
{
23-
get { return GetValue(ControlProperty); }
24-
set { SetValue(ControlProperty, value); }
23+
get => GetValue(ControlProperty);
24+
set => SetValue(ControlProperty, value);
2525
}
2626

2727
public string String
2828
{
29-
get { return GetValue(StringProperty); }
30-
set { SetValue(StringProperty, value); }
29+
get => GetValue(StringProperty);
30+
set => SetValue(StringProperty, value);
3131
}
3232

33-
public string Bar
34-
{
35-
get { return GetValue(BarProperty); }
36-
}
33+
public string Bar => GetValue(BarProperty);
3734
}
3835
}

tests/Avalonia.ReactiveUI.UnitTests/AvaloniaObjectTests_GetSubject.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ private class Class1 : AvaloniaObject
3737

3838
public string Foo
3939
{
40-
get { return GetValue(FooProperty); }
41-
set { SetValue(FooProperty, value); }
40+
get => GetValue(FooProperty);
41+
set => SetValue(FooProperty, value);
4242
}
4343
}
4444
}

tests/Avalonia.RenderTests/Media/ImageBrushTests.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,18 @@ public ImageBrushTests()
2121

2222
private string BitmapPath
2323
{
24-
get { return System.IO.Path.Combine(OutputPath, "github_icon.png"); }
24+
get
25+
{
26+
return System.IO.Path.Combine(OutputPath, "github_icon.png");
27+
}
2528
}
2629

2730
private string SmallBitmapPath
2831
{
29-
get { return System.IO.Path.Combine(OutputPath, "github_icon_small.png"); }
32+
get
33+
{
34+
return System.IO.Path.Combine(OutputPath, "github_icon_small.png");
35+
}
3036
}
3137

3238
[Fact]

tests/Avalonia.RenderTests/Media/ImageDrawingTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ public ImageDrawingTests()
1919

2020
private string BitmapPath
2121
{
22-
get { return System.IO.Path.Combine(OutputPath, "github_icon.png"); }
22+
get
23+
{
24+
return System.IO.Path.Combine(OutputPath, "github_icon.png");
25+
}
2326
}
2427

2528
[Fact]

tests/Avalonia.RenderTests/Media/VisualBrushTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ public VisualBrushTests()
2121

2222
private string BitmapPath
2323
{
24-
get { return System.IO.Path.Combine(OutputPath, "github_icon.png"); }
24+
get
25+
{
26+
return System.IO.Path.Combine(OutputPath, "github_icon.png");
27+
}
2528
}
2629

2730
private Control Visual

0 commit comments

Comments
 (0)