[NetAnalyzers]CA1031 suppressions cleanup (#18706)

This commit is contained in:
Davide Giacometti
2022-06-12 15:11:52 +02:00
committed by GitHub
parent 33072c7ee3
commit b33bc2ecd0
54 changed files with 0 additions and 143 deletions

View File

@@ -50,7 +50,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library
[JsonPropertyName("download_updates_automatically")]
public bool AutoDownloadUpdates { get; set; }
[SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Any error from calling interop code should not prevent the program from loading.")]
public GeneralSettings()
{
Startup = false;

View File

@@ -109,7 +109,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library
}
// Save settings to a json file.
[SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "General exceptions will be logged until we can better understand runtime exception scenarios")]
public void SaveSettings(string jsonSettings, string powertoy = DefaultModuleName, string fileName = DefaultFileName)
{
try

View File

@@ -55,9 +55,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
string version = ReleasePageLink.Substring(ReleasePageLink.LastIndexOf('/') + 1);
return version.Trim();
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception)
#pragma warning restore CA1031 // Do not catch general exception types
{
}
@@ -75,9 +73,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
var date = DateTimeOffset.FromUnixTimeSeconds(seconds).UtcDateTime;
return date.ToLocalTime().ToString(CultureInfo.CurrentCulture);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception)
#pragma warning restore CA1031 // Do not catch general exception types
{
}
@@ -108,9 +104,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
return JsonSerializer.Deserialize<UpdatingSettings>(data);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception)
#pragma warning restore CA1031 // Do not catch general exception types
{
}
}

View File

@@ -278,9 +278,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
{
UpdateUIThemeCallBack(GeneralSettingsConfig.Theme);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception e)
#pragma warning restore CA1031 // Do not catch general exception types
{
Logger.LogError("Exception encountered when changing Settings theme", e);
}

View File

@@ -26,7 +26,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private Func<string, int> SendConfigMSG { get; }
[SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Exceptions should not crash the program but will be logged until we can understand common exception scenarios")]
public ImageResizerViewModel(ISettingsUtils settingsUtils, ISettingsRepository<GeneralSettings> settingsRepository, Func<string, int> ipcMSGCallBackFunc, Func<string, string> resourceLoader)
{
_settingsUtils = settingsUtils ?? throw new ArgumentNullException(nameof(settingsUtils));

View File

@@ -47,7 +47,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private Func<List<KeysDataModel>, int> FilterRemapKeysList { get; }
[SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Exceptions should not crash the program but will be logged until we can understand common exception scenarios")]
public KeyboardManagerViewModel(ISettingsUtils settingsUtils, ISettingsRepository<GeneralSettings> settingsRepository, Func<string, int> ipcMSGCallBackFunc, Func<List<KeysDataModel>, int> filterRemapKeysList)
{
if (settingsRepository == null)
@@ -200,7 +199,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
NativeMethods.SetForegroundWindow(handle);
}
[SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Exceptions here (especially mutex errors) should not halt app execution, but they will be logged.")]
private void OpenEditor(int type)
{
try
@@ -236,7 +234,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
OnPropertyChanged(nameof(RemapShortcuts));
}
[SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Exceptions here (especially mutex errors) should not halt app execution, but they will be logged.")]
public bool LoadProfile()
{
var success = true;

View File

@@ -26,7 +26,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private Func<string, int> SendConfigMSG { get; }
[SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Exceptions should not crash the program but will be logged until we can understand common exception scenarios")]
public PowerRenameViewModel(ISettingsUtils settingsUtils, ISettingsRepository<GeneralSettings> settingsRepository, Func<string, int> ipcMSGCallBackFunc, string configFileSubfolder = "")
{
// Update Settings file folder:

View File

@@ -53,9 +53,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
Settings = _settingsUtils.GetSettings<VideoConferenceSettings>(GetSettingsSubPath());
}
#pragma warning disable CA1031 // Do not catch general exception types
catch
#pragma warning restore CA1031 // Do not catch general exception types
{
Settings = new VideoConferenceSettings();
_settingsUtils.SaveSettings(Settings.ToJsonString(), GetSettingsSubPath());
@@ -177,9 +175,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
RaisePropertyChanged(nameof(CameraImageOverlayPath));
}
}
#pragma warning disable CA1031 // Do not catch general exception types
catch
#pragma warning restore CA1031 // Do not catch general exception types
{
}
}