From 89ca1376e499c43372d1120d17361207ed25aee7 Mon Sep 17 00:00:00 2001
From: fgsfds <4870330+fgsfds@users.noreply.github.com>
Date: Thu, 26 Sep 2024 08:57:32 +0500
Subject: [PATCH] added configureawait, sealed, cleanup
---
Directory.Packages.props | 1 +
Web.Blazor/Components/AddonsList.razor | 6 +-
Web.Blazor/Pages/Error.cshtml.cs | 2 +-
Web.Blazor/Program.cs | 2 +-
Web.Blazor/Web.Blazor.csproj | 4 ++
src/Avalonia.Desktop/Avalonia.Desktop.csproj | 5 ++
.../Controls/MapsControl.axaml.cs | 14 ++--
.../ViewModels/AboutViewModel.cs | 4 +-
.../ViewModels/CampaignsViewModel.cs | 11 +--
.../ViewModels/DevViewModel.cs | 5 +-
.../ViewModels/MapsViewModel.cs | 11 +--
.../ViewModels/ModsViewModel.cs | 8 +--
.../ViewModels/PortViewModel.cs | 4 +-
.../ViewModels/RightPanelViewModel.cs | 2 -
.../ViewModels/ToolViewModel.cs | 8 +--
src/Common.Client/Common.Client.csproj | 11 +++
src/Common.Client/Config/ConfigProvider.cs | 68 ++++++++++---------
src/Common.Client/Providers/RatingProvider.cs | 2 +-
src/Common/Common.csproj | 4 ++
src/Common/Helpers/ImageHelper.cs | 3 +-
src/Database.Client/Database.Client.csproj | 8 +++
src/Database.Client/DatabaseContext.cs | 6 +-
src/Database.Client/DatabaseContextFactory.cs | 2 +-
.../Migrations/20240617165320_Initial.cs | 34 +++++-----
.../20240619080751_CreateRatingTable.cs | 14 ++--
.../DatabaseContextModelSnapshot.cs | 2 +-
src/Database.Server/Database.Server.csproj | 8 +++
src/Database.Server/DatabaseContextFactory.cs | 2 +-
src/Games/Games.csproj | 4 ++
src/Games/Games/BaseGame.cs | 11 +--
src/Mods/FilesUploader.cs | 10 +--
src/Mods/Mods.csproj | 4 ++
.../Providers/DownloadableAddonsProvider.cs | 4 +-
src/Mods/Providers/InstalledAddonsProvider.cs | 18 ++---
src/Mods/Serializable/JsonConverters.cs | 6 ++
src/Ports/Installer/PortsInstaller.cs | 2 +-
src/Ports/Installer/PortsReleasesProvider.cs | 4 +-
src/Ports/Ports.csproj | 4 ++
src/Ports/Ports/EDuke32/EDuke32.cs | 36 +++++-----
src/Ports/Ports/EDuke32/RedNukem.cs | 24 +++----
src/Ports/Ports/Raze.cs | 8 +--
.../CmdArguments/BloodCmdArgumentsTests.cs | 2 +-
.../CmdArguments/DukeCmdArgumentsTests.cs | 2 +-
.../CmdArguments/FuryCmdArgumentsTests.cs | 2 +-
.../CmdArguments/RedneckCmdArgumentsTests.cs | 2 +-
.../CmdArguments/SlaveCmdArgumentsTests.cs | 2 +-
.../CmdArguments/WangCmdArgumentsTests.cs | 2 +-
src/Tests/SerializeTest.cs | 6 +-
src/Tests/Tests.csproj | 8 +++
src/Tests/VersionCompareTests.cs | 2 +-
src/Tools/Installer/ToolsInstaller.cs | 2 +-
src/Tools/Tools.csproj | 4 ++
52 files changed, 248 insertions(+), 172 deletions(-)
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 1410e9b4..e6a9eab2 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -22,6 +22,7 @@
+
diff --git a/Web.Blazor/Components/AddonsList.razor b/Web.Blazor/Components/AddonsList.razor
index 9677500f..2003e942 100644
--- a/Web.Blazor/Components/AddonsList.razor
+++ b/Web.Blazor/Components/AddonsList.razor
@@ -33,7 +33,7 @@ else
}
-
@((MarkupString)@Markdown.ToHtml(addon.Description))
+ @((MarkupString)@Markdown.ToHtml(addon.Description ?? string.Empty))
Download
@@ -44,7 +44,7 @@ else
{
@addon.Title
- @((MarkupString)@Markdown.ToHtml(addon.Description))
+ @((MarkupString)@Markdown.ToHtml(addon.Description ?? string.Empty))
Download
@@ -55,7 +55,7 @@ else
{
@addon.Title
- @((MarkupString)@Markdown.ToHtml(addon.Description))
+ @((MarkupString)@Markdown.ToHtml(addon.Description ?? string.Empty))
Download
diff --git a/Web.Blazor/Pages/Error.cshtml.cs b/Web.Blazor/Pages/Error.cshtml.cs
index ee40e7c2..4c3edad3 100644
--- a/Web.Blazor/Pages/Error.cshtml.cs
+++ b/Web.Blazor/Pages/Error.cshtml.cs
@@ -6,7 +6,7 @@ namespace Web.Blazor.Pages;
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
-public class ErrorModel : PageModel
+public sealed class ErrorModel : PageModel
{
public string? RequestId { get; set; }
diff --git a/Web.Blazor/Program.cs b/Web.Blazor/Program.cs
index 78b2524a..71e9e803 100644
--- a/Web.Blazor/Program.cs
+++ b/Web.Blazor/Program.cs
@@ -6,7 +6,7 @@
namespace Web.Blazor;
-public class Program
+public sealed class Program
{
public static void Main(string[] args)
{
diff --git a/Web.Blazor/Web.Blazor.csproj b/Web.Blazor/Web.Blazor.csproj
index ed8217e0..a9d1fd22 100644
--- a/Web.Blazor/Web.Blazor.csproj
+++ b/Web.Blazor/Web.Blazor.csproj
@@ -9,6 +9,10 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/src/Avalonia.Desktop/Avalonia.Desktop.csproj b/src/Avalonia.Desktop/Avalonia.Desktop.csproj
index 42df7098..2d2c7218 100644
--- a/src/Avalonia.Desktop/Avalonia.Desktop.csproj
+++ b/src/Avalonia.Desktop/Avalonia.Desktop.csproj
@@ -46,12 +46,17 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
diff --git a/src/Avalonia.Desktop/Controls/MapsControl.axaml.cs b/src/Avalonia.Desktop/Controls/MapsControl.axaml.cs
index b33d46a7..b320be28 100644
--- a/src/Avalonia.Desktop/Controls/MapsControl.axaml.cs
+++ b/src/Avalonia.Desktop/Controls/MapsControl.axaml.cs
@@ -59,7 +59,7 @@ private void CreateSkillsFlyout()
foreach (var skill in skills)
{
- flyout.Items.Add(skill);
+ _ = flyout.Items.Add(skill);
}
_flyout = flyout;
@@ -176,7 +176,7 @@ private void AddContextMenuButtons()
foreach (var skill in skills)
{
- portButton.Items.Add(skill);
+ _ = portButton.Items.Add(skill);
}
}
else
@@ -188,12 +188,12 @@ private void AddContextMenuButtons()
};
}
- MapsList.ContextMenu.Items.Add(portButton);
+ _ = MapsList.ContextMenu.Items.Add(portButton);
}
if (MapsList.ContextMenu.Items.Count > 0)
{
- MapsList.ContextMenu.Items.Add(new Separator());
+ _ = MapsList.ContextMenu.Items.Add(new Separator());
}
var deleteButton = new MenuItem()
@@ -205,7 +205,7 @@ private void AddContextMenuButtons()
)
};
- MapsList.ContextMenu.Items.Add(deleteButton);
+ _ = MapsList.ContextMenu.Items.Add(deleteButton);
}
@@ -264,7 +264,7 @@ private BasePort GetPort(BasePort? port)
{
if (_flyout?.Target is not null)
{
- return ((Button)_flyout.Target!).CommandParameter as BasePort;
+ return ((Button)_flyout.Target!).CommandParameter as BasePort ?? ThrowHelper.Exception();
}
else if (port is not null)
{
@@ -325,7 +325,7 @@ private void OnListBoxEmptySpaceClicked(object? sender, Input.PointerPressedEven
{
MapsList.SelectedItem = null;
MapsList.Focusable = true;
- MapsList.Focus();
+ _ = MapsList.Focus();
MapsList.Focusable = false;
}
diff --git a/src/Avalonia.Desktop/ViewModels/AboutViewModel.cs b/src/Avalonia.Desktop/ViewModels/AboutViewModel.cs
index 216d2931..f693ff4e 100644
--- a/src/Avalonia.Desktop/ViewModels/AboutViewModel.cs
+++ b/src/Avalonia.Desktop/ViewModels/AboutViewModel.cs
@@ -47,7 +47,7 @@ public sealed partial class AboutViewModel(AppUpdateInstaller updateInstaller) :
[RelayCommand(CanExecute = (nameof(CheckForUpdatesCanExecute)))]
private async Task CheckForUpdatesAsync()
{
- await CheckForUpdateAsync();
+ await CheckForUpdateAsync().ConfigureAwait(true);
}
private bool CheckForUpdatesCanExecute() => IsInProgress is false;
@@ -91,7 +91,7 @@ private async Task CheckForUpdateAsync()
try
{
CheckForUpdatesButtonText = "Checking...";
- updates = await _updateInstaller.CheckForUpdates(CurrentVersion);
+ updates = await _updateInstaller.CheckForUpdates(CurrentVersion).ConfigureAwait(true);
}
catch
{
diff --git a/src/Avalonia.Desktop/ViewModels/CampaignsViewModel.cs b/src/Avalonia.Desktop/ViewModels/CampaignsViewModel.cs
index 8fbe1fe4..bb8aa6f3 100644
--- a/src/Avalonia.Desktop/ViewModels/CampaignsViewModel.cs
+++ b/src/Avalonia.Desktop/ViewModels/CampaignsViewModel.cs
@@ -113,7 +113,7 @@ public override IAddon? SelectedAddon
///
private async Task UpdateAsync(bool createNew)
{
- await _installedAddonsProvider.CreateCache(createNew);
+ await _installedAddonsProvider.CreateCache(createNew).ConfigureAwait(true);
OnPropertyChanged(nameof(CampaignsList));
}
@@ -135,7 +135,7 @@ private async Task StartCampaignAsync(object? command)
var args = port.GetStartGameArgs(Game, SelectedAddon, mods, _config.SkipIntro, _config.SkipStartup);
- await StartPortAsync(SelectedAddon.Id, port.FullPathToExe, args);
+ await StartPortAsync(SelectedAddon.Id, port.FullPathToExe, args).ConfigureAwait(true);
}
@@ -145,7 +145,7 @@ private async Task StartCampaignAsync(object? command)
[RelayCommand]
private void OpenFolder()
{
- Process.Start(new ProcessStartInfo
+ _ = Process.Start(new ProcessStartInfo
{
FileName = Game.CampaignsFolderPath,
UseShellExecute = true,
@@ -159,7 +159,7 @@ private void OpenFolder()
[RelayCommand]
private async Task RefreshListAsync()
{
- await UpdateAsync(true);
+ await UpdateAsync(true).ConfigureAwait(true);
}
@@ -190,6 +190,7 @@ private void DeleteCampaign()
///
/// Start port with command line args
///
+ /// Campaign id
/// Path to port exe
/// Command line arguments
private async Task StartPortAsync(string id, string exe, string args)
@@ -202,7 +203,7 @@ await Process.Start(new ProcessStartInfo
UseShellExecute = true,
Arguments = args,
WorkingDirectory = Path.GetDirectoryName(exe)
- })!.WaitForExitAsync();
+ })!.WaitForExitAsync().ConfigureAwait(true);
sw.Stop();
var time = sw.Elapsed;
diff --git a/src/Avalonia.Desktop/ViewModels/DevViewModel.cs b/src/Avalonia.Desktop/ViewModels/DevViewModel.cs
index 401c3a2c..bd41b9ae 100644
--- a/src/Avalonia.Desktop/ViewModels/DevViewModel.cs
+++ b/src/Avalonia.Desktop/ViewModels/DevViewModel.cs
@@ -15,7 +15,6 @@
using SharpCompress.Archives;
using SharpCompress.Archives.Zip;
using SharpCompress.Common;
-using System;
using System.Collections.Immutable;
using System.Text;
using System.Text.Json;
@@ -364,7 +363,7 @@ private async Task AddAddonAsync()
return;
}
- var result = await _filesUploader.AddAddonToDatabaseAsync(files[0].Path.LocalPath);
+ var result = await _filesUploader.AddAddonToDatabaseAsync(files[0].Path.LocalPath).ConfigureAwait(true);
if (result)
{
@@ -800,7 +799,7 @@ private async Task UploadAddonAsync()
return;
}
- var uploadResult = await _filesUploader.UploadFilesToFtpAsync(files[0].Path.LocalPath, CancellationToken.None);
+ var uploadResult = await _filesUploader.UploadFilesToFtpAsync(files[0].Path.LocalPath, CancellationToken.None).ConfigureAwait(true);
if (uploadResult)
{
diff --git a/src/Avalonia.Desktop/ViewModels/MapsViewModel.cs b/src/Avalonia.Desktop/ViewModels/MapsViewModel.cs
index d9de072e..2e964aa3 100644
--- a/src/Avalonia.Desktop/ViewModels/MapsViewModel.cs
+++ b/src/Avalonia.Desktop/ViewModels/MapsViewModel.cs
@@ -59,7 +59,7 @@ DownloadableAddonsProviderFactory _downloadableAddonsProviderFactory
///
private async Task UpdateAsync(bool createNew)
{
- await _installedAddonsProvider.CreateCache(createNew);
+ await _installedAddonsProvider.CreateCache(createNew).ConfigureAwait(true);
OnPropertyChanged(nameof(MapsList));
}
@@ -135,7 +135,7 @@ private async Task StartMapAsync(object? command)
var args = parameter.Item1.GetStartGameArgs(Game, SelectedAddon, mods, _config.SkipIntro, _config.SkipStartup, parameter.Item2);
- await StartPortAsync(SelectedAddon.Id, parameter.Item1.FullPathToExe, args);
+ await StartPortAsync(SelectedAddon.Id, parameter.Item1.FullPathToExe, args).ConfigureAwait(true);
}
@@ -145,7 +145,7 @@ private async Task StartMapAsync(object? command)
[RelayCommand]
private void OpenFolder()
{
- Process.Start(new ProcessStartInfo
+ _ = Process.Start(new ProcessStartInfo
{
FileName = Game.MapsFolderPath,
UseShellExecute = true,
@@ -159,7 +159,7 @@ private void OpenFolder()
[RelayCommand]
private async Task RefreshListAsync()
{
- await UpdateAsync(true);
+ await UpdateAsync(true).ConfigureAwait(true);
}
@@ -190,6 +190,7 @@ private void DeleteMap()
///
/// Start port with command line args
///
+ /// Map id
/// Path to port exe
/// Command line arguments
private async Task StartPortAsync(string id, string exe, string args)
@@ -202,7 +203,7 @@ await Process.Start(new ProcessStartInfo
UseShellExecute = true,
Arguments = args,
WorkingDirectory = Path.GetDirectoryName(exe)
- })!.WaitForExitAsync();
+ })!.WaitForExitAsync().ConfigureAwait(true);
sw.Stop();
var time = sw.Elapsed;
diff --git a/src/Avalonia.Desktop/ViewModels/ModsViewModel.cs b/src/Avalonia.Desktop/ViewModels/ModsViewModel.cs
index 1dd0147f..ea7b1e4a 100644
--- a/src/Avalonia.Desktop/ViewModels/ModsViewModel.cs
+++ b/src/Avalonia.Desktop/ViewModels/ModsViewModel.cs
@@ -1,5 +1,3 @@
-using Common.Client.API;
-using Common.Client.Config;
using Common.Client.Providers;
using Common.Enums;
using Common.Helpers;
@@ -54,7 +52,7 @@ DownloadableAddonsProviderFactory _downloadableAddonsProviderFactory
///
private async Task UpdateAsync(bool createNew)
{
- await _installedAddonsProvider.CreateCache(createNew);
+ await _installedAddonsProvider.CreateCache(createNew).ConfigureAwait(true);
OnPropertyChanged(nameof(ModsList));
}
@@ -98,7 +96,7 @@ public override IAddon? SelectedAddon
[RelayCommand]
private void OpenFolder()
{
- Process.Start(new ProcessStartInfo
+ _ = Process.Start(new ProcessStartInfo
{
FileName = Game.ModsFolderPath,
UseShellExecute = true,
@@ -112,7 +110,7 @@ private void OpenFolder()
[RelayCommand]
private async Task RefreshListAsync()
{
- await UpdateAsync(true);
+ await UpdateAsync(true).ConfigureAwait(true);
}
diff --git a/src/Avalonia.Desktop/ViewModels/PortViewModel.cs b/src/Avalonia.Desktop/ViewModels/PortViewModel.cs
index aec52c13..d771e151 100644
--- a/src/Avalonia.Desktop/ViewModels/PortViewModel.cs
+++ b/src/Avalonia.Desktop/ViewModels/PortViewModel.cs
@@ -140,7 +140,7 @@ out var newVersion
///
public async Task InitializeAsync()
{
- _release = await _portsReleasesProvider.GetLatestReleaseAsync(_port.PortEnum);
+ _release = await _portsReleasesProvider.GetLatestReleaseAsync(_port.PortEnum).ConfigureAwait(true);
OnPropertyChanged(nameof(LatestVersion));
OnPropertyChanged(nameof(InstallButtonText));
@@ -165,7 +165,7 @@ private async Task InstallAsync()
ProgressBarValue = 0;
OnPropertyChanged(nameof(ProgressBarValue));
- await installer.InstallAsync(_port);
+ await installer.InstallAsync(_port).ConfigureAwait(true);
installer.Progress.ProgressChanged -= OnProgressChanged;
ProgressBarValue = 0;
diff --git a/src/Avalonia.Desktop/ViewModels/RightPanelViewModel.cs b/src/Avalonia.Desktop/ViewModels/RightPanelViewModel.cs
index be5feabd..f7d24d43 100644
--- a/src/Avalonia.Desktop/ViewModels/RightPanelViewModel.cs
+++ b/src/Avalonia.Desktop/ViewModels/RightPanelViewModel.cs
@@ -1,5 +1,3 @@
-using Common.Client.API;
-using Common.Client.Config;
using Common.Client.Providers;
using Common.Enums;
using Common.Helpers;
diff --git a/src/Avalonia.Desktop/ViewModels/ToolViewModel.cs b/src/Avalonia.Desktop/ViewModels/ToolViewModel.cs
index 46c980f6..7bad6b68 100644
--- a/src/Avalonia.Desktop/ViewModels/ToolViewModel.cs
+++ b/src/Avalonia.Desktop/ViewModels/ToolViewModel.cs
@@ -111,7 +111,7 @@ public string InstallButtonText
///
public async Task InitializeAsync()
{
- _release = await _toolsReleasesProvider.GetLatestReleaseAsync(_tool);
+ _release = await _toolsReleasesProvider.GetLatestReleaseAsync(_tool).ConfigureAwait(true);
OnPropertyChanged(nameof(LatestVersion));
OnPropertyChanged(nameof(InstallButtonText));
@@ -130,7 +130,7 @@ private async Task InstallAsync()
ProgressBarValue = 0;
OnPropertyChanged(nameof(ProgressBarValue));
- await installer.InstallAsync(_tool);
+ await installer.InstallAsync(_tool).ConfigureAwait(true);
installer.Progress.ProgressChanged -= OnProgressChanged;
ProgressBarValue = 0;
@@ -151,7 +151,7 @@ private async Task CheckUpdateAsync()
{
IsInProgress = true;
- _release = await _toolsReleasesProvider.GetLatestReleaseAsync(_tool);
+ _release = await _toolsReleasesProvider.GetLatestReleaseAsync(_tool).ConfigureAwait(true);
OnPropertyChanged(nameof(LatestVersion));
OnPropertyChanged(nameof(InstallButtonText));
@@ -169,7 +169,7 @@ public void Start()
{
var args = _tool.GetStartToolArgs();
- Process.Start(new ProcessStartInfo
+ _ = Process.Start(new ProcessStartInfo
{
FileName = _tool.FullPathToExe,
UseShellExecute = true,
diff --git a/src/Common.Client/Common.Client.csproj b/src/Common.Client/Common.Client.csproj
index 2a623c94..3ca8f382 100644
--- a/src/Common.Client/Common.Client.csproj
+++ b/src/Common.Client/Common.Client.csproj
@@ -7,6 +7,17 @@
BuildLauncher.$(MSBuildProjectName)
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
diff --git a/src/Common.Client/Config/ConfigProvider.cs b/src/Common.Client/Config/ConfigProvider.cs
index 751f27fb..6451b8eb 100644
--- a/src/Common.Client/Config/ConfigProvider.cs
+++ b/src/Common.Client/Config/ConfigProvider.cs
@@ -66,14 +66,14 @@ public void AddScore(string addonId, byte rating)
if (existing is null)
{
- _dbContext.Rating.Add(new() { AddonId = addonId, Rating = rating });
+ _ = _dbContext.Rating.Add(new() { AddonId = addonId, Rating = rating });
}
else
{
existing.Rating = rating;
}
- _dbContext.SaveChanges();
+ _ = _dbContext.SaveChanges();
ParameterChangedEvent?.Invoke(nameof(Rating));
}
@@ -88,14 +88,14 @@ public void AddPlaytime(string addonId, TimeSpan playTime)
if (existing is null)
{
- _dbContext.Playtimes.Add(new() { AddonId = addonId, Playtime = playTime });
+ _ = _dbContext.Playtimes.Add(new() { AddonId = addonId, Playtime = playTime });
}
else
{
existing.Playtime += playTime;
}
- _dbContext.SaveChanges();
+ _ = _dbContext.SaveChanges();
ParameterChangedEvent?.Invoke(nameof(Playtimes));
}
@@ -116,14 +116,14 @@ public void ChangeModState(AddonVersion addonId, bool isEnabled)
}
else
{
- _dbContext.DisabledAddons.Add(new() { AddonId = addonId.Id });
+ _ = _dbContext.DisabledAddons.Add(new() { AddonId = addonId.Id });
}
}
else
{
if (isEnabled)
{
- _dbContext.DisabledAddons.Remove(existing);
+ _ = _dbContext.DisabledAddons.Remove(existing);
}
else
{
@@ -131,7 +131,7 @@ public void ChangeModState(AddonVersion addonId, bool isEnabled)
}
}
- _dbContext.SaveChanges();
+ _ = _dbContext.SaveChanges();
ParameterChangedEvent?.Invoke(nameof(DisabledAutoloadMods));
}
@@ -199,14 +199,14 @@ private void SetSettingsValue(string value, [CallerMemberName] string caller = "
if (setting is null)
{
- _dbContext.Settings.Add(new() { Name = caller, Value = value });
+ _ = _dbContext.Settings.Add(new() { Name = caller, Value = value });
}
else
{
setting.Value = value;
}
- _dbContext.SaveChanges();
+ _ = _dbContext.SaveChanges();
ParameterChangedEvent?.Invoke(caller);
}
@@ -221,14 +221,14 @@ private void SetGamePathValue(string? value, [CallerMemberName] string caller =
if (setting is null)
{
- _dbContext.GamePaths.Add(new() { Game = caller, Path = value });
+ _ = _dbContext.GamePaths.Add(new() { Game = caller, Path = value });
}
else
{
setting.Path = value;
}
- _dbContext.SaveChanges();
+ _ = _dbContext.SaveChanges();
ParameterChangedEvent?.Invoke(caller);
}
@@ -246,36 +246,42 @@ private void ConvertOldConfig()
FileStream fs = new(Consts.ConfigFile, FileMode.Open);
var config = JsonSerializer.Deserialize(fs, ConfigEntityContext.Default.ConfigEntityObsolete);
- _dbContext.Settings.Add(new() { Name = nameof(config.Theme), Value = config.Theme.ToString() });
- _dbContext.Settings.Add(new() { Name = nameof(config.SkipIntro), Value = config.SkipIntro.ToString() });
- _dbContext.Settings.Add(new() { Name = nameof(config.SkipStartup), Value = config.SkipStartup.ToString() });
+ if (config is null)
+ {
+ fs.Dispose();
+ return;
+ }
+
+ _ = _dbContext.Settings.Add(new() { Name = nameof(config.Theme), Value = config.Theme.ToString() });
+ _ = _dbContext.Settings.Add(new() { Name = nameof(config.SkipIntro), Value = config.SkipIntro.ToString() });
+ _ = _dbContext.Settings.Add(new() { Name = nameof(config.SkipStartup), Value = config.SkipStartup.ToString() });
- _dbContext.Settings.Add(new() { Name = nameof(config.UseLocalApi), Value = config.UseLocalApi.ToString() });
- _dbContext.Settings.Add(new() { Name = nameof(config.ApiPassword), Value = config.ApiPassword ?? string.Empty });
+ _ = _dbContext.Settings.Add(new() { Name = nameof(config.UseLocalApi), Value = config.UseLocalApi.ToString() });
+ _ = _dbContext.Settings.Add(new() { Name = nameof(config.ApiPassword), Value = config.ApiPassword ?? string.Empty });
foreach (var addon in config.DisabledAutoloadMods)
{
- _dbContext.DisabledAddons.Add(new() { AddonId = addon });
+ _ = _dbContext.DisabledAddons.Add(new() { AddonId = addon });
}
foreach (var addon in config.Playtimes)
{
- _dbContext.Playtimes.Add(new() { AddonId = addon.Key, Playtime = addon.Value });
+ _ = _dbContext.Playtimes.Add(new() { AddonId = addon.Key, Playtime = addon.Value });
}
- _dbContext.GamePaths.Add(new() { Game = "PathDuke3D", Path = config.GamePathDuke3D });
- _dbContext.GamePaths.Add(new() { Game = "PathDukeWT", Path = config.GamePathDukeWT });
- _dbContext.GamePaths.Add(new() { Game = "PathDuke64", Path = config.GamePathDuke64 });
- _dbContext.GamePaths.Add(new() { Game = "PathWang", Path = config.GamePathWang });
- _dbContext.GamePaths.Add(new() { Game = "PathBlood", Path = config.GamePathBlood });
- _dbContext.GamePaths.Add(new() { Game = "PathRedneck", Path = config.GamePathRedneck });
- _dbContext.GamePaths.Add(new() { Game = "PathRidesAgain", Path = config.GamePathAgain });
- _dbContext.GamePaths.Add(new() { Game = "PathSlave", Path = config.GamePathSlave });
- _dbContext.GamePaths.Add(new() { Game = "PathFury", Path = config.GamePathFury });
+ _ = _dbContext.GamePaths.Add(new() { Game = "PathDuke3D", Path = config.GamePathDuke3D });
+ _ = _dbContext.GamePaths.Add(new() { Game = "PathDukeWT", Path = config.GamePathDukeWT });
+ _ = _dbContext.GamePaths.Add(new() { Game = "PathDuke64", Path = config.GamePathDuke64 });
+ _ = _dbContext.GamePaths.Add(new() { Game = "PathWang", Path = config.GamePathWang });
+ _ = _dbContext.GamePaths.Add(new() { Game = "PathBlood", Path = config.GamePathBlood });
+ _ = _dbContext.GamePaths.Add(new() { Game = "PathRedneck", Path = config.GamePathRedneck });
+ _ = _dbContext.GamePaths.Add(new() { Game = "PathRidesAgain", Path = config.GamePathAgain });
+ _ = _dbContext.GamePaths.Add(new() { Game = "PathSlave", Path = config.GamePathSlave });
+ _ = _dbContext.GamePaths.Add(new() { Game = "PathFury", Path = config.GamePathFury });
- _dbContext.SaveChanges();
+ _ = _dbContext.SaveChanges();
fs.Dispose();
File.Delete(Path.Combine(ClientProperties.ExeFolderPath, Consts.ConfigFile));
@@ -291,10 +297,10 @@ private void FixTypo()
var game = nameof(PathRidesAgain);
var path = old.Path;
- _dbContext.GamePaths.Remove(old);
- _dbContext.GamePaths.Add(new() { Game = game, Path = path });
+ _ = _dbContext.GamePaths.Remove(old);
+ _ = _dbContext.GamePaths.Add(new() { Game = game, Path = path });
- _dbContext.SaveChanges();
+ _ = _dbContext.SaveChanges();
}
}
}
diff --git a/src/Common.Client/Providers/RatingProvider.cs b/src/Common.Client/Providers/RatingProvider.cs
index f1cd1d22..5e67cbf1 100644
--- a/src/Common.Client/Providers/RatingProvider.cs
+++ b/src/Common.Client/Providers/RatingProvider.cs
@@ -36,7 +36,7 @@ public RatingProvider(
private async Task CreateCacheAsync()
{
- var cache = await _apiInterface.GetScoresAsync();
+ var cache = await _apiInterface.GetScoresAsync().ConfigureAwait(false);
if (cache is null)
{
diff --git a/src/Common/Common.csproj b/src/Common/Common.csproj
index 7031ca24..fd69789e 100644
--- a/src/Common/Common.csproj
+++ b/src/Common/Common.csproj
@@ -10,6 +10,10 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/src/Common/Helpers/ImageHelper.cs b/src/Common/Helpers/ImageHelper.cs
index 936edbe5..a5f1a68e 100644
--- a/src/Common/Helpers/ImageHelper.cs
+++ b/src/Common/Helpers/ImageHelper.cs
@@ -9,7 +9,7 @@ public static class ImageHelper
/// Get Stream from file name
///
/// File name
- /// Assembly
+ /// Calling assembly
public static Stream FileNameToStream(string fileName, Assembly callingAss)
{
var assName = callingAss.GetName().Name!.Replace("BuildLauncher.", "");
@@ -31,6 +31,7 @@ public static Stream FileNameToStream(string fileName, Assembly callingAss)
/// Get grid cover from the archive
///
/// Archive
+ /// Name of the image
public static Stream? GetImageFromArchive(IArchive archive, string imageName)
{
var image = archive.Entries.FirstOrDefault(x => x.Key?.StartsWith(imageName) ?? false);
diff --git a/src/Database.Client/Database.Client.csproj b/src/Database.Client/Database.Client.csproj
index 39838777..4eb50d6b 100644
--- a/src/Database.Client/Database.Client.csproj
+++ b/src/Database.Client/Database.Client.csproj
@@ -8,6 +8,14 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/src/Database.Client/DatabaseContext.cs b/src/Database.Client/DatabaseContext.cs
index 1d936e07..c721e1e5 100644
--- a/src/Database.Client/DatabaseContext.cs
+++ b/src/Database.Client/DatabaseContext.cs
@@ -31,7 +31,7 @@ private void ConvertOldConfig()
var playtimes = Playtimes.ToList();
var paths = GamePaths.ToList();
- Database.EnsureDeleted();
+ _ = Database.EnsureDeleted();
Database.Migrate();
Settings.AddRange(settings);
@@ -39,11 +39,11 @@ private void ConvertOldConfig()
Playtimes.AddRange(playtimes);
GamePaths.AddRange(paths);
- SaveChanges();
+ _ = SaveChanges();
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
- optionsBuilder.UseSqlite("Data Source=config.db");
+ _ = optionsBuilder.UseSqlite("Data Source=config.db");
}
}
diff --git a/src/Database.Client/DatabaseContextFactory.cs b/src/Database.Client/DatabaseContextFactory.cs
index d35d585f..2da71e80 100644
--- a/src/Database.Client/DatabaseContextFactory.cs
+++ b/src/Database.Client/DatabaseContextFactory.cs
@@ -1,6 +1,6 @@
namespace Database.Client;
-public class DatabaseContextFactory
+public sealed class DatabaseContextFactory
{
public DatabaseContext Get() => new();
}
diff --git a/src/Database.Client/Migrations/20240617165320_Initial.cs b/src/Database.Client/Migrations/20240617165320_Initial.cs
index f8b90c61..cad6401d 100644
--- a/src/Database.Client/Migrations/20240617165320_Initial.cs
+++ b/src/Database.Client/Migrations/20240617165320_Initial.cs
@@ -5,15 +5,15 @@
namespace Database.Client.Migrations;
///
-public partial class Initial : Migration
+public sealed partial class Initial : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
- migrationBuilder.EnsureSchema(
+ _ = migrationBuilder.EnsureSchema(
name: "main");
- migrationBuilder.CreateTable(
+ _ = migrationBuilder.CreateTable(
name: "disabled_addons",
schema: "main",
columns: table => new
@@ -22,10 +22,10 @@ protected override void Up(MigrationBuilder migrationBuilder)
},
constraints: table =>
{
- table.PrimaryKey("PK_disabled_addons", x => x.addon_id);
+ _ = table.PrimaryKey("PK_disabled_addons", x => x.addon_id);
});
- migrationBuilder.CreateTable(
+ _ = migrationBuilder.CreateTable(
name: "game_paths",
schema: "main",
columns: table => new
@@ -35,10 +35,10 @@ protected override void Up(MigrationBuilder migrationBuilder)
},
constraints: table =>
{
- table.PrimaryKey("PK_game_paths", x => x.game);
+ _ = table.PrimaryKey("PK_game_paths", x => x.game);
});
- migrationBuilder.CreateTable(
+ _ = migrationBuilder.CreateTable(
name: "playtimes",
schema: "main",
columns: table => new
@@ -48,10 +48,10 @@ protected override void Up(MigrationBuilder migrationBuilder)
},
constraints: table =>
{
- table.PrimaryKey("PK_playtimes", x => x.addon_id);
+ _ = table.PrimaryKey("PK_playtimes", x => x.addon_id);
});
- migrationBuilder.CreateTable(
+ _ = migrationBuilder.CreateTable(
name: "scores",
schema: "main",
columns: table => new
@@ -61,10 +61,10 @@ protected override void Up(MigrationBuilder migrationBuilder)
},
constraints: table =>
{
- table.PrimaryKey("PK_scores", x => x.addon_id);
+ _ = table.PrimaryKey("PK_scores", x => x.addon_id);
});
- migrationBuilder.CreateTable(
+ _ = migrationBuilder.CreateTable(
name: "settings",
schema: "main",
columns: table => new
@@ -74,30 +74,30 @@ protected override void Up(MigrationBuilder migrationBuilder)
},
constraints: table =>
{
- table.PrimaryKey("PK_settings", x => x.name);
+ _ = table.PrimaryKey("PK_settings", x => x.name);
});
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
- migrationBuilder.DropTable(
+ _ = migrationBuilder.DropTable(
name: "disabled_addons",
schema: "main");
- migrationBuilder.DropTable(
+ _ = migrationBuilder.DropTable(
name: "game_paths",
schema: "main");
- migrationBuilder.DropTable(
+ _ = migrationBuilder.DropTable(
name: "playtimes",
schema: "main");
- migrationBuilder.DropTable(
+ _ = migrationBuilder.DropTable(
name: "scores",
schema: "main");
- migrationBuilder.DropTable(
+ _ = migrationBuilder.DropTable(
name: "settings",
schema: "main");
}
diff --git a/src/Database.Client/Migrations/20240619080751_CreateRatingTable.cs b/src/Database.Client/Migrations/20240619080751_CreateRatingTable.cs
index b5edf38f..67a33384 100644
--- a/src/Database.Client/Migrations/20240619080751_CreateRatingTable.cs
+++ b/src/Database.Client/Migrations/20240619080751_CreateRatingTable.cs
@@ -5,16 +5,16 @@
namespace Database.Client.Migrations;
///
-public partial class CreateRatingTable : Migration
+public sealed partial class CreateRatingTable : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
- migrationBuilder.DropTable(
+ _ = migrationBuilder.DropTable(
name: "scores",
schema: "main");
- migrationBuilder.CreateTable(
+ _ = migrationBuilder.CreateTable(
name: "rating",
schema: "main",
columns: table => new
@@ -24,18 +24,18 @@ protected override void Up(MigrationBuilder migrationBuilder)
},
constraints: table =>
{
- table.PrimaryKey("PK_rating", x => x.addon_id);
+ _ = table.PrimaryKey("PK_rating", x => x.addon_id);
});
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
- migrationBuilder.DropTable(
+ _ = migrationBuilder.DropTable(
name: "rating",
schema: "main");
- migrationBuilder.CreateTable(
+ _ = migrationBuilder.CreateTable(
name: "scores",
schema: "main",
columns: table => new
@@ -45,7 +45,7 @@ protected override void Down(MigrationBuilder migrationBuilder)
},
constraints: table =>
{
- table.PrimaryKey("PK_scores", x => x.addon_id);
+ _ = table.PrimaryKey("PK_scores", x => x.addon_id);
});
}
}
diff --git a/src/Database.Client/Migrations/DatabaseContextModelSnapshot.cs b/src/Database.Client/Migrations/DatabaseContextModelSnapshot.cs
index d682a8f6..a00b023a 100644
--- a/src/Database.Client/Migrations/DatabaseContextModelSnapshot.cs
+++ b/src/Database.Client/Migrations/DatabaseContextModelSnapshot.cs
@@ -7,7 +7,7 @@
namespace Database.Client.Migrations
{
[DbContext(typeof(DatabaseContext))]
- partial class DatabaseContextModelSnapshot : ModelSnapshot
+ sealed partial class DatabaseContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
diff --git a/src/Database.Server/Database.Server.csproj b/src/Database.Server/Database.Server.csproj
index c1b2252a..d21f2d6e 100644
--- a/src/Database.Server/Database.Server.csproj
+++ b/src/Database.Server/Database.Server.csproj
@@ -8,6 +8,14 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/src/Database.Server/DatabaseContextFactory.cs b/src/Database.Server/DatabaseContextFactory.cs
index 39cb30c2..a3661344 100644
--- a/src/Database.Server/DatabaseContextFactory.cs
+++ b/src/Database.Server/DatabaseContextFactory.cs
@@ -1,6 +1,6 @@
namespace Database.Server;
-public class DatabaseContextFactory
+public sealed class DatabaseContextFactory
{
private readonly bool _isDevMode;
diff --git a/src/Games/Games.csproj b/src/Games/Games.csproj
index 2223b80e..09036f66 100644
--- a/src/Games/Games.csproj
+++ b/src/Games/Games.csproj
@@ -33,6 +33,10 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/src/Games/Games/BaseGame.cs b/src/Games/Games/BaseGame.cs
index 168402c3..036ef271 100644
--- a/src/Games/Games/BaseGame.cs
+++ b/src/Games/Games/BaseGame.cs
@@ -46,22 +46,22 @@ public BaseGame()
{
if (!Directory.Exists(CampaignsFolderPath))
{
- Directory.CreateDirectory(CampaignsFolderPath);
+ _ = Directory.CreateDirectory(CampaignsFolderPath);
}
if (!Directory.Exists(MapsFolderPath))
{
- Directory.CreateDirectory(MapsFolderPath);
+ _ = Directory.CreateDirectory(MapsFolderPath);
}
if (!Directory.Exists(ModsFolderPath))
{
- Directory.CreateDirectory(ModsFolderPath);
+ _ = Directory.CreateDirectory(ModsFolderPath);
}
if (!Directory.Exists(SpecialFolderPath))
{
- Directory.CreateDirectory(SpecialFolderPath);
+ _ = Directory.CreateDirectory(SpecialFolderPath);
}
}
@@ -71,9 +71,10 @@ public BaseGame()
///
- /// Do provided files exist in the game install folder
+ /// Do provided files exist in the folder
///
/// List of required files
+ /// Folder where the files are searched
protected bool IsInstalled(List files, string? path = null)
{
var gamePath = path is null ? GameInstallFolder : path;
diff --git a/src/Mods/FilesUploader.cs b/src/Mods/FilesUploader.cs
index 35bef8fe..84983b1f 100644
--- a/src/Mods/FilesUploader.cs
+++ b/src/Mods/FilesUploader.cs
@@ -21,14 +21,14 @@ public FilesUploader(ApiInterface apiInterface)
public async Task AddAddonToDatabaseAsync(string pathToFile)
{
- var entity = await GetDownloadableAddonDtoAsync(pathToFile);
+ var entity = await GetDownloadableAddonDtoAsync(pathToFile).ConfigureAwait(false);
if (entity is null)
{
return false;
}
- var result = await _apiInterface.AddAddonToDatabaseAsync(entity);
+ var result = await _apiInterface.AddAddonToDatabaseAsync(entity).ConfigureAwait(false);
return result;
}
@@ -86,7 +86,7 @@ public async Task AddAddonToDatabaseAsync(string pathToFile)
var downloadUrl = $"{Consts.FilesRepo}/{gameName}/{folderName}/{Path.GetFileName(pathToFile)}";
using HttpClient httpClient = new();
- var response = await httpClient.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead);
+ var response = await httpClient.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
if (!response.IsSuccessStatusCode)
{
@@ -118,7 +118,7 @@ public async Task UploadFilesToFtpAsync(string pathToFile, CancellationTok
{
var path = "buildlauncher_uploads/" + Guid.NewGuid() + "/" + Path.GetFileName(pathToFile);
- var signedUrl = await _apiInterface.GetSignedUrlAsync(path);
+ var signedUrl = await _apiInterface.GetSignedUrlAsync(path).ConfigureAwait(false);
await using var fileStream = File.OpenRead(pathToFile);
using StreamContent content = new(fileStream);
@@ -157,7 +157,7 @@ public async Task UploadFilesToFtpAsync(string pathToFile, CancellationTok
}
using var archive = ZipArchive.Open(pathToFile);
- var jsonExists = archive.Entries.Any(static x => x.Key.Equals("addon.json"));
+ var jsonExists = archive.Entries.Any(static x => x.Key!.Equals("addon.json"));
if (!jsonExists)
{
diff --git a/src/Mods/Mods.csproj b/src/Mods/Mods.csproj
index 14b24741..c38300cc 100644
--- a/src/Mods/Mods.csproj
+++ b/src/Mods/Mods.csproj
@@ -12,6 +12,10 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/src/Mods/Providers/DownloadableAddonsProvider.cs b/src/Mods/Providers/DownloadableAddonsProvider.cs
index b2fbdbf5..12380a41 100644
--- a/src/Mods/Providers/DownloadableAddonsProvider.cs
+++ b/src/Mods/Providers/DownloadableAddonsProvider.cs
@@ -47,7 +47,7 @@ InstalledAddonsProviderFactory installedAddonsProviderFactory
///
public async Task CreateCacheAsync(bool createNew)
{
- await _semaphore.WaitAsync();
+ await _semaphore.WaitAsync().ConfigureAwait(false);
if (_cache is not null && !createNew)
{
@@ -174,7 +174,7 @@ public async Task DownloadAddonAsync(IDownloadableAddon addon)
if (!ClientProperties.IsDevMode)
{
- var result = await _apiInterface.IncreaseNumberOfInstallsAsync(addon.Id);
+ var result = await _apiInterface.IncreaseNumberOfInstallsAsync(addon.Id).ConfigureAwait(false);
if (result)
{
diff --git a/src/Mods/Providers/InstalledAddonsProvider.cs b/src/Mods/Providers/InstalledAddonsProvider.cs
index e0079a97..948634b6 100644
--- a/src/Mods/Providers/InstalledAddonsProvider.cs
+++ b/src/Mods/Providers/InstalledAddonsProvider.cs
@@ -43,7 +43,7 @@ IConfigProvider config
///
public async Task CreateCache(bool createNew)
{
- await _semaphore.WaitAsync();
+ await _semaphore.WaitAsync().ConfigureAwait(false);
_isCacheUpdating = true;
if (createNew)
@@ -70,17 +70,17 @@ await Task.Run(async () =>
}
}
- var camps = await GetAddonsFromFilesAsync(AddonTypeEnum.TC, files);
+ var camps = await GetAddonsFromFilesAsync(AddonTypeEnum.TC, files).ConfigureAwait(false);
_cache.Add(AddonTypeEnum.TC, camps);
//maps
files = Directory.GetFiles(_game.MapsFolderPath).Where(static x => x.EndsWith(".zip", StringComparison.OrdinalIgnoreCase) || x.EndsWith(".map", StringComparison.OrdinalIgnoreCase));
- var maps = await GetAddonsFromFilesAsync(AddonTypeEnum.Map, files);
+ var maps = await GetAddonsFromFilesAsync(AddonTypeEnum.Map, files).ConfigureAwait(false);
_cache.Add(AddonTypeEnum.Map, maps);
//mods
files = Directory.GetFiles(_game.ModsFolderPath, "*.zip");
- var mods = await GetAddonsFromFilesAsync(AddonTypeEnum.Mod, files);
+ var mods = await GetAddonsFromFilesAsync(AddonTypeEnum.Mod, files).ConfigureAwait(false);
_cache.Add(AddonTypeEnum.Mod, mods);
}).WaitAsync(CancellationToken.None).ConfigureAwait(false);
}
@@ -97,7 +97,7 @@ public async Task AddAddonAsync(AddonTypeEnum addonType, string pathToFile)
{
_cache.ThrowIfNull();
- var addon = await GetAddonFromFileAsync(addonType, pathToFile);
+ var addon = await GetAddonFromFileAsync(addonType, pathToFile).ConfigureAwait(false);
addon.ThrowIfNull();
@@ -248,7 +248,7 @@ private async Task> GetAddonsFromFilesAsync(Add
{
try
{
- var newAddon = await GetAddonFromFileAsync(addonType, file);
+ var newAddon = await GetAddonFromFileAsync(addonType, file).ConfigureAwait(false);
if (newAddon is null)
{
@@ -323,7 +323,7 @@ newAddon.Version is not null &&
Dictionary? incompatibles = null;
IStartMap? startMap = null;
- bool isUnpacked = false;
+ var isUnpacked = false;
Addon? addon;
@@ -395,12 +395,12 @@ newAddon.Version is not null &&
if (gridFile.Length > 0)
{
- var stream = await File.ReadAllBytesAsync(gridFile[0]);
+ var stream = await File.ReadAllBytesAsync(gridFile[0]).ConfigureAwait(false);
image = new MemoryStream(stream);
}
if (previewFile.Length > 0)
{
- var stream = await File.ReadAllBytesAsync(previewFile[0]);
+ var stream = await File.ReadAllBytesAsync(previewFile[0]).ConfigureAwait(false);
preview = new MemoryStream(stream);
}
diff --git a/src/Mods/Serializable/JsonConverters.cs b/src/Mods/Serializable/JsonConverters.cs
index 55158912..16eb7ea8 100644
--- a/src/Mods/Serializable/JsonConverters.cs
+++ b/src/Mods/Serializable/JsonConverters.cs
@@ -18,6 +18,12 @@ public sealed class SupportedGameDtoConverter : JsonConverter
else if (reader.TokenType is JsonTokenType.String)
{
var str = reader.GetString();
+
+ if (str is null)
+ {
+ ThrowHelper.NullReferenceException(nameof(str));
+ }
+
var gameEnum = Enum.Parse(str, true);
SupportedGameDto dto = new()
diff --git a/src/Ports/Installer/PortsInstaller.cs b/src/Ports/Installer/PortsInstaller.cs
index 84809cfc..e6cc79e2 100644
--- a/src/Ports/Installer/PortsInstaller.cs
+++ b/src/Ports/Installer/PortsInstaller.cs
@@ -37,7 +37,7 @@ public async Task InstallAsync(BasePort port)
{
var release = await _portsReleasesProvider.GetLatestReleaseAsync(port.PortEnum).ConfigureAwait(false);
- if (release is null || release.WindowsDownloadUrl is null)
+ if (release?.WindowsDownloadUrl is null)
{
return;
}
diff --git a/src/Ports/Installer/PortsReleasesProvider.cs b/src/Ports/Installer/PortsReleasesProvider.cs
index 62588872..f28d8037 100644
--- a/src/Ports/Installer/PortsReleasesProvider.cs
+++ b/src/Ports/Installer/PortsReleasesProvider.cs
@@ -22,7 +22,7 @@ public PortsReleasesProvider(ApiInterface apiInterface)
///
/// Get the latest release of the selected port
///
- /// Port
+ /// Port enum
public async Task GetLatestReleaseAsync(PortEnum portEnum)
{
await _semaphore.WaitAsync().ConfigureAwait(false);
@@ -32,7 +32,7 @@ public PortsReleasesProvider(ApiInterface apiInterface)
_releases = await GetReleasesAsync().ConfigureAwait(false);
}
- _semaphore.Release();
+ _ = _semaphore.Release();
if (_releases is null)
{
diff --git a/src/Ports/Ports.csproj b/src/Ports/Ports.csproj
index 737359c2..f4f8848e 100644
--- a/src/Ports/Ports.csproj
+++ b/src/Ports/Ports.csproj
@@ -24,6 +24,10 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/src/Ports/Ports/EDuke32/EDuke32.cs b/src/Ports/Ports/EDuke32/EDuke32.cs
index 8d8d3ce7..4e37fe0d 100644
--- a/src/Ports/Ports/EDuke32/EDuke32.cs
+++ b/src/Ports/Ports/EDuke32/EDuke32.cs
@@ -120,24 +120,24 @@ protected override void BeforeStart(IGame game, IAddon campaign)
///
protected override void GetStartCampaignArgs(StringBuilder sb, IGame game, IAddon addon)
{
- sb.Append(" -usecwd"); //don't search for steam/gog installs
- sb.Append(" -cachesize 262144"); //set cache to 256MiB
+ _ = sb.Append(" -usecwd"); //don't search for steam/gog installs
+ _ = sb.Append(" -cachesize 262144"); //set cache to 256MiB
if (addon.MainDef is not null)
{
- sb.Append($@" {MainDefParam}""{addon.MainDef}""");
+ _ = sb.Append($@" {MainDefParam}""{addon.MainDef}""");
}
else
{
//overriding default def so gamename.def files are ignored
- sb.Append($@" {MainDefParam}""a""");
+ _ = sb.Append($@" {MainDefParam}""a""");
}
if (addon.AdditionalDefs is not null)
{
foreach (var def in addon.AdditionalDefs)
{
- sb.Append($@" {AddDefParam}""{def}""");
+ _ = sb.Append($@" {AddDefParam}""{def}""");
}
}
@@ -158,19 +158,19 @@ protected override void GetStartCampaignArgs(StringBuilder sb, IGame game, IAddo
///
/// StringBuilder
/// DukeGame
- /// DukeCampaign
+ /// DukeCampaign
protected void GetDukeArgs(StringBuilder sb, DukeGame game, IAddon addon)
{
if (addon.SupportedGame.GameEnum is GameEnum.Duke64)
{
- sb.Append(@$" {AddDirectoryParam}""{Path.GetDirectoryName(game.Duke64RomPath)}"" -gamegrp ""{Path.GetFileName(game.Duke64RomPath)}""");
+ _ = sb.Append(@$" {AddDirectoryParam}""{Path.GetDirectoryName(game.Duke64RomPath)}"" -gamegrp ""{Path.GetFileName(game.Duke64RomPath)}""");
return;
}
if (addon.SupportedGame.GameVersion is not null &&
addon.SupportedGame.GameVersion.Equals(nameof(DukeVersionEnum.Duke3D_WT), StringComparison.InvariantCultureIgnoreCase))
{
- sb.Append($@" {AddDirectoryParam}""{game.DukeWTInstallPath}"" -addon {(byte)DukeAddonEnum.Base} {AddDirectoryParam}""{Path.Combine(game.SpecialFolderPath, Consts.WTStopgap)}"" -gamegrp e32wt.grp");
+ _ = sb.Append($@" {AddDirectoryParam}""{game.DukeWTInstallPath}"" -addon {(byte)DukeAddonEnum.Base} {AddDirectoryParam}""{Path.Combine(game.SpecialFolderPath, Consts.WTStopgap)}"" -gamegrp e32wt.grp");
}
else
{
@@ -193,14 +193,14 @@ protected void GetDukeArgs(StringBuilder sb, DukeGame game, IAddon addon)
dukeAddon = (byte)DukeAddonEnum.DukeVaca;
}
- sb.Append($@" {AddDirectoryParam}""{game.GameInstallFolder}""");
+ _ = sb.Append($@" {AddDirectoryParam}""{game.GameInstallFolder}""");
if (Directory.Exists(Path.Combine(game.GameInstallFolder!, "AddOns")))
{
- sb.Append($@" {AddDirectoryParam}""{Path.Combine(game.GameInstallFolder!, "AddOns")}""");
+ _ = sb.Append($@" {AddDirectoryParam}""{Path.Combine(game.GameInstallFolder!, "AddOns")}""");
}
- sb.Append($" -addon {dukeAddon}");
+ _ = sb.Append($" -addon {dukeAddon}");
}
@@ -224,21 +224,21 @@ protected void GetDukeArgs(StringBuilder sb, DukeGame game, IAddon addon)
if (dCamp.MainCon is not null)
{
- sb.Append($@" {MainConParam}""{dCamp.MainCon}""");
+ _ = sb.Append($@" {MainConParam}""{dCamp.MainCon}""");
}
if (dCamp.AdditionalCons?.Count > 0)
{
foreach (var con in dCamp.AdditionalCons)
{
- sb.Append($@" {AddConParam}""{con}""");
+ _ = sb.Append($@" {AddConParam}""{con}""");
}
}
if (dCamp.Type is AddonTypeEnum.TC)
{
- sb.Append($@" {AddFileParam}""{Path.Combine(game.CampaignsFolderPath, dCamp.FileName)}""");
+ _ = sb.Append($@" {AddFileParam}""{Path.Combine(game.CampaignsFolderPath, dCamp.FileName!)}""");
}
else if (dCamp.Type is AddonTypeEnum.Map)
{
@@ -260,7 +260,7 @@ protected override void GetAutoloadModsArgs(StringBuilder sb, IGame game, IAddon
return;
}
- sb.Append($@" {AddDirectoryParam}""{game.ModsFolderPath}""");
+ _ = sb.Append($@" {AddDirectoryParam}""{game.ModsFolderPath}""");
foreach (var mod in mods)
{
@@ -274,13 +274,13 @@ protected override void GetAutoloadModsArgs(StringBuilder sb, IGame game, IAddon
continue;
}
- sb.Append($@" {AddFileParam}""{aMod.FileName}""");
+ _ = sb.Append($@" {AddFileParam}""{aMod.FileName}""");
if (aMod.AdditionalDefs is not null)
{
foreach (var def in aMod.AdditionalDefs)
{
- sb.Append($@" {AddDefParam}""{def}""");
+ _ = sb.Append($@" {AddDefParam}""{def}""");
}
}
@@ -288,7 +288,7 @@ protected override void GetAutoloadModsArgs(StringBuilder sb, IGame game, IAddon
{
foreach (var con in aMod.AdditionalCons)
{
- sb.Append($@" {AddConParam}""{con}""");
+ _ = sb.Append($@" {AddConParam}""{con}""");
}
}
}
diff --git a/src/Ports/Ports/EDuke32/RedNukem.cs b/src/Ports/Ports/EDuke32/RedNukem.cs
index 2b4254c3..aa05ed2a 100644
--- a/src/Ports/Ports/EDuke32/RedNukem.cs
+++ b/src/Ports/Ports/EDuke32/RedNukem.cs
@@ -64,23 +64,23 @@ protected override void BeforeStart(IGame game, IAddon campaign)
protected override void GetStartCampaignArgs(StringBuilder sb, IGame game, IAddon addon)
{
//don't search for steam/gog installs
- sb.Append(" -usecwd");
+ _ = sb.Append(" -usecwd");
if (addon.MainDef is not null)
{
- sb.Append($@" {MainDefParam}""{addon.MainDef}""");
+ _ = sb.Append($@" {MainDefParam}""{addon.MainDef}""");
}
else
{
//overriding default def so gamename.def files are ignored
- sb.Append($@" {MainDefParam}""a""");
+ _ = sb.Append($@" {MainDefParam}""a""");
}
if (addon.AdditionalDefs is not null)
{
foreach (var def in addon.AdditionalDefs)
{
- sb.Append($@" {AddDefParam}""{def}""");
+ _ = sb.Append($@" {AddDefParam}""{def}""");
}
}
@@ -105,21 +105,21 @@ protected override void GetStartCampaignArgs(StringBuilder sb, IGame game, IAddo
///
/// StringBuilder
/// RedneckGame
- /// RedneckCampaign
+ /// RedneckCampaign
private void GetRedneckArgs(StringBuilder sb, RedneckGame game, IAddon addon)
{
if (addon.SupportedGame.GameEnum is GameEnum.RidesAgain)
{
- sb.Append($@" {AddDirectoryParam}""{game.AgainInstallPath}""");
+ _ = sb.Append($@" {AddDirectoryParam}""{game.AgainInstallPath}""");
}
else if (addon.DependentAddons is not null &&
addon.DependentAddons.ContainsKey(nameof(RedneckAddonEnum.Route66)))
{
- sb.Append($@" {AddDirectoryParam}""{game.GameInstallFolder}"" -x GAME66.CON");
+ _ = sb.Append($@" {AddDirectoryParam}""{game.GameInstallFolder}"" -x GAME66.CON");
}
else
{
- sb.Append($@" {AddDirectoryParam}""{game.GameInstallFolder}""");
+ _ = sb.Append($@" {AddDirectoryParam}""{game.GameInstallFolder}""");
}
@@ -143,21 +143,21 @@ private void GetRedneckArgs(StringBuilder sb, RedneckGame game, IAddon addon)
if (rCamp.MainCon is not null)
{
- sb.Append($@" {MainConParam}""{rCamp.MainCon}""");
+ _ = sb.Append($@" {MainConParam}""{rCamp.MainCon}""");
}
if (rCamp.AdditionalCons?.Count > 0)
{
foreach (var con in rCamp.AdditionalCons)
{
- sb.Append($@" {AddConParam}""{con}""");
+ _ = sb.Append($@" {AddConParam}""{con}""");
}
}
if (rCamp.Type is AddonTypeEnum.TC)
{
- sb.Append($@" {AddFileParam}""{Path.Combine(game.CampaignsFolderPath, rCamp.FileName)}""");
+ _ = sb.Append($@" {AddFileParam}""{Path.Combine(game.CampaignsFolderPath, rCamp.FileName!)}""");
}
else if (rCamp.Type is AddonTypeEnum.Map)
{
@@ -177,7 +177,7 @@ private void GetRedneckArgs(StringBuilder sb, RedneckGame game, IAddon addon)
[Obsolete("Remove if RedNukem can ever properly launch R66")]
private static void FixRoute66Files(IGame game, IAddon campaign)
{
- if (game is not RedneckGame rGame || !rGame.IsRoute66Installed)
+ if (game is not RedneckGame rGame || !rGame.IsRoute66Installed || game.GameInstallFolder is null)
{
return;
}
diff --git a/src/Ports/Ports/Raze.cs b/src/Ports/Ports/Raze.cs
index 67e05a39..e7fa13f7 100644
--- a/src/Ports/Ports/Raze.cs
+++ b/src/Ports/Ports/Raze.cs
@@ -141,7 +141,7 @@ protected override void BeforeStart(IGame game, IAddon campaign)
File.WriteAllText(config, DefaultConfig);
}
- AddGamePathsToConfig(game.GameInstallFolder, game.ModsFolderPath, config, campaign);
+ AddGamePathsToConfig(game.GameInstallFolder!, game.ModsFolderPath, config, campaign);
FixRoute66Files(game, campaign);
}
@@ -214,7 +214,7 @@ private void GetDukeArgs(StringBuilder sb, DukeGame game, IAddon addon)
{
var config = Path.Combine(PathToExecutableFolder, ConfigFile);
- AddGamePathsToConfig(game.DukeWTInstallPath, game.ModsFolderPath, config, addon);
+ AddGamePathsToConfig(game.DukeWTInstallPath!, game.ModsFolderPath, config, addon);
_ = sb.Append($" -addon {(byte)DukeAddonEnum.Base}");
}
@@ -349,8 +349,8 @@ private void GetRedneckArgs(StringBuilder sb, RedneckGame game, IAddon addon)
if (rCamp.Id.Equals(nameof(GameEnum.RidesAgain), StringComparison.OrdinalIgnoreCase))
{
- var config = Path.Combine(PathToExecutableFolder, ConfigFile);
- AddGamePathsToConfig(game.AgainInstallPath, game.ModsFolderPath, config, addon);
+ var pathToConfig = Path.Combine(PathToExecutableFolder, ConfigFile);
+ AddGamePathsToConfig(game.AgainInstallPath!, game.ModsFolderPath, pathToConfig, addon);
}
diff --git a/src/Tests/CmdArguments/BloodCmdArgumentsTests.cs b/src/Tests/CmdArguments/BloodCmdArgumentsTests.cs
index 86ac6d42..22a24d75 100644
--- a/src/Tests/CmdArguments/BloodCmdArgumentsTests.cs
+++ b/src/Tests/CmdArguments/BloodCmdArgumentsTests.cs
@@ -10,7 +10,7 @@
namespace Tests.CmdArguments;
[Collection("Sync")]
-public class BloodCmdArgumentsTests
+public sealed class BloodCmdArgumentsTests
{
private readonly BloodGame _bloodGame;
private readonly BloodCampaign _bloodCamp;
diff --git a/src/Tests/CmdArguments/DukeCmdArgumentsTests.cs b/src/Tests/CmdArguments/DukeCmdArgumentsTests.cs
index 77c4327b..16b57651 100644
--- a/src/Tests/CmdArguments/DukeCmdArgumentsTests.cs
+++ b/src/Tests/CmdArguments/DukeCmdArgumentsTests.cs
@@ -11,7 +11,7 @@
namespace Tests.CmdArguments;
[Collection("Sync")]
-public class DukeCmdArgumentsTests
+public sealed class DukeCmdArgumentsTests
{
private readonly DukeGame _dukeGame;
private readonly DukeCampaign _dukeCamp;
diff --git a/src/Tests/CmdArguments/FuryCmdArgumentsTests.cs b/src/Tests/CmdArguments/FuryCmdArgumentsTests.cs
index 8a5c288d..77c8b7da 100644
--- a/src/Tests/CmdArguments/FuryCmdArgumentsTests.cs
+++ b/src/Tests/CmdArguments/FuryCmdArgumentsTests.cs
@@ -9,7 +9,7 @@
namespace Tests.CmdArguments;
[Collection("Sync")]
-public class FuryCmdArgumentsTests
+public sealed class FuryCmdArgumentsTests
{
private readonly FuryGame _dukeGame;
private readonly FuryCampaign _dukeCamp;
diff --git a/src/Tests/CmdArguments/RedneckCmdArgumentsTests.cs b/src/Tests/CmdArguments/RedneckCmdArgumentsTests.cs
index add99f54..edd23707 100644
--- a/src/Tests/CmdArguments/RedneckCmdArgumentsTests.cs
+++ b/src/Tests/CmdArguments/RedneckCmdArgumentsTests.cs
@@ -9,7 +9,7 @@
namespace Tests.CmdArguments;
[Collection("Sync")]
-public class RedneckCmdArgumentsTests
+public sealed class RedneckCmdArgumentsTests
{
private readonly RedneckGame _redneckGame;
private readonly RedneckCampaign _redneckCamp;
diff --git a/src/Tests/CmdArguments/SlaveCmdArgumentsTests.cs b/src/Tests/CmdArguments/SlaveCmdArgumentsTests.cs
index 42978f23..acccc1e3 100644
--- a/src/Tests/CmdArguments/SlaveCmdArgumentsTests.cs
+++ b/src/Tests/CmdArguments/SlaveCmdArgumentsTests.cs
@@ -9,7 +9,7 @@
namespace Tests.CmdArguments;
[Collection("Sync")]
-public class SlaveCmdArgumentsTests
+public sealed class SlaveCmdArgumentsTests
{
private readonly SlaveGame _slaveGame;
private readonly SlaveCampaign _slaveCamp;
diff --git a/src/Tests/CmdArguments/WangCmdArgumentsTests.cs b/src/Tests/CmdArguments/WangCmdArgumentsTests.cs
index 2affabd0..eafca82a 100644
--- a/src/Tests/CmdArguments/WangCmdArgumentsTests.cs
+++ b/src/Tests/CmdArguments/WangCmdArgumentsTests.cs
@@ -10,7 +10,7 @@
namespace Tests.CmdArguments;
[Collection("Sync")]
-public class WangCmdArgumentsTests
+public sealed class WangCmdArgumentsTests
{
private readonly WangGame _wangGame;
private readonly WangCampaign _wangCamp;
diff --git a/src/Tests/SerializeTest.cs b/src/Tests/SerializeTest.cs
index 60d78a0f..09e808e4 100644
--- a/src/Tests/SerializeTest.cs
+++ b/src/Tests/SerializeTest.cs
@@ -5,7 +5,7 @@
namespace Tests;
-public class SerializerTests
+public sealed class SerializerTests
{
private const string AddonJson =
"""
@@ -135,7 +135,7 @@ public void DeserializeAddonJson()
Assert.Equal("MAIN.RFF", result.MainRff);
Assert.Equal("SOUND.RFF", result.SoundRff);
- Assert.Equal("TEST.MAP", ((MapFileDto)result.StartMap).File);
+ Assert.Equal("TEST.MAP", ((MapFileDto)result.StartMap!).File);
Assert.Equal("Addon description", result.Description);
}
@@ -163,7 +163,7 @@ public void DeserializeSlotMapJson()
var result = JsonSerializer.Deserialize(SlotMapJson, AddonManifestContext.Default.AddonDto);
Assert.NotNull(result);
- Assert.IsType(result.StartMap);
+ _ = Assert.IsType(result.StartMap);
Assert.Equal(1, ((MapSlotDto)result.StartMap).Episode);
Assert.Equal(2, ((MapSlotDto)result.StartMap).Level);
diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj
index 786a396c..95513056 100644
--- a/src/Tests/Tests.csproj
+++ b/src/Tests/Tests.csproj
@@ -11,6 +11,14 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/src/Tests/VersionCompareTests.cs b/src/Tests/VersionCompareTests.cs
index 0bdb9cc0..7c8c6ecf 100644
--- a/src/Tests/VersionCompareTests.cs
+++ b/src/Tests/VersionCompareTests.cs
@@ -2,7 +2,7 @@
namespace Tests;
-public class VersionCompareTests
+public sealed class VersionCompareTests
{
[Theory]
[InlineData("1.1", "==1.1")]
diff --git a/src/Tools/Installer/ToolsInstaller.cs b/src/Tools/Installer/ToolsInstaller.cs
index b8cec3b2..1ee73175 100644
--- a/src/Tools/Installer/ToolsInstaller.cs
+++ b/src/Tools/Installer/ToolsInstaller.cs
@@ -37,7 +37,7 @@ public async Task InstallAsync(BaseTool port)
{
var release = await _toolsReleasesProvider.GetLatestReleaseAsync(port).ConfigureAwait(false);
- if (release is null)
+ if (release?.WindowsDownloadUrl is null)
{
return;
}
diff --git a/src/Tools/Tools.csproj b/src/Tools/Tools.csproj
index f7dd1365..0b2e3b40 100644
--- a/src/Tools/Tools.csproj
+++ b/src/Tools/Tools.csproj
@@ -22,6 +22,10 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+