From 7176ebb531328732b6a46ba0d2ab10f1c9d772e4 Mon Sep 17 00:00:00 2001 From: Halgari Date: Fri, 7 Oct 2022 21:43:44 -0600 Subject: [PATCH] Most warnings are fixed now --- Wabbajack.App.Wpf/Models/ResourceMonitor.cs | 10 ++--- .../View Models/Compilers/CompilerVM.cs | 2 +- .../View Models/Compilers/ISubCompilerVM.cs | 16 -------- .../View Models/Compilers/MO2CompilerVM.cs | 8 +--- .../View Models/Installers/InstallerVM.cs | 2 - .../Views/Compilers/CompilerView.xaml.cs | 7 ++-- Wabbajack.App.Wpf/Wabbajack.App.Wpf.csproj | 2 +- Wabbajack.Compiler.Test/ModListHarness.cs | 2 +- Wabbajack.Compiler.Test/SanityTests.cs | 9 ++--- Wabbajack.Compiler/ACompiler.cs | 10 ++--- .../CompilationSteps/IgnoreSaveFiles.cs | 1 - .../CompilationSteps/MatchSimilarTextures.cs | 4 +- .../PatchCache/BinaryPatchCache.cs | 38 ------------------- Wabbajack.Compiler/Wabbajack.Compiler.csproj | 2 +- .../StandardInstallerTest.cs | 1 - .../ViewModels/MainWindowViewModel.cs | 1 + Wabbajack.Launcher/Wabbajack.Launcher.csproj | 2 +- .../ApiKeyAuthorizationHandler.cs | 1 - Wabbajack.Server/AppSettings.cs | 4 +- Wabbajack.Server/Controllers/Metrics.cs | 18 --------- Wabbajack.Server/Controllers/NexusCache.cs | 20 +--------- Wabbajack.Server/Controllers/Proxy.cs | 2 +- Wabbajack.Server/Services/AbstractService.cs | 3 +- Wabbajack.Server/Services/DiscordWebHook.cs | 2 +- .../Services/NexusCacheManager.cs | 2 +- Wabbajack.Server/Wabbajack.Server.csproj | 2 +- .../ProtectedData.cs | 3 +- .../Wabbajack.Services.OSIntegrated.csproj | 4 ++ Wabbajack.VFS/IndexRoot.cs | 4 +- 29 files changed, 44 insertions(+), 138 deletions(-) delete mode 100644 Wabbajack.App.Wpf/View Models/Compilers/ISubCompilerVM.cs diff --git a/Wabbajack.App.Wpf/Models/ResourceMonitor.cs b/Wabbajack.App.Wpf/Models/ResourceMonitor.cs index 27fb755f..8b7bf883 100644 --- a/Wabbajack.App.Wpf/Models/ResourceMonitor.cs +++ b/Wabbajack.App.Wpf/Models/ResourceMonitor.cs @@ -4,7 +4,6 @@ using System.Collections.ObjectModel; using System.Linq; using System.Reactive.Disposables; using System.Reactive.Subjects; -using System.Timers; using DynamicData; using DynamicData.Kernel; using Microsoft.Extensions.Logging; @@ -15,11 +14,10 @@ namespace Wabbajack.Models; public class ResourceMonitor : IDisposable { - private readonly TimeSpan PollInterval = TimeSpan.FromMilliseconds(250); + private readonly TimeSpan _pollInterval = TimeSpan.FromMilliseconds(250); private readonly IResource[] _resources; - private readonly Timer _timer; - + private readonly Subject<(string Name, long Througput)[]> _updates = new (); private (string Name, long Throughput)[] _prev; public IObservable<(string Name, long Throughput)[]> Updates => _updates; @@ -41,7 +39,7 @@ public class ResourceMonitor : IDisposable _resources = resources.ToArray(); _prev = _resources.Select(x => (x.Name, (long)0)).ToArray(); - RxApp.MainThreadScheduler.ScheduleRecurringAction(PollInterval, Elapsed) + RxApp.MainThreadScheduler.ScheduleRecurringAction(_pollInterval, Elapsed) .DisposeWith(_compositeDisposable); _tasks.Connect() @@ -55,7 +53,7 @@ public class ResourceMonitor : IDisposable { var current = _resources.Select(x => (x.Name, x.StatusReport.Transferred)).ToArray(); var diff = _prev.Zip(current) - .Select(t => (t.First.Name, (long)((t.Second.Transferred - t.First.Throughput) / PollInterval.TotalSeconds))) + .Select(t => (t.First.Name, (long)((t.Second.Transferred - t.First.Throughput) / _pollInterval.TotalSeconds))) .ToArray(); _prev = current; _updates.OnNext(diff); diff --git a/Wabbajack.App.Wpf/View Models/Compilers/CompilerVM.cs b/Wabbajack.App.Wpf/View Models/Compilers/CompilerVM.cs index d0575cb0..7eb0ecb9 100644 --- a/Wabbajack.App.Wpf/View Models/Compilers/CompilerVM.cs +++ b/Wabbajack.App.Wpf/View Models/Compilers/CompilerVM.cs @@ -58,7 +58,7 @@ namespace Wabbajack public CompilerState State { get; set; } [Reactive] - public ISubCompilerVM SubCompilerVM { get; set; } + public MO2CompilerVM SubCompilerVM { get; set; } // Paths public FilePickerVM ModlistLocation { get; } diff --git a/Wabbajack.App.Wpf/View Models/Compilers/ISubCompilerVM.cs b/Wabbajack.App.Wpf/View Models/Compilers/ISubCompilerVM.cs deleted file mode 100644 index 8444a96a..00000000 --- a/Wabbajack.App.Wpf/View Models/Compilers/ISubCompilerVM.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Threading.Tasks; -using Wabbajack.Compiler; -using Wabbajack.DTOs; - -namespace Wabbajack -{ - public interface ISubCompilerVM - { - ACompiler ActiveCompilation { get; } - ModlistSettingsEditorVM ModlistSettings { get; } - void Unload(); - IObservable CanCompile { get; } - Task> Compile(); - } -} diff --git a/Wabbajack.App.Wpf/View Models/Compilers/MO2CompilerVM.cs b/Wabbajack.App.Wpf/View Models/Compilers/MO2CompilerVM.cs index 42d92a47..0939db86 100644 --- a/Wabbajack.App.Wpf/View Models/Compilers/MO2CompilerVM.cs +++ b/Wabbajack.App.Wpf/View Models/Compilers/MO2CompilerVM.cs @@ -18,7 +18,7 @@ using Consts = Wabbajack.Consts; namespace Wabbajack { - public class MO2CompilerVM : ViewModel, ISubCompilerVM + public class MO2CompilerVM : ViewModel { public CompilerVM Parent { get; } @@ -36,11 +36,7 @@ namespace Wabbajack [Reactive] public ACompiler ActiveCompilation { get; private set; } - - private readonly ObservableAsPropertyHelper _modlistSettings; - private readonly IObservable> _authorKeys; - public ModlistSettingsEditorVM ModlistSettings => _modlistSettings.Value; - + [Reactive] public object StatusTracker { get; private set; } diff --git a/Wabbajack.App.Wpf/View Models/Installers/InstallerVM.cs b/Wabbajack.App.Wpf/View Models/Installers/InstallerVM.cs index 550ec88b..eaccbfad 100644 --- a/Wabbajack.App.Wpf/View Models/Installers/InstallerVM.cs +++ b/Wabbajack.App.Wpf/View Models/Installers/InstallerVM.cs @@ -145,9 +145,7 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM public ReactiveCommand OpenLogsCommand { get; } public ReactiveCommand GoToInstallCommand { get; } public ReactiveCommand BeginCommand { get; } - public ReactiveCommand BackCommand { get; } - public InstallerVM(ILogger logger, DTOSerializer dtos, SettingsManager settingsManager, IServiceProvider serviceProvider, SystemParametersConstructor parametersConstructor, IGameLocator gameLocator, LogStream loggerProvider, ResourceMonitor resourceMonitor, Wabbajack.Services.OSIntegrated.Configuration configuration, HttpClient client, DownloadDispatcher dispatcher, IEnumerable logins) : base(logger) diff --git a/Wabbajack.App.Wpf/Views/Compilers/CompilerView.xaml.cs b/Wabbajack.App.Wpf/Views/Compilers/CompilerView.xaml.cs index 32346186..da3702f7 100644 --- a/Wabbajack.App.Wpf/Views/Compilers/CompilerView.xaml.cs +++ b/Wabbajack.App.Wpf/Views/Compilers/CompilerView.xaml.cs @@ -307,7 +307,7 @@ namespace Wabbajack ViewModel.AddOtherProfile(selectedPath.FileName.ToString()); } - public async Task AddNoMatchIncludeCommand() + public Task AddNoMatchIncludeCommand() { var dlg = new CommonOpenFileDialog { @@ -325,12 +325,13 @@ namespace Wabbajack ShowPlacesList = true, }; - if (dlg.ShowDialog() != CommonFileDialogResult.Ok) return; + if (dlg.ShowDialog() != CommonFileDialogResult.Ok) return Task.CompletedTask; var selectedPath = dlg.FileNames.First().ToAbsolutePath(); - if (!selectedPath.InFolder(ViewModel.Source)) return; + if (!selectedPath.InFolder(ViewModel.Source)) return Task.CompletedTask; ViewModel.AddNoMatchInclude(selectedPath.RelativeTo(ViewModel!.Source)); + return Task.CompletedTask; } public async Task AddIncludeCommand() diff --git a/Wabbajack.App.Wpf/Wabbajack.App.Wpf.csproj b/Wabbajack.App.Wpf/Wabbajack.App.Wpf.csproj index 92592bdc..e5b0a189 100644 --- a/Wabbajack.App.Wpf/Wabbajack.App.Wpf.csproj +++ b/Wabbajack.App.Wpf/Wabbajack.App.Wpf.csproj @@ -19,7 +19,7 @@ - CS8600,CS8601,CS8618,CS8604,CS8632 + CS8600,CS8601,CS8618,CS8604,CS8632,CS1998 diff --git a/Wabbajack.Compiler.Test/ModListHarness.cs b/Wabbajack.Compiler.Test/ModListHarness.cs index 6ce4adc1..ec749052 100644 --- a/Wabbajack.Compiler.Test/ModListHarness.cs +++ b/Wabbajack.Compiler.Test/ModListHarness.cs @@ -97,7 +97,7 @@ public class ModListHarness CancellationToken.None); var compiler = scope.ServiceProvider.GetService(); - if (!await compiler.Begin(CancellationToken.None)) + if (!await compiler!.Begin(CancellationToken.None)) return null; var modlist = await StandardInstaller.LoadFromFile(_dtos, settings.OutputFile); diff --git a/Wabbajack.Compiler.Test/SanityTests.cs b/Wabbajack.Compiler.Test/SanityTests.cs index 84cbd1a0..4154400e 100644 --- a/Wabbajack.Compiler.Test/SanityTests.cs +++ b/Wabbajack.Compiler.Test/SanityTests.cs @@ -13,7 +13,6 @@ using Wabbajack.DTOs.Texture; using Wabbajack.Hashing.PHash; using Wabbajack.Paths.IO; using Wabbajack.RateLimiter; -using Wabbajack.Services.OSIntegrated; using Xunit; namespace Wabbajack.Compiler.Test; @@ -29,7 +28,6 @@ public class CompilerSanityTests : IAsyncLifetime private readonly IServiceProvider _serviceProvider; private Mod _mod; private ModList? _modlist; - private readonly LoggingRateLimiterReporter _reporter; public CompilerSanityTests(ILogger logger, IServiceProvider serviceProvider, FileExtractor.FileExtractor fileExtractor, @@ -52,8 +50,9 @@ public class CompilerSanityTests : IAsyncLifetime "https://authored-files.wabbajack.org/Tonal%20Architect_WJ_TEST_FILES.zip_9cb97a01-3354-4077-9e4a-7e808d47794f")); } - public async Task DisposeAsync() + public Task DisposeAsync() { + return Task.CompletedTask; } private async Task CompileAndValidate(int expectedDirectives, Action? configureSettings = null) @@ -97,7 +96,7 @@ public class CompilerSanityTests : IAsyncLifetime await CompileAndValidate(4); - Assert.Single(_modlist.Directives.OfType()); + Assert.Single(_modlist!.Directives.OfType()); await InstallAndValidate(); } @@ -135,7 +134,7 @@ public class CompilerSanityTests : IAsyncLifetime } await CompileAndValidate(42); - Assert.Single(_modlist.Directives.OfType()); + Assert.Single(_modlist!.Directives.OfType()); await InstallAndValidate(); } diff --git a/Wabbajack.Compiler/ACompiler.cs b/Wabbajack.Compiler/ACompiler.cs index 2c593060..6665c2b3 100644 --- a/Wabbajack.Compiler/ACompiler.cs +++ b/Wabbajack.Compiler/ACompiler.cs @@ -286,7 +286,7 @@ public abstract class ACompiler protected async Task CleanInvalidArchivesAndFillState() { NextStep("Compiling", "Cleaning Invalid Archives", IndexedArchives.Count); - var remove = await IndexedArchives.PKeepAll(CompilerLimiter, async a => + var remove = await IndexedArchives.PMapAllBatchedAsync(CompilerLimiter, async a => { UpdateProgress(1); try @@ -302,14 +302,15 @@ public abstract class ACompiler _logger.LogWarning(ex, "While resolving archive {Archive}", a.Name); return a; } - }).ToHashSet(); + }).Where(x => x != null) + .ToHashSet(); if (remove.Count == 0) return; _logger.LogWarning( "Removing {count} archives from the compilation state, this is probably not an issue but reference this if you have compilation failures", remove.Count); - remove.Do(r => _logger.LogWarning("Resolution failed for: ({size} {hash}) {path}", r.File.Size, r.File.Hash, + remove.Do(r => _logger.LogWarning("Resolution failed for: ({size} {hash}) {path}", r!.File.Size, r.File.Hash, r.File.FullPath)); IndexedArchives.RemoveAll(a => remove.Contains(a)); } @@ -596,7 +597,7 @@ public abstract class ACompiler public async Task ResolveArchive(Hash hash, IDictionary archives) { - if (archives.TryGetValue(hash, out var found)) return await ResolveArchive(found); + if (archives.TryGetValue(hash, out var found)) return (await ResolveArchive(found))!; throw new ArgumentException($"No match found for Archive sha: {hash.ToBase64()} this shouldn't happen"); } @@ -663,7 +664,6 @@ public abstract class ACompiler public void PrintNoMatches(ICollection noMatches) { - const int max = 10; if (noMatches.Count > 0) foreach (var file in noMatches) _logger.LogWarning(" {fileTo} - {fileReason}", file.To, file.Reason); diff --git a/Wabbajack.Compiler/CompilationSteps/IgnoreSaveFiles.cs b/Wabbajack.Compiler/CompilationSteps/IgnoreSaveFiles.cs index b5865950..dd3278b2 100644 --- a/Wabbajack.Compiler/CompilationSteps/IgnoreSaveFiles.cs +++ b/Wabbajack.Compiler/CompilationSteps/IgnoreSaveFiles.cs @@ -11,7 +11,6 @@ namespace Wabbajack.Compiler.CompilationSteps; public class IgnoreSaveFiles : MO2CompilationStep { private readonly bool _includeSaves; - private readonly AbsolutePath _sourcePath; private readonly string _tag; private readonly AbsolutePath[] _profilePaths; diff --git a/Wabbajack.Compiler/CompilationSteps/MatchSimilarTextures.cs b/Wabbajack.Compiler/CompilationSteps/MatchSimilarTextures.cs index 7f4e4491..68f87d93 100644 --- a/Wabbajack.Compiler/CompilationSteps/MatchSimilarTextures.cs +++ b/Wabbajack.Compiler/CompilationSteps/MatchSimilarTextures.cs @@ -58,8 +58,8 @@ public class MatchSimilarTextures : ACompilationStep from mainMatch in _byName[mainFile.FullPath.FileName.FileNameWithoutExtension] where mainMatch.ImageState != null where mainFile.ImageState != null - let similarity = ImageLoader.ComputeDifference(mainFile.ImageState.PerceptualHash, - mainMatch.ImageState.PerceptualHash) + let similarity = ImageLoader.ComputeDifference(mainFile.ImageState!.PerceptualHash, + mainMatch.ImageState!.PerceptualHash) where similarity >= PerceptualTolerance orderby similarity descending let foundFile = mainMatch.InSameFolder(source.Path.FileName) diff --git a/Wabbajack.Compiler/PatchCache/BinaryPatchCache.cs b/Wabbajack.Compiler/PatchCache/BinaryPatchCache.cs index bff35753..a2896bc9 100644 --- a/Wabbajack.Compiler/PatchCache/BinaryPatchCache.cs +++ b/Wabbajack.Compiler/PatchCache/BinaryPatchCache.cs @@ -1,5 +1,4 @@ using System; -using System.Data.SQLite; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -15,8 +14,6 @@ namespace Wabbajack.Compiler; public class BinaryPatchCache : IBinaryPatchCache { - private readonly SQLiteConnection _conn; - private readonly string _connectionString; private readonly AbsolutePath _location; private readonly ILogger _logger; @@ -76,39 +73,4 @@ public class BinaryPatchCache : IBinaryPatchCache return await location.ReadAllBytesAsync(); return Array.Empty(); } - - public async Task CreatePatchCached(byte[] a, byte[] b, Stream output) - { - await using var cmd = new SQLiteCommand(_conn); - cmd.CommandText = @"INSERT INTO PatchCache (FromHash, ToHash, PatchSize, Patch) - VALUES (@fromHash, @toHash, @patchSize, @patch)"; - - xxHashAlgorithm aAl = new(0), bAl = new(0); - - var dataA = Hash.FromULong(aAl.HashBytes(a)); - ; - var dataB = Hash.FromULong(bAl.HashBytes(b)); - ; - - cmd.Parameters.AddWithValue("@fromHash", (long) dataA); - cmd.Parameters.AddWithValue("@toHash", (long) dataB); - - await using var patch = new MemoryStream(); - OctoDiff.Create(a, b, patch); - patch.Position = 0; - - cmd.Parameters.AddWithValue("@patchSize", patch.Length); - cmd.Parameters.AddWithValue("@patch", patch.ToArray()); - try - { - await cmd.ExecuteNonQueryAsync(); - } - catch (SQLiteException ex) - { - if (!ex.Message.StartsWith("constraint failed")) - throw; - } - - await patch.CopyToAsync(output); - } } \ No newline at end of file diff --git a/Wabbajack.Compiler/Wabbajack.Compiler.csproj b/Wabbajack.Compiler/Wabbajack.Compiler.csproj index 7c08cd41..62584356 100644 --- a/Wabbajack.Compiler/Wabbajack.Compiler.csproj +++ b/Wabbajack.Compiler/Wabbajack.Compiler.csproj @@ -8,7 +8,7 @@ - CS8600,CS8601,CS8618,CS8604 + CS8600,CS8601,CS8618,CS8604,CS1998 diff --git a/Wabbajack.Installer.Test/StandardInstallerTest.cs b/Wabbajack.Installer.Test/StandardInstallerTest.cs index 9d9133c5..bb8ac293 100644 --- a/Wabbajack.Installer.Test/StandardInstallerTest.cs +++ b/Wabbajack.Installer.Test/StandardInstallerTest.cs @@ -11,7 +11,6 @@ namespace Wabbajack.Installer.Test; public class StandardInstallerTest { - private readonly StandardInstaller _installer; private readonly TemporaryFileManager _manager; private readonly AbsolutePath _modList; private readonly IServiceProvider _provider; diff --git a/Wabbajack.Launcher/ViewModels/MainWindowViewModel.cs b/Wabbajack.Launcher/ViewModels/MainWindowViewModel.cs index 69522848..7bf75296 100644 --- a/Wabbajack.Launcher/ViewModels/MainWindowViewModel.cs +++ b/Wabbajack.Launcher/ViewModels/MainWindowViewModel.cs @@ -20,6 +20,7 @@ using Wabbajack.Networking.Http.Interfaces; using Wabbajack.Networking.NexusApi; using Wabbajack.Paths; using Wabbajack.Paths.IO; +#pragma warning disable SYSLIB0014 namespace Wabbajack.Launcher.ViewModels; diff --git a/Wabbajack.Launcher/Wabbajack.Launcher.csproj b/Wabbajack.Launcher/Wabbajack.Launcher.csproj index 2b668595..7dc12f64 100644 --- a/Wabbajack.Launcher/Wabbajack.Launcher.csproj +++ b/Wabbajack.Launcher/Wabbajack.Launcher.csproj @@ -8,7 +8,7 @@ - CS8600,CS8601,CS8618,CS8604 + CS8600,CS8601,CS8618,CS8604,CS1998 diff --git a/Wabbajack.Server/ApiKeyAuthorizationHandler.cs b/Wabbajack.Server/ApiKeyAuthorizationHandler.cs index 8a50a1f1..9ea02cb3 100644 --- a/Wabbajack.Server/ApiKeyAuthorizationHandler.cs +++ b/Wabbajack.Server/ApiKeyAuthorizationHandler.cs @@ -27,7 +27,6 @@ public class ApiKeyAuthenticationHandler : AuthenticationHandler> _tarKeys; private readonly Metrics _metricsStore; private readonly TarLog _tarLog; private readonly Client _githubClient; diff --git a/Wabbajack.Server/AppSettings.cs b/Wabbajack.Server/AppSettings.cs index b9436c50..5c51ebeb 100644 --- a/Wabbajack.Server/AppSettings.cs +++ b/Wabbajack.Server/AppSettings.cs @@ -21,8 +21,8 @@ public class AppSettings public string ProxyFolder { get; set; } public AbsolutePath ProxyPath => (AbsolutePath) ProxyFolder; public AbsolutePath TempPath => (AbsolutePath) TempFolder; - public string SpamWebHook { get; set; } = null; - public string HamWebHook { get; set; } = null; + public string SpamWebHook { get; set; } = ""; + public string HamWebHook { get; set; } = ""; public string DiscordKey { get; set; } diff --git a/Wabbajack.Server/Controllers/Metrics.cs b/Wabbajack.Server/Controllers/Metrics.cs index ec4f4ee6..085dcf79 100644 --- a/Wabbajack.Server/Controllers/Metrics.cs +++ b/Wabbajack.Server/Controllers/Metrics.cs @@ -100,24 +100,6 @@ public class MetricsController : ControllerBase public async Task GetMetrics([FromQuery] string action, [FromQuery] string from, [FromQuery] string? to, [FromQuery] string? subject) { throw new NotImplementedException(); - var parser = new Parser(); - - to ??= "now"; - - var toDate = parser.Parse(to).Start; - var fromDate = parser.Parse(from).Start; - - var records = _metricsStore.GetRecords(fromDate!.Value, toDate!.Value, action); - - Response.Headers.ContentType = "application/json"; - await foreach (var record in records) - { - if (!string.IsNullOrWhiteSpace(subject) && !record.Subject.Contains(subject)) - continue; - - await JsonSerializer.SerializeAsync(Response.Body, record); - await Response.Body.WriteAsync(EOL); - } } [HttpGet] diff --git a/Wabbajack.Server/Controllers/NexusCache.cs b/Wabbajack.Server/Controllers/NexusCache.cs index 24d810eb..753c8d1a 100644 --- a/Wabbajack.Server/Controllers/NexusCache.cs +++ b/Wabbajack.Server/Controllers/NexusCache.cs @@ -8,9 +8,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Wabbajack.Common; using Wabbajack.DTOs.JsonConverters; -using Wabbajack.Networking.NexusApi; using Wabbajack.Networking.NexusApi.DTOs; -using Wabbajack.Paths; using Wabbajack.Paths.IO; using Wabbajack.Server.Services; @@ -22,35 +20,19 @@ namespace Wabbajack.BuildServer.Controllers; [Route("/v1/games/")] public class NexusCache : ControllerBase { - private readonly NexusApi _api; private readonly ILogger _logger; - private AppSettings _settings; private readonly HttpClient _client; - private readonly AbsolutePath _cacheFolder; private readonly DTOSerializer _dtos; private readonly NexusCacheManager _cache; - public NexusCache(ILogger logger,AppSettings settings, HttpClient client, NexusCacheManager cache, DTOSerializer dtos) + public NexusCache(ILogger logger, HttpClient client, NexusCacheManager cache, DTOSerializer dtos) { - _settings = settings; _logger = logger; _client = client; _cache = cache; _dtos = dtos; } - private async Task ForwardToNexus(HttpRequest src) - { - _logger.LogInformation("Nexus Cache Forwarding: {path}", src.Path); - var request = new HttpRequestMessage(HttpMethod.Get, (Uri?)new Uri("https://api.nexusmods.com/" + src.Path)); - request.Headers.Add("apikey", (string?)src.Headers["apikey"]); - request.Headers.Add("User-Agent", (string?)src.Headers.UserAgent); - using var response = await _client.SendAsync(request); - Response.Headers.ContentType = "application/json"; - Response.StatusCode = (int)response.StatusCode; - await response.Content.CopyToAsync(Response.Body); - } - private async Task ForwardRequest(HttpRequest src, CancellationToken token) { _logger.LogInformation("Nexus Cache Forwarding: {path}", src.Path); diff --git a/Wabbajack.Server/Controllers/Proxy.cs b/Wabbajack.Server/Controllers/Proxy.cs index 3903cc64..eba4175d 100644 --- a/Wabbajack.Server/Controllers/Proxy.cs +++ b/Wabbajack.Server/Controllers/Proxy.cs @@ -141,7 +141,7 @@ public class Proxy : ControllerBase Response.Headers.Add( HeaderNames.ContentType, "application/octet-stream" ); - var result = await proxyDownloader.DownloadStream(archive, async s => { + var result = await proxyDownloader!.DownloadStream(archive, async s => { return await s.HashingCopy(async m => { var strmA = of.WriteAsync(m, token); diff --git a/Wabbajack.Server/Services/AbstractService.cs b/Wabbajack.Server/Services/AbstractService.cs index 87c7b034..ae7ef118 100644 --- a/Wabbajack.Server/Services/AbstractService.cs +++ b/Wabbajack.Server/Services/AbstractService.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Wabbajack.BuildServer; @@ -100,7 +101,7 @@ public static class AbstractServiceExtensions { public static void UseService(this IApplicationBuilder b) { - var poll = (IStartable) b.ApplicationServices.GetService(typeof(T)); + var poll = (IStartable) b.ApplicationServices.GetRequiredService(typeof(T)); poll.Start(); } } \ No newline at end of file diff --git a/Wabbajack.Server/Services/DiscordWebHook.cs b/Wabbajack.Server/Services/DiscordWebHook.cs index 1a01ca0c..f3390925 100644 --- a/Wabbajack.Server/Services/DiscordWebHook.cs +++ b/Wabbajack.Server/Services/DiscordWebHook.cs @@ -56,7 +56,7 @@ public class DiscordWebHook : AbstractService Channel.Ham => _settings.HamWebHook, _ => null }; - if (url == null) return; + if (string.IsNullOrWhiteSpace(url)) return; await _client.PostAsync(url, new StringContent(_dtos.Serialize(message), Encoding.UTF8, "application/json")); diff --git a/Wabbajack.Server/Services/NexusCacheManager.cs b/Wabbajack.Server/Services/NexusCacheManager.cs index e38d6eb2..01997b71 100644 --- a/Wabbajack.Server/Services/NexusCacheManager.cs +++ b/Wabbajack.Server/Services/NexusCacheManager.cs @@ -81,7 +81,7 @@ public class NexusCacheManager { data = await file.ReadAllBytesAsync(token); } - catch (FileNotFoundException ex) + catch (FileNotFoundException) { return default; } diff --git a/Wabbajack.Server/Wabbajack.Server.csproj b/Wabbajack.Server/Wabbajack.Server.csproj index 73d5e627..0cd08299 100644 --- a/Wabbajack.Server/Wabbajack.Server.csproj +++ b/Wabbajack.Server/Wabbajack.Server.csproj @@ -8,7 +8,7 @@ - CS8600,CS8601,CS8618,CS8604 + CS8600,CS8601,CS8618,CS8604,CS1998 diff --git a/Wabbajack.Services.OSIntegrated/ProtectedData.cs b/Wabbajack.Services.OSIntegrated/ProtectedData.cs index 72f6e297..268dd921 100644 --- a/Wabbajack.Services.OSIntegrated/ProtectedData.cs +++ b/Wabbajack.Services.OSIntegrated/ProtectedData.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using System.Security.Cryptography; using System.Text; @@ -74,7 +75,7 @@ public static class ProtectedData public static async Task FromEncryptedDataFile(this AbsolutePath destination) { - if (!destination.FileExists()) return default; + if (!destination.FileExists()) return Array.Empty(); await using var fs = destination.Open(FileMode.Open, FileAccess.Read, FileShare.Read); await using var enc = await fs.UnProtect(destination.FileName.ToString()); diff --git a/Wabbajack.Services.OSIntegrated/Wabbajack.Services.OSIntegrated.csproj b/Wabbajack.Services.OSIntegrated/Wabbajack.Services.OSIntegrated.csproj index 21fdb3e2..b2cfce82 100644 --- a/Wabbajack.Services.OSIntegrated/Wabbajack.Services.OSIntegrated.csproj +++ b/Wabbajack.Services.OSIntegrated/Wabbajack.Services.OSIntegrated.csproj @@ -6,6 +6,10 @@ $(VERSION) GPL-3.0-or-later + + + CS8600,CS8601,CS8618,CS8604,CS1998 + diff --git a/Wabbajack.VFS/IndexRoot.cs b/Wabbajack.VFS/IndexRoot.cs index 12070858..025383e6 100644 --- a/Wabbajack.VFS/IndexRoot.cs +++ b/Wabbajack.VFS/IndexRoot.cs @@ -15,7 +15,7 @@ public class IndexRoot IDictionary byFullPath, ILookup byHash, IDictionary byRoot, - ILookup byName) + ILookup byName) { AllFiles = aFiles; ByFullPath = byFullPath; @@ -56,7 +56,7 @@ public class IndexRoot .ToLookup(f => f.Hash)); var byName = Task.Run(() => allFiles.SelectMany(f => f.ThisAndAllChildren) - .ToLookup(f => f.Name)); + .ToLookup(f => f.Name)); var byRootPath = Task.Run(() => allFiles.ToDictionary(f => f.AbsoluteName));