Przeglądaj źródła

Use nameof where possible.

José Pedro 7 lat temu
rodzic
commit
7cccc6bda0
28 zmienionych plików z 64 dodań i 64 usunięć
  1. 1 1
      src/Avalonia.Controls/Carousel.cs
  2. 3 3
      src/Avalonia.Controls/ColumnDefinition.cs
  3. 1 1
      src/Avalonia.Controls/DropDown.cs
  4. 1 1
      src/Avalonia.Controls/Primitives/HeaderedContentControl.cs
  5. 1 1
      src/Avalonia.Controls/Primitives/TemplatedControl.cs
  6. 3 3
      src/Avalonia.Controls/Primitives/Thumb.cs
  7. 3 3
      src/Avalonia.Controls/RowDefinition.cs
  8. 2 2
      src/Avalonia.Controls/Shapes/Line.cs
  9. 1 1
      src/Avalonia.Controls/Shapes/Path.cs
  10. 4 4
      src/Avalonia.Controls/Shapes/Shape.cs
  11. 5 5
      src/Avalonia.Controls/TextBox.cs
  12. 1 1
      src/Avalonia.Diagnostics/Views/ControlDetailsView.cs
  13. 8 8
      src/Avalonia.HtmlRenderer/HtmlControl.cs
  14. 9 9
      src/Avalonia.Input/InputElement.cs
  15. 3 3
      src/Avalonia.Input/KeyBinding.cs
  16. 1 1
      src/Avalonia.Visuals/Media/Geometry.cs
  17. 1 1
      src/Avalonia.Visuals/Media/ImageBrush.cs
  18. 1 1
      src/Avalonia.Visuals/Media/MatrixTransform.cs
  19. 1 1
      src/Avalonia.Visuals/Media/RotateTransform.cs
  20. 2 2
      src/Avalonia.Visuals/Media/TranslateTransform.cs
  21. 1 1
      src/Avalonia.Visuals/Media/VisualBrush.cs
  22. 3 3
      tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_Direct.cs
  23. 1 1
      tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_GetSubject.cs
  24. 1 1
      tests/Avalonia.Base.UnitTests/DirectPropertyTests.cs
  25. 1 1
      tests/Avalonia.Markup.UnitTests/Data/ExpressionObserverTests_AttachedProperty.cs
  26. 1 1
      tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests.cs
  27. 3 3
      tests/Avalonia.Markup.Xaml.UnitTests/Xaml/NonControl.cs
  28. 1 1
      tests/Avalonia.Styling.UnitTests/StyleTests.cs

+ 1 - 1
src/Avalonia.Controls/Carousel.cs

@@ -24,7 +24,7 @@ namespace Avalonia.Controls
         /// Defines the <see cref="Transition"/> property.
         /// </summary>
         public static readonly StyledProperty<IPageTransition> TransitionProperty =
-            AvaloniaProperty.Register<Carousel, IPageTransition>("Transition");
+            AvaloniaProperty.Register<Carousel, IPageTransition>(nameof(Transition));
 
         /// <summary>
         /// The default value of <see cref="ItemsControl.ItemsPanelProperty"/> for 

+ 3 - 3
src/Avalonia.Controls/ColumnDefinition.cs

@@ -12,19 +12,19 @@ namespace Avalonia.Controls
         /// Defines the <see cref="MaxWidth"/> property.
         /// </summary>
         public static readonly StyledProperty<double> MaxWidthProperty =
-            AvaloniaProperty.Register<ColumnDefinition, double>("MaxWidth", double.PositiveInfinity);
+            AvaloniaProperty.Register<ColumnDefinition, double>(nameof(MaxWidth), double.PositiveInfinity);
 
         /// <summary>
         /// Defines the <see cref="MinWidth"/> property.
         /// </summary>
         public static readonly StyledProperty<double> MinWidthProperty =
