Skip to content

Commit c6acba9

Browse files
committed
No more warnings
1 parent f58dc3c commit c6acba9

35 files changed

Lines changed: 97 additions & 101 deletions

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ indent_size = 2
1212
[*.cs]
1313
max_line_length = 140
1414

15+
# Transitional analyzer levels while legacy filesystem/settings migration is in progress.
16+
dotnet_diagnostic.CS0618.severity = suggestion
17+
dotnet_diagnostic.IO0002.severity = suggestion
18+
dotnet_diagnostic.IO0003.severity = suggestion
19+
dotnet_diagnostic.IO0004.severity = suggestion
20+
dotnet_diagnostic.IO0005.severity = suggestion
21+
dotnet_diagnostic.IO0006.severity = suggestion
22+
dotnet_diagnostic.IO0007.severity = suggestion
23+
1524
#### Core EditorConfig Options ####
1625

1726
# Indentation and spacing

WheelWizard.Test/Features/MiiDbServiceTests.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using NSubstitute.ExceptionExtensions;
2-
using Testably.Abstractions;
32
using WheelWizard.Shared;
43
using WheelWizard.WiiManagement.MiiManagement;
54
using WheelWizard.WiiManagement.MiiManagement.Domain.Mii;
@@ -9,16 +8,14 @@ namespace WheelWizard.Test.Features
98
public class MiiDbServiceTests
109
{
1110
private readonly IMiiRepositoryService _repositoryService;
12-
private readonly IRandomSystem _randomSystemService;
1311
private readonly MiiDbService _service;
1412

1513
// --- Test Setup ---
1614

1715
public MiiDbServiceTests()
1816
{
1917
_repositoryService = Substitute.For<IMiiRepositoryService>();
20-
_randomSystemService = Substitute.For<IRandomSystem>();
21-
_service = new(_repositoryService, _randomSystemService);
18+
_service = new(_repositoryService);
2219
}
2320

2421
// --- Helper Methods ---
@@ -188,7 +185,7 @@ public void GetAllMiis_ShouldSkipInvalidBlocks_AndReturnOnlyValidMiis()
188185
Assert.True(mii1Result.IsSuccess, "Setup Failed: Could not create valid Mii");
189186
var mii1Bytes = GetSerializedBytes(mii1Result.Value);
190187
var invalidBytesShort = new byte[10]; // Invalid length
191-
var invalidBytesNull = (byte[])null; // Null entry (if possible from repo)
188+
byte[]? invalidBytesNull = null; // Null entry (if possible from repo)
192189
// Simulate a block that's the right size but contains garbage data causing deserialization failure
193190
var potentiallyBadBytes = new byte[MiiSerializer.MiiBlockSize];
194191
_repositoryService.LoadAllBlocks().Returns([invalidBytesShort, mii1Bytes, potentiallyBadBytes, invalidBytesNull!]);

WheelWizard/Features/WiiManagement/GameLicense/Domain/LicenseProfile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ public class LicenseProfile : PlayerProfileBase
77
public required uint TotalRaceCount { get; set; }
88
public required uint TotalWinCount { get; set; }
99
public List<FriendProfile> Friends { get; set; } = [];
10-
public LicenseStatistics Statistics { get; set; }
10+
public LicenseStatistics Statistics { get; set; } = new();
1111
}

WheelWizard/Features/WiiManagement/MiiManagement/MiiDbService.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Testably.Abstractions;
2-
using WheelWizard.Shared.MessageTranslations;
1+
using WheelWizard.Shared.MessageTranslations;
32
using WheelWizard.WiiManagement.MiiManagement.Domain.Mii;
43

54
namespace WheelWizard.WiiManagement.MiiManagement;
@@ -55,7 +54,7 @@ public interface IMiiDbService
5554
bool Exists();
5655
}
5756

58-
public class MiiDbService(IMiiRepositoryService repository, IRandomSystem randomSystem) : IMiiDbService
57+
public class MiiDbService(IMiiRepositoryService repository) : IMiiDbService
5958
{
6059
public List<Mii> GetAllMiis()
6160
{

WheelWizard/Features/WiiManagement/MiiManagement/MiiRepositoryService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public interface IMiiRepositoryService
5454

5555
public class MiiRepositoryServiceService(IFileSystem fileSystem) : IMiiRepositoryService
5656
{
57-
private readonly IFileSystem _fileSystem;
5857
private const int MiiLength = 74;
5958
private const int MaxMiiSlots = 100;
6059
private const int CrcOffset = 0x1F1DE;

WheelWizard/Helpers/Humanizer.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ public static string HumanizeTimeSpan(TimeSpan timeSpan)
5555
}
5656

5757
return ReplaceDynamic(Phrases.Time_Seconds_x, timeSpan.Seconds)!;
58-
59-
// internal method to simplify the pluralization of words
60-
string P(int count) => Math.Abs(count) != 1 ? "s" : "";
6158
}
6259

6360
public static string HumanizeSeconds(int seconds) => HumanizeTimeSpan(TimeSpan.FromSeconds(seconds));

WheelWizard/Services/Installation/ModInstallation.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,11 @@ public static void ProcessFile(string file, string destinationDirectory, Progres
135135
});
136136

137137
// Normalize entry path by removing empty folder segments
138+
var entryKey = entry.Key ?? string.Empty;
138139
var sanitizedKey = string.Join(
139140
Path.DirectorySeparatorChar.ToString(),
140-
entry
141-
.Key.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)
141+
entryKey
142+
.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)
142143
.Where(segment => !string.IsNullOrWhiteSpace(segment))
143144
);
144145

@@ -176,7 +177,7 @@ public static void ProcessFile(string file, string destinationDirectory, Progres
176177
}
177178
}
178179

179-
private static IArchive OpenArchive(string filePath, string extension)
180+
private static IArchive? OpenArchive(string filePath, string extension)
180181
{
181182
try
182183
{
@@ -201,7 +202,7 @@ private static IArchive OpenArchive(string filePath, string extension)
201202
/// </summary>
202203
public static async Task InstallModFromFileAsync(string filePath, string givenModName, string author = "-1", int modID = -1)
203204
{
204-
ProgressWindow progressWindow = null;
205+
ProgressWindow? progressWindow = null;
205206
try
206207
{
207208
if (!File.Exists(filePath))

WheelWizard/Services/ModManager.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void RemoveMod(Mod mod)
101101
OnPropertyChanged(nameof(Mods));
102102
}
103103

104-
private void Mod_PropertyChanged(object sender, PropertyChangedEventArgs e)
104+
private void Mod_PropertyChanged(object? sender, PropertyChangedEventArgs e)
105105
{
106106
if (_isBatchUpdating)
107107
return;
@@ -161,7 +161,7 @@ private async Task CombineFilesIntoSingleModAsync(string[] filePaths)
161161
.SetPlaceholderText("Enter mod name...")
162162
.SetValidation(ValidateModName)
163163
.ShowDialog();
164-
if (!IsValidName(modName))
164+
if (string.IsNullOrWhiteSpace(modName) || !IsValidName(modName))
165165
return;
166166

167167
var tempZipPath = Path.Combine(Path.GetTempPath(), $"{modName}.zip");
@@ -230,7 +230,7 @@ public void ToggleAllMods(bool enable)
230230
// TODO: Use this validation method when refactoring the ModManager
231231
public OperationResult ValidateModName(string? oldName, string newName)
232232
{
233-
newName = newName?.Trim();
233+
newName = (newName ?? string.Empty).Trim();
234234
if (string.IsNullOrWhiteSpace(newName))
235235
return Fail("Mod name cannot be empty.");
236236

@@ -423,7 +423,7 @@ private void ErrorOccurred(string? errorMessage)
423423
new MessageBoxWindow()
424424
.SetMessageType(MessageBoxWindow.MessageType.Error)
425425
.SetTitleText("An error occurred")
426-
.SetInfoText(errorMessage)
426+
.SetInfoText(errorMessage ?? "An unknown error occurred.")
427427
.Show();
428428
}
429429

WheelWizard/Services/Storage/FilePickerHelper.cs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public static async Task<List<string>> OpenFilePickerAsync(
2525
var storageProvider = Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime;
2626
if (storageProvider == null)
2727
return [];
28+
if (storageProvider.MainWindow?.StorageProvider == null)
29+
return [];
2830

2931
var options = new FilePickerOpenOptions
3032
{
@@ -71,37 +73,15 @@ public static async Task<List<string>> OpenFilePickerAsync(
7173
return null;
7274
}
7375

74-
public static async Task<List<string>> OpenMultipleFilesAsync(string title, IEnumerable<FilePickerFileType> fileTypes)
75-
{
76-
var storageProvider = Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime;
77-
if (storageProvider == null)
78-
return null;
79-
80-
var topLevel = TopLevel.GetTopLevel(storageProvider.MainWindow);
81-
if (topLevel?.StorageProvider == null)
82-
return [];
83-
84-
var files = await topLevel.StorageProvider.OpenFilePickerAsync(
85-
new()
86-
{
87-
Title = title,
88-
AllowMultiple = true,
89-
FileTypeFilter = fileTypes.ToList(),
90-
}
91-
);
92-
93-
return files?.Select(TryResolveLocalPath).Where(path => !string.IsNullOrWhiteSpace(path)).Select(path => path!).ToList() ?? [];
94-
}
95-
9676
public static async Task<IReadOnlyList<IStorageFolder?>> SelectFolderAsync(string title, IStorageFolder? suggestedStartLocation = null)
9777
{
9878
var storageProvider = Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime;
9979
if (storageProvider == null)
100-
return null;
80+
return [];
10181

10282
var topLevel = TopLevel.GetTopLevel(storageProvider.MainWindow);
10383
if (topLevel?.StorageProvider == null)
104-
return null;
84+
return [];
10585

10686
var folders = await topLevel.StorageProvider.OpenFolderPickerAsync(
10787
new()

WheelWizard/Utilities/Mockers/MockingDataFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public abstract class MockingDataFactory<T, U>
88
public static U Instance { get; } = new();
99
public abstract T Create(int? seed = null);
1010

11-
protected virtual string DictionaryKeyGenerator(T value) => value.ToString();
11+
protected virtual string DictionaryKeyGenerator(T value) => value is null ? string.Empty : value.ToString() ?? string.Empty;
1212

1313
public T[] CreateMultiple(int count = 5, int? seed = null)
1414
{

0 commit comments

Comments
 (0)