Browse Source

Remove public setter where possible on events or replace with "init;"

pull/9902/head
Max Katz 3 years ago
parent
commit
39f232dcff
  1. 7
      src/Avalonia.Base/Input/GotFocusEventArgs.cs
  2. 6
      src/Avalonia.Base/Input/KeyEventArgs.cs
  3. 1
      src/Avalonia.Base/Input/KeyboardDevice.cs
  4. 2
      src/Avalonia.Base/Input/PointerDeltaEventArgs.cs
  5. 2
      src/Avalonia.Base/Input/PointerWheelEventArgs.cs
  6. 2
      src/Avalonia.Base/Input/Raw/RawTextInputEventArgs.cs
  7. 2
      src/Avalonia.Base/Input/VectorEventArgs.cs
  8. 3
      tests/Avalonia.Controls.UnitTests/ListBoxTests_Multiple.cs
  9. 4
      tests/Avalonia.Controls.UnitTests/ListBoxTests_Single.cs

7
src/Avalonia.Base/Input/GotFocusEventArgs.cs

@ -7,19 +7,18 @@ namespace Avalonia.Input
/// </summary> /// </summary>
public class GotFocusEventArgs : RoutedEventArgs public class GotFocusEventArgs : RoutedEventArgs
{ {
internal GotFocusEventArgs() public GotFocusEventArgs() : base(InputElement.GotFocusEvent)
{ {
} }
/// <summary> /// <summary>
/// Gets or sets a value indicating how the change in focus occurred. /// Gets or sets a value indicating how the change in focus occurred.
/// </summary> /// </summary>
public NavigationMethod NavigationMethod { get; set; } public NavigationMethod NavigationMethod { get; init; }
/// <summary> /// <summary>
/// Gets or sets any key modifiers active at the time of focus. /// Gets or sets any key modifiers active at the time of focus.
/// </summary> /// </summary>
public KeyModifiers KeyModifiers { get; set; } public KeyModifiers KeyModifiers { get; init; }
} }
} }

6
src/Avalonia.Base/Input/KeyEventArgs.cs

@ -10,10 +10,10 @@ namespace Avalonia.Input
} }
public IKeyboardDevice? Device { get; set; } public IKeyboardDevice? Device { get; init; }
public Key Key { get; set; } public Key Key { get; init; }
public KeyModifiers KeyModifiers { get; set; } public KeyModifiers KeyModifiers { get; init; }
} }
} }

1
src/Avalonia.Base/Input/KeyboardDevice.cs

@ -156,7 +156,6 @@ namespace Avalonia.Input
interactive?.RaiseEvent(new GotFocusEventArgs interactive?.RaiseEvent(new GotFocusEventArgs
{ {
RoutedEvent = InputElement.GotFocusEvent,
NavigationMethod = method, NavigationMethod = method,
KeyModifiers = keyModifiers, KeyModifiers = keyModifiers,
}); });

2
src/Avalonia.Base/Input/PointerDeltaEventArgs.cs