-            AvaloniaProperty.Register<ColumnDefinition, double>("MinWidth");
+            AvaloniaProperty.Register<ColumnDefinition, double>(nameof(MinWidth));
 
         /// <summary>
         /// Defines the <see cref="Width"/> property.
         /// </summary>
         public static readonly StyledProperty<GridLength> WidthProperty =
-            AvaloniaProperty.Register<ColumnDefinition, GridLength>("Width", new GridLength(1, GridUnitType.Star));
+            AvaloniaProperty.Register<ColumnDefinition, GridLength>(nameof(Width), new GridLength(1, GridUnitType.Star));
 
         /// <summary>
         /// Initializes a new instance of the <see cref="ColumnDefinition"/> class.

+ 1 - 1
src/Avalonia.Controls/DropDown.cs

@@ -38,7 +38,7 @@ namespace Avalonia.Controls
         /// Defines the <see cref="SelectionBoxItem"/> property.
         /// </summary>
         public static readonly DirectProperty<DropDown, object> SelectionBoxItemProperty =
-            AvaloniaProperty.RegisterDirect<DropDown, object>("SelectionBoxItem", o => o.SelectionBoxItem);
+            AvaloniaProperty.RegisterDirect<DropDown, object>(nameof(SelectionBoxItem), o => o.SelectionBoxItem);
 
         private bool _isDropDownOpen;
         private Popup _popup;

+ 1 - 1
src/Avalonia.Controls/Primitives/HeaderedContentControl.cs

@@ -12,7 +12,7 @@ namespace Avalonia.Controls.Primitives
         /// Defines the <see cref="Header"/> property.
         /// </summary>
         public static readonly StyledProperty<object> HeaderProperty =
-            AvaloniaProperty.Register<ContentControl, object>("Header");
+            AvaloniaProperty.Register<ContentControl, object>(nameof(Header));
 
         /// <summary>
         /// Gets or sets the header content.

+ 1 - 1
src/Avalonia.Controls/Primitives/TemplatedControl.cs

@@ -75,7 +75,7 @@ namespace Avalonia.Controls.Primitives
         /// Defines the <see cref="Template"/> property.
         /// </summary>
         public static readonly StyledProperty<IControlTemplate> TemplateProperty =
-            AvaloniaProperty.Register<TemplatedControl, IControlTemplate>("Template");
+            AvaloniaProperty.Register<TemplatedControl, IControlTemplate>(nameof(Template));
 
         /// <summary>
         /// Defines the IsTemplateFocusTarget attached property.

+ 3 - 3
src/Avalonia.Controls/Primitives/Thumb.cs

