From c6acba9ee8958908e0985499ebdfd660b5075547 Mon Sep 17 00:00:00 2001 From: Patchzy <64382339+patchzyy@users.noreply.github.com> Date: Wed, 25 Feb 2026 22:36:48 +0100 Subject: [PATCH] No more warnings --- .editorconfig | 9 ++++++ .../Features/MiiDbServiceTests.cs | 7 ++--- .../GameLicense/Domain/LicenseProfile.cs | 2 +- .../MiiManagement/MiiDbService.cs | 5 ++-- .../MiiManagement/MiiRepositoryService.cs | 1 - WheelWizard/Helpers/Humanizer.cs | 3 -- .../Services/Installation/ModInstallation.cs | 9 +++--- WheelWizard/Services/ModManager.cs | 8 +++--- .../Services/Storage/FilePickerHelper.cs | 28 +++---------------- .../Utilities/Mockers/MockingDataFactory.cs | 2 +- .../RepeatedTasks/RepeatedTaskManager.cs | 2 ++ .../Components/MultiColoredIcon.axaml.cs | 2 +- .../Views/Converters/NullToBoolConverter.cs | 4 +-- WheelWizard/Views/Pages/FriendsPage.axaml.cs | 3 +- WheelWizard/Views/Pages/MiiListPage.axaml.cs | 20 +++++++------ .../Views/Pages/RoomDetailsPage.axaml.cs | 4 +-- WheelWizard/Views/Pages/RoomsPage.axaml.cs | 9 +++--- .../Pages/Settings/VideoSettings.axaml.cs | 9 ++++-- .../Pages/Settings/WhWzSettings.axaml.cs | 11 ++++++-- .../Views/Pages/UserProfilePage.axaml.cs | 9 +++--- .../Views/Patterns/FriendsListItem.axaml.cs | 2 +- WheelWizard/Views/Patterns/MiiBlock.axaml.cs | 1 - .../Views/Patterns/VrHistoryGraph.axaml.cs | 2 +- .../Views/Popups/Base/PopupWindow.axaml.cs | 2 +- .../Popups/Generic/OptionsWindow.axaml.cs | 6 ++-- .../Popups/Generic/ProgressWindow.axaml.cs | 2 +- .../Popups/Generic/TextInputWindow.axaml.cs | 2 +- .../Views/Popups/Generic/YesNoWindow.axaml.cs | 6 ++-- .../MiiEditor/EditorGeneral.axaml.cs | 4 +-- .../MiiManagement/MiiEditorWindow.axaml.cs | 8 +++--- .../MiiManagement/MiiSelectorWindow.axaml.cs | 6 ++-- .../ModManagement/ModBrowserWindow.axaml.cs | 2 +- .../Popups/ModManagement/ModContent.axaml.cs | 5 ---- .../Views/Popups/PlayerProfileWindow.axaml.cs | 2 +- WheelWizard/WheelWizard.csproj | 1 + 35 files changed, 97 insertions(+), 101 deletions(-) diff --git a/.editorconfig b/.editorconfig index dd5e3224..b86d0a2d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,6 +12,15 @@ indent_size = 2 [*.cs] max_line_length = 140 +# Transitional analyzer levels while legacy filesystem/settings migration is in progress. +dotnet_diagnostic.CS0618.severity = suggestion +dotnet_diagnostic.IO0002.severity = suggestion +dotnet_diagnostic.IO0003.severity = suggestion +dotnet_diagnostic.IO0004.severity = suggestion +dotnet_diagnostic.IO0005.severity = suggestion +dotnet_diagnostic.IO0006.severity = suggestion +dotnet_diagnostic.IO0007.severity = suggestion + #### Core EditorConfig Options #### # Indentation and spacing diff --git a/WheelWizard.Test/Features/MiiDbServiceTests.cs b/WheelWizard.Test/Features/MiiDbServiceTests.cs index b2cbafc1..ecaaa9e1 100644 --- a/WheelWizard.Test/Features/MiiDbServiceTests.cs +++ b/WheelWizard.Test/Features/MiiDbServiceTests.cs @@ -1,5 +1,4 @@ using NSubstitute.ExceptionExtensions; -using Testably.Abstractions; using WheelWizard.Shared; using WheelWizard.WiiManagement.MiiManagement; using WheelWizard.WiiManagement.MiiManagement.Domain.Mii; @@ -9,7 +8,6 @@ namespace WheelWizard.Test.Features public class MiiDbServiceTests { private readonly IMiiRepositoryService _repositoryService; - private readonly IRandomSystem _randomSystemService; private readonly MiiDbService _service; // --- Test Setup --- @@ -17,8 +15,7 @@ public class MiiDbServiceTests public MiiDbServiceTests() { _repositoryService = Substitute.For(); - _randomSystemService = Substitute.For(); - _service = new(_repositoryService, _randomSystemService); + _service = new(_repositoryService); } // --- Helper Methods --- @@ -188,7 +185,7 @@ public void GetAllMiis_ShouldSkipInvalidBlocks_AndReturnOnlyValidMiis() Assert.True(mii1Result.IsSuccess, "Setup Failed: Could not create valid Mii"); var mii1Bytes = GetSerializedBytes(mii1Result.Value); var invalidBytesShort = new byte[10]; // Invalid length - var invalidBytesNull = (byte[])null; // Null entry (if possible from repo) + byte[]? invalidBytesNull = null; // Null entry (if possible from repo) // Simulate a block that's the right size but contains garbage data causing deserialization failure var potentiallyBadBytes = new byte[MiiSerializer.MiiBlockSize]; _repositoryService.LoadAllBlocks().Returns([invalidBytesShort, mii1Bytes, potentiallyBadBytes, invalidBytesNull!]); diff --git a/WheelWizard/Features/WiiManagement/GameLicense/Domain/LicenseProfile.cs b/WheelWizard/Features/WiiManagement/GameLicense/Domain/LicenseProfile.cs index bd20da4e..380a9e30 100644 --- a/WheelWizard/Features/WiiManagement/GameLicense/Domain/LicenseProfile.cs +++ b/WheelWizard/Features/WiiManagement/GameLicense/Domain/LicenseProfile.cs @@ -7,5 +7,5 @@ public class LicenseProfile : PlayerProfileBase public required uint TotalRaceCount { get; set; } public required uint TotalWinCount { get; set; } public List Friends { get; set; } = []; - public LicenseStatistics Statistics { get; set; } + public LicenseStatistics Statistics { get; set; } = new(); } diff --git a/WheelWizard/Features/WiiManagement/MiiManagement/MiiDbService.cs b/WheelWizard/Features/WiiManagement/MiiManagement/MiiDbService.cs index c66eaf45..d2ceeff2 100644 --- a/WheelWizard/Features/WiiManagement/MiiManagement/MiiDbService.cs +++ b/WheelWizard/Features/WiiManagement/MiiManagement/MiiDbService.cs @@ -1,5 +1,4 @@ -using Testably.Abstractions; -using WheelWizard.Shared.MessageTranslations; +using WheelWizard.Shared.MessageTranslations; using WheelWizard.WiiManagement.MiiManagement.Domain.Mii; namespace WheelWizard.WiiManagement.MiiManagement; @@ -55,7 +54,7 @@ public interface IMiiDbService bool Exists(); } -public class MiiDbService(IMiiRepositoryService repository, IRandomSystem randomSystem) : IMiiDbService +public class MiiDbService(IMiiRepositoryService repository) : IMiiDbService { public List GetAllMiis() { diff --git a/WheelWizard/Features/WiiManagement/MiiManagement/MiiRepositoryService.cs b/WheelWizard/Features/WiiManagement/MiiManagement/MiiRepositoryService.cs index 5a441ed9..e51c8015 100644 --- a/WheelWizard/Features/WiiManagement/MiiManagement/MiiRepositoryService.cs +++ b/WheelWizard/Features/WiiManagement/MiiManagement/MiiRepositoryService.cs @@ -54,7 +54,6 @@ public interface IMiiRepositoryService public class MiiRepositoryServiceService(IFileSystem fileSystem) : IMiiRepositoryService { - private readonly IFileSystem _fileSystem; private const int MiiLength = 74; private const int MaxMiiSlots = 100; private const int CrcOffset = 0x1F1DE; diff --git a/WheelWizard/Helpers/Humanizer.cs b/WheelWizard/Helpers/Humanizer.cs index abc9aa0b..779782f9 100644 --- a/WheelWizard/Helpers/Humanizer.cs +++ b/WheelWizard/Helpers/Humanizer.cs @@ -55,9 +55,6 @@ public static string HumanizeTimeSpan(TimeSpan timeSpan) } return ReplaceDynamic(Phrases.Time_Seconds_x, timeSpan.Seconds)!; - - // internal method to simplify the pluralization of words - string P(int count) => Math.Abs(count) != 1 ? "s" : ""; } public static string HumanizeSeconds(int seconds) => HumanizeTimeSpan(TimeSpan.FromSeconds(seconds)); diff --git a/WheelWizard/Services/Installation/ModInstallation.cs b/WheelWizard/Services/Installation/ModInstallation.cs index 35250358..5662bf8a 100644 --- a/WheelWizard/Services/Installation/ModInstallation.cs +++ b/WheelWizard/Services/Installation/ModInstallation.cs @@ -135,10 +135,11 @@ public static void ProcessFile(string file, string destinationDirectory, Progres }); // Normalize entry path by removing empty folder segments + var entryKey = entry.Key ?? string.Empty; var sanitizedKey = string.Join( Path.DirectorySeparatorChar.ToString(), - entry - .Key.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) + entryKey + .Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) .Where(segment => !string.IsNullOrWhiteSpace(segment)) ); @@ -176,7 +177,7 @@ public static void ProcessFile(string file, string destinationDirectory, Progres } } - private static IArchive OpenArchive(string filePath, string extension) + private static IArchive? OpenArchive(string filePath, string extension) { try { @@ -201,7 +202,7 @@ private static IArchive OpenArchive(string filePath, string extension) /// public static async Task InstallModFromFileAsync(string filePath, string givenModName, string author = "-1", int modID = -1) { - ProgressWindow progressWindow = null; + ProgressWindow? progressWindow = null; try { if (!File.Exists(filePath)) diff --git a/WheelWizard/Services/ModManager.cs b/WheelWizard/Services/ModManager.cs index b51cb587..48f84fa0 100644 --- a/WheelWizard/Services/ModManager.cs +++ b/WheelWizard/Services/ModManager.cs @@ -101,7 +101,7 @@ public void RemoveMod(Mod mod) OnPropertyChanged(nameof(Mods)); } - private void Mod_PropertyChanged(object sender, PropertyChangedEventArgs e) + private void Mod_PropertyChanged(object? sender, PropertyChangedEventArgs e) { if (_isBatchUpdating) return; @@ -161,7 +161,7 @@ private async Task CombineFilesIntoSingleModAsync(string[] filePaths) .SetPlaceholderText("Enter mod name...") .SetValidation(ValidateModName) .ShowDialog(); - if (!IsValidName(modName)) + if (string.IsNullOrWhiteSpace(modName) || !IsValidName(modName)) return; var tempZipPath = Path.Combine(Path.GetTempPath(), $"{modName}.zip"); @@ -230,7 +230,7 @@ public void ToggleAllMods(bool enable) // TODO: Use this validation method when refactoring the ModManager public OperationResult ValidateModName(string? oldName, string newName) { - newName = newName?.Trim(); + newName = (newName ?? string.Empty).Trim(); if (string.IsNullOrWhiteSpace(newName)) return Fail("Mod name cannot be empty."); @@ -423,7 +423,7 @@ private void ErrorOccurred(string? errorMessage) new MessageBoxWindow() .SetMessageType(MessageBoxWindow.MessageType.Error) .SetTitleText("An error occurred") - .SetInfoText(errorMessage) + .SetInfoText(errorMessage ?? "An unknown error occurred.") .Show(); } diff --git a/WheelWizard/Services/Storage/FilePickerHelper.cs b/WheelWizard/Services/Storage/FilePickerHelper.cs index 9d9570af..e01a8abd 100644 --- a/WheelWizard/Services/Storage/FilePickerHelper.cs +++ b/WheelWizard/Services/Storage/FilePickerHelper.cs @@ -25,6 +25,8 @@ public static async Task> OpenFilePickerAsync( var storageProvider = Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime; if (storageProvider == null) return []; + if (storageProvider.MainWindow?.StorageProvider == null) + return []; var options = new FilePickerOpenOptions { @@ -71,37 +73,15 @@ public static async Task> OpenFilePickerAsync( return null; } - public static async Task> OpenMultipleFilesAsync(string title, IEnumerable fileTypes) - { - var storageProvider = Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime; - if (storageProvider == null) - return null; - - var topLevel = TopLevel.GetTopLevel(storageProvider.MainWindow); - if (topLevel?.StorageProvider == null) - return []; - - var files = await topLevel.StorageProvider.OpenFilePickerAsync( - new() - { - Title = title, - AllowMultiple = true, - FileTypeFilter = fileTypes.ToList(), - } - ); - - return files?.Select(TryResolveLocalPath).Where(path => !string.IsNullOrWhiteSpace(path)).Select(path => path!).ToList() ?? []; - } - public static async Task> SelectFolderAsync(string title, IStorageFolder? suggestedStartLocation = null) { var storageProvider = Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime; if (storageProvider == null) - return null; + return []; var topLevel = TopLevel.GetTopLevel(storageProvider.MainWindow); if (topLevel?.StorageProvider == null) - return null; + return []; var folders = await topLevel.StorageProvider.OpenFolderPickerAsync( new() diff --git a/WheelWizard/Utilities/Mockers/MockingDataFactory.cs b/WheelWizard/Utilities/Mockers/MockingDataFactory.cs index 6a2d0ae6..652d7193 100644 --- a/WheelWizard/Utilities/Mockers/MockingDataFactory.cs +++ b/WheelWizard/Utilities/Mockers/MockingDataFactory.cs @@ -8,7 +8,7 @@ public abstract class MockingDataFactory public static U Instance { get; } = new(); public abstract T Create(int? seed = null); - protected virtual string DictionaryKeyGenerator(T value) => value.ToString(); + protected virtual string DictionaryKeyGenerator(T value) => value is null ? string.Empty : value.ToString() ?? string.Empty; public T[] CreateMultiple(int count = 5, int? seed = null) { diff --git a/WheelWizard/Utilities/RepeatedTasks/RepeatedTaskManager.cs b/WheelWizard/Utilities/RepeatedTasks/RepeatedTaskManager.cs index fd446753..7c58e675 100644 --- a/WheelWizard/Utilities/RepeatedTasks/RepeatedTaskManager.cs +++ b/WheelWizard/Utilities/RepeatedTasks/RepeatedTaskManager.cs @@ -44,7 +44,9 @@ public void Start() _timer.Start(); // Run the initial execution +#pragma warning disable CS4014 ExecuteAndNotifyAsync(); +#pragma warning restore CS4014 } public void Stop() diff --git a/WheelWizard/Views/Components/MultiColoredIcon.axaml.cs b/WheelWizard/Views/Components/MultiColoredIcon.axaml.cs index 7a3c89a9..015503fb 100644 --- a/WheelWizard/Views/Components/MultiColoredIcon.axaml.cs +++ b/WheelWizard/Views/Components/MultiColoredIcon.axaml.cs @@ -146,7 +146,7 @@ private void UpdateDrawingColors() var originalDrawing = IconData; if (originalDrawing?.Drawing is not DrawingGroup originalGroup) { - ProcessedIconData = originalDrawing; + ProcessedIconData = originalDrawing ?? new DrawingImage(); return; } diff --git a/WheelWizard/Views/Converters/NullToBoolConverter.cs b/WheelWizard/Views/Converters/NullToBoolConverter.cs index 16407c0f..79dc7a54 100644 --- a/WheelWizard/Views/Converters/NullToBoolConverter.cs +++ b/WheelWizard/Views/Converters/NullToBoolConverter.cs @@ -5,8 +5,8 @@ namespace WheelWizard.Views.Converters; public class NullToBoolConverter : IValueConverter { - public object Convert(object? value, Type targetType, object parameter, CultureInfo culture) => value != null; + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value != null; - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => Avalonia.Data.BindingOperations.DoNothing; } diff --git a/WheelWizard/Views/Pages/FriendsPage.axaml.cs b/WheelWizard/Views/Pages/FriendsPage.axaml.cs index 2d8b4957..1ab3c137 100644 --- a/WheelWizard/Views/Pages/FriendsPage.axaml.cs +++ b/WheelWizard/Views/Pages/FriendsPage.axaml.cs @@ -127,6 +127,7 @@ private void PopulateSortingList() ListOrderCondition.WINS => Common.Attribute_Wins, ListOrderCondition.TOTAL_RACES => Common.Attribute_RacesPlayed, ListOrderCondition.IS_ONLINE => Common.Attribute_IsOnline, + _ => Common.State_Unknown, }; SortByDropdown.Items.Add(name); @@ -393,7 +394,7 @@ private void SaveMii_OnClick(object sender, RoutedEventArgs e) #region PropertyChanged - public event PropertyChangedEventHandler? PropertyChanged; + public new event PropertyChangedEventHandler? PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { diff --git a/WheelWizard/Views/Pages/MiiListPage.axaml.cs b/WheelWizard/Views/Pages/MiiListPage.axaml.cs index 90b70267..28616cd3 100644 --- a/WheelWizard/Views/Pages/MiiListPage.axaml.cs +++ b/WheelWizard/Views/Pages/MiiListPage.axaml.cs @@ -191,15 +191,15 @@ private void ReloadMiiList() MiiList.Children.Add(addBlock); } - private async void DeleteMii_OnClick(object? sender, RoutedEventArgs e) => DeleteMii(GetSelectedMiis()); + private void DeleteMii_OnClick(object? sender, RoutedEventArgs e) => DeleteMii(GetSelectedMiis()); - private async void EditMii_OnClick(object? sender, RoutedEventArgs e) => EditMii(GetSelectedMiis()[0]); + private void EditMii_OnClick(object? sender, RoutedEventArgs e) => EditMii(GetSelectedMiis()[0]); - private async void FavMii_OnClick(object? sender, RoutedEventArgs e) => ToggleFavorite(GetSelectedMiis()); + private void FavMii_OnClick(object? sender, RoutedEventArgs e) => ToggleFavorite(GetSelectedMiis()); - private async void ExportMii_OnClick(object? sender, RoutedEventArgs e) => ExportMultipleMiiFiles(GetSelectedMiis()); + private void ExportMii_OnClick(object? sender, RoutedEventArgs e) => ExportMultipleMiiFiles(GetSelectedMiis()); - private async void DuplicateMii_OnClick(object? sender, RoutedEventArgs e) => DuplicateMii(GetSelectedMiis()); + private void DuplicateMii_OnClick(object? sender, RoutedEventArgs e) => DuplicateMii(GetSelectedMiis()); private async void ImportMii_OnClick(object? sender, RoutedEventArgs e) { @@ -246,7 +246,7 @@ private async void ImportMii_OnClick(object? sender, RoutedEventArgs e) ReloadMiiList(); } - private async void ToggleFavorite(Mii[] miis) + private void ToggleFavorite(Mii[] miis) { var allFavorite = miis.All(m => m.IsFavorite); @@ -267,7 +267,7 @@ private async void ToggleFavorite(Mii[] miis) ReloadMiiList(); } - private async void ExportMultipleMiiFiles(Mii[] miis) + private void ExportMultipleMiiFiles(Mii[] miis) { if (miis.Length == 0) { @@ -513,7 +513,11 @@ private class MyCommand(Action command) : ICommand public void Execute(object? parameter) => command.Invoke(); - public event EventHandler? CanExecuteChanged; + public event EventHandler? CanExecuteChanged + { + add { } + remove { } + } } #endregion diff --git a/WheelWizard/Views/Pages/RoomDetailsPage.axaml.cs b/WheelWizard/Views/Pages/RoomDetailsPage.axaml.cs index f5ec7339..c64a198c 100644 --- a/WheelWizard/Views/Pages/RoomDetailsPage.axaml.cs +++ b/WheelWizard/Views/Pages/RoomDetailsPage.axaml.cs @@ -227,7 +227,7 @@ private static OperationResult NormalizeFriendCode(string friendCode) return formatted; } - private void RoomsDetailPage_Unloaded(object sender, RoutedEventArgs e) + private void RoomsDetailPage_Unloaded(object? sender, RoutedEventArgs e) { RRLiveRooms.Instance.Unsubscribe(this); } @@ -241,7 +241,7 @@ private void PlayerView_SelectionChanged(object? sender, SelectionChangedEventAr #region PropertyChanged - public event PropertyChangedEventHandler? PropertyChanged; + public new event PropertyChangedEventHandler? PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { diff --git a/WheelWizard/Views/Pages/RoomsPage.axaml.cs b/WheelWizard/Views/Pages/RoomsPage.axaml.cs index ea311f1d..c0bd52e5 100644 --- a/WheelWizard/Views/Pages/RoomsPage.axaml.cs +++ b/WheelWizard/Views/Pages/RoomsPage.axaml.cs @@ -74,12 +74,13 @@ private void PerformSearch(string? query) if (isStringEmpty) return; + var safeQuery = query ?? string.Empty; Players.Clear(); var matchingPlayers = Rooms .SelectMany(r => r.Players) .Where(p => - p.Name.Contains(query, StringComparison.OrdinalIgnoreCase) - || p.FriendCode.Contains(query, StringComparison.OrdinalIgnoreCase) + (p.Name?.Contains(safeQuery, StringComparison.OrdinalIgnoreCase) ?? false) + || (p.FriendCode?.Contains(safeQuery, StringComparison.OrdinalIgnoreCase) ?? false) ) .Distinct() .ToList(); @@ -90,7 +91,7 @@ private void PerformSearch(string? query) PlayerListItemCount.Text = matchingPlayers.Count.ToString(); } - private void RoomsPage_Unloaded(object sender, RoutedEventArgs e) + private void RoomsPage_Unloaded(object? sender, RoutedEventArgs e) { RRLiveRooms.Instance.Unsubscribe(this); } @@ -135,7 +136,7 @@ private void PlayerView_SelectionChanged(object? sender, SelectionChangedEventAr #region PropertyChanged - public event PropertyChangedEventHandler? PropertyChanged; + public new event PropertyChangedEventHandler? PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { diff --git a/WheelWizard/Views/Pages/Settings/VideoSettings.axaml.cs b/WheelWizard/Views/Pages/Settings/VideoSettings.axaml.cs index 37ed1df3..e5b918ec 100644 --- a/WheelWizard/Views/Pages/Settings/VideoSettings.axaml.cs +++ b/WheelWizard/Views/Pages/Settings/VideoSettings.axaml.cs @@ -49,7 +49,8 @@ private void LoadSettings() var finalResolution = SettingsService.Get(SettingsService.INTERNAL_RESOLUTION); foreach (RadioButton radioButton in ResolutionStackPanel.Children) { - radioButton.IsChecked = (radioButton.Tag.ToString() == finalResolution.ToString()); + var tag = radioButton.Tag?.ToString(); + radioButton.IsChecked = string.Equals(tag, finalResolution.ToString(), StringComparison.Ordinal); } } @@ -73,7 +74,8 @@ private void UpdateResolution(object? sender, RoutedEventArgs e) { if (sender is RadioButton radioButton && radioButton.IsChecked == true) { - SettingsService.Set(SettingsService.INTERNAL_RESOLUTION, int.Parse(radioButton.Tag.ToString()!)); + if (int.TryParse(radioButton.Tag?.ToString(), out var resolution)) + SettingsService.Set(SettingsService.INTERNAL_RESOLUTION, resolution); } } @@ -100,6 +102,9 @@ private void RemoveBlur_OnClick(object? sender, RoutedEventArgs e) private void RendererDropdown_OnSelectionChanged(object? sender, SelectionChangedEventArgs e) { var selectedDisplayName = RendererDropdown.SelectedItem?.ToString(); + if (string.IsNullOrWhiteSpace(selectedDisplayName)) + return; + if (SettingValues.GFXRenderers.TryGetValue(selectedDisplayName, out var actualValue)) { SettingsService.Set(SettingsService.GFX_BACKEND, actualValue); diff --git a/WheelWizard/Views/Pages/Settings/WhWzSettings.axaml.cs b/WheelWizard/Views/Pages/Settings/WhWzSettings.axaml.cs index b3a87ad4..5011d11a 100644 --- a/WheelWizard/Views/Pages/Settings/WhWzSettings.axaml.cs +++ b/WheelWizard/Views/Pages/Settings/WhWzSettings.axaml.cs @@ -297,9 +297,14 @@ private async void SaveButton_OnClick(object sender, RoutedEventArgs e) var oldPath2 = (string)SettingsService.GAME_LOCATION.Get(); var oldPath3 = (string)SettingsService.USER_FOLDER_PATH.Get(); - var path1 = SettingsService.DOLPHIN_LOCATION.Set(DolphinExeInput.Text); - var path2 = SettingsService.GAME_LOCATION.Set(MarioKartInput.Text); - var path3 = SettingsService.USER_FOLDER_PATH.Set(DolphinUserPathInput.Text.TrimEnd(Path.DirectorySeparatorChar)); + var dolphinPath = DolphinExeInput.Text ?? string.Empty; + var gamePath = MarioKartInput.Text ?? string.Empty; + var userPathInput = DolphinUserPathInput.Text; + var userPath = string.IsNullOrWhiteSpace(userPathInput) ? string.Empty : userPathInput.TrimEnd(Path.DirectorySeparatorChar); + + var path1 = SettingsService.DOLPHIN_LOCATION.Set(dolphinPath); + var path2 = SettingsService.GAME_LOCATION.Set(gamePath); + var path3 = SettingsService.USER_FOLDER_PATH.Set(userPath); // These 3 lines is only saving the settings TogglePathSettings(false); if (!(SettingsService.PathsSetupCorrectly() && path1 && path2 && path3)) diff --git a/WheelWizard/Views/Pages/UserProfilePage.axaml.cs b/WheelWizard/Views/Pages/UserProfilePage.axaml.cs index ac6e1525..adc2fcf0 100644 --- a/WheelWizard/Views/Pages/UserProfilePage.axaml.cs +++ b/WheelWizard/Views/Pages/UserProfilePage.axaml.cs @@ -255,7 +255,7 @@ private void SetUserAsPrimary() ViewUtils.ShowSnackbar(Phrases.SnackbarSuccess_ProfileSetPrimary); } - private void RegionDropdown_SelectionChanged(object sender, SelectionChangedEventArgs e) + private void RegionDropdown_SelectionChanged(object? sender, SelectionChangedEventArgs e) { if (RegionDropdown.SelectedItem is not ComboBoxItem { Tag: MarioKartWiiEnums.Regions region }) return; @@ -356,7 +356,7 @@ private void CopyFriendCode_OnClick(object? sender, EventArgs e) // But we as team wheel wizard don't think it makes sense to have a mii name shorter than 3, and so from the UI we don't allow it private OperationResult ValidateMiiName(string? oldName, string newName) { - newName = newName?.Trim(); + newName = (newName ?? string.Empty).Trim(); if (newName.Length is > 10 or < 3) return Fail(Phrases.HelperNote_NameMustBetween); @@ -366,9 +366,10 @@ private OperationResult ValidateMiiName(string? oldName, string newName) private async void RenameMii_OnClick(object? sender, EventArgs e) { var oldName = CurrentMii?.Name.ToString(); + var extraText = Humanizer.ReplaceDynamic(Phrases.Question_EnterNewName_Extra, oldName ?? string.Empty) ?? string.Empty; var renamePopup = new TextInputWindow() .SetMainText(Phrases.Question_EnterNewName_Title) - .SetExtraText(Humanizer.ReplaceDynamic(Phrases.Question_EnterNewName_Extra, oldName)) + .SetExtraText(extraText) .SetAllowCustomChars(true) .SetValidation(ValidateMiiName) .SetInitialText(oldName ?? "") @@ -436,7 +437,7 @@ private void UpdateOnlineBorders() #region PropertyChanged - public event PropertyChangedEventHandler? PropertyChanged; + public new event PropertyChangedEventHandler? PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { diff --git a/WheelWizard/Views/Patterns/FriendsListItem.axaml.cs b/WheelWizard/Views/Patterns/FriendsListItem.axaml.cs index 0926fc73..ff06066b 100644 --- a/WheelWizard/Views/Patterns/FriendsListItem.axaml.cs +++ b/WheelWizard/Views/Patterns/FriendsListItem.axaml.cs @@ -115,7 +115,7 @@ public Action? ViewRoomAction public void ViewRoom(object? sender, RoutedEventArgs e) { - ViewRoomAction.Invoke(FriendCode); + ViewRoomAction?.Invoke(FriendCode); } protected override void OnApplyTemplate(TemplateAppliedEventArgs e) diff --git a/WheelWizard/Views/Patterns/MiiBlock.axaml.cs b/WheelWizard/Views/Patterns/MiiBlock.axaml.cs index c55f1c76..8d945570 100644 --- a/WheelWizard/Views/Patterns/MiiBlock.axaml.cs +++ b/WheelWizard/Views/Patterns/MiiBlock.axaml.cs @@ -13,7 +13,6 @@ namespace WheelWizard.Views.Patterns; public class MiiBlock : RadioButton { - private static ContextMenu? s_oldMenu; private MiiImageLoaderWithHover? _miiImageLoader; public static readonly StyledProperty MiiProperty = AvaloniaProperty.Register(nameof(Mii)); diff --git a/WheelWizard/Views/Patterns/VrHistoryGraph.axaml.cs b/WheelWizard/Views/Patterns/VrHistoryGraph.axaml.cs index f3e7c04a..cd1cdde8 100644 --- a/WheelWizard/Views/Patterns/VrHistoryGraph.axaml.cs +++ b/WheelWizard/Views/Patterns/VrHistoryGraph.axaml.cs @@ -531,7 +531,7 @@ private static bool IsMissingFriendCode(string friendCode) return digits.All(digit => digit == '0'); } - public event PropertyChangedEventHandler? PropertyChanged; + public new event PropertyChangedEventHandler? PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { diff --git a/WheelWizard/Views/Popups/Base/PopupWindow.axaml.cs b/WheelWizard/Views/Popups/Base/PopupWindow.axaml.cs index bed94f8d..988440e1 100644 --- a/WheelWizard/Views/Popups/Base/PopupWindow.axaml.cs +++ b/WheelWizard/Views/Popups/Base/PopupWindow.axaml.cs @@ -161,7 +161,7 @@ protected override void OnClosed(EventArgs e) #region PropertyChanged - public event PropertyChangedEventHandler? PropertyChanged; + public new event PropertyChangedEventHandler? PropertyChanged; protected void OnPropertyChanged(string propertyName) { diff --git a/WheelWizard/Views/Popups/Generic/OptionsWindow.axaml.cs b/WheelWizard/Views/Popups/Generic/OptionsWindow.axaml.cs index 412e14f6..3a5d41e6 100644 --- a/WheelWizard/Views/Popups/Generic/OptionsWindow.axaml.cs +++ b/WheelWizard/Views/Popups/Generic/OptionsWindow.axaml.cs @@ -10,7 +10,7 @@ namespace WheelWizard.Views.Popups.Generic; public partial class OptionsWindow : PopupContent { public string? Result { get; private set; } = null; - private TaskCompletionSource _tcs; + private TaskCompletionSource? _tcs; public OptionsWindow() : base(true, false, true, "Wheel Wizard") @@ -36,7 +36,7 @@ public OptionsWindow AddOption(Geometry icon, string title, Action onClick, bool { onClick.Invoke(); Result = title; - _tcs.TrySetResult(title); + _tcs?.TrySetResult(title); Close(); }; @@ -65,7 +65,7 @@ private void OptimizeColumns() protected override void BeforeClose() { // If you want to return something different, then to the TrySetResult before you close it - _tcs.TrySetResult(null); + _tcs?.TrySetResult(null); } public async Task AwaitAnswer() diff --git a/WheelWizard/Views/Popups/Generic/ProgressWindow.axaml.cs b/WheelWizard/Views/Popups/Generic/ProgressWindow.axaml.cs index 6dcd49dd..6c980155 100644 --- a/WheelWizard/Views/Popups/Generic/ProgressWindow.axaml.cs +++ b/WheelWizard/Views/Popups/Generic/ProgressWindow.axaml.cs @@ -41,7 +41,7 @@ protected override void BeforeClose() _updateTimer.Stop(); } - private void UpdateTimer_Tick(object sender, EventArgs e) + private void UpdateTimer_Tick(object? sender, EventArgs e) { InternalUpdate(); } diff --git a/WheelWizard/Views/Popups/Generic/TextInputWindow.axaml.cs b/WheelWizard/Views/Popups/Generic/TextInputWindow.axaml.cs index d35898ba..599ad4a1 100644 --- a/WheelWizard/Views/Popups/Generic/TextInputWindow.axaml.cs +++ b/WheelWizard/Views/Popups/Generic/TextInputWindow.axaml.cs @@ -116,7 +116,7 @@ private void SetupCustomChars() } // Handle text changes to enable/disable Submit button - private void InputField_TextChanged(object sender, TextChangedEventArgs e) + private void InputField_TextChanged(object? sender, TextChangedEventArgs e) { UpdateSubmitButtonState(); } diff --git a/WheelWizard/Views/Popups/Generic/YesNoWindow.axaml.cs b/WheelWizard/Views/Popups/Generic/YesNoWindow.axaml.cs index 3b5f3739..7447aeb7 100644 --- a/WheelWizard/Views/Popups/Generic/YesNoWindow.axaml.cs +++ b/WheelWizard/Views/Popups/Generic/YesNoWindow.axaml.cs @@ -9,7 +9,7 @@ namespace WheelWizard.Views.Popups.Generic; public partial class YesNoWindow : PopupContent { public bool Result { get; private set; } = false; - private TaskCompletionSource _tcs; + private TaskCompletionSource? _tcs; public YesNoWindow() : base(true, false, true, "Wheel Wizard") @@ -45,7 +45,7 @@ public YesNoWindow SetButtonText(string yesText, string noText) private void yesButton_Click(object sender, RoutedEventArgs e) { Result = true; - _tcs.TrySetResult(true); // Signal that the task is complete + _tcs?.TrySetResult(true); // Signal that the task is complete Close(); } @@ -54,7 +54,7 @@ private void yesButton_Click(object sender, RoutedEventArgs e) protected override void BeforeClose() { // If you want to return something different, then to the TrySetResult before you close it - _tcs.TrySetResult(false); + _tcs?.TrySetResult(false); } public async Task AwaitAnswer() diff --git a/WheelWizard/Views/Popups/MiiManagement/MiiEditor/EditorGeneral.axaml.cs b/WheelWizard/Views/Popups/MiiManagement/MiiEditor/EditorGeneral.axaml.cs index 6fa7a230..8a1192f8 100644 --- a/WheelWizard/Views/Popups/MiiManagement/MiiEditor/EditorGeneral.axaml.cs +++ b/WheelWizard/Views/Popups/MiiManagement/MiiEditor/EditorGeneral.axaml.cs @@ -158,10 +158,10 @@ private async void ComplexName_OnClick(object? sender, RoutedEventArgs e) { var textPopup = new TextInputWindow() .SetMainText(Phrases.Question_EnterNewName_Title) - .SetExtraText(Humanizer.ReplaceDynamic(Phrases.Question_EnterNewName_Extra, MiiName.Text)) + .SetExtraText(Humanizer.ReplaceDynamic(Phrases.Question_EnterNewName_Extra, MiiName.Text ?? string.Empty) ?? string.Empty) .SetAllowCustomChars(true, true) .SetValidation(ValidateMiiName) - .SetInitialText(MiiName.Text) + .SetInitialText(MiiName.Text ?? string.Empty) .SetPlaceholderText(Phrases.Placeholder_EnterMiiName); var newName = await textPopup.ShowDialog(); diff --git a/WheelWizard/Views/Popups/MiiManagement/MiiEditorWindow.axaml.cs b/WheelWizard/Views/Popups/MiiManagement/MiiEditorWindow.axaml.cs index 586d6170..52169eb9 100644 --- a/WheelWizard/Views/Popups/MiiManagement/MiiEditorWindow.axaml.cs +++ b/WheelWizard/Views/Popups/MiiManagement/MiiEditorWindow.axaml.cs @@ -16,9 +16,9 @@ public partial class MiiEditorWindow : PopupContent, INotifyPropertyChanged { // whether you want to save the Mii public bool Result { get; private set; } = false; - private TaskCompletionSource _tcs; + private TaskCompletionSource? _tcs; - private Mii _mii; + private Mii _mii = null!; public Mii Mii { get => _mii; @@ -71,14 +71,14 @@ public MiiEditorWindow SetMii(Mii miiToEdit) public void SignalSaveMii() { Result = true; - _tcs.TrySetResult(true); + _tcs?.TrySetResult(true); Close(); } protected override void BeforeClose() { // If you want to return something different, then to the TrySetResult before you close it - _tcs.TrySetResult(false); + _tcs?.TrySetResult(false); } public async Task AwaitAnswer() diff --git a/WheelWizard/Views/Popups/MiiManagement/MiiSelectorWindow.axaml.cs b/WheelWizard/Views/Popups/MiiManagement/MiiSelectorWindow.axaml.cs index d6fb21d1..4a5f9218 100644 --- a/WheelWizard/Views/Popups/MiiManagement/MiiSelectorWindow.axaml.cs +++ b/WheelWizard/Views/Popups/MiiManagement/MiiSelectorWindow.axaml.cs @@ -13,7 +13,7 @@ namespace WheelWizard.Views.Popups.MiiManagement; public partial class MiiSelectorWindow : PopupContent { public Mii? Result { get; private set; } = null; - private TaskCompletionSource _tcs; + private TaskCompletionSource? _tcs; public MiiSelectorWindow() : base(true, false, false, Common.PopupTitle_MiiSelector) @@ -64,7 +64,7 @@ private void ChangeMii_Click(object? sender, RoutedEventArgs e) private void yesButton_Click(object sender, RoutedEventArgs e) { Result = MiiList.Children.OfType().FirstOrDefault(block => block.IsChecked == true)?.Mii; - _tcs.TrySetResult(Result); // Signal that the task is complete + _tcs?.TrySetResult(Result); // Signal that the task is complete Close(); } @@ -73,7 +73,7 @@ private void yesButton_Click(object sender, RoutedEventArgs e) protected override void BeforeClose() { // If you want to return something different, then to the TrySetResult before you close it - _tcs.TrySetResult(null); + _tcs?.TrySetResult(null); } public async Task AwaitAnswer() diff --git a/WheelWizard/Views/Popups/ModManagement/ModBrowserWindow.axaml.cs b/WheelWizard/Views/Popups/ModManagement/ModBrowserWindow.axaml.cs index 4e96220c..fd05f524 100644 --- a/WheelWizard/Views/Popups/ModManagement/ModBrowserWindow.axaml.cs +++ b/WheelWizard/Views/Popups/ModManagement/ModBrowserWindow.axaml.cs @@ -135,7 +135,7 @@ private async void Search_Click(object? sender, RoutedEventArgs e) _currentPage = 1; _hasMoreMods = true; - Dispatcher.UIThread.InvokeAsync(Mods.Clear); + await Dispatcher.UIThread.InvokeAsync(Mods.Clear); await LoadMods(_currentPage, _currentSearchTerm); } diff --git a/WheelWizard/Views/Popups/ModManagement/ModContent.axaml.cs b/WheelWizard/Views/Popups/ModManagement/ModContent.axaml.cs index 44538e30..d0492f36 100644 --- a/WheelWizard/Views/Popups/ModManagement/ModContent.axaml.cs +++ b/WheelWizard/Views/Popups/ModManagement/ModContent.axaml.cs @@ -16,7 +16,6 @@ public record ModItem(Bitmap FullImageUrl); public partial class ModContent : UserControlBase { - private bool loading; private bool loadingVisual; private GameBananaModDetails? CurrentMod { get; set; } private string? OverrideDownloadUrl { get; set; } @@ -71,7 +70,6 @@ public async Task LoadModDetailsAsync(int ModId, string? newDownloadUrl = return false; // Set the UI to show loading state loadingVisual = true; - loading = true; ResetVisibility(); // Retrieve the mod details. @@ -88,7 +86,6 @@ public async Task LoadModDetailsAsync(int ModId, string? newDownloadUrl = NoDetailsView.Title = Phrases.MessageError_FailedRetrieveMod_Title; NoDetailsView.BodyText = modDetailsResult.Error.Message; - loading = false; loadingVisual = false; ResetVisibility(); return false; @@ -115,7 +112,6 @@ public async Task LoadModDetailsAsync(int ModId, string? newDownloadUrl = // If there are no images to load, finish up early if (CurrentMod.PreviewMedia?.Images == null || !CurrentMod.PreviewMedia.Images.Any()) { - loading = false; loadingVisual = false; ResetVisibility(); return true; @@ -154,7 +150,6 @@ public async Task LoadModDetailsAsync(int ModId, string? newDownloadUrl = } // Reset the loading state once all operations have completed - loading = false; loadingVisual = false; ResetVisibility(); diff --git a/WheelWizard/Views/Popups/PlayerProfileWindow.axaml.cs b/WheelWizard/Views/Popups/PlayerProfileWindow.axaml.cs index a2acb218..f24e47a0 100644 --- a/WheelWizard/Views/Popups/PlayerProfileWindow.axaml.cs +++ b/WheelWizard/Views/Popups/PlayerProfileWindow.axaml.cs @@ -140,7 +140,7 @@ private static string FormatSignedValue(int value) return value.ToString("N0"); } - public event PropertyChangedEventHandler? PropertyChanged; + public new event PropertyChangedEventHandler? PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { diff --git a/WheelWizard/WheelWizard.csproj b/WheelWizard/WheelWizard.csproj index 35575db0..35e4c3ca 100644 --- a/WheelWizard/WheelWizard.csproj +++ b/WheelWizard/WheelWizard.csproj @@ -9,6 +9,7 @@ true true + $(NoWarn);AVLN3001 2.4.1