From 733041ba2bfdcbca55350af1de5b6c9717d6657a Mon Sep 17 00:00:00 2001 From: CleanCodeDeveloper <16760760+CleanCodeDeveloper@users.noreply.github.com> Date: Mon, 15 Aug 2022 20:21:52 +0200 Subject: [PATCH] Remove obsolete fxCop suppressions and references (#19905) --- src/codeAnalysis/GlobalSuppressions.cs | 2 +- .../Settings.UI.Library/HotkeySettingsControlHook.cs | 2 -- .../Settings.UI.Library/ViewModels/GeneralViewModel.cs | 8 +------- .../ViewModels/ImageResizerViewModel.cs | 5 ----- .../ViewModelTests/PowerLauncherViewModelTest.cs | 2 +- 5 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/codeAnalysis/GlobalSuppressions.cs b/src/codeAnalysis/GlobalSuppressions.cs index ac92f3a0d4..92fa1d258e 100644 --- a/src/codeAnalysis/GlobalSuppressions.cs +++ b/src/codeAnalysis/GlobalSuppressions.cs @@ -50,7 +50,7 @@ using System.Diagnostics.CodeAnalysis; [assembly: SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Documents.InlineCollection.Add(System.String)", Scope = "member", Target = "Microsoft.Templates.UI.Extensions.TextBlockExtensions.#OnSequentialFlowStepChanged(System.Windows.DependencyObject,System.Windows.DependencyPropertyChangedEventArgs)", Justification = "No text here")] [assembly: SuppressMessage("Globalization", "CA1309:Use ordinal string comparison", Justification = "The user's search term should be compared with culture based rules.", Scope = "type", Target = "~T:Microsoft.PowerToys.Run.Plugin.TimeDate.Components.SearchController")] -// FxCop warning suppression for uninstantiated TestFixture classes +// Uninstantiated TestFixture classes [assembly: SuppressMessage("Microsoft.Performance", "CA1812: Avoid uninstantiated internal classes", Scope = "module", Justification = "CA1812 will be thrown for every file in the test project. This is mentioned here: dotnet/roslyn-analyzers#1830")] // Code quality diff --git a/src/settings-ui/Settings.UI.Library/HotkeySettingsControlHook.cs b/src/settings-ui/Settings.UI.Library/HotkeySettingsControlHook.cs index 0c738a2ff2..dbb619ea73 100644 --- a/src/settings-ui/Settings.UI.Library/HotkeySettingsControlHook.cs +++ b/src/settings-ui/Settings.UI.Library/HotkeySettingsControlHook.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Diagnostics.CodeAnalysis; using interop; namespace Microsoft.PowerToys.Settings.UI.Library @@ -21,7 +20,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library private const int WmSysKeyDown = 0x0104; private const int WmSysKeyUp = 0x0105; - [SuppressMessage("Usage", "CA2213:Disposable fields should be disposed", Justification = "This class conforms to the IDisposable pattern, and the Dispose and C++ destructor does get called when debugging. Looks like a false positive from FxCop.")] private KeyboardHook _hook; private KeyEvent _keyDown; private KeyEvent _keyUp; diff --git a/src/settings-ui/Settings.UI.Library/ViewModels/GeneralViewModel.cs b/src/settings-ui/Settings.UI.Library/ViewModels/GeneralViewModel.cs index 28e672afb1..f365524b7c 100644 --- a/src/settings-ui/Settings.UI.Library/ViewModels/GeneralViewModel.cs +++ b/src/settings-ui/Settings.UI.Library/ViewModels/GeneralViewModel.cs @@ -4,7 +4,6 @@ using System; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.IO.Abstractions; using System.Runtime.CompilerServices; using Microsoft.PowerToys.Settings.UI.Library.Helpers; @@ -74,7 +73,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels // Update Settings file folder: _settingsConfigFileFolder = configFileSubfolder; - // Using Invariant here as these are internal strings and fxcop + // Using Invariant here as these are internal strings and the analyzer // expects strings to be normalized to uppercase. While the theme names // are represented in lowercase everywhere else, we'll use uppercase // normalization for switch statements @@ -288,12 +287,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels } } - // FxCop suggests marking this member static, but it is accessed through - // an instance in autogenerated files (GeneralPage.g.cs) and will break - // the file if modified -#pragma warning disable CA1822 // Mark members as static public string PowerToysVersion -#pragma warning restore CA1822 // Mark members as static { get { diff --git a/src/settings-ui/Settings.UI.Library/ViewModels/ImageResizerViewModel.cs b/src/settings-ui/Settings.UI.Library/ViewModels/ImageResizerViewModel.cs index 116fc6a316..abaebc1cfa 100644 --- a/src/settings-ui/Settings.UI.Library/ViewModels/ImageResizerViewModel.cs +++ b/src/settings-ui/Settings.UI.Library/ViewModels/ImageResizerViewModel.cs @@ -109,18 +109,13 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels } } -#pragma warning disable CA2227 // Collection properties should be read only public ObservableCollection Sizes -#pragma warning restore CA2227 // Collection properties should be read only { get { return _advancedSizes; } - // FxCop demands collection properties to be read-only, but this - // setter is used in autogenerated files (ImageResizerPage.g.cs) - // and replacing the setter with its own method will break the file set { SavesImageSizes(value); diff --git a/src/settings-ui/Settings.UI.UnitTests/ViewModelTests/PowerLauncherViewModelTest.cs b/src/settings-ui/Settings.UI.UnitTests/ViewModelTests/PowerLauncherViewModelTest.cs index 0164787426..8a80f0cbf6 100644 --- a/src/settings-ui/Settings.UI.UnitTests/ViewModelTests/PowerLauncherViewModelTest.cs +++ b/src/settings-ui/Settings.UI.UnitTests/ViewModelTests/PowerLauncherViewModelTest.cs @@ -19,7 +19,7 @@ namespace ViewModelTests public int TimesSent { get; set; } // PowerLauncherSettings is unused, but required according to SendCallback's signature. - // Naming parameter with discard symbol to suppress FxCop warnings. + // Naming parameter with discard symbol to suppress StyleCop warnings. [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1313:Parameter names should begin with lower-case letter", Justification = "We actually don't validate setting, just calculate it was sent")] public void OnSend(PowerLauncherSettings _) {