@@ -11,13 +11,13 @@ namespace Avalonia.Controls.Primitives
     public class Thumb : TemplatedControl
     {
         public static readonly RoutedEvent<VectorEventArgs> DragStartedEvent =
-            RoutedEvent.Register<Thumb, VectorEventArgs>("DragStarted", RoutingStrategies.Bubble);
+            RoutedEvent.Register<Thumb, VectorEventArgs>(nameof(DragStarted), RoutingStrategies.Bubble);
 
         public static readonly RoutedEvent<VectorEventArgs> DragDeltaEvent =
-            RoutedEvent.Register<Thumb, VectorEventArgs>("DragDelta", RoutingStrategies.Bubble);
+            RoutedEvent.Register<Thumb, VectorEventArgs>(nameof(DragDelta), RoutingStrategies.Bubble);
 
         public static readonly RoutedEvent<VectorEventArgs> DragCompletedEvent =
-            RoutedEvent.Register<Thumb, VectorEventArgs>("DragCompleted", RoutingStrategies.Bubble);
+            RoutedEvent.Register<Thumb, VectorEventArgs>(nameof(DragCompleted), RoutingStrategies.Bubble);
 
         private Point? _lastPoint;
 

+ 3 - 3
src/Avalonia.Controls/RowDefinition.cs

@@ -12,19 +12,19 @@ namespace Avalonia.Controls
         /// Defines the <see cref="MaxHeight"/> property.
         /// </summary>
         public static readonly StyledProperty<double> MaxHeightProperty =
-            AvaloniaProperty.Register<RowDefinition, double>("MaxHeight", double.PositiveInfinity);
+            AvaloniaProperty.Register<RowDefinition, double>(nameof(MaxHeight), double.PositiveInfinity);
 
         /// <summary>
         /// Defines the <see cref="MinHeight"/> property.
         /// </summary>
         public static readonly StyledProperty<double> MinHeightProperty =
-            AvaloniaProperty.Register<RowDefinition, double>("MinHeight");
+            AvaloniaProperty.Register<RowDefinition, double>(nameof(MinHeight));
 
         /// <summary>
         /// Defines the <see cref="Height"/> property.
         /// </summary>
         public static readonly StyledProperty<GridLength> HeightProperty =
-            AvaloniaProperty.Register<RowDefinition, GridLength>("Height", new GridLength(1, GridUnitType.Star));
+            AvaloniaProperty.Register<RowDefinition, GridLength>(nameof(Height), new GridLength(1, GridUnitType.Star));
 
         /// <summary>
         /// Initializes a new instance of the <see cref="RowDefinition"/> class.

+ 2 - 2
src/Avalonia.Controls/Shapes/Line.cs

@@ -8,10 +8,10 @@ namespace Avalonia.Controls.Shapes
     public class Line : Shape
     {
         public static readonly StyledProperty<Point> StartPointProperty =
-            AvaloniaProperty.Register<Line, Point>("StartPoint");
+            AvaloniaProperty.Register<Line, Point>(nameof(StartPoint));
 
         public static readonly StyledProperty<Point> EndPointProperty =
-            AvaloniaProperty.Register<Line, Point>("EndPoint");
+            AvaloniaProperty.Register<Line, Point>(nameof(EndPoint));
 
         static Line()
         {

+ 1 - 1
src/Avalonia.Controls/Shapes/Path.cs

@@ -9,7 +9,7 @@ namespace Avalonia.Controls.Shapes
     public class Path : Shape
     {
         public static readonly StyledProperty<Geometry> DataProperty =
-            AvaloniaProperty.Register<Path, Geometry>("Data");
+            AvaloniaProperty.Register<Path, Geometry>(nameof(Data));
 
         static Path()
         {

+ 4 - 4
src/Avalonia.Controls/Shapes/Shape.cs

@@ -12,19 +12,19 @@ namespace Avalonia.Controls.Shapes
     public abstract class Shape : Control
     {
         public static readonly StyledProperty<IBrush> FillProperty =
-            AvaloniaProperty.Register<Shape, IBrush>("Fill");
+            AvaloniaProperty.Register<Shape, IBrush>(nameof(Fill));
 
         public static readonly StyledProperty<Stretch> StretchProperty =
-            AvaloniaProperty.Register<Shape, Stretch>("Stretch");
+            AvaloniaProperty.Register<Shape, Stretch>(nameof(Stretch));
 
         public static readonly StyledProperty<IBrush> StrokeProperty =
-            AvaloniaProperty.Register<Shape, IBrush>("Stroke");
+            AvaloniaProperty.Register<Shape, IBrush>(nameof(Stroke));
 
         public static readonly StyledProperty<AvaloniaList<double>> StrokeDashArrayProperty =
             AvaloniaProperty.Register<Shape, AvaloniaList<double>>("StrokeDashArray");
 
         public static readonly StyledProperty<double> StrokeThicknessProperty =
-            AvaloniaProperty.Register<Shape, double>("StrokeThickness");
+            AvaloniaProperty.Register<Shape, double>(nameof(StrokeThickness));
 
         private Matrix _transform = Matrix.Identity;
         private Geometry _definingGeometry;

+ 5 - 5
src/Avalonia.Controls/TextBox.cs

@@ -21,13 +21,13 @@ namespace Avalonia.Controls
     public class TextBox : TemplatedControl, UndoRedoHelper<TextBox.UndoRedoState>.IUndoRedoHost
     {
         public static readonly StyledProperty<bool> AcceptsReturnProperty =
-            AvaloniaProperty.Register<TextBox, bool>("AcceptsReturn");
+            AvaloniaProperty.Register<TextBox, bool>(nameof(AcceptsReturn));
 
         public static readonly StyledProperty<bool> AcceptsTabProperty =
-            AvaloniaProperty.Register<TextBox, bool>("AcceptsTab");
+            AvaloniaProperty.Register<TextBox, bool>(nameof(AcceptsTab));
 
         public static readonly DirectProperty<TextBox, bool> CanScrollHorizontallyProperty =
-            AvaloniaProperty.RegisterDirect<TextBox, bool>("CanScrollHorizontally", o => o.CanScrollHorizontally);
+            AvaloniaProperty.RegisterDirect<TextBox, bool>(nameof(CanScrollHorizontally), o => o.CanScrollHorizontally);
 
         public static readonly DirectProperty<TextBox, int> CaretIndexProperty =
             AvaloniaProperty.RegisterDirect<TextBox, int>(
@@ -69,10 +69,10 @@ namespace Avalonia.Controls
             TextBlock.TextWrappingProperty.AddOwner<TextBox>();
 
         public static readonly StyledProperty<string> WatermarkProperty =
-            AvaloniaProperty.Register<TextBox, string>("Watermark");
+            AvaloniaProperty.Register<TextBox, string>(nameof(Watermark));
 
         public static readonly StyledProperty<bool> UseFloatingWatermarkProperty =
-            AvaloniaProperty.Register<TextBox, bool>("UseFloatingWatermark");
+            AvaloniaProperty.Register<TextBox, bool>(nameof(UseFloatingWatermark));
 
         struct UndoRedoState : IEquatable<UndoRedoState>
         {

+ 1 - 1
src/Avalonia.Diagnostics/Views/ControlDetailsView.cs

@@ -14,7 +14,7 @@ namespace Avalonia.Diagnostics.Views
     internal class ControlDetailsView : UserControl
     {
         private static readonly StyledProperty<ControlDetailsViewModel> ViewModelProperty =
-            AvaloniaProperty.Register<ControlDetailsView, ControlDetailsViewModel>("ViewModel");
+            AvaloniaProperty.Register<ControlDetailsView, ControlDetailsViewModel>(nameof(ViewModel));
         private SimpleGrid _grid;
 
         public ControlDetailsView()

+ 8 - 8
src/Avalonia.HtmlRenderer/HtmlControl.cs

@@ -74,29 +74,29 @@ namespace Avalonia.Controls.Html
         protected Point _lastScrollOffset;
 
         public static readonly AvaloniaProperty AvoidImagesLateLoadingProperty = 
-            PropertyHelper.Register<HtmlControl, bool>("AvoidImagesLateLoading", false, OnAvaloniaProperty_valueChanged);
+            PropertyHelper.Register<HtmlControl, bool>(nameof(AvoidImagesLateLoading), false, OnAvaloniaProperty_valueChanged);
         public static readonly AvaloniaProperty IsSelectionEnabledProperty =
-            PropertyHelper.Register<HtmlControl, bool>("IsSelectionEnabled", true, OnAvaloniaProperty_valueChanged);
+            PropertyHelper.Register<HtmlControl, bool>(nameof(IsSelectionEnabled), true, OnAvaloniaProperty_valueChanged);
         public static readonly AvaloniaProperty IsContextMenuEnabledProperty =
-            PropertyHelper.Register<HtmlControl, bool>("IsContextMenuEnabled", true, OnAvaloniaProperty_valueChanged);
+            PropertyHelper.Register<HtmlControl, bool>(nameof(IsContextMenuEnabled), true, OnAvaloniaProperty_valueChanged);
 
         public static readonly AvaloniaProperty BaseStylesheetProperty =
-            PropertyHelper.Register<HtmlControl, string>("BaseStylesheet", null, OnAvaloniaProperty_valueChanged);
+            PropertyHelper.Register<HtmlControl, string>(nameof(BaseStylesheet), null, OnAvaloniaProperty_valueChanged);
 
         public static readonly AvaloniaProperty TextProperty =
-            PropertyHelper.Register<HtmlControl, string>("Text", null, OnAvaloniaProperty_valueChanged);
+            PropertyHelper.Register<HtmlControl, string>(nameof(Text), null, OnAvaloniaProperty_valueChanged);
 
         public static readonly StyledProperty<IBrush> BackgroundProperty =
             Border.BackgroundProperty.AddOwner<HtmlControl>();
 
         public static readonly AvaloniaProperty BorderThicknessProperty =
-            AvaloniaProperty.Register<HtmlControl, Thickness>("BorderThickness", new Thickness(0));
+            AvaloniaProperty.Register<HtmlControl, Thickness>(nameof(BorderThickness), new Thickness(0));
 
         public static readonly AvaloniaProperty BorderBrushProperty =
-    AvaloniaProperty.Register<HtmlControl, IBrush>("BorderBrush");
+    AvaloniaProperty.Register<HtmlControl, IBrush>(nameof(BorderBrush));
 
         public static readonly AvaloniaProperty PaddingProperty =
-            AvaloniaProperty.Register<HtmlControl, Thickness>("Padding", new Thickness(0));
+            AvaloniaProperty.Register<HtmlControl, Thickness>(nameof(Padding), new Thickness(0));
 
         public static readonly RoutedEvent LoadCompleteEvent =
             RoutedEvent.Register<RoutedEventArgs>("LoadComplete",  RoutingStrategies.Bubble, typeof(HtmlControl));

+ 9 - 9
src/Avalonia.Input/InputElement.cs

@@ -31,43 +31,43 @@ namespace Avalonia.Input
         /// Defines the <see cref="IsEnabledCore"/> property.
         /// </summary>
         public static readonly StyledProperty<bool> IsEnabledCoreProperty =
-            AvaloniaProperty.Register<InputElement, bool>("IsEnabledCore", true);
+            AvaloniaProperty.Register<InputElement, bool>(nameof(IsEnabledCore), true);
 
         /// <summary>
         /// Gets or sets associated mouse cursor.
         /// </summary>
         public static readonly StyledProperty<Cursor> CursorProperty =
-            AvaloniaProperty.Register<InputElement, Cursor>("Cursor", null, true);
+            AvaloniaProperty.Register<InputElement, Cursor>(nameof(Cursor), null, true);
 
         /// <summary>
         /// Defines the <see cref="IsFocused"/> property.
         /// </summary>
         public static readonly DirectProperty<InputElement, bool> IsFocusedProperty =
-            AvaloniaProperty.RegisterDirect<InputElement, bool>("IsFocused", o => o.IsFocused);
+            AvaloniaProperty.RegisterDirect<InputElement, bool>(nameof(IsFocused), o => o.IsFocused);
 
         /// <summary>
         /// Defines the <see cref="IsHitTestVisible"/> property.
         /// </summary>
         public static readonly StyledProperty<bool> IsHitTestVisibleProperty =
-            AvaloniaProperty.Register<InputElement, bool>("IsHitTestVisible", true);
+            AvaloniaProperty.Register<InputElement, bool>(nameof(IsHitTestVisible), true);
 
         /// <summary>
         /// Defines the <see cref="IsPointerOver"/> property.
         /// </summary>
         public static readonly DirectProperty<InputElement, bool> IsPointerOverProperty =
-            AvaloniaProperty.RegisterDirect<InputElement, bool>("IsPointerOver", o => o.IsPointerOver);
+            AvaloniaProperty.RegisterDirect<InputElement, bool>(nameof(IsPointerOver), o => o.IsPointerOver);
 
         /// <summary>
         /// Defines the <see cref="GotFocus"/> event.
         /// </summary>
         public static readonly RoutedEvent<GotFocusEventArgs> GotFocusEvent =
-            RoutedEvent.Register<InputElement, GotFocusEventArgs>("GotFocus", RoutingStrategies.Bubble);
+            RoutedEvent.Register<InputElement, GotFocusEventArgs>(nameof(GotFocus), RoutingStrategies.Bubble);
 
         /// <summary>
         /// Defines the <see cref="LostFocus"/> event.
         /// </summary>
         public static readonly RoutedEvent<RoutedEventArgs> LostFocusEvent =
-            RoutedEvent.Register<InputElement, RoutedEventArgs>("LostFocus", RoutingStrategies.Bubble);
+            RoutedEvent.Register<InputElement, RoutedEventArgs>(nameof(LostFocus), RoutingStrategies.Bubble);
 
         /// <summary>
         /// Defines the <see cref="KeyDown"/> event.
@@ -97,13 +97,13 @@ namespace Avalonia.Input
         /// Defines the <see cref="PointerEnter"/> event.
         /// </summary>
         public static readonly RoutedEvent<PointerEventArgs> PointerEnterEvent =
-            RoutedEvent.Register<InputElement, PointerEventArgs>("PointerEnter", RoutingStrategies.Direct);
+            RoutedEvent.Register<InputElement, PointerEventArgs>(nameof(PointerEnter), RoutingStrategies.Direct);
 
         /// <summary>
         /// Defines the <see cref="PointerLeave"/> event.
         /// </summary>
         public static readonly RoutedEvent<PointerEventArgs> PointerLeaveEvent =
-            RoutedEvent.Register<InputElement, PointerEventArgs>("PointerLeave", RoutingStrategies.Direct);
+            RoutedEvent.Register<InputElement, PointerEventArgs>(nameof(PointerLeave), RoutingStrategies.Direct);
 
         /// <summary>
         /// Defines the <see cref="PointerMoved"/> event.

+ 3 - 3
src/Avalonia.Input/KeyBinding.cs

@@ -10,7 +10,7 @@ namespace Avalonia.Input
     public class KeyBinding : AvaloniaObject
     {
         public static readonly StyledProperty<ICommand> CommandProperty =
-            AvaloniaProperty.Register<KeyBinding, ICommand>("Command");
+            AvaloniaProperty.Register<KeyBinding, ICommand>(nameof(Command));
 
         public ICommand Command
         {
@@ -19,7 +19,7 @@ namespace Avalonia.Input
         }
 
         public static readonly StyledProperty<object> CommandParameterProperty =
-            AvaloniaProperty.Register<KeyBinding, object>("CommandParameter");
+            AvaloniaProperty.Register<KeyBinding, object>(nameof(CommandParameter));
 
         public object CommandParameter
         {
@@ -28,7 +28,7 @@ namespace Avalonia.Input
         }
 
         public static readonly StyledProperty<KeyGesture> GestureProperty =
-            AvaloniaProperty.Register<KeyBinding, KeyGesture>("Gesture");
+            AvaloniaProperty.Register<KeyBinding, KeyGesture>(nameof(Gesture));
 
         public KeyGesture Gesture
         {

+ 1 - 1
src/Avalonia.Visuals/Media/Geometry.cs

@@ -15,7 +15,7 @@ namespace Avalonia.Media
         /// Defines the <see cref="Transform"/> property.
         /// </summary>
         public static readonly StyledProperty<Transform> TransformProperty =
-            AvaloniaProperty.Register<Geometry, Transform>("Transform");
+            AvaloniaProperty.Register<Geometry, Transform>(nameof(Transform));
 
         /// <summary>
         /// Initializes static members of the <see cref="Geometry"/> class.

+ 1 - 1
src/Avalonia.Visuals/Media/ImageBrush.cs

@@ -14,7 +14,7 @@ namespace Avalonia.Media
         /// Defines the <see cref="Visual"/> property.
         /// </summary>
         public static readonly StyledProperty<IBitmap> SourceProperty =
-            AvaloniaProperty.Register<ImageBrush, IBitmap>("Source");
+            AvaloniaProperty.Register<ImageBrush, IBitmap>(nameof(Source));
 
         /// <summary>
         /// Initializes a new instance of the <see cref="ImageBrush"/> class.

+ 1 - 1
src/Avalonia.Visuals/Media/MatrixTransform.cs

@@ -15,7 +15,7 @@ namespace Avalonia.Media
         /// Defines the <see cref="Matrix"/> property.
         /// </summary>
         public static readonly StyledProperty<Matrix> MatrixProperty =
-            AvaloniaProperty.Register<MatrixTransform, Matrix>("Matrix", Matrix.Identity);
+            AvaloniaProperty.Register<MatrixTransform, Matrix>(nameof(Matrix), Matrix.Identity);
 
         /// <summary>
         /// Initializes a new instance of the <see cref="MatrixTransform"/> class.

+ 1 - 1
src/Avalonia.Visuals/Media/RotateTransform.cs

@@ -15,7 +15,7 @@ namespace Avalonia.Media
         /// Defines the <see cref="Angle"/> property.
         /// </summary>
         public static readonly StyledProperty<double> AngleProperty =
-            AvaloniaProperty.Register<RotateTransform, double>("Angle");
+            AvaloniaProperty.Register<RotateTransform, double>(nameof(Angle));
 
         /// <summary>
         /// Initializes a new instance of the <see cref="RotateTransform"/> class.

+ 2 - 2
src/Avalonia.Visuals/Media/TranslateTransform.cs

@@ -15,13 +15,13 @@ namespace Avalonia.Media
         /// Defines the <see cref="X"/> property.
         /// </summary>
         public static readonly StyledProperty<double> XProperty =
-            AvaloniaProperty.Register<TranslateTransform, double>("X");
+            AvaloniaProperty.Register<TranslateTransform, double>(nameof(X));
 
         /// <summary>
         /// Defines the <see cref="Y"/> property.
         /// </summary>
         public static readonly StyledProperty<double> YProperty =
-            AvaloniaProperty.Register<TranslateTransform, double>("Y");
+            AvaloniaProperty.Register<TranslateTransform, double>(nameof(Y));
 
         /// <summary>
         /// Initializes a new instance of the <see cref="TranslateTransform"/> class.

+ 1 - 1
src/Avalonia.Visuals/Media/VisualBrush.cs

@@ -14,7 +14,7 @@ namespace Avalonia.Media
         /// Defines the <see cref="Visual"/> property.
         /// </summary>
         public static readonly StyledProperty<IVisual> VisualProperty =
-            AvaloniaProperty.Register<VisualBrush, IVisual>("Visual");
+            AvaloniaProperty.Register<VisualBrush, IVisual>(nameof(Visual));
 
         /// <summary>
         /// Initializes a new instance of the <see cref="VisualBrush"/> class.

+ 3 - 3
tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_Direct.cs

@@ -506,17 +506,17 @@ namespace Avalonia.Base.UnitTests
         {
             public static readonly DirectProperty<Class1, string> FooProperty =
                 AvaloniaProperty.RegisterDirect<Class1, string>(
-                    "Foo",
+                    nameof(Foo),
                     o => o.Foo,
                     (o, v) => o.Foo = v,
                     unsetValue: "unset");
 
             public static readonly DirectProperty<Class1, string> BarProperty =
-                AvaloniaProperty.RegisterDirect<Class1, string>("Bar", o => o.Bar);
+                AvaloniaProperty.RegisterDirect<Class1, string>(nameof(Bar), o => o.Bar);
 
             public static readonly DirectProperty<Class1, int> BazProperty =
                 AvaloniaProperty.RegisterDirect<Class1, int>(
-                    "Bar",
+                    nameof(Baz),
                     o => o.Baz,
                     (o, v) => o.Baz = v,
                     unsetValue: -1);

+ 1 - 1
tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_GetSubject.cs

@@ -37,7 +37,7 @@ namespace Avalonia.Base.UnitTests
         private class Class1 : AvaloniaObject
         {
             public static readonly StyledProperty<string> FooProperty =
-                AvaloniaProperty.Register<Class1, string>("Foo", "foodefault");
+                AvaloniaProperty.Register<Class1, string>(nameof(Foo), "foodefault");
 
             public string Foo
             {

+ 1 - 1
tests/Avalonia.Base.UnitTests/DirectPropertyTests.cs

@@ -85,7 +85,7 @@ namespace Avalonia.Base.UnitTests
         private class Class1 : AvaloniaObject
         {
             public static readonly DirectProperty<Class1, string> FooProperty =
-                AvaloniaProperty.RegisterDirect<Class1, string>("Foo", o => o.Foo, (o, v) => o.Foo = v);
+                AvaloniaProperty.RegisterDirect<Class1, string>(nameof(Foo), o => o.Foo, (o, v) => o.Foo = v);
 
             private string _foo = "foo";
 

+ 1 - 1
tests/Avalonia.Markup.UnitTests/Data/ExpressionObserverTests_AttachedProperty.cs

@@ -136,7 +136,7 @@ namespace Avalonia.Markup.UnitTests.Data
         private class Class1 : AvaloniaObject
         {
             public static readonly StyledProperty<Class1> NextProperty =
-                AvaloniaProperty.Register<Class1, Class1>("Next");
+                AvaloniaProperty.Register<Class1, Class1>(nameof(Next));
 
             public Class1 Next
             {

+ 1 - 1
tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests.cs

@@ -558,7 +558,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.Data
         private class InheritanceTest : Decorator
         {
             public static readonly StyledProperty<int> BazProperty =
-                AvaloniaProperty.Register<InheritanceTest, int>("Baz", defaultValue: 6, inherits: true);
+                AvaloniaProperty.Register<InheritanceTest, int>(nameof(Baz), defaultValue: 6, inherits: true);
 
             public int Baz
             {

+ 3 - 3
tests/Avalonia.Markup.Xaml.UnitTests/Xaml/NonControl.cs

@@ -8,10 +8,10 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml
     public class NonControl : AvaloniaObject
     {
         public static readonly StyledProperty<Control> ControlProperty =
-            AvaloniaProperty.Register<NonControl, Control>("Control");
+            AvaloniaProperty.Register<NonControl, Control>(nameof(Control));
 
         public static readonly StyledProperty<string> StringProperty =
-            AvaloniaProperty.Register<NonControl, string>("String");
+            AvaloniaProperty.Register<NonControl, string>(nameof(String));
 
         //No getter or setter Avalonia property
         public static readonly StyledProperty<int> FooProperty =
@@ -19,7 +19,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml
 
         //getter only Avalonia property
         public static readonly StyledProperty<string> BarProperty =
-                AvaloniaProperty.Register<NonControl, string>("Bar");
+                AvaloniaProperty.Register<NonControl, string>(nameof(Bar));
 
         public Control Control
         {

+ 1 - 1
tests/Avalonia.Styling.UnitTests/StyleTests.cs

@@ -170,7 +170,7 @@ namespace Avalonia.Styling.UnitTests
         private class Class1 : Control
         {
             public static readonly StyledProperty<string> FooProperty =
-                AvaloniaProperty.Register<Class1, string>("Foo", "foodefault");
+                AvaloniaProperty.Register<Class1, string>(nameof(Foo), "foodefault");
 
             public string Foo
             {