@ -7,7 +7,7 @@ namespace Avalonia.Input
{ {
public class PointerDeltaEventArgs : PointerEventArgs public class PointerDeltaEventArgs : PointerEventArgs
{ {
public Vector Delta { get; set; } public Vector Delta { get; }
[Unstable] [Unstable]
[Obsolete("This constructor might be removed in 12.0.")] [Obsolete("This constructor might be removed in 12.0.")]

2
src/Avalonia.Base/Input/PointerWheelEventArgs.cs

@ -7,7 +7,7 @@ namespace Avalonia.Input
{ {
public class PointerWheelEventArgs : PointerEventArgs public class PointerWheelEventArgs : PointerEventArgs
{ {
public Vector Delta { get; set; } public Vector Delta { get; }
[Unstable] [Unstable]
[Obsolete("This constructor might be removed in 12.0. For unit testing, consider using IHeadlessWindow.MouseWheel.")] [Obsolete("This constructor might be removed in 12.0. For unit testing, consider using IHeadlessWindow.MouseWheel.")]

2
src/Avalonia.Base/Input/Raw/RawTextInputEventArgs.cs

@ -12,6 +12,6 @@ namespace Avalonia.Input.Raw
Text = text; Text = text;
} }
public string Text { get; set; } public string Text { get; }
} }
} }

2
src/Avalonia.Base/Input/VectorEventArgs.cs

@ -5,6 +5,6 @@ namespace Avalonia.Input
{ {
public class VectorEventArgs : RoutedEventArgs public class VectorEventArgs : RoutedEventArgs
{ {
public Vector Vector { get; set; } public Vector Vector { get; init; }
} }
} }

3
tests/Avalonia.Controls.UnitTests/ListBoxTests_Multiple.cs

@ -28,7 +28,6 @@ namespace Avalonia.Controls.UnitTests
target.Presenter.Panel.Children[1].RaiseEvent(new GotFocusEventArgs target.Presenter.Panel.Children[1].RaiseEvent(new GotFocusEventArgs
{ {
RoutedEvent = InputElement.GotFocusEvent,
NavigationMethod = NavigationMethod.Directional, NavigationMethod = NavigationMethod.Directional,
KeyModifiers = KeyModifiers.Shift KeyModifiers = KeyModifiers.Shift
}); });
@ -52,7 +51,6 @@ namespace Avalonia.Controls.UnitTests
target.Presenter.Panel.Children[1].RaiseEvent(new GotFocusEventArgs target.Presenter.Panel.Children[1].RaiseEvent(new GotFocusEventArgs
{ {
RoutedEvent = InputElement.GotFocusEvent,
NavigationMethod = NavigationMethod.Directional, NavigationMethod = NavigationMethod.Directional,
KeyModifiers = KeyModifiers.Control KeyModifiers = KeyModifiers.Control
}); });
@ -77,7 +75,6 @@ namespace Avalonia.Controls.UnitTests
target.Presenter.Panel.Children[0].RaiseEvent(new GotFocusEventArgs target.Presenter.Panel.Children[0].RaiseEvent(new GotFocusEventArgs
{ {
RoutedEvent = InputElement.GotFocusEvent,
NavigationMethod = NavigationMethod.Directional, NavigationMethod = NavigationMethod.Directional,
KeyModifiers = KeyModifiers.Control KeyModifiers = KeyModifiers.Control
}); });

4
tests/Avalonia.Controls.UnitTests/ListBoxTests_Single.cs

@ -33,7 +33,6 @@ namespace Avalonia.Controls.UnitTests
target.Presenter.Panel.Children[0].RaiseEvent(new GotFocusEventArgs target.Presenter.Panel.Children[0].RaiseEvent(new GotFocusEventArgs
{ {
RoutedEvent = InputElement.GotFocusEvent,
NavigationMethod = NavigationMethod.Tab, NavigationMethod = NavigationMethod.Tab,
}); });
@ -53,7 +52,6 @@ namespace Avalonia.Controls.UnitTests
target.Presenter.Panel.Children[0].RaiseEvent(new GotFocusEventArgs target.Presenter.Panel.Children[0].RaiseEvent(new GotFocusEventArgs
{ {
RoutedEvent = InputElement.GotFocusEvent,
NavigationMethod = NavigationMethod.Directional, NavigationMethod = NavigationMethod.Directional,
}); });
@ -73,7 +71,6 @@ namespace Avalonia.Controls.UnitTests
target.Presenter.Panel.Children[0].RaiseEvent(new GotFocusEventArgs target.Presenter.Panel.Children[0].RaiseEvent(new GotFocusEventArgs
{ {
RoutedEvent = InputElement.GotFocusEvent,
NavigationMethod = NavigationMethod.Directional, NavigationMethod = NavigationMethod.Directional,
KeyModifiers = KeyModifiers.Control KeyModifiers = KeyModifiers.Control
}); });
@ -96,7 +93,6 @@ namespace Avalonia.Controls.UnitTests
target.Presenter.Panel.Children[0].RaiseEvent(new GotFocusEventArgs target.Presenter.Panel.Children[0].RaiseEvent(new GotFocusEventArgs
{ {
RoutedEvent = InputElement.GotFocusEvent,
NavigationMethod = NavigationMethod.Directional, NavigationMethod = NavigationMethod.Directional,
KeyModifiers = KeyModifiers.Control KeyModifiers = KeyModifiers.Control
}); });

Loading…
Cancel
Save