From 88c05b1a19991bf3b5219b540b287d3f7e136495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro?= Date: Wed, 21 Nov 2018 01:26:31 +0000 Subject: [PATCH] Fixed field declarations which should be readonly. --- src/Avalonia.Controls/Calendar/CalendarItem.cs | 2 +- src/Avalonia.Controls/Primitives/AdornerLayer.cs | 2 +- src/Avalonia.Controls/Viewbox.cs | 2 +- src/Avalonia.Input/Cursors.cs | 2 +- src/Avalonia.Input/DataFormats.cs | 6 +++--- src/Avalonia.Input/DragDrop.cs | 10 +++++----- src/Avalonia.Visuals/Media/GradientStop.cs | 4 ++-- src/Avalonia.Visuals/Media/Typeface.cs | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Avalonia.Controls/Calendar/CalendarItem.cs b/src/Avalonia.Controls/Calendar/CalendarItem.cs index 577555333f..fb6dacaf81 100644 --- a/src/Avalonia.Controls/Calendar/CalendarItem.cs +++ b/src/Avalonia.Controls/Calendar/CalendarItem.cs @@ -52,7 +52,7 @@ namespace Avalonia.Controls.Primitives internal Calendar Owner { get; set; } internal CalendarDayButton CurrentButton { get; set; } - public static StyledProperty HeaderBackgroundProperty = Calendar.HeaderBackgroundProperty.AddOwner(); + public static readonly StyledProperty HeaderBackgroundProperty = Calendar.HeaderBackgroundProperty.AddOwner(); public IBrush HeaderBackground { get { return GetValue(HeaderBackgroundProperty); } diff --git a/src/Avalonia.Controls/Primitives/AdornerLayer.cs b/src/Avalonia.Controls/Primitives/AdornerLayer.cs index 5308a062ec..ed590679cd 100644 --- a/src/Avalonia.Controls/Primitives/AdornerLayer.cs +++ b/src/Avalonia.Controls/Primitives/AdornerLayer.cs @@ -13,7 +13,7 @@ namespace Avalonia.Controls.Primitives // TODO: Need to track position of adorned elements and move the adorner if they move. public class AdornerLayer : Panel, ICustomSimpleHitTest { - public static AttachedProperty AdornedElementProperty = + public static readonly AttachedProperty AdornedElementProperty = AvaloniaProperty.RegisterAttached("AdornedElement"); private static readonly AttachedProperty s_adornedElementInfoProperty = diff --git a/src/Avalonia.Controls/Viewbox.cs b/src/Avalonia.Controls/Viewbox.cs index db753f4ab4..3a070d07b2 100644 --- a/src/Avalonia.Controls/Viewbox.cs +++ b/src/Avalonia.Controls/Viewbox.cs @@ -12,7 +12,7 @@ namespace Avalonia.Controls /// /// The stretch property /// - public static AvaloniaProperty StretchProperty = + public static readonly AvaloniaProperty StretchProperty = AvaloniaProperty.RegisterDirect(nameof(Stretch), v => v.Stretch, (c, v) => c.Stretch = v, Stretch.Uniform); diff --git a/src/Avalonia.Input/Cursors.cs b/src/Avalonia.Input/Cursors.cs index 6f67f3b08c..d3618f30f3 100644 --- a/src/Avalonia.Input/Cursors.cs +++ b/src/Avalonia.Input/Cursors.cs @@ -47,7 +47,7 @@ namespace Avalonia.Input public class Cursor { - public static Cursor Default = new Cursor(StandardCursorType.Arrow); + public static readonly Cursor Default = new Cursor(StandardCursorType.Arrow); internal Cursor(IPlatformHandle platformCursor) { diff --git a/src/Avalonia.Input/DataFormats.cs b/src/Avalonia.Input/DataFormats.cs index 559d2cb643..cf5a6592e1 100644 --- a/src/Avalonia.Input/DataFormats.cs +++ b/src/Avalonia.Input/DataFormats.cs @@ -5,11 +5,11 @@ /// /// Dataformat for plaintext /// - public static string Text = nameof(Text); + public static readonly string Text = nameof(Text); /// /// Dataformat for one or more filenames /// - public static string FileNames = nameof(FileNames); + public static readonly string FileNames = nameof(FileNames); } -} \ No newline at end of file +} diff --git a/src/Avalonia.Input/DragDrop.cs b/src/Avalonia.Input/DragDrop.cs index b5aba55f6c..c58b764b1d 100644 --- a/src/Avalonia.Input/DragDrop.cs +++ b/src/Avalonia.Input/DragDrop.cs @@ -9,21 +9,21 @@ namespace Avalonia.Input /// /// Event which is raised, when a drag-and-drop operation enters the element. /// - public static RoutedEvent DragEnterEvent = RoutedEvent.Register("DragEnter", RoutingStrategies.Bubble, typeof(DragDrop)); + public static readonly RoutedEvent DragEnterEvent = RoutedEvent.Register("DragEnter", RoutingStrategies.Bubble, typeof(DragDrop)); /// /// Event which is raised, when a drag-and-drop operation leaves the element. /// - public static RoutedEvent DragLeaveEvent = RoutedEvent.Register("DragLeave", RoutingStrategies.Bubble, typeof(DragDrop)); + public static readonly RoutedEvent DragLeaveEvent = RoutedEvent.Register("DragLeave", RoutingStrategies.Bubble, typeof(DragDrop)); /// /// Event which is raised, when a drag-and-drop operation is updated while over the element. /// - public static RoutedEvent DragOverEvent = RoutedEvent.Register("DragOver", RoutingStrategies.Bubble, typeof(DragDrop)); + public static readonly RoutedEvent DragOverEvent = RoutedEvent.Register("DragOver", RoutingStrategies.Bubble, typeof(DragDrop)); /// /// Event which is raised, when a drag-and-drop operation should complete over the element. /// - public static RoutedEvent DropEvent = RoutedEvent.Register("Drop", RoutingStrategies.Bubble, typeof(DragDrop)); + public static readonly RoutedEvent DropEvent = RoutedEvent.Register("Drop", RoutingStrategies.Bubble, typeof(DragDrop)); - public static AvaloniaProperty AllowDropProperty = AvaloniaProperty.RegisterAttached("AllowDrop", typeof(DragDrop), inherits: true); + public static readonly AvaloniaProperty AllowDropProperty = AvaloniaProperty.RegisterAttached("AllowDrop", typeof(DragDrop), inherits: true); /// /// Gets a value indicating whether the given element can be used as the target of a drag-and-drop operation. diff --git a/src/Avalonia.Visuals/Media/GradientStop.cs b/src/Avalonia.Visuals/Media/GradientStop.cs index 00d96a0b3c..25a6eb10dc 100644 --- a/src/Avalonia.Visuals/Media/GradientStop.cs +++ b/src/Avalonia.Visuals/Media/GradientStop.cs @@ -11,13 +11,13 @@ namespace Avalonia.Media /// /// Describes the property. /// - public static StyledProperty OffsetProperty = + public static readonly StyledProperty OffsetProperty = AvaloniaProperty.Register(nameof(Offset)); /// /// Describes the property. /// - public static StyledProperty ColorProperty = + public static readonly StyledProperty ColorProperty = AvaloniaProperty.Register(nameof(Color)); /// diff --git a/src/Avalonia.Visuals/Media/Typeface.cs b/src/Avalonia.Visuals/Media/Typeface.cs index 6dde2bb591..37ac0953bf 100644 --- a/src/Avalonia.Visuals/Media/Typeface.cs +++ b/src/Avalonia.Visuals/Media/Typeface.cs @@ -7,7 +7,7 @@ namespace Avalonia.Media /// public class Typeface { - public static Typeface Default = new Typeface(FontFamily.Default); + public static readonly Typeface Default = new Typeface(FontFamily.Default); /// /// Initializes a new instance of the class.