From 1ab2f99783c066aeec93af63fe5548dec274bc98 Mon Sep 17 00:00:00 2001 From: achiez Date: Fri, 13 Mar 2026 14:54:33 +0200 Subject: [PATCH] chore: perform resharper cleanup --- src/NebulaAuth/Core/DialogsController.cs | 6 +- src/NebulaAuth/Core/UpdateManager.cs | 19 +-- src/NebulaAuth/MainWindow.xaml.cs | 17 +-- src/NebulaAuth/Model/Mafiles/Storage.cs | 4 +- .../MafilesLegacy/SDAEncryptionHelper.cs | 3 +- .../Model/MafilesLegacy/SDAEncryptor.cs | 3 +- src/NebulaAuth/Model/Update/ChangelogEntry.cs | 20 ++-- src/NebulaAuth/Model/Update/UpdateSettings.cs | 8 +- src/NebulaAuth/NLog.config | 10 +- .../View/ConfirmationTemplates.xaml | 5 +- .../View/Dialogs/SdaPasswordDialog.xaml | 2 +- .../View/Dialogs/SdaPasswordDialog.xaml.cs | 2 +- src/NebulaAuth/View/Dialogs/UpdateDialog.xaml | 113 ++++++++++-------- .../View/Dialogs/UpdateDialog.xaml.cs | 2 +- src/NebulaAuth/View/LinksView.xaml.cs | 8 +- src/NebulaAuth/ViewModel/MainVM.cs | 3 +- .../ViewModel/MainVM_Confirmations.cs | 1 - src/NebulaAuth/ViewModel/MainVM_Proxy.cs | 2 +- .../ViewModel/Other/SdaPasswordDialogVM.cs | 9 +- src/NebulaAuth/ViewModel/Other/SettingsVM.cs | 3 +- .../ViewModel/Other/UpdateDialogVM.cs | 11 +- 21 files changed, 127 insertions(+), 124 deletions(-) diff --git a/src/NebulaAuth/Core/DialogsController.cs b/src/NebulaAuth/Core/DialogsController.cs index 831398a..8ee1339 100644 --- a/src/NebulaAuth/Core/DialogsController.cs +++ b/src/NebulaAuth/Core/DialogsController.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Threading.Tasks; using AutoUpdaterDotNET; using MaterialDesignThemes.Wpf; -using Microsoft.Win32; using NebulaAuth.Model; using NebulaAuth.Model.Entities; using NebulaAuth.Model.Update; @@ -55,7 +54,7 @@ public static class DialogsController } /// - /// Shows the SDA encryption password dialog for unlocking SDA-encrypted mafiles. + /// Shows the SDA encryption password dialog for unlocking SDA-encrypted mafiles. /// /// The entered password if user clicked OK, otherwise null. public static async Task ShowSdaPasswordDialog() @@ -73,6 +72,7 @@ public static class DialogsController return null; } + public static async Task ShowProxyManager() { var vm = new ProxyManagerVM(); @@ -163,7 +163,7 @@ public static class DialogsController var content = msg == null ? new ConfirmCancelDialog() : new ConfirmCancelDialog(msg); var result = await DialogHost.Show(content); - return result != null && (bool)result; + return result != null && (bool) result; } public static async Task ShowTextFieldDialog(string? title = null, string? msg = null) diff --git a/src/NebulaAuth/Core/UpdateManager.cs b/src/NebulaAuth/Core/UpdateManager.cs index f6610e6..578e921 100644 --- a/src/NebulaAuth/Core/UpdateManager.cs +++ b/src/NebulaAuth/Core/UpdateManager.cs @@ -1,11 +1,11 @@ -using AutoUpdaterDotNET; -using NebulaAuth.Model; -using NebulaAuth.Model.Update; -using Newtonsoft.Json; -using System; +using System; using System.IO; using System.Net.Http; using System.Windows; +using AutoUpdaterDotNET; +using NebulaAuth.Model; +using NebulaAuth.Model.Update; +using Newtonsoft.Json; namespace NebulaAuth.Core; @@ -13,6 +13,7 @@ public static class UpdateManager { private const string BASE_URL = "https://raw.githubusercontent.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies/master/"; + private const string UPDATE_URL = BASE_URL + "NebulaAuth/update.xml"; private const string CHANGELOG_BASE_URL = BASE_URL + "changelog/"; @@ -21,13 +22,14 @@ public static class UpdateManager private static bool _isManualCheck; public static bool HasPendingUpdate { get; private set; } - public static event Action? PendingUpdateDetected; static UpdateManager() { AutoUpdater.CheckForUpdateEvent += HandleCheckForUpdateEvent; } + public static event Action? PendingUpdateDetected; + public static void CheckForUpdates(bool manual = false) { _isManualCheck = manual; @@ -62,7 +64,8 @@ public static class UpdateManager if (isManual) { Application.Current.Dispatcher.Invoke(() => - SnackbarController.SendSnackbar(LocManager.GetCommonOrDefault("Request error", "RequestError"))); + SnackbarController.SendSnackbar(LocManager.GetCommonOrDefault("Request error", + "RequestError"))); } return; @@ -81,7 +84,7 @@ public static class UpdateManager return; } - var version = args.CurrentVersion.ToString(); + var version = args.CurrentVersion; var settings = UpdateSettings.Load(); if (!isManual && !settings.ShouldShow(version)) diff --git a/src/NebulaAuth/MainWindow.xaml.cs b/src/NebulaAuth/MainWindow.xaml.cs index 5796f0a..39e23db 100644 --- a/src/NebulaAuth/MainWindow.xaml.cs +++ b/src/NebulaAuth/MainWindow.xaml.cs @@ -1,10 +1,4 @@ -using MaterialDesignThemes.Wpf; -using NebulaAuth.Core; -using NebulaAuth.Model; -using NebulaAuth.View.Dialogs; -using NebulaAuth.ViewModel; -using NebulaAuth.ViewModel.Other; -using System; +using System; using System.Reflection; using System.Threading.Tasks; using System.Windows; @@ -13,6 +7,12 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Threading; +using MaterialDesignThemes.Wpf; +using NebulaAuth.Core; +using NebulaAuth.Model; +using NebulaAuth.View.Dialogs; +using NebulaAuth.ViewModel; +using NebulaAuth.ViewModel.Other; namespace NebulaAuth; @@ -55,12 +55,13 @@ public partial class MainWindow private static ColorAnimationUsingKeyFrames BuildBlinkAnimation(Duration duration, string targetName) { - var anim = new ColorAnimationUsingKeyFrames { Duration = duration }; + var anim = new ColorAnimationUsingKeyFrames {Duration = duration}; for (var i = 0; i <= 6; i++) { var color = i % 2 == 0 ? Colors.DodgerBlue : Colors.OrangeRed; anim.KeyFrames.Add(new DiscreteColorKeyFrame(color, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(i)))); } + Storyboard.SetTargetName(anim, targetName); Storyboard.SetTargetProperty(anim, new PropertyPath(SolidColorBrush.ColorProperty)); return anim; diff --git a/src/NebulaAuth/Model/Mafiles/Storage.cs b/src/NebulaAuth/Model/Mafiles/Storage.cs index c2f71cc..4f57b5f 100644 --- a/src/NebulaAuth/Model/Mafiles/Storage.cs +++ b/src/NebulaAuth/Model/Mafiles/Storage.cs @@ -51,7 +51,7 @@ public static class Storage await Task.Run(() => { return Parallel.ForEachAsync(files, - new ParallelOptions { CancellationToken = token, MaxDegreeOfParallelism = threadCount }, + new ParallelOptions {CancellationToken = token, MaxDegreeOfParallelism = threadCount}, async (file, ct) => { try @@ -241,7 +241,7 @@ public static class Storage if (counter % 5 == 0) { - progress?.Report(counter / (double)files.Count); + progress?.Report(counter / (double) files.Count); await Task.Delay(10); } } diff --git a/src/NebulaAuth/Model/MafilesLegacy/SDAEncryptionHelper.cs b/src/NebulaAuth/Model/MafilesLegacy/SDAEncryptionHelper.cs index 3d1b1c3..a6e0bc5 100644 --- a/src/NebulaAuth/Model/MafilesLegacy/SDAEncryptionHelper.cs +++ b/src/NebulaAuth/Model/MafilesLegacy/SDAEncryptionHelper.cs @@ -54,7 +54,8 @@ public static class SDAEncryptionHelper if (string.IsNullOrWhiteSpace(fileName)) return null; - var entries = sdaManifest.Entries.ToDictionary(x => Path.GetFileName(x.Filename), StringComparer.OrdinalIgnoreCase); + var entries = + sdaManifest.Entries.ToDictionary(x => Path.GetFileName(x.Filename), StringComparer.OrdinalIgnoreCase); return new Context(sdaManifest, entries, null); } diff --git a/src/NebulaAuth/Model/MafilesLegacy/SDAEncryptor.cs b/src/NebulaAuth/Model/MafilesLegacy/SDAEncryptor.cs index 0c5daa6..ef36a43 100644 --- a/src/NebulaAuth/Model/MafilesLegacy/SDAEncryptor.cs +++ b/src/NebulaAuth/Model/MafilesLegacy/SDAEncryptor.cs @@ -86,7 +86,8 @@ public static class SDAEncryptor } } - public static bool TryDecryptData(string password, string passwordSalt, string IV, string encryptedData, [NotNullWhen(true)] out string? plaintext) + public static bool TryDecryptData(string password, string passwordSalt, string IV, string encryptedData, + [NotNullWhen(true)] out string? plaintext) { plaintext = null; try diff --git a/src/NebulaAuth/Model/Update/ChangelogEntry.cs b/src/NebulaAuth/Model/Update/ChangelogEntry.cs index 6d494eb..17b7225 100644 --- a/src/NebulaAuth/Model/Update/ChangelogEntry.cs +++ b/src/NebulaAuth/Model/Update/ChangelogEntry.cs @@ -5,24 +5,18 @@ namespace NebulaAuth.Model.Update; public class ChangelogEntry { - [JsonProperty("version")] - public string Version { get; set; } = string.Empty; + [JsonProperty("version")] public string Version { get; set; } = string.Empty; - [JsonProperty("date")] - public string Date { get; set; } = string.Empty; + [JsonProperty("date")] public string Date { get; set; } = string.Empty; - [JsonProperty("changes")] - public List Changes { get; set; } = new(); + [JsonProperty("changes")] public List Changes { get; set; } = new(); } public class ChangeItem { - [JsonProperty("type")] - public string Type { get; set; } = string.Empty; + [JsonProperty("type")] public string Type { get; set; } = string.Empty; - [JsonProperty("text")] - public string Text { get; set; } = string.Empty; + [JsonProperty("text")] public string Text { get; set; } = string.Empty; - [JsonProperty("link")] - public string? Link { get; set; } -} + [JsonProperty("link")] public string? Link { get; set; } +} \ No newline at end of file diff --git a/src/NebulaAuth/Model/Update/UpdateSettings.cs b/src/NebulaAuth/Model/Update/UpdateSettings.cs index b025d74..e9609aa 100644 --- a/src/NebulaAuth/Model/Update/UpdateSettings.cs +++ b/src/NebulaAuth/Model/Update/UpdateSettings.cs @@ -8,11 +8,9 @@ public class UpdateSettings { private static readonly string FilePath = Path.Combine("settings", "update.json"); - [JsonProperty("skippedVersion")] - public string? SkippedVersion { get; set; } + [JsonProperty("skippedVersion")] public string? SkippedVersion { get; set; } - [JsonProperty("remindAfter")] - public DateTime? RemindAfter { get; set; } + [JsonProperty("remindAfter")] public DateTime? RemindAfter { get; set; } public static UpdateSettings Load() { @@ -56,4 +54,4 @@ public class UpdateSettings if (RemindAfter.HasValue && DateTime.Now < RemindAfter.Value) return false; return true; } -} +} \ No newline at end of file diff --git a/src/NebulaAuth/NLog.config b/src/NebulaAuth/NLog.config index d35ee8f..6ade154 100644 --- a/src/NebulaAuth/NLog.config +++ b/src/NebulaAuth/NLog.config @@ -5,11 +5,11 @@ throwExceptions="true"> - + diff --git a/src/NebulaAuth/View/ConfirmationTemplates.xaml b/src/NebulaAuth/View/ConfirmationTemplates.xaml index 584647b..aea0292 100644 --- a/src/NebulaAuth/View/ConfirmationTemplates.xaml +++ b/src/NebulaAuth/View/ConfirmationTemplates.xaml @@ -174,7 +174,8 @@ - + @@ -236,7 +237,7 @@ - + - + \ No newline at end of file diff --git a/src/NebulaAuth/View/Dialogs/SdaPasswordDialog.xaml.cs b/src/NebulaAuth/View/Dialogs/SdaPasswordDialog.xaml.cs index c0263bb..5823c3d 100644 --- a/src/NebulaAuth/View/Dialogs/SdaPasswordDialog.xaml.cs +++ b/src/NebulaAuth/View/Dialogs/SdaPasswordDialog.xaml.cs @@ -6,4 +6,4 @@ public partial class SdaPasswordDialog { InitializeComponent(); } -} +} \ No newline at end of file diff --git a/src/NebulaAuth/View/Dialogs/UpdateDialog.xaml b/src/NebulaAuth/View/Dialogs/UpdateDialog.xaml index f5def78..35cc9b6 100644 --- a/src/NebulaAuth/View/Dialogs/UpdateDialog.xaml +++ b/src/NebulaAuth/View/Dialogs/UpdateDialog.xaml @@ -57,57 +57,62 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - + + + - +