[Chore] Run solution code cleanup (#20584)

This commit is contained in:
Andrey Nekrasov
2022-09-16 11:54:58 +03:00
committed by GitHub
parent 09f4dead7f
commit ca3c758046
133 changed files with 108 additions and 359 deletions

View File

@@ -38,14 +38,12 @@ namespace Microsoft.PowerToys.Settings.UI.Library
public ColorPickerActivationAction ActivationAction { get; set; }
[JsonPropertyName("colorhistory")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "Need to change this collection")]
public List<string> ColorHistory { get; set; }
[JsonPropertyName("colorhistorylimit")]
public int ColorHistoryLimit { get; set; }
[JsonPropertyName("visiblecolorformats")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "Need to change this collection")]
public Dictionary<string, bool> VisibleColorFormats { get; set; }
[JsonPropertyName("showcolorname")]

View File

@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;

View File

@@ -136,8 +136,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library
case 40: // The Down Arrow key or button.
case 37: // The Left Arrow key or button.
case 39: // The Right Arrow key or button.
// case 8: // The Back key or button.
// case 13: // The Enter key or button.
// case 8: // The Back key or button.
// case 13: // The Enter key or button.
shortcutList.Add(Code);
break;
default:

View File

@@ -14,9 +14,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
// deserialization with System.Text.Json. This affects the UI display.
// See: https://github.com/dotnet/runtime/issues/30258
[JsonPropertyName("value")]
#pragma warning disable CA2227 // Collection properties should be read only
public ObservableCollection<ImageSize> Value { get; set; }
#pragma warning restore CA2227 // Collection properties should be read only
public ImageResizerSizes()
{

View File

@@ -2,10 +2,8 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
namespace Microsoft.PowerToys.Settings.UI.Library
{

View File

@@ -2,8 +2,6 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;

View File

@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Text.Json.Serialization;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
namespace Microsoft.PowerToys.Settings.UI.Library

View File

@@ -14,9 +14,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
// deserialization with System.Text.Json. This affects the UI display.
// See: https://github.com/dotnet/runtime/issues/30258
[JsonPropertyName("inProcess")]
#pragma warning disable CA2227 // Collection properties should be read only
public List<KeysDataModel> InProcessRemapKeys { get; set; }
#pragma warning restore CA2227 // Collection properties should be read only
public RemapKeysDataModel()
{

View File

@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.Abstractions;
using System.Text.Json;

View File

@@ -14,14 +14,10 @@ namespace Microsoft.PowerToys.Settings.UI.Library
// deserialization with System.Text.Json. This affects the UI display.
// See: https://github.com/dotnet/runtime/issues/30258
[JsonPropertyName("global")]
#pragma warning disable CA2227 // Collection properties should be read only
public List<KeysDataModel> GlobalRemapShortcuts { get; set; }
#pragma warning restore CA2227 // Collection properties should be read only
[JsonPropertyName("appSpecific")]
#pragma warning disable CA2227 // Collection properties should be read only
public List<AppSpecificKeysDataModel> AppSpecificRemapShortcuts { get; set; }
#pragma warning restore CA2227 // Collection properties should be read only
public ShortcutsKeyDataModel()
{

View File

@@ -2,9 +2,6 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;

View File

@@ -2,7 +2,6 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Text.Json;
using System.Text.Json.Serialization;

View File

@@ -3,9 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace Microsoft.PowerToys.Settings.UI.Library.Utilities
{

View File

@@ -2,7 +2,6 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;

View File

@@ -5,7 +5,6 @@
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;

View File

@@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;

View File

@@ -3,14 +3,9 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Timers;
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;

View File

@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.CompilerServices;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
@@ -89,14 +88,14 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
{
if (value != _powerRenameEnabled)
{
GeneralSettingsConfig.Enabled.PowerRename = value;
OutGoingGeneralSettings snd = new OutGoingGeneralSettings(GeneralSettingsConfig);
GeneralSettingsConfig.Enabled.PowerRename = value;
OutGoingGeneralSettings snd = new OutGoingGeneralSettings(GeneralSettingsConfig);
SendConfigMSG(snd.ToString());
SendConfigMSG(snd.ToString());
_powerRenameEnabled = value;
OnPropertyChanged(nameof(IsEnabled));
RaisePropertyChanged(nameof(GlobalAndMruEnabled));
_powerRenameEnabled = value;
OnPropertyChanged(nameof(IsEnabled));
RaisePropertyChanged(nameof(GlobalAndMruEnabled));
}
}
}

View File

@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -400,9 +399,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
return _settingsConfigFileFolder + "\\" + ModuleName;
}
#pragma warning disable CA1030 // Use events where appropriate
public void RaisePropertyChanged([CallerMemberName] string propertyName = null)
#pragma warning restore CA1030 // Use events where appropriate
{
OnPropertyChanged(propertyName);
SndVideoConferenceSettings outsettings = new SndVideoConferenceSettings(Settings);

View File

@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Linq;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels;
using Microsoft.VisualStudio.TestTools.UnitTesting;

View File

@@ -18,9 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(PowerAccentShortcutControl), new PropertyMetadata(default(string)));
#pragma warning disable CA2227 // Collection properties should be read only
public List<object> Keys
#pragma warning restore CA2227 // Collection properties should be read only
{
get { return (List<object>)GetValue(KeysProperty); }
set { SetValue(KeysProperty, value); }

View File

@@ -35,9 +35,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
set => SetValue(ModuleImageSourceProperty, value);
}
#pragma warning disable CA2227 // Collection properties should be read only
public ObservableCollection<PageLink> PrimaryLinks
#pragma warning restore CA2227 // Collection properties should be read only
{
get => (ObservableCollection<PageLink>)GetValue(PrimaryLinksProperty);
set => SetValue(PrimaryLinksProperty, value);
@@ -49,9 +47,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
set { SetValue(SecondaryLinksHeaderProperty, value); }
}
#pragma warning disable CA2227 // Collection properties should be read only
public ObservableCollection<PageLink> SecondaryLinks
#pragma warning restore CA2227 // Collection properties should be read only
{
get => (ObservableCollection<PageLink>)GetValue(SecondaryLinksProperty);
set => SetValue(SecondaryLinksProperty, value);

View File

@@ -305,9 +305,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
return _isActive;
}
#pragma warning disable CA1801 // Review unused parameters
private void ShortcutDialog_Opened(ContentDialog sender, ContentDialogOpenedEventArgs args)
#pragma warning restore CA1801 // Review unused parameters
{
if (!ComboIsValid(hotkeySettings))
{
@@ -340,9 +338,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
await shortcutDialog.ShowAsync();
}
#pragma warning disable CA1801 // Review unused parameters
private void ShortcutDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
#pragma warning restore CA1801 // Review unused parameters
{
if (ComboIsValid(lastValidSettings))
{
@@ -366,9 +362,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
}
}
#pragma warning disable CA1801 // Review unused parameters
private void ShortcutDialog_Closing(ContentDialog sender, ContentDialogClosingEventArgs args)
#pragma warning restore CA1801 // Review unused parameters
{
_isActive = false;
}

View File

@@ -15,9 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
this.InitializeComponent();
}
#pragma warning disable CA2227 // Collection properties should be read only
public List<object> Keys
#pragma warning restore CA2227 // Collection properties should be read only
{
get { return (List<object>)GetValue(KeysProperty); }
set { SetValue(KeysProperty, value); }

View File

@@ -18,9 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(ShortcutWithTextLabelControl), new PropertyMetadata(default(string)));
#pragma warning disable CA2227 // Collection properties should be read only
public List<object> Keys
#pragma warning restore CA2227 // Collection properties should be read only
{
get { return (List<object>)GetValue(KeysProperty); }
set { SetValue(KeysProperty, value); }

View File

@@ -9,7 +9,6 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
{
[Serializable]
[StructLayout(LayoutKind.Sequential)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1815:Override equals and operator equals on value types", Justification = "Interop")]
public struct POINT
{
public int X { get; set; }

View File

@@ -9,7 +9,6 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
{
[Serializable]
[StructLayout(LayoutKind.Sequential)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1815:Override equals and operator equals on value types", Justification = "Interop")]
public struct RECT
{
public int Left { get; set; }

View File

@@ -9,7 +9,6 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
{
[Serializable]
[StructLayout(LayoutKind.Sequential)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1815:Override equals and operator equals on value types", Justification = "Interop")]
public struct WINDOWPLACEMENT
{
public int Length { get; set; }

View File

@@ -2,7 +2,6 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Threading;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.OOBE.Enums;
using Microsoft.PowerToys.Settings.UI.OOBE.ViewModel;

View File

@@ -4,7 +4,6 @@
using System;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.OOBE.Enums;
using Microsoft.PowerToys.Settings.UI.OOBE.ViewModel;
@@ -168,7 +167,6 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
}
}
[SuppressMessage("Usage", "CA1801:Review unused parameters", Justification = "Params are required for event handler signature requirements.")]
private void NavigationView_SelectionChanged(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewSelectionChangedEventArgs args)
{
Microsoft.UI.Xaml.Controls.NavigationViewItem selectedItem = args.SelectedItem as Microsoft.UI.Xaml.Controls.NavigationViewItem;

View File

@@ -27,12 +27,12 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// <param name="e">The arguments of this event</param>
private void ColorPicker_ComboBox_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
/**
* UWP hack
* because UWP load the bound ItemSource of the ComboBox asynchronous,
* so after InitializeComponent() the ItemSource is still empty and can't automatically select a entry.
* Selection via SelectedItem and SelectedValue is still not working too
*/
/**
* UWP hack
* because UWP load the bound ItemSource of the ComboBox asynchronous,
* so after InitializeComponent() the ItemSource is still empty and can't automatically select a entry.
* Selection via SelectedItem and SelectedValue is still not working too
*/
var index = 0;
foreach (var item in ViewModel.SelectableColorRepresentations)

View File

@@ -3,14 +3,12 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Windows.ApplicationModel.Resources;
using Windows.UI.Core;
namespace Microsoft.PowerToys.Settings.UI.Views
{

View File

@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
@@ -50,9 +49,9 @@ namespace Microsoft.PowerToys.Settings.UI.Views
dialog.Content = new TextBlock() { Text = resourceLoader.GetString("Delete_Dialog_Description") };
dialog.PrimaryButtonClick += (s, args) =>
{
// Using InvariantCulture since this is internal and expected to be numerical
bool success = int.TryParse(deleteRowButton?.CommandParameter?.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int rowNum);
if (success)
// Using InvariantCulture since this is internal and expected to be numerical
bool success = int.TryParse(deleteRowButton?.CommandParameter?.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int rowNum);
if (success)
{
ViewModel.DeleteImageSize(rowNum);
}
@@ -77,7 +76,6 @@ namespace Microsoft.PowerToys.Settings.UI.Views
}
}
[SuppressMessage("Usage", "CA1801:Review unused parameters", Justification = "Params are required for event handler signature requirements.")]
private void ImagesSizesListView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args)
{
if (ViewModel.IsListViewFocusRequested)

View File

@@ -10,7 +10,6 @@ using Microsoft.PowerToys.Settings.UI.Library.Utilities;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels;
using Microsoft.UI.Xaml.Controls;
using Windows.ApplicationModel.Resources;
using Windows.UI.Core;
namespace Microsoft.PowerToys.Settings.UI.Views
{

View File

@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.PowerToys.Settings.UI.Services;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using Microsoft.UI.Xaml;
@@ -167,8 +166,6 @@ namespace Microsoft.PowerToys.Settings.UI.Views
private bool navigationViewInitialStateProcessed; // avoid announcing initial state of the navigation pane.
[SuppressMessage("Usage", "CA1801:Review unused parameters", Justification = "Params are required for event handler signature requirements.")]
#pragma warning disable CA1822 // Mark members as static
private void NavigationView_PaneOpened(Microsoft.UI.Xaml.Controls.NavigationView sender, object args)
{
if (!navigationViewInitialStateProcessed)
@@ -194,7 +191,6 @@ namespace Microsoft.PowerToys.Settings.UI.Views
}
}
[SuppressMessage("Usage", "CA1801:Review unused parameters", Justification = "Params are required for event handler signature requirements.")]
private void NavigationView_PaneClosed(Microsoft.UI.Xaml.Controls.NavigationView sender, object args)
{
if (!navigationViewInitialStateProcessed)