diff --git a/src/Consolonia.Core/Infrastructure/ArrowsAndKeyboardNavigationHandler.cs b/src/Consolonia.Core/Infrastructure/ArrowsAndKeyboardNavigationHandler.cs index 6f999e99..4fc52088 100644 --- a/src/Consolonia.Core/Infrastructure/ArrowsAndKeyboardNavigationHandler.cs +++ b/src/Consolonia.Core/Infrastructure/ArrowsAndKeyboardNavigationHandler.cs @@ -37,11 +37,11 @@ NavigationDirection.Down or NavigationDirection.Up) { var elementCast = (InputElement)element; - var visualRoot = (Visual)elementCast.GetVisualRoot()!; + var visualRoot = (Visual)elementCast.GetVisualRoot(); (Point p1, Point p2) = GetOriginalPoint(elementCast.GetTransformedBounds().NotNull().Clip); Point originalPoint = p1 / 2 + p2 / 2; - var focusableElements = visualRoot.GetVisualDescendants() + var focusableElements = visualRoot!.GetVisualDescendants() .OfType() // only focusable .Where(inputElement => inputElement.Focusable && inputElement.IsEffectivelyEnabled && diff --git a/src/Consolonia.Themes.TurboVision/Templates/Controls/Dialog/DialogWindow.cs b/src/Consolonia.Themes.TurboVision/Templates/Controls/Dialog/DialogWindow.cs index 47b2cc90..f3081bd1 100644 --- a/src/Consolonia.Themes.TurboVision/Templates/Controls/Dialog/DialogWindow.cs +++ b/src/Consolonia.Themes.TurboVision/Templates/Controls/Dialog/DialogWindow.cs @@ -107,10 +107,10 @@ public Task ShowDialogAsync(Control parent) return _taskCompletionSource.Task; } - private static DialogHost GetDialogHost(Control parent) + private static DialogHost GetDialogHost(Visual parent) { - var window = parent.FindAncestorOfType(true)!; - DialogHost dialogHost = window.GetValue(DialogHost.DialogHostProperty); + var window = parent.FindAncestorOfType(true); + DialogHost dialogHost = window!.GetValue(DialogHost.DialogHostProperty); return dialogHost; } diff --git a/src/Consolonia.Themes.TurboVision/Templates/Controls/DialogWrap.axaml.cs b/src/Consolonia.Themes.TurboVision/Templates/Controls/DialogWrap.axaml.cs index 697d7769..9f4b1be5 100644 --- a/src/Consolonia.Themes.TurboVision/Templates/Controls/DialogWrap.axaml.cs +++ b/src/Consolonia.Themes.TurboVision/Templates/Controls/DialogWrap.axaml.cs @@ -11,7 +11,8 @@ namespace Consolonia.Themes.TurboVision.Templates.Controls { - [SuppressMessage("Resharper", "PartialTypeWithSinglePart")] + [SuppressMessage("Usage", "PartialTypeWithSinglePart", Justification = "Partial class required for XAML code generation.")] + // ReSharper disable once PartialTypeWithSinglePart internal partial class DialogWrap : UserControl { public readonly ContentPresenter FoundContentPresenter; @@ -24,15 +25,15 @@ public DialogWrap() AttachedToVisualTree += (_, _) => { - var parentWindow = this.FindAncestorOfType()!; - _disposable = parentWindow.GetPropertyChangedObservable(TopLevel.ClientSizeProperty).Subscribe(new AnonymousObserver( + var parentWindow = this.FindAncestorOfType(); + _disposable = parentWindow!.GetPropertyChangedObservable(TopLevel.ClientSizeProperty).Subscribe(new AnonymousObserver( args => { var newSize = (Size)args.NewValue!; SetNewSize(newSize); })); - SetNewSize(parentWindow.ClientSize); + SetNewSize(parentWindow!.ClientSize); }; DetachedFromLogicalTree += (_, _) => { _disposable.Dispose(); }; } diff --git a/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/ComboBoxExtensions.cs b/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/ComboBoxExtensions.cs index b6f56484..030e058d 100644 --- a/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/ComboBoxExtensions.cs +++ b/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/ComboBoxExtensions.cs @@ -1,4 +1,3 @@ -using System; using System.Reflection; using Avalonia; using Avalonia.Controls; diff --git a/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/ConsoloniaTextPresenter.cs b/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/ConsoloniaTextPresenter.cs index 9b159310..6e0c0d36 100644 --- a/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/ConsoloniaTextPresenter.cs +++ b/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/ConsoloniaTextPresenter.cs @@ -69,11 +69,11 @@ static ConsoloniaTextPresenter() public ConsoloniaTextPresenter() { // we need to disable blinking caret, our terminal caret blinks itself once shown - var caretTickTimer = (DispatcherTimer)TickTimerField.GetValue(this)!; - caretTickTimer.Interval = + var caretTickTimer = (DispatcherTimer)TickTimerField.GetValue(this); + caretTickTimer!.Interval = TimeSpan.FromMilliseconds(int .MaxValue); //see DispatcherTimer.Interval, since we can not disable it, setting it to the longest interval possible - caretTickTimer.Tick += (_, _) => throw new NotImplementedException("How to disable timer completely?"); + caretTickTimer!.Tick += (_, _) => throw new NotImplementedException("How to disable timer completely?"); CaretBrush = new FourBitColorBrush(ConsoleColor.Black, PixelBackgroundMode.Transparent); // we want to draw own caret diff --git a/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/DropDownExtensions.cs b/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/DropDownExtensions.cs index fa44349e..6a8594a2 100644 --- a/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/DropDownExtensions.cs +++ b/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/DropDownExtensions.cs @@ -19,28 +19,28 @@ public static void ProcessFocusOnOpen(AvaloniaProp where TElementType : Control where TParentControl : Control { var dropDownControl = (TElementType)args.Sender; - var parentControl = dropDownControl.FindLogicalAncestorOfType()!; + var parentControl = dropDownControl.FindLogicalAncestorOfType(); if (args.NewValue.Value) { dropDownControl.AttachedToVisualTree += focusDropDownAction; - IDisposable disposable1 = parentControl.GetPropertyChangedObservable(InputElement.IsFocusedProperty) + IDisposable disposable1 = parentControl!.GetPropertyChangedObservable(InputElement.IsFocusedProperty) .Subscribe(new AnonymousObserver(eventArgs => { if (!(bool)eventArgs.NewValue! && !dropDownControl.IsKeyboardFocusWithin) - Dispatcher.UIThread.Post(() => { parentControl.SetValue(dropDownProperty, false); }); + Dispatcher.UIThread.Post(() => { parentControl!.SetValue(dropDownProperty, false); }); })); IDisposable disposable2 = dropDownControl .GetPropertyChangedObservable(InputElement.IsKeyboardFocusWithinProperty) .Subscribe(new AnonymousObserver(eventArgs => { - if (!(bool)eventArgs.NewValue! && !parentControl.IsKeyboardFocusWithin) + if (!(bool)eventArgs.NewValue! && !parentControl!.IsKeyboardFocusWithin) Dispatcher.UIThread.Post(() => { - parentControl.SetValue(dropDownProperty, false); - focusParentAction(parentControl); + parentControl!.SetValue(dropDownProperty, false); + focusParentAction(parentControl!); }); })); diff --git a/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/MenuExtensions.cs b/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/MenuExtensions.cs index 36b3149f..b7904c56 100644 --- a/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/MenuExtensions.cs +++ b/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/MenuExtensions.cs @@ -35,10 +35,10 @@ static MenuExtensions() if (!(bool)eventArgs.NewValue!) Dispatcher.UIThread.Post(() => { - var focusedControl = (Control)AvaloniaLocator.Current.GetRequiredService()!.GetFocusedElement()!; + var focusedControl = (Control)AvaloniaLocator.Current.GetRequiredService()!.GetFocusedElement(); var menuItems = visual.GetLogicalAncestors().OfType(); - var focusedTree = focusedControl.GetLogicalAncestors(); + var focusedTree = focusedControl!.GetLogicalAncestors(); foreach (MenuItem menuItem in menuItems.Where(item => !focusedTree.Contains(item)) .ToArray())