diff --git a/Wabbajack.BuildServer.Test/IndexedFilesTests.cs b/Wabbajack.BuildServer.Test/IndexedFilesTests.cs index e8d594bc..c7af0997 100644 --- a/Wabbajack.BuildServer.Test/IndexedFilesTests.cs +++ b/Wabbajack.BuildServer.Test/IndexedFilesTests.cs @@ -53,14 +53,14 @@ namespace Wabbajack.BuildServer.Test public async Task CanNotifyOfInis() { var archive = - new Archive - { - State = new NexusDownloader.State + new Archive( + new NexusDownloader.State { Game = Game.SkyrimSpecialEdition, ModID = long.MaxValue >> 3, FileID = long.MaxValue >> 3, - }, + }) + { Name = Guid.NewGuid().ToString() }; Assert.True(await AuthorAPI.UploadPackagedInis(new[] {archive})); diff --git a/Wabbajack.BuildServer.Test/ModListValidationTests.cs b/Wabbajack.BuildServer.Test/ModListValidationTests.cs index 434cc824..761d2b5c 100644 --- a/Wabbajack.BuildServer.Test/ModListValidationTests.cs +++ b/Wabbajack.BuildServer.Test/ModListValidationTests.cs @@ -121,19 +121,14 @@ namespace Wabbajack.BuildServer.Test - var modListData = new ModList - { - Archives = new List + var modListData = new ModList(); + modListData.Archives.Add( + new Archive(new HTTPDownloader.State(MakeURL("test_archive.txt"))) { - new Archive - { - Hash = await test_archive_path.FileHashAsync(), - Name = "test_archive", - Size = test_archive_path.Size, - State = new HTTPDownloader.State(MakeURL("test_archive.txt")) - } - } - }; + Hash = await test_archive_path.FileHashAsync(), + Name = "test_archive", + Size = test_archive_path.Size, + }); var modListPath = "test_modlist.wabbajack".RelativeTo(Fixture.ServerPublicFolder); diff --git a/Wabbajack.BuildServer.Test/ModlistUpdater.cs b/Wabbajack.BuildServer.Test/ModlistUpdater.cs index e7d62c15..3a9a5f5d 100644 --- a/Wabbajack.BuildServer.Test/ModlistUpdater.cs +++ b/Wabbajack.BuildServer.Test/ModlistUpdater.cs @@ -42,10 +42,9 @@ namespace Wabbajack.BuildServer.Test { Payload = new IndexJob { - Archive = new Archive + Archive = new Archive(new HTTPDownloader.State(MakeURL("old_file_data.random"))) { Name = "Oldfile", - State = new HTTPDownloader.State(MakeURL("old_file_data.random")) } } }); @@ -54,10 +53,9 @@ namespace Wabbajack.BuildServer.Test { Payload = new IndexJob { - Archive = new Archive + Archive = new Archive(new HTTPDownloader.State(MakeURL("new_file_data.random"))) { Name = "Newfile", - State = new HTTPDownloader.State(MakeURL("new_file_data.random")) } } }); @@ -120,6 +118,5 @@ namespace Wabbajack.BuildServer.Test Assert.True($"{oldDataHash.ToHex()}_{newDataHash.ToHex()}".RelativeTo(Fixture.ServerUpdatesFolder).IsFile); } - } } diff --git a/Wabbajack.BuildServer/Controllers/IndexedFiles.cs b/Wabbajack.BuildServer/Controllers/IndexedFiles.cs index 6db8b742..30587e1a 100644 --- a/Wabbajack.BuildServer/Controllers/IndexedFiles.cs +++ b/Wabbajack.BuildServer/Controllers/IndexedFiles.cs @@ -102,10 +102,9 @@ namespace Wabbajack.BuildServer.Controllers Priority = Job.JobPriority.Low, Payload = new IndexJob { - Archive = new Archive + Archive = new Archive(data) { Name = entry.Name, - State = data } } }); diff --git a/Wabbajack.BuildServer/Controllers/ModlistUpdater.cs b/Wabbajack.BuildServer/Controllers/ModlistUpdater.cs index 1ccb2e11..3b6fca2c 100644 --- a/Wabbajack.BuildServer/Controllers/ModlistUpdater.cs +++ b/Wabbajack.BuildServer/Controllers/ModlistUpdater.cs @@ -175,15 +175,19 @@ namespace Wabbajack.BuildServer.Controllers var allMods = await api.GetModFiles(state.Game, state.ModID); var archive = allMods.files.Where(m => !string.IsNullOrEmpty(m.category_name)) .OrderBy(s => Math.Abs((long)s.size - origSize)) - .Select(s => new Archive { - Name = s.file_name, - Size = (long)s.size, - State = new NexusDownloader.State + .Select(s => + new Archive( + new NexusDownloader.State + { + Game = state.Game, + ModID = state.ModID, + FileID = s.file_id + }) { - Game = state.Game, - ModID = state.ModID, - FileID = s.file_id - }}).FirstOrDefault(); + Name = s.file_name, + Size = (long)s.size, + }) + .FirstOrDefault(); if (archive == null) { diff --git a/Wabbajack.BuildServer/Models/Jobs/EnqueueAllGameFiles.cs b/Wabbajack.BuildServer/Models/Jobs/EnqueueAllGameFiles.cs index 7f42cf04..f628f69c 100644 --- a/Wabbajack.BuildServer/Models/Jobs/EnqueueAllGameFiles.cs +++ b/Wabbajack.BuildServer/Models/Jobs/EnqueueAllGameFiles.cs @@ -53,7 +53,7 @@ namespace Wabbajack.BuildServer.Models.Jobs var with_hash = states.Where(state => state.Hash != default).ToList(); Utils.Log($"Inserting {with_hash.Count} jobs."); - var jobs = states.Select(state => new IndexJob {Archive = new Archive {Name = state.GameFile.FileName.ToString(), State = state}}) + var jobs = states.Select(state => new IndexJob {Archive = new Archive(state) { Name = state.GameFile.FileName.ToString()}}) .Select(j => new Job {Payload = j, RequiresNexus = j.UsesNexus}) .ToList(); diff --git a/Wabbajack.BuildServer/Models/Jobs/IndexDynDOLOD.cs b/Wabbajack.BuildServer/Models/Jobs/IndexDynDOLOD.cs index 20353260..7f065767 100644 --- a/Wabbajack.BuildServer/Models/Jobs/IndexDynDOLOD.cs +++ b/Wabbajack.BuildServer/Models/Jobs/IndexDynDOLOD.cs @@ -38,10 +38,9 @@ namespace Wabbajack.BuildServer.Models.Jobs { Payload = new IndexJob { - Archive = new Archive + Archive = new Archive(new MegaDownloader.State(url.ToString())) { Name = Guid.NewGuid() + ".7z", - State = new MegaDownloader.State(url.ToString()) } } }) diff --git a/Wabbajack.BuildServer/Models/Jobs/UploadToCDN.cs b/Wabbajack.BuildServer/Models/Jobs/UploadToCDN.cs index 1b9fa398..e3639aca 100644 --- a/Wabbajack.BuildServer/Models/Jobs/UploadToCDN.cs +++ b/Wabbajack.BuildServer/Models/Jobs/UploadToCDN.cs @@ -56,12 +56,11 @@ namespace Wabbajack.BuildServer.Models.Jobs Priority = Job.JobPriority.High, Payload = new IndexJob { - Archive = new Archive + Archive = new Archive(new HTTPDownloader.State(file.Uri)) { Name = file.MungedName, Size = file.Size, Hash = file.Hash, - State = new HTTPDownloader.State(file.Uri) } } }); diff --git a/Wabbajack.BuildServer/Models/Sql/SqlService.cs b/Wabbajack.BuildServer/Models/Sql/SqlService.cs index b1756323..24223f80 100644 --- a/Wabbajack.BuildServer/Models/Sql/SqlService.cs +++ b/Wabbajack.BuildServer/Models/Sql/SqlService.cs @@ -519,9 +519,8 @@ namespace Wabbajack.BuildServer.Model.Models var result = await conn.QueryFirstOrDefaultAsync(@"SELECT JsonState FROM dbo.DownloadStates WHERE Hash = @hash AND PrimaryKey like 'NexusDownloader+State|%'", new {Hash = (long)startingHash}); - return result == null ? null : new Archive + return result == null ? null : new Archive(result.FromJsonString()) { - State = result.FromJsonString(), Hash = startingHash }; } @@ -531,9 +530,8 @@ namespace Wabbajack.BuildServer.Model.Models await using var conn = await Open(); var result = await conn.QueryFirstOrDefaultAsync<(long Hash, string State)>(@"SELECT Hash, JsonState FROM dbo.DownloadStates WHERE PrimaryKey = @PrimaryKey", new {PrimaryKey = primaryKey}); - return result == default ? null : new Archive + return result == default ? null : new Archive(result.State.FromJsonString()) { - State = result.State.FromJsonString(), Hash = Hash.FromLong(result.Hash) }; } diff --git a/Wabbajack.CLI/Verbs/Changelog.cs b/Wabbajack.CLI/Verbs/Changelog.cs index 8ed0462d..63549a01 100644 --- a/Wabbajack.CLI/Verbs/Changelog.cs +++ b/Wabbajack.CLI/Verbs/Changelog.cs @@ -318,7 +318,7 @@ namespace Wabbajack.CLI.Verbs private static async Task GetTextFileFromModlist(AbsolutePath archive, ModList modlist, RelativePath sourceID) { - var installer = new MO2Installer(archive, modlist, default, default, null); + var installer = new MO2Installer(archive, modlist, default, default, parameters: null!); byte[] bytes = await installer.LoadBytesFromPath(sourceID); return Encoding.Default.GetString(bytes); } @@ -328,9 +328,9 @@ namespace Wabbajack.CLI.Verbs return header.Trim().Replace(" ", "").Replace(".", ""); } - private static string GetModName(Archive a) + private static string? GetModName(Archive a) { - var result = a.Name; + string? result = a.Name; if (a.State is IMetaState metaState) { diff --git a/Wabbajack.CLI/Verbs/DeleteFile.cs b/Wabbajack.CLI/Verbs/DeleteFile.cs index 2b48617e..a0de0efa 100644 --- a/Wabbajack.CLI/Verbs/DeleteFile.cs +++ b/Wabbajack.CLI/Verbs/DeleteFile.cs @@ -9,7 +9,7 @@ namespace Wabbajack.CLI.Verbs public class DeleteFile : AVerb { [Option('n', "name", Required = true, HelpText = @"Full name (as returned by my-files) of the file")] - public string? Name { get; set; } + public string Name { get; set; } = null!; protected override async Task Run() { diff --git a/Wabbajack.CLI/Verbs/DownloadUrl.cs b/Wabbajack.CLI/Verbs/DownloadUrl.cs index 9ea450a2..6263c649 100644 --- a/Wabbajack.CLI/Verbs/DownloadUrl.cs +++ b/Wabbajack.CLI/Verbs/DownloadUrl.cs @@ -35,7 +35,7 @@ namespace Wabbajack.CLI.Verbs new[] {state} .PMap(queue, async s => { - await s.Download(new Archive {Name = Path.GetFileName(Output)}, (AbsolutePath)Output); + await s.Download(new Archive(state: null!) {Name = Path.GetFileName(Output)}, (AbsolutePath)Output); }).Wait(); File.WriteAllLines(Output + ".meta", state.GetMetaIni()); diff --git a/Wabbajack.Common/Http/Client.cs b/Wabbajack.Common/Http/Client.cs index 098f8866..3a7bfb0a 100644 --- a/Wabbajack.Common/Http/Client.cs +++ b/Wabbajack.Common/Http/Client.cs @@ -11,7 +11,7 @@ namespace Wabbajack.Common.Http { public class Client { - public List<(string, string)> Headers = new List<(string, string)>(); + public List<(string, string?)> Headers = new List<(string, string?)>(); public List Cookies = new List(); public async Task GetAsync(string url, HttpCompletionOption responseHeadersRead = HttpCompletionOption.ResponseHeadersRead) { diff --git a/Wabbajack.Common/StoreHandlers/SteamHandler.cs b/Wabbajack.Common/StoreHandlers/SteamHandler.cs index c84e7794..6f9af723 100644 --- a/Wabbajack.Common/StoreHandlers/SteamHandler.cs +++ b/Wabbajack.Common/StoreHandlers/SteamHandler.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Security; using DynamicData; using Microsoft.Win32; +#nullable enable namespace Wabbajack.Common.StoreHandlers { @@ -21,9 +22,14 @@ namespace Wabbajack.Common.StoreHandlers public class SteamWorkshopItem { - public SteamGame? Game; + public readonly SteamGame Game; public int ItemID; public int Size; + + public SteamWorkshopItem(SteamGame game) + { + Game = game; + } } public class SteamHandler : AStoreHandler @@ -202,14 +208,14 @@ namespace Wabbajack.Common.StoreHandlers var bracketStart = 0; var bracketEnd = 0; - SteamWorkshopItem? currentItem = new SteamWorkshopItem(); + SteamWorkshopItem? currentItem = new SteamWorkshopItem(game); lines.Do(l => { if (end) return; if (currentItem == null) - currentItem = new SteamWorkshopItem(); + currentItem = new SteamWorkshopItem(game); var currentLine = lines.IndexOf(l); if (l.ContainsCaseInsensitive("\"appid\"") && !foundAppID) @@ -271,7 +277,6 @@ namespace Wabbajack.Common.StoreHandlers bracketStart = 0; bracketEnd = 0; - currentItem.Game = game; game.WorkshopItems.Add(currentItem); Utils.Log($"Found Steam Workshop item {currentItem.ItemID}"); diff --git a/Wabbajack.Lib/ABatchProcessor.cs b/Wabbajack.Lib/ABatchProcessor.cs index ef775efc..12a0aab8 100644 --- a/Wabbajack.Lib/ABatchProcessor.cs +++ b/Wabbajack.Lib/ABatchProcessor.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; using Wabbajack.Common; using Wabbajack.Common.StatusFeed; using Wabbajack.VirtualFileSystem; -#nullable enable namespace Wabbajack.Lib { diff --git a/Wabbajack.Lib/ACompiler.cs b/Wabbajack.Lib/ACompiler.cs index ef5490eb..06654835 100644 --- a/Wabbajack.Lib/ACompiler.cs +++ b/Wabbajack.Lib/ACompiler.cs @@ -14,7 +14,6 @@ using Wabbajack.VirtualFileSystem; using Directory = Alphaleonis.Win32.Filesystem.Directory; using File = Alphaleonis.Win32.Filesystem.File; using Path = Alphaleonis.Win32.Filesystem.Path; -#nullable enable namespace Wabbajack.Lib { @@ -243,10 +242,7 @@ namespace Wabbajack.Lib Error( $"No download metadata found for {archive.Name}, please use MO2 to query info or add a .meta file and try again."); - var result = new Archive - { - State = await DownloadDispatcher.ResolveArchive(archive.IniData) - }; + var result = new Archive(await DownloadDispatcher.ResolveArchive(archive.IniData)); if (result.State == null) Error($"{archive.Name} could not be handled by any of the downloaders"); diff --git a/Wabbajack.Lib/AInstaller.cs b/Wabbajack.Lib/AInstaller.cs index ac103756..2ddbceda 100644 --- a/Wabbajack.Lib/AInstaller.cs +++ b/Wabbajack.Lib/AInstaller.cs @@ -13,7 +13,6 @@ using Directory = Alphaleonis.Win32.Filesystem.Directory; using File = Alphaleonis.Win32.Filesystem.File; using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo; using Path = Alphaleonis.Win32.Filesystem.Path; -#nullable enable namespace Wabbajack.Lib { @@ -30,9 +29,9 @@ namespace Wabbajack.Lib public ModList ModList { get; private set; } public Dictionary HashedArchives { get; } = new Dictionary(); - public SystemParameters SystemParameters { get; set; } + public SystemParameters? SystemParameters { get; set; } - public AInstaller(AbsolutePath archive, ModList modList, AbsolutePath outputFolder, AbsolutePath downloadFolder, SystemParameters parameters, int steps) + public AInstaller(AbsolutePath archive, ModList modList, AbsolutePath outputFolder, AbsolutePath downloadFolder, SystemParameters? parameters, int steps) : base(steps) { ModList = modList; @@ -168,6 +167,10 @@ namespace Wabbajack.Lib .PDoIndexed(queue, async (idx, group) => { Utils.Status("Installing files", Percent.FactoryPutInRange(idx, vFiles.Count)); + if (group.Key == null) + { + throw new ArgumentNullException("FromFile was null"); + } var firstDest = OutputFolder.Combine(group.First().To); await CopyFile(group.Key.StagedPath, firstDest, true); @@ -175,7 +178,6 @@ namespace Wabbajack.Lib { await CopyFile(firstDest, OutputFolder.Combine(copy.To), false); } - }); Status("Unstaging files"); diff --git a/Wabbajack.Lib/ClientAPI.cs b/Wabbajack.Lib/ClientAPI.cs index 80fc2043..959fbbf7 100644 --- a/Wabbajack.Lib/ClientAPI.cs +++ b/Wabbajack.Lib/ClientAPI.cs @@ -1,7 +1,6 @@ using System.Threading.Tasks; using Wabbajack.Common; using Wabbajack.Lib.Exceptions; -#nullable enable namespace Wabbajack.Lib { diff --git a/Wabbajack.Lib/CompilationSteps/ACompilationStep.cs b/Wabbajack.Lib/CompilationSteps/ACompilationStep.cs index 4427334f..e00ac6e7 100644 --- a/Wabbajack.Lib/CompilationSteps/ACompilationStep.cs +++ b/Wabbajack.Lib/CompilationSteps/ACompilationStep.cs @@ -1,5 +1,4 @@ using System.Threading.Tasks; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/DeconstructBSAs.cs b/Wabbajack.Lib/CompilationSteps/DeconstructBSAs.cs index d8ea17f5..5e37d3d4 100644 --- a/Wabbajack.Lib/CompilationSteps/DeconstructBSAs.cs +++ b/Wabbajack.Lib/CompilationSteps/DeconstructBSAs.cs @@ -8,7 +8,6 @@ using Newtonsoft.Json; using Wabbajack.Common; using Wabbajack.Common.StatusFeed.Errors; using Wabbajack.VirtualFileSystem; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { @@ -80,12 +79,12 @@ namespace Wabbajack.Lib.CompilationSteps CreateBSA directive; using (var bsa = BSADispatch.OpenRead(source.AbsolutePath)) { - directive = new CreateBSA + directive = new CreateBSA( + state: bsa.State, + items: bsa.Files.Select(f => f.State).ToList()) { To = source.Path, TempID = (RelativePath)id, - State = bsa.State, - FileStates = bsa.Files.Select(f => f.State).ToList() }; } diff --git a/Wabbajack.Lib/CompilationSteps/DirectMatch.cs b/Wabbajack.Lib/CompilationSteps/DirectMatch.cs index 6f883117..0f57cee3 100644 --- a/Wabbajack.Lib/CompilationSteps/DirectMatch.cs +++ b/Wabbajack.Lib/CompilationSteps/DirectMatch.cs @@ -2,7 +2,6 @@ using System.Threading.Tasks; using Alphaleonis.Win32.Filesystem; using Newtonsoft.Json; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/DropAll.cs b/Wabbajack.Lib/CompilationSteps/DropAll.cs index 0c3a6fc4..bcbc32f3 100644 --- a/Wabbajack.Lib/CompilationSteps/DropAll.cs +++ b/Wabbajack.Lib/CompilationSteps/DropAll.cs @@ -1,7 +1,6 @@ using System.Threading.Tasks; using Newtonsoft.Json; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/ICompilationStep.cs b/Wabbajack.Lib/CompilationSteps/ICompilationStep.cs index 68b8b73b..eafa5914 100644 --- a/Wabbajack.Lib/CompilationSteps/ICompilationStep.cs +++ b/Wabbajack.Lib/CompilationSteps/ICompilationStep.cs @@ -1,5 +1,4 @@ using System.Threading.Tasks; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IgnoreDisabledMods.cs b/Wabbajack.Lib/CompilationSteps/IgnoreDisabledMods.cs index f9b9f1bc..3fd9912b 100644 --- a/Wabbajack.Lib/CompilationSteps/IgnoreDisabledMods.cs +++ b/Wabbajack.Lib/CompilationSteps/IgnoreDisabledMods.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using Alphaleonis.Win32.Filesystem; using Newtonsoft.Json; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IgnoreEndsWith.cs b/Wabbajack.Lib/CompilationSteps/IgnoreEndsWith.cs index 53b44621..b9918d95 100644 --- a/Wabbajack.Lib/CompilationSteps/IgnoreEndsWith.cs +++ b/Wabbajack.Lib/CompilationSteps/IgnoreEndsWith.cs @@ -1,6 +1,5 @@ using System.Threading.Tasks; using Newtonsoft.Json; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IgnoreGameFiles.cs b/Wabbajack.Lib/CompilationSteps/IgnoreGameFiles.cs index 9b95d35d..7581c566 100644 --- a/Wabbajack.Lib/CompilationSteps/IgnoreGameFiles.cs +++ b/Wabbajack.Lib/CompilationSteps/IgnoreGameFiles.cs @@ -1,7 +1,6 @@ using System.Threading.Tasks; using Newtonsoft.Json; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IgnoreGameFilesIfGameFolderFilesExist.cs b/Wabbajack.Lib/CompilationSteps/IgnoreGameFilesIfGameFolderFilesExist.cs index 59026899..6f86f783 100644 --- a/Wabbajack.Lib/CompilationSteps/IgnoreGameFilesIfGameFolderFilesExist.cs +++ b/Wabbajack.Lib/CompilationSteps/IgnoreGameFilesIfGameFolderFilesExist.cs @@ -1,7 +1,6 @@ using System.Threading.Tasks; using Alphaleonis.Win32.Filesystem; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IgnorePathContains.cs b/Wabbajack.Lib/CompilationSteps/IgnorePathContains.cs index 1a8c627b..eac01fe7 100644 --- a/Wabbajack.Lib/CompilationSteps/IgnorePathContains.cs +++ b/Wabbajack.Lib/CompilationSteps/IgnorePathContains.cs @@ -1,6 +1,5 @@ using System.Threading.Tasks; using Newtonsoft.Json; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IgnoreRegex.cs b/Wabbajack.Lib/CompilationSteps/IgnoreRegex.cs index abf48183..739ad00c 100644 --- a/Wabbajack.Lib/CompilationSteps/IgnoreRegex.cs +++ b/Wabbajack.Lib/CompilationSteps/IgnoreRegex.cs @@ -1,7 +1,6 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using Newtonsoft.Json; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IgnoreStartsWith.cs b/Wabbajack.Lib/CompilationSteps/IgnoreStartsWith.cs index 087ea169..5abad699 100644 --- a/Wabbajack.Lib/CompilationSteps/IgnoreStartsWith.cs +++ b/Wabbajack.Lib/CompilationSteps/IgnoreStartsWith.cs @@ -1,6 +1,5 @@ using System.Threading.Tasks; using Newtonsoft.Json; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IgnoreWabbajackInstallCruft.cs b/Wabbajack.Lib/CompilationSteps/IgnoreWabbajackInstallCruft.cs index c1f36243..e8e71212 100644 --- a/Wabbajack.Lib/CompilationSteps/IgnoreWabbajackInstallCruft.cs +++ b/Wabbajack.Lib/CompilationSteps/IgnoreWabbajackInstallCruft.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Threading.Tasks; using Newtonsoft.Json; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IncludeAll.cs b/Wabbajack.Lib/CompilationSteps/IncludeAll.cs index 6f229c45..db63b34b 100644 --- a/Wabbajack.Lib/CompilationSteps/IncludeAll.cs +++ b/Wabbajack.Lib/CompilationSteps/IncludeAll.cs @@ -1,7 +1,6 @@ using System.Threading.Tasks; using Alphaleonis.Win32.Filesystem; using Newtonsoft.Json; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IncludeAllConfigs.cs b/Wabbajack.Lib/CompilationSteps/IncludeAllConfigs.cs index eb73f724..9bf53920 100644 --- a/Wabbajack.Lib/CompilationSteps/IncludeAllConfigs.cs +++ b/Wabbajack.Lib/CompilationSteps/IncludeAllConfigs.cs @@ -2,7 +2,6 @@ using Alphaleonis.Win32.Filesystem; using Newtonsoft.Json; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IncludeDummyESPs.cs b/Wabbajack.Lib/CompilationSteps/IncludeDummyESPs.cs index 127d7555..89466c52 100644 --- a/Wabbajack.Lib/CompilationSteps/IncludeDummyESPs.cs +++ b/Wabbajack.Lib/CompilationSteps/IncludeDummyESPs.cs @@ -2,7 +2,6 @@ using Alphaleonis.Win32.Filesystem; using Newtonsoft.Json; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IncludeLOOTFiles.cs b/Wabbajack.Lib/CompilationSteps/IncludeLOOTFiles.cs index a34e0a3f..5a89a131 100644 --- a/Wabbajack.Lib/CompilationSteps/IncludeLOOTFiles.cs +++ b/Wabbajack.Lib/CompilationSteps/IncludeLOOTFiles.cs @@ -2,7 +2,6 @@ using Alphaleonis.Win32.Filesystem; using Newtonsoft.Json; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IncludeModIniData.cs b/Wabbajack.Lib/CompilationSteps/IncludeModIniData.cs index 70bc66b8..f1def248 100644 --- a/Wabbajack.Lib/CompilationSteps/IncludeModIniData.cs +++ b/Wabbajack.Lib/CompilationSteps/IncludeModIniData.cs @@ -2,7 +2,6 @@ using Alphaleonis.Win32.Filesystem; using Newtonsoft.Json; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IncludeOtherProfiles.cs b/Wabbajack.Lib/CompilationSteps/IncludeOtherProfiles.cs index a6190347..9c89d361 100644 --- a/Wabbajack.Lib/CompilationSteps/IncludeOtherProfiles.cs +++ b/Wabbajack.Lib/CompilationSteps/IncludeOtherProfiles.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using Alphaleonis.Win32.Filesystem; using Newtonsoft.Json; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IncludePatches.cs b/Wabbajack.Lib/CompilationSteps/IncludePatches.cs index 228cc7e3..65cb6b40 100644 --- a/Wabbajack.Lib/CompilationSteps/IncludePatches.cs +++ b/Wabbajack.Lib/CompilationSteps/IncludePatches.cs @@ -6,7 +6,6 @@ using Alphaleonis.Win32.Filesystem; using Newtonsoft.Json; using Wabbajack.Common; using Wabbajack.VirtualFileSystem; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IncludePropertyFiles.cs b/Wabbajack.Lib/CompilationSteps/IncludePropertyFiles.cs index eb877762..3add0f20 100644 --- a/Wabbajack.Lib/CompilationSteps/IncludePropertyFiles.cs +++ b/Wabbajack.Lib/CompilationSteps/IncludePropertyFiles.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using Alphaleonis.Win32.Filesystem; using Newtonsoft.Json; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IncludeRegex.cs b/Wabbajack.Lib/CompilationSteps/IncludeRegex.cs index e5fbda99..edd9128c 100644 --- a/Wabbajack.Lib/CompilationSteps/IncludeRegex.cs +++ b/Wabbajack.Lib/CompilationSteps/IncludeRegex.cs @@ -2,7 +2,6 @@ using System.Threading.Tasks; using Alphaleonis.Win32.Filesystem; using Newtonsoft.Json; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IncludeSteamWorkshopItems.cs b/Wabbajack.Lib/CompilationSteps/IncludeSteamWorkshopItems.cs index 68cd72bd..1bcbef60 100644 --- a/Wabbajack.Lib/CompilationSteps/IncludeSteamWorkshopItems.cs +++ b/Wabbajack.Lib/CompilationSteps/IncludeSteamWorkshopItems.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using Alphaleonis.Win32.Filesystem; using Wabbajack.Common; using Wabbajack.Common.StoreHandlers; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IncludeStubbedConfigfiles.cs b/Wabbajack.Lib/CompilationSteps/IncludeStubbedConfigfiles.cs index b1c1abff..392cb1b3 100644 --- a/Wabbajack.Lib/CompilationSteps/IncludeStubbedConfigfiles.cs +++ b/Wabbajack.Lib/CompilationSteps/IncludeStubbedConfigfiles.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using Alphaleonis.Win32.Filesystem; using Newtonsoft.Json; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IncludeTaggedMods.cs b/Wabbajack.Lib/CompilationSteps/IncludeTaggedMods.cs index 2409568a..d2d8a06f 100644 --- a/Wabbajack.Lib/CompilationSteps/IncludeTaggedMods.cs +++ b/Wabbajack.Lib/CompilationSteps/IncludeTaggedMods.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using Alphaleonis.Win32.Filesystem; using Newtonsoft.Json; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IncludeThisProfile.cs b/Wabbajack.Lib/CompilationSteps/IncludeThisProfile.cs index d01cf628..4d0141a3 100644 --- a/Wabbajack.Lib/CompilationSteps/IncludeThisProfile.cs +++ b/Wabbajack.Lib/CompilationSteps/IncludeThisProfile.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using Alphaleonis.Win32.Filesystem; using Newtonsoft.Json; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/IncludeVortexDeployment.cs b/Wabbajack.Lib/CompilationSteps/IncludeVortexDeployment.cs index 303afbfa..19a386dc 100644 --- a/Wabbajack.Lib/CompilationSteps/IncludeVortexDeployment.cs +++ b/Wabbajack.Lib/CompilationSteps/IncludeVortexDeployment.cs @@ -3,7 +3,6 @@ using System.IO; using System.Linq; using System.Threading.Tasks; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/CompilationSteps/PatchStockESMs.cs b/Wabbajack.Lib/CompilationSteps/PatchStockESMs.cs index fabc3072..2a8f9d12 100644 --- a/Wabbajack.Lib/CompilationSteps/PatchStockESMs.cs +++ b/Wabbajack.Lib/CompilationSteps/PatchStockESMs.cs @@ -4,7 +4,6 @@ using Newtonsoft.Json; using Wabbajack.Common; using File = Alphaleonis.Win32.Filesystem.File; using Path = Alphaleonis.Win32.Filesystem.Path; -#nullable enable namespace Wabbajack.Lib.CompilationSteps { diff --git a/Wabbajack.Lib/Data.cs b/Wabbajack.Lib/Data.cs index c48e75ac..4fe5a4c5 100644 --- a/Wabbajack.Lib/Data.cs +++ b/Wabbajack.Lib/Data.cs @@ -43,22 +43,22 @@ namespace Wabbajack.Lib /// /// Archives required by this modlist /// - public List Archives; + public List Archives = new List(); /// /// Author of the ModList /// - public string Author; + public string Author = string.Empty; /// /// Description of the ModList /// - public string Description; + public string Description = string.Empty; /// /// Install directives /// - public List Directives; + public List Directives = new List(); /// /// The game variant to which this game applies @@ -78,12 +78,12 @@ namespace Wabbajack.Lib /// /// Name of the ModList /// - public string Name; + public string Name = string.Empty; /// /// readme path or website /// - public string Readme; + public string Readme = string.Empty; /// /// Whether readme is a website @@ -93,12 +93,12 @@ namespace Wabbajack.Lib /// /// The build version of Wabbajack used when compiling the Modlist /// - public Version WabbajackVersion; + public Version? WabbajackVersion; /// /// Website of the ModList /// - public Uri Website; + public Uri? Website; /// /// The size of all the archives once they're downloaded @@ -134,7 +134,7 @@ namespace Wabbajack.Lib public class IgnoredDirectly : Directive { - public string Reason; + public string Reason = string.Empty; } public class NoMatch : IgnoredDirectly @@ -190,12 +190,12 @@ namespace Wabbajack.Lib [JsonName("FromArchive")] public class FromArchive : Directive { - private string _fullPath; + private string? _fullPath; public HashRelativePath ArchiveHashPath { get; set; } [JsonIgnore] - public VirtualFile FromFile { get; set; } + public VirtualFile? FromFile { get; set; } [JsonIgnore] public string FullPath => _fullPath ??= string.Join("|", ArchiveHashPath); @@ -205,8 +205,17 @@ namespace Wabbajack.Lib public class CreateBSA : Directive { public RelativePath TempID { get; set; } - public ArchiveStateObject State { get; set; } - public List FileStates { get; set; } + public ArchiveStateObject State { get; } + public List FileStates { get; set; } = new List(); + + public CreateBSA(ArchiveStateObject state, IEnumerable? items = null) + { + State = state; + if (items != null) + { + FileStates.AddRange(items); + } + } } [JsonName("PatchedFromArchive")] @@ -231,7 +240,7 @@ namespace Wabbajack.Lib public class MergedPatch : Directive { public RelativePath PatchID { get; set; } - public List Sources { get; set; } + public List Sources { get; set; } = new List(); } [JsonName("Archive")] @@ -245,49 +254,33 @@ namespace Wabbajack.Lib /// /// Meta INI for the downloaded archive /// - public string Meta { get; set; } + public string? Meta { get; set; } /// /// Human friendly name of this archive /// - public string Name { get; set; } + public string Name { get; set; } = string.Empty; public long Size { get; set; } - public AbstractDownloadState State { get; set; } + public AbstractDownloadState State { get; } + + public Archive(AbstractDownloadState state) + { + State = state; + } } public class IndexedArchive { - public dynamic IniData; - public string Meta; - public string Name; - public VirtualFile File { get; internal set; } - } + public dynamic? IniData; + public string Meta = string.Empty; + public string Name = string.Empty; + public VirtualFile File { get; } - /// - /// A archive entry - /// - public class IndexedEntry - { - /// - /// MurMur3 hash of this file - /// - public string Hash; - - /// - /// Path in the archive to this file - /// - public string Path; - - /// - /// Size of the file (uncompressed) - /// - public long Size; - } - - public class IndexedArchiveEntry : IndexedEntry - { - public string[] HashPath; + public IndexedArchive(VirtualFile file) + { + File = file; + } } } diff --git a/Wabbajack.Lib/Downloaders/AFKModsDownloader.cs b/Wabbajack.Lib/Downloaders/AFKModsDownloader.cs index 62f84da3..fdeb1385 100644 --- a/Wabbajack.Lib/Downloaders/AFKModsDownloader.cs +++ b/Wabbajack.Lib/Downloaders/AFKModsDownloader.cs @@ -1,5 +1,4 @@ using System; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/AbstractDownloadState.cs b/Wabbajack.Lib/Downloaders/AbstractDownloadState.cs index 196934d7..e5ea3c75 100644 --- a/Wabbajack.Lib/Downloaders/AbstractDownloadState.cs +++ b/Wabbajack.Lib/Downloaders/AbstractDownloadState.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using Newtonsoft.Json; using Wabbajack.Common; using Wabbajack.Lib.Validation; -#nullable enable namespace Wabbajack.Lib.Downloaders { @@ -84,7 +83,9 @@ namespace Wabbajack.Lib.Downloaders public async Task Download(AbsolutePath destination) { destination.Parent.CreateDirectory(); - return await Download(new Archive {Name = (string)destination.FileName}, destination); + // ToDo + // Is this null override needed? Why is state allowed to be null here? + return await Download(new Archive(state: null!) {Name = (string)destination.FileName}, destination); } /// diff --git a/Wabbajack.Lib/Downloaders/AbstractIPS4Downloader.cs b/Wabbajack.Lib/Downloaders/AbstractIPS4Downloader.cs index 5bff0424..cca6e4cc 100644 --- a/Wabbajack.Lib/Downloaders/AbstractIPS4Downloader.cs +++ b/Wabbajack.Lib/Downloaders/AbstractIPS4Downloader.cs @@ -8,7 +8,6 @@ using System.Web; using Newtonsoft.Json; using Wabbajack.Common; using Wabbajack.Lib.Validation; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/AbstractNeedsLoginDownloader.cs b/Wabbajack.Lib/Downloaders/AbstractNeedsLoginDownloader.cs index e256b1b4..a6a4e681 100644 --- a/Wabbajack.Lib/Downloaders/AbstractNeedsLoginDownloader.cs +++ b/Wabbajack.Lib/Downloaders/AbstractNeedsLoginDownloader.cs @@ -21,7 +21,17 @@ namespace Wabbajack.Lib.Downloaders private readonly string _encryptedKeyName; private readonly string _cookieDomain; private readonly string _cookieName; - internal Common.Http.Client AuthedClient; + // ToDo + // Remove null assignment. Either add nullability to type, or figure way to prepare it safely + public Common.Http.Client AuthedClient { get; private set; } = null!; + + public ReactiveCommand TriggerLogin { get; } + public ReactiveCommand ClearLogin { get; } + public IObservable IsLoggedIn => Utils.HaveEncryptedJsonObservable(_encryptedKeyName); + public abstract string SiteName { get; } + public virtual IObservable? MetaInfo { get; } + public abstract Uri SiteURL { get; } + public virtual Uri? IconUri { get; } /// /// Sets up all the login facilites needed for a INeedsLogin downloader based on having the user log @@ -48,14 +58,6 @@ namespace Wabbajack.Lib.Downloaders execute: () => Utils.CatchAndLog(() => Utils.DeleteEncryptedJson(_encryptedKeyName)), canExecute: IsLoggedIn.ObserveOnGuiThread()); } - - public ReactiveCommand TriggerLogin { get; } - public ReactiveCommand ClearLogin { get; } - public IObservable IsLoggedIn => Utils.HaveEncryptedJsonObservable(_encryptedKeyName); - public abstract string SiteName { get; } - public virtual IObservable MetaInfo { get; } - public abstract Uri SiteURL { get; } - public virtual Uri IconUri { get; } protected virtual async Task WhileWaiting(IWebDriver browser) { @@ -120,7 +122,7 @@ namespace Wabbajack.Lib.Downloaders Downloader = downloader; } public override string ShortDescription => $"Getting {Downloader.SiteName} Login"; - public override string ExtendedDescription { get; } + public override string ExtendedDescription { get; } = string.Empty; private readonly TaskCompletionSource _source = new TaskCompletionSource(); public Task Task => _source.Task; diff --git a/Wabbajack.Lib/Downloaders/BethesdaNetDownloader.cs b/Wabbajack.Lib/Downloaders/BethesdaNetDownloader.cs index 8ca7a9f3..f7b9ea30 100644 --- a/Wabbajack.Lib/Downloaders/BethesdaNetDownloader.cs +++ b/Wabbajack.Lib/Downloaders/BethesdaNetDownloader.cs @@ -24,7 +24,6 @@ using Wabbajack.Lib.Validation; using File = Alphaleonis.Win32.Filesystem.File; using Game = Wabbajack.Common.Game; using Path = Alphaleonis.Win32.Filesystem.Path; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/DeadlyStreamDownloader.cs b/Wabbajack.Lib/Downloaders/DeadlyStreamDownloader.cs index a1131998..2da650c1 100644 --- a/Wabbajack.Lib/Downloaders/DeadlyStreamDownloader.cs +++ b/Wabbajack.Lib/Downloaders/DeadlyStreamDownloader.cs @@ -1,5 +1,4 @@ using System; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/DownloadDispatcher.cs b/Wabbajack.Lib/Downloaders/DownloadDispatcher.cs index 7bdb271a..4c680dfe 100644 --- a/Wabbajack.Lib/Downloaders/DownloadDispatcher.cs +++ b/Wabbajack.Lib/Downloaders/DownloadDispatcher.cs @@ -43,7 +43,7 @@ namespace Wabbajack.Lib.Downloaders IndexedDownloaders = Downloaders.ToDictionary(d => d.GetType()); } - public static async Task Infer(Uri uri) + public static async Task Infer(Uri uri) { foreach (var inf in Inferencers) { @@ -74,7 +74,7 @@ namespace Wabbajack.Lib.Downloaders /// /// /// - public static AbstractDownloadState ResolveArchive(string url) + public static AbstractDownloadState? ResolveArchive(string url) { return Downloaders.OfType().Select(d => d.GetDownloaderState(url)).FirstOrDefault(result => result != null); } @@ -112,10 +112,9 @@ namespace Wabbajack.Lib.Downloaders var patchName = $"{archive.Hash.ToHex()}_{upgrade.Hash.ToHex()}"; var patchPath = destination.Parent.Combine("_Patch_" + patchName); - var patchState = new Archive + var patchState = new Archive(new HTTPDownloader.State($"https://wabbajackcdn.b-cdn.net/updates/{patchName}")) { Name = patchName, - State = new HTTPDownloader.State($"https://wabbajackcdn.b-cdn.net/updates/{patchName}") }; var patchResult = await Download(patchState, patchPath); diff --git a/Wabbajack.Lib/Downloaders/DownloaderUtils.cs b/Wabbajack.Lib/Downloaders/DownloaderUtils.cs index fbe309d8..f798856f 100644 --- a/Wabbajack.Lib/Downloaders/DownloaderUtils.cs +++ b/Wabbajack.Lib/Downloaders/DownloaderUtils.cs @@ -4,7 +4,7 @@ namespace Wabbajack.Lib.Downloaders { public static class DownloaderUtils { - public static Uri GetDirectURL(dynamic meta) + public static Uri? GetDirectURL(dynamic? meta) { var url = meta?.General?.directURL; if (url == null) return null; diff --git a/Wabbajack.Lib/Downloaders/DropboxDownloader.cs b/Wabbajack.Lib/Downloaders/DropboxDownloader.cs index 270b4299..0247b14e 100644 --- a/Wabbajack.Lib/Downloaders/DropboxDownloader.cs +++ b/Wabbajack.Lib/Downloaders/DropboxDownloader.cs @@ -2,7 +2,6 @@ using System.Threading.Tasks; using System.Web; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/GameFileSourceDownloader.cs b/Wabbajack.Lib/Downloaders/GameFileSourceDownloader.cs index b4b2ace7..b8dbdceb 100644 --- a/Wabbajack.Lib/Downloaders/GameFileSourceDownloader.cs +++ b/Wabbajack.Lib/Downloaders/GameFileSourceDownloader.cs @@ -4,7 +4,6 @@ using Wabbajack.Common; using Wabbajack.Common.Serialization.Json; using Wabbajack.Lib.Validation; using Game = Wabbajack.Common.Game; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/GoogleDriveDownloader.cs b/Wabbajack.Lib/Downloaders/GoogleDriveDownloader.cs index db385314..26602978 100644 --- a/Wabbajack.Lib/Downloaders/GoogleDriveDownloader.cs +++ b/Wabbajack.Lib/Downloaders/GoogleDriveDownloader.cs @@ -5,7 +5,6 @@ using Wabbajack.Common; using Wabbajack.Common.Serialization.Json; using Wabbajack.Lib.Exceptions; using Wabbajack.Lib.Validation; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/HTTPDownloader.cs b/Wabbajack.Lib/Downloaders/HTTPDownloader.cs index 12455dca..912306a2 100644 --- a/Wabbajack.Lib/Downloaders/HTTPDownloader.cs +++ b/Wabbajack.Lib/Downloaders/HTTPDownloader.cs @@ -10,7 +10,6 @@ using Wabbajack.Common; using Wabbajack.Common.Serialization.Json; using Wabbajack.Lib.Exceptions; using Wabbajack.Lib.Validation; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/IDownloader.cs b/Wabbajack.Lib/Downloaders/IDownloader.cs index b43aef76..17ced7bc 100644 --- a/Wabbajack.Lib/Downloaders/IDownloader.cs +++ b/Wabbajack.Lib/Downloaders/IDownloader.cs @@ -1,5 +1,4 @@ using System.Threading.Tasks; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/INeedsLogin.cs b/Wabbajack.Lib/Downloaders/INeedsLogin.cs index d22a6f05..8ce03afe 100644 --- a/Wabbajack.Lib/Downloaders/INeedsLogin.cs +++ b/Wabbajack.Lib/Downloaders/INeedsLogin.cs @@ -2,7 +2,6 @@ using System.Reactive; using System.Security; using ReactiveUI; -#nullable enable namespace Wabbajack.Lib.Downloaders { @@ -12,7 +11,7 @@ namespace Wabbajack.Lib.Downloaders ReactiveCommand ClearLogin { get; } IObservable IsLoggedIn { get; } string SiteName { get; } - IObservable MetaInfo { get; } + IObservable? MetaInfo { get; } Uri SiteURL { get; } Uri? IconUri { get; } } diff --git a/Wabbajack.Lib/Downloaders/IUrlDownloader.cs b/Wabbajack.Lib/Downloaders/IUrlDownloader.cs index 7650e0e5..1b4384af 100644 --- a/Wabbajack.Lib/Downloaders/IUrlDownloader.cs +++ b/Wabbajack.Lib/Downloaders/IUrlDownloader.cs @@ -2,6 +2,6 @@ { public interface IUrlDownloader : IDownloader { - AbstractDownloadState GetDownloaderState(string url); + AbstractDownloadState? GetDownloaderState(string url); } } diff --git a/Wabbajack.Lib/Downloaders/LoversLabDownloader.cs b/Wabbajack.Lib/Downloaders/LoversLabDownloader.cs index e1b7a06d..c319fb7a 100644 --- a/Wabbajack.Lib/Downloaders/LoversLabDownloader.cs +++ b/Wabbajack.Lib/Downloaders/LoversLabDownloader.cs @@ -7,7 +7,6 @@ using Newtonsoft.Json; using Wabbajack.Common; using Wabbajack.Common.Serialization.Json; using Wabbajack.Lib.WebAutomation; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/MEGADownloader.cs b/Wabbajack.Lib/Downloaders/MEGADownloader.cs index 02977628..e318a06a 100644 --- a/Wabbajack.Lib/Downloaders/MEGADownloader.cs +++ b/Wabbajack.Lib/Downloaders/MEGADownloader.cs @@ -8,7 +8,6 @@ using Newtonsoft.Json; using ReactiveUI; using Wabbajack.Common; using Wabbajack.Common.Serialization.Json; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/ManualDownloader.cs b/Wabbajack.Lib/Downloaders/ManualDownloader.cs index b9f4ba72..805ebc45 100644 --- a/Wabbajack.Lib/Downloaders/ManualDownloader.cs +++ b/Wabbajack.Lib/Downloaders/ManualDownloader.cs @@ -6,7 +6,6 @@ using Wabbajack.Common; using Wabbajack.Common.IO; using Wabbajack.Common.Serialization.Json; using Wabbajack.Lib.Validation; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/MediaFireDownloader.cs b/Wabbajack.Lib/Downloaders/MediaFireDownloader.cs index c895002a..a9678fd8 100644 --- a/Wabbajack.Lib/Downloaders/MediaFireDownloader.cs +++ b/Wabbajack.Lib/Downloaders/MediaFireDownloader.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using Wabbajack.Common; using Wabbajack.Lib.Validation; using Wabbajack.Lib.WebAutomation; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/ModDBDownloader.cs b/Wabbajack.Lib/Downloaders/ModDBDownloader.cs index 1a3b51fe..9d0022ae 100644 --- a/Wabbajack.Lib/Downloaders/ModDBDownloader.cs +++ b/Wabbajack.Lib/Downloaders/ModDBDownloader.cs @@ -6,7 +6,6 @@ using Newtonsoft.Json; using Wabbajack.Common; using Wabbajack.Common.Serialization.Json; using Wabbajack.Lib.Validation; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/NexusDownloader.cs b/Wabbajack.Lib/Downloaders/NexusDownloader.cs index fc4728d3..d6914624 100644 --- a/Wabbajack.Lib/Downloaders/NexusDownloader.cs +++ b/Wabbajack.Lib/Downloaders/NexusDownloader.cs @@ -12,7 +12,6 @@ using Wabbajack.Common.StatusFeed.Errors; using Wabbajack.Lib.NexusApi; using Wabbajack.Lib.Validation; using Game = Wabbajack.Common.Game; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/SteamWorkshopDownloader.cs b/Wabbajack.Lib/Downloaders/SteamWorkshopDownloader.cs index 96cfadde..cdf1ad5a 100644 --- a/Wabbajack.Lib/Downloaders/SteamWorkshopDownloader.cs +++ b/Wabbajack.Lib/Downloaders/SteamWorkshopDownloader.cs @@ -14,20 +14,21 @@ namespace Wabbajack.Lib.Downloaders { public class SteamWorkshopDownloader : IUrlDownloader { - private SteamWorkshopItem _item; - - public async Task GetDownloaderState(dynamic archiveINI, bool quickMode) + public async Task GetDownloaderState(dynamic archiveINI, bool quickMode) { var id = archiveINI?.General?.itemID; var steamID = archiveINI?.General?.steamID; var size = archiveINI?.General?.itemSize; - _item = new SteamWorkshopItem + if (steamID == null) + { + throw new ArgumentException("Steam workshop item had no steam ID."); + } + var item = new SteamWorkshopItem(GameRegistry.GetBySteamID(int.Parse(steamID))) { ItemID = id != null ? int.Parse(id) : 0, Size = size != null ? int.Parse(size) : 0, - Game = steamID != null ? GameRegistry.GetBySteamID(int.Parse(steamID)) : null }; - return new State {Item = _item}; + return new State(item); } public async Task Prepare() @@ -41,8 +42,14 @@ namespace Wabbajack.Lib.Downloaders public class State : AbstractDownloadState { - public SteamWorkshopItem Item { get; set; } - public override object[] PrimaryKey { get => new object[] {Item.Game, Item.ItemID}; } + public SteamWorkshopItem Item { get; } + + public override object[] PrimaryKey => new object[] { Item.Game, Item.ItemID }; + + public State(SteamWorkshopItem item) + { + Item = item; + } public override bool IsWhitelisted(ServerWhitelist whitelist) { diff --git a/Wabbajack.Lib/Downloaders/TESAllianceDownloader.cs b/Wabbajack.Lib/Downloaders/TESAllianceDownloader.cs index 16cf46cc..ae6a8fa1 100644 --- a/Wabbajack.Lib/Downloaders/TESAllianceDownloader.cs +++ b/Wabbajack.Lib/Downloaders/TESAllianceDownloader.cs @@ -1,7 +1,6 @@ using System; using Wabbajack.Common; using Wabbajack.Common.Serialization.Json; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/UrlDownloaders/BethesdaNetInferencer.cs b/Wabbajack.Lib/Downloaders/UrlDownloaders/BethesdaNetInferencer.cs index 2dfd3cf2..0ef367e1 100644 --- a/Wabbajack.Lib/Downloaders/UrlDownloaders/BethesdaNetInferencer.cs +++ b/Wabbajack.Lib/Downloaders/UrlDownloaders/BethesdaNetInferencer.cs @@ -1,6 +1,5 @@ using System; using System.Threading.Tasks; -#nullable enable namespace Wabbajack.Lib.Downloaders.UrlDownloaders { diff --git a/Wabbajack.Lib/Downloaders/UrlDownloaders/IUrlInferencer.cs b/Wabbajack.Lib/Downloaders/UrlDownloaders/IUrlInferencer.cs index 84be4335..9aaf73d7 100644 --- a/Wabbajack.Lib/Downloaders/UrlDownloaders/IUrlInferencer.cs +++ b/Wabbajack.Lib/Downloaders/UrlDownloaders/IUrlInferencer.cs @@ -1,6 +1,5 @@ using System; using System.Threading.Tasks; -#nullable enable namespace Wabbajack.Lib.Downloaders.UrlDownloaders { diff --git a/Wabbajack.Lib/Downloaders/UrlDownloaders/YoutubeInferencer.cs b/Wabbajack.Lib/Downloaders/UrlDownloaders/YoutubeInferencer.cs index 8c8d1974..c3f96716 100644 --- a/Wabbajack.Lib/Downloaders/UrlDownloaders/YoutubeInferencer.cs +++ b/Wabbajack.Lib/Downloaders/UrlDownloaders/YoutubeInferencer.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Threading.Tasks; using Wabbajack.Common; using YoutubeExplode; -#nullable enable namespace Wabbajack.Lib.Downloaders.UrlDownloaders { diff --git a/Wabbajack.Lib/Downloaders/VectorPlexusDownloader.cs b/Wabbajack.Lib/Downloaders/VectorPlexusDownloader.cs index f0cdafb8..8f7d1c5c 100644 --- a/Wabbajack.Lib/Downloaders/VectorPlexusDownloader.cs +++ b/Wabbajack.Lib/Downloaders/VectorPlexusDownloader.cs @@ -1,6 +1,5 @@ using System; using Wabbajack.Common.Serialization.Json; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Downloaders/YouTubeDownloader.cs b/Wabbajack.Lib/Downloaders/YouTubeDownloader.cs index 4e6be90c..3f076305 100644 --- a/Wabbajack.Lib/Downloaders/YouTubeDownloader.cs +++ b/Wabbajack.Lib/Downloaders/YouTubeDownloader.cs @@ -15,7 +15,6 @@ using YoutubeExplode.Exceptions; using YoutubeExplode.Models.MediaStreams; using File = Alphaleonis.Win32.Filesystem.File; using Path = Alphaleonis.Win32.Filesystem.Path; -#nullable enable namespace Wabbajack.Lib.Downloaders { diff --git a/Wabbajack.Lib/Exceptions/HttpException.cs b/Wabbajack.Lib/Exceptions/HttpException.cs index 41d46b03..af0a3bb0 100644 --- a/Wabbajack.Lib/Exceptions/HttpException.cs +++ b/Wabbajack.Lib/Exceptions/HttpException.cs @@ -12,6 +12,5 @@ namespace Wabbajack.Lib.Exceptions Code = code; Reason = reason; } - } } diff --git a/Wabbajack.Lib/FileUploader/AuthorAPI.cs b/Wabbajack.Lib/FileUploader/AuthorAPI.cs index 149b4d35..638dc927 100644 --- a/Wabbajack.Lib/FileUploader/AuthorAPI.cs +++ b/Wabbajack.Lib/FileUploader/AuthorAPI.cs @@ -21,9 +21,9 @@ namespace Wabbajack.Lib.FileUploader { public static IObservable HaveAuthorAPIKey => Utils.HaveEncryptedJsonObservable(Consts.AuthorAPIKeyFile); - public static string ApiKeyOverride = null; + public static string? ApiKeyOverride = null; - public static async Task GetAPIKey(string apiKey = null) + public static async Task GetAPIKey(string? apiKey = null) { if (ApiKeyOverride != null) return ApiKeyOverride; return apiKey ?? (await Consts.LocalAppDataPath.Combine(Consts.AuthorAPIKeyFile).ReadAllTextAsync()).Trim(); @@ -32,7 +32,7 @@ namespace Wabbajack.Lib.FileUploader public static Uri UploadURL => new Uri($"{Consts.WabbajackBuildServerUri}upload_file"); public static long BLOCK_SIZE = (long)1024 * 1024 * 2; public static int MAX_CONNECTIONS = 8; - public static Task UploadFile(AbsolutePath filename, Action progressFn, string apikey=null) + public static Task UploadFile(AbsolutePath filename, Action progressFn, string? apikey = null) { var tcs = new TaskCompletionSource(); Task.Run(async () => @@ -123,7 +123,7 @@ namespace Wabbajack.Lib.FileUploader return tcs.Task; } - public static async Task GetAuthorizedClient(string apiKey=null) + public static async Task GetAuthorizedClient(string? apiKey = null) { var client = new Common.Http.Client(); client.Headers.Add(("X-API-KEY", await GetAPIKey(apiKey))); diff --git a/Wabbajack.Lib/IBatchProcessor.cs b/Wabbajack.Lib/IBatchProcessor.cs index e8f34b8c..ebf4531f 100644 --- a/Wabbajack.Lib/IBatchProcessor.cs +++ b/Wabbajack.Lib/IBatchProcessor.cs @@ -1,7 +1,6 @@ using System; using System.Threading.Tasks; using Wabbajack.Common; -#nullable enable namespace Wabbajack.Lib { diff --git a/Wabbajack.Lib/LibCefHelpers/Init.cs b/Wabbajack.Lib/LibCefHelpers/Init.cs index 573fd9db..9f3c9985 100644 --- a/Wabbajack.Lib/LibCefHelpers/Init.cs +++ b/Wabbajack.Lib/LibCefHelpers/Init.cs @@ -78,10 +78,10 @@ namespace Wabbajack.Lib.LibCefHelpers [JsonName("HttpCookie")] public class Cookie { - public string Name { get; set; } - public string Value { get; set; } - public string Domain { get; set; } - public string Path { get; set; } + public string Name { get; set; } = string.Empty; + public string Value { get; set; } = string.Empty; + public string Domain { get; set; } = string.Empty; + public string Path { get; set; } = string.Empty; } public static void Init() diff --git a/Wabbajack.Lib/MO2Compiler.cs b/Wabbajack.Lib/MO2Compiler.cs index 79181eaa..97b54ee7 100644 --- a/Wabbajack.Lib/MO2Compiler.cs +++ b/Wabbajack.Lib/MO2Compiler.cs @@ -20,7 +20,6 @@ using File = Alphaleonis.Win32.Filesystem.File; using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo; using Game = Wabbajack.Common.Game; using Path = Alphaleonis.Win32.Filesystem.Path; -#nullable enable namespace Wabbajack.Lib { @@ -175,9 +174,8 @@ namespace Wabbajack.Lib IndexedArchives = (await MO2DownloadsFolder.EnumerateFiles() .Where(f => f.WithExtension(Consts.MetaFileExtension).Exists) - .PMap(Queue, async f => new IndexedArchive + .PMap(Queue, async f => new IndexedArchive(VFS.Index.ByRootPath[f]) { - File = VFS.Index.ByRootPath[f], Name = (string)f.FileName, IniData = f.WithExtension(Consts.MetaFileExtension).LoadIniFile(), Meta = await f.WithExtension(Consts.MetaFileExtension).ReadAllTextAsync() diff --git a/Wabbajack.Lib/MO2Installer.cs b/Wabbajack.Lib/MO2Installer.cs index ab4af57a..6ca32b01 100644 --- a/Wabbajack.Lib/MO2Installer.cs +++ b/Wabbajack.Lib/MO2Installer.cs @@ -21,7 +21,6 @@ using Directory = Alphaleonis.Win32.Filesystem.Directory; using File = Alphaleonis.Win32.Filesystem.File; using Path = Alphaleonis.Win32.Filesystem.Path; using SectionData = Wabbajack.Common.SectionData; -#nullable enable namespace Wabbajack.Lib { @@ -332,6 +331,10 @@ namespace Wabbajack.Lib private void SetScreenSizeInPrefs() { + if (SystemParameters == null) + { + throw new ArgumentNullException("System Parameters was null. Cannot set screen size prefs"); + } var config = new IniParserConfiguration {AllowDuplicateKeys = true, AllowDuplicateSections = true}; foreach (var file in OutputFolder.Combine("profiles").EnumerateFiles() .Where(f => ((string)f.FileName).EndsWith("refs.ini"))) diff --git a/Wabbajack.Lib/Manifest.cs b/Wabbajack.Lib/Manifest.cs index 00ce5d6a..1aa4d846 100644 --- a/Wabbajack.Lib/Manifest.cs +++ b/Wabbajack.Lib/Manifest.cs @@ -2,7 +2,6 @@ using System.Linq; using Wabbajack.Common; using Wabbajack.Common.Serialization.Json; -#nullable enable namespace Wabbajack.Lib { @@ -42,12 +41,11 @@ namespace Wabbajack.Lib InstallSize = modlist.InstallSize; // meta is being omitted due to it being useless and not very space friendly - Archives = modlist.Archives.Select(a => new Archive + Archives = modlist.Archives.Select(a => new Archive(a.State) { Hash = a.Hash, Name = a.Name, Size = a.Size, - State = a.State }).ToList(); } } diff --git a/Wabbajack.Lib/ModListRegistry/ModListMetadata.cs b/Wabbajack.Lib/ModListRegistry/ModListMetadata.cs index e68df7e2..4bae4f76 100644 --- a/Wabbajack.Lib/ModListRegistry/ModListMetadata.cs +++ b/Wabbajack.Lib/ModListRegistry/ModListMetadata.cs @@ -13,13 +13,13 @@ namespace Wabbajack.Lib.ModListRegistry public class ModlistMetadata { [JsonProperty("title")] - public string Title { get; set; } + public string Title { get; set; } = string.Empty; [JsonProperty("description")] - public string Description { get; set; } + public string Description { get; set; } = string.Empty; [JsonProperty("author")] - public string Author { get; set; } + public string Author { get; set; } = string.Empty; [JsonProperty("game")] public Game Game { get; set; } @@ -33,7 +33,7 @@ namespace Wabbajack.Lib.ModListRegistry public LinksObject Links { get; set; } = new LinksObject(); [JsonProperty("download_metadata")] - public DownloadMetadata DownloadMetadata { get; set; } + public DownloadMetadata? DownloadMetadata { get; set; } [JsonIgnore] public ModListSummary ValidationSummary { get; set; } = new ModListSummary(); @@ -42,22 +42,18 @@ namespace Wabbajack.Lib.ModListRegistry public class LinksObject { [JsonProperty("image")] - public string ImageUri { get; set; } + public string ImageUri { get; set; } = string.Empty; [JsonProperty("readme")] - public string Readme { get; set; } + public string Readme { get; set; } = string.Empty; [JsonProperty("download")] - public string Download { get; set; } - + public string Download { get; set; } = string.Empty; + [JsonProperty("machineURL")] - public string MachineURL { get; set; } + public string MachineURL { get; set; } = string.Empty; } - - - - public static async Task> LoadFromGithub() { var client = new Common.Http.Client(); @@ -103,18 +99,17 @@ namespace Wabbajack.Lib.ModListRegistry public long SizeOfArchives { get; set; } public long NumberOfInstalledFiles { get; set; } public long SizeOfInstalledFiles { get; set; } - } [JsonName("ModListSummary")] public class ModListSummary { [JsonProperty("name")] - public string Name { get; set; } - + public string Name { get; set; } = string.Empty; + [JsonProperty("machineURL")] - public string MachineURL { get; set; } - + public string MachineURL { get; set; } = string.Empty; + [JsonProperty("checked")] public DateTime Checked { get; set; } [JsonProperty("failed")] diff --git a/Wabbajack.Lib/NexusApi/Dtos.cs b/Wabbajack.Lib/NexusApi/Dtos.cs index 3ffe2d4c..594cc1ad 100644 --- a/Wabbajack.Lib/NexusApi/Dtos.cs +++ b/Wabbajack.Lib/NexusApi/Dtos.cs @@ -4,57 +4,57 @@ namespace Wabbajack.Lib.NexusApi { public class UserStatus { - public string email; + public string email = string.Empty; public bool is_premium; public bool is_supporter; - public string key; - public string name; - public string profile_url; - public string user_id; + public string key = string.Empty; + public string name = string.Empty; + public string profile_url = string.Empty; + public string user_id = string.Empty; } public class NexusFileInfo { public long category_id { get; set; } - public string category_name { get; set; } - public string changelog_html { get; set; } - public string description { get; set; } - public string external_virus_scan_url { get; set; } + public string category_name { get; set; } = string.Empty; + public string changelog_html { get; set; } = string.Empty; + public string description { get; set; } = string.Empty; + public string external_virus_scan_url { get; set; } = string.Empty; public long file_id { get; set; } - public string file_name { get; set; } + public string file_name { get; set; } = string.Empty; public bool is_primary { get; set; } - public string mod_version { get; set; } - public string name { get; set; } + public string mod_version { get; set; } = string.Empty; + public string name { get; set; } = string.Empty; public long size { get; set; } public long size_kb { get; set; } public DateTime uploaded_time { get; set; } public long uploaded_timestamp { get; set; } - public string version { get; set; } + public string version { get; set; } = string.Empty; } public class ModInfo { public uint _internal_version { get; set; } - public string game_name { get; set; } - public string mod_id { get; set; } - public string name { get; set; } - public string summary { get; set; } - public string author { get; set; } - public string uploaded_by { get; set; } - public string uploaded_users_profile_url { get; set; } - public string picture_url { get; set; } + public string game_name { get; set; } = string.Empty; + public string mod_id { get; set; } = string.Empty; + public string name { get; set; } = string.Empty; + public string summary { get; set; } = string.Empty; + public string author { get; set; } = string.Empty; + public string uploaded_by { get; set; } = string.Empty; + public string uploaded_users_profile_url { get; set; } = string.Empty; + public string picture_url { get; set; } = string.Empty; public bool contains_adult_content { get; set; } } public class MD5Response { - public ModInfo mod; - public NexusFileInfo file_details; + public ModInfo? mod; + public NexusFileInfo? file_details; } public class EndorsementResponse { - public string message; - public string status; + public string message = string.Empty; + public string status = string.Empty; } } diff --git a/Wabbajack.Lib/NexusApi/NexusApi.cs b/Wabbajack.Lib/NexusApi/NexusApi.cs index eb5d486b..7ca855d8 100644 --- a/Wabbajack.Lib/NexusApi/NexusApi.cs +++ b/Wabbajack.Lib/NexusApi/NexusApi.cs @@ -27,12 +27,11 @@ namespace Wabbajack.Lib.NexusApi #region Authentication - public string ApiKey { get; } + public string? ApiKey { get; } public bool IsAuthenticated => ApiKey != null; - private Task _userStatus; - + private Task? _userStatus; public Task UserStatus { get @@ -214,7 +213,7 @@ namespace Wabbajack.Lib.NexusApi #endregion - private NexusApiClient(string apiKey = null) + private NexusApiClient(string? apiKey = null) { ApiKey = apiKey; @@ -230,9 +229,9 @@ namespace Wabbajack.Lib.NexusApi Directory.CreateDirectory(Consts.NexusCacheDirectory); } - public static async Task Get(string apiKey = null) + public static async Task Get(string? apiKey = null) { - apiKey = apiKey ?? await GetApiKey(); + apiKey ??= await GetApiKey(); return new NexusApiClient(apiKey); } @@ -316,9 +315,10 @@ namespace Wabbajack.Lib.NexusApi throw; } } + public class GetModFilesResponse { - public List files { get; set; } + public List files { get; set; } = new List(); } public async Task GetModFiles(Game game, long modid) @@ -344,18 +344,18 @@ namespace Wabbajack.Lib.NexusApi private class DownloadLink { - public string URI { get; set; } + public string URI { get; set; } = string.Empty; } - public static MethodInfo CacheMethod { get; set; } - - private static string _localCacheDir; + private static string? _localCacheDir; public static string LocalCacheDir { get { if (_localCacheDir == null) _localCacheDir = Environment.GetEnvironmentVariable("NEXUSCACHEDIR"); + if (_localCacheDir == null) + throw new ArgumentNullException($"Enviornment variable could not be located: NEXUSCACHEDIR"); return _localCacheDir; } set => _localCacheDir = value; diff --git a/Wabbajack.Lib/NexusApi/NexusApiUtils.cs b/Wabbajack.Lib/NexusApi/NexusApiUtils.cs index f29959e4..c75ecf78 100644 --- a/Wabbajack.Lib/NexusApi/NexusApiUtils.cs +++ b/Wabbajack.Lib/NexusApi/NexusApiUtils.cs @@ -19,15 +19,10 @@ namespace Wabbajack.Lib.NexusApi public static string FixupSummary(string argSummary) { - if (argSummary != null) - { - return argSummary.Replace("'", "'") - .Replace("
", "\n\n") - .Replace("
", "\n\n") - .Replace("!", "!"); - } - - return argSummary; + return argSummary.Replace("'", "'") + .Replace("
", "\n\n") + .Replace("
", "\n\n") + .Replace("!", "!"); } } } diff --git a/Wabbajack.Lib/NexusApi/RequestNexusAuthorization.cs b/Wabbajack.Lib/NexusApi/RequestNexusAuthorization.cs index bf17e3a3..a84c707e 100644 --- a/Wabbajack.Lib/NexusApi/RequestNexusAuthorization.cs +++ b/Wabbajack.Lib/NexusApi/RequestNexusAuthorization.cs @@ -10,7 +10,7 @@ namespace Wabbajack.Lib.NexusApi public class RequestNexusAuthorization : AUserIntervention { public override string ShortDescription => "Getting User's Nexus API Key"; - public override string ExtendedDescription { get; } + public override string ExtendedDescription { get; } = string.Empty; private readonly TaskCompletionSource _source = new TaskCompletionSource(); public Task Task => _source.Task; diff --git a/Wabbajack.Lib/StatusMessages/ConfirmUpdateOfExistingInstall.cs b/Wabbajack.Lib/StatusMessages/ConfirmUpdateOfExistingInstall.cs index d3e7db4f..6e65243d 100644 --- a/Wabbajack.Lib/StatusMessages/ConfirmUpdateOfExistingInstall.cs +++ b/Wabbajack.Lib/StatusMessages/ConfirmUpdateOfExistingInstall.cs @@ -10,7 +10,7 @@ namespace Wabbajack.Lib public class ConfirmUpdateOfExistingInstall : ConfirmationIntervention { public AbsolutePath OutputFolder { get; set; } - public string ModListName { get; set; } + public string ModListName { get; set; } = string.Empty; public override string ShortDescription { get; } = "Do you want to overwrite existing files?"; diff --git a/Wabbajack.Lib/StatusMessages/ManuallyDownloadFile.cs b/Wabbajack.Lib/StatusMessages/ManuallyDownloadFile.cs index a782e089..ee02101d 100644 --- a/Wabbajack.Lib/StatusMessages/ManuallyDownloadFile.cs +++ b/Wabbajack.Lib/StatusMessages/ManuallyDownloadFile.cs @@ -9,9 +9,9 @@ namespace Wabbajack.Lib public class ManuallyDownloadFile : AUserIntervention { public ManualDownloader.State State { get; } - public override string ShortDescription { get; } - public override string ExtendedDescription { get; } - + public override string ShortDescription { get; } = string.Empty; + public override string ExtendedDescription { get; } = string.Empty; + private TaskCompletionSource<(Uri, Common.Http.Client)> _tcs = new TaskCompletionSource<(Uri, Common.Http.Client)>(); public Task<(Uri, Common.Http.Client)> Task => _tcs.Task; diff --git a/Wabbajack.Lib/StatusMessages/ManuallyDownloadNexusFile.cs b/Wabbajack.Lib/StatusMessages/ManuallyDownloadNexusFile.cs index e403ab73..8637f1cb 100644 --- a/Wabbajack.Lib/StatusMessages/ManuallyDownloadNexusFile.cs +++ b/Wabbajack.Lib/StatusMessages/ManuallyDownloadNexusFile.cs @@ -9,9 +9,9 @@ namespace Wabbajack.Lib public class ManuallyDownloadNexusFile : AUserIntervention { public NexusDownloader.State State { get; } - public override string ShortDescription { get; } - public override string ExtendedDescription { get; } - + public override string ShortDescription { get; } = string.Empty; + public override string ExtendedDescription { get; } = string.Empty; + private TaskCompletionSource _tcs = new TaskCompletionSource(); public Task Task => _tcs.Task; diff --git a/Wabbajack.Lib/SystemParameters.cs b/Wabbajack.Lib/SystemParameters.cs index 2dc7c9d5..2f288894 100644 --- a/Wabbajack.Lib/SystemParameters.cs +++ b/Wabbajack.Lib/SystemParameters.cs @@ -1,5 +1,4 @@ using System; -#nullable enable namespace Wabbajack.Lib { diff --git a/Wabbajack.Lib/Validation/DTOs.cs b/Wabbajack.Lib/Validation/DTOs.cs index 25a0741e..00be5104 100644 --- a/Wabbajack.Lib/Validation/DTOs.cs +++ b/Wabbajack.Lib/Validation/DTOs.cs @@ -10,33 +10,32 @@ namespace Wabbajack.Lib.Validation public bool? CanUseInOtherGames { get; set; } } - public class Author - { - public Permissions Permissions { get; set; } - public Dictionary Games; - } + //public class Author + //{ + // public Permissions Permissions { get; set; } + // public Dictionary Games; + //} - public class Game - { - public Permissions Permissions; - public Dictionary Mods; - } + //public class Game + //{ + // public Permissions Permissions; + // public Dictionary Mods; + //} - public class Mod - { - public Permissions Permissions; - public Dictionary Files; - } - - public class File - { - public Permissions Permissions; - } + //public class Mod + //{ + // public Permissions Permissions; + // public Dictionary Files; + //} + //public class File + //{ + // public Permissions Permissions; + //} public class ServerWhitelist { - public List GoogleIDs; - public List AllowedPrefixes; + public List GoogleIDs = new List(); + public List AllowedPrefixes = new List(); } } diff --git a/Wabbajack.Lib/ViewModel.cs b/Wabbajack.Lib/ViewModel.cs index ce5da622..719a7ccc 100644 --- a/Wabbajack.Lib/ViewModel.cs +++ b/Wabbajack.Lib/ViewModel.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Reactive.Disposables; using System.Runtime.CompilerServices; -#nullable enable namespace Wabbajack.Lib { diff --git a/Wabbajack.Lib/VortexCompiler.cs b/Wabbajack.Lib/VortexCompiler.cs index 8f0e3022..4ad94116 100644 --- a/Wabbajack.Lib/VortexCompiler.cs +++ b/Wabbajack.Lib/VortexCompiler.cs @@ -15,7 +15,6 @@ using Wabbajack.Lib.NexusApi; using Wabbajack.Lib.Validation; using File = Alphaleonis.Win32.Filesystem.File; using Game = Wabbajack.Common.Game; -#nullable enable namespace Wabbajack.Lib { diff --git a/Wabbajack.Lib/Wabbajack.Lib.csproj b/Wabbajack.Lib/Wabbajack.Lib.csproj index b79980e0..9b204559 100644 --- a/Wabbajack.Lib/Wabbajack.Lib.csproj +++ b/Wabbajack.Lib/Wabbajack.Lib.csproj @@ -1,9 +1,10 @@  - netcoreapp3.1 - x64 - win10-x64 + netcoreapp3.1 + x64 + win10-x64 + enable diff --git a/Wabbajack.Lib/WebAutomation/CefSharpWrapper.cs b/Wabbajack.Lib/WebAutomation/CefSharpWrapper.cs index 513d3008..48e73d50 100644 --- a/Wabbajack.Lib/WebAutomation/CefSharpWrapper.cs +++ b/Wabbajack.Lib/WebAutomation/CefSharpWrapper.cs @@ -13,8 +13,8 @@ namespace Wabbajack.Lib.WebAutomation { public class CefSharpWrapper : IWebDriver { - private IWebBrowser _browser; - public Action DownloadHandler { get; set; } + private readonly IWebBrowser _browser; + public Action? DownloadHandler { get; set; } public CefSharpWrapper(IWebBrowser browser) { _browser = browser; @@ -24,7 +24,7 @@ namespace Wabbajack.Lib.WebAutomation { var tcs = new TaskCompletionSource(); - EventHandler handler = null; + EventHandler? handler = null; handler = (sender, e) => { if (!e.IsLoading) @@ -68,7 +68,7 @@ namespace Wabbajack.Lib.WebAutomation public class PopupBlocker : ILifeSpanHandler { - private CefSharpWrapper _wrapper; + private readonly CefSharpWrapper _wrapper; public PopupBlocker(CefSharpWrapper cefSharpWrapper) { @@ -77,7 +77,7 @@ namespace Wabbajack.Lib.WebAutomation public bool OnBeforePopup(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, - IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser) + IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser? newBrowser) { // Block popups newBrowser = null; @@ -86,7 +86,6 @@ namespace Wabbajack.Lib.WebAutomation public void OnAfterCreated(IWebBrowser chromiumWebBrowser, IBrowser browser) { - } public bool DoClose(IWebBrowser chromiumWebBrowser, IBrowser browser) @@ -96,7 +95,6 @@ namespace Wabbajack.Lib.WebAutomation public void OnBeforeClose(IWebBrowser chromiumWebBrowser, IBrowser browser) { - } } @@ -112,7 +110,7 @@ namespace Wabbajack.Lib.WebAutomation public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { - _wrapper.DownloadHandler(new Uri(downloadItem.Url)); + _wrapper.DownloadHandler?.Invoke(new Uri(downloadItem.Url)); } public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, diff --git a/Wabbajack.Lib/WebAutomation/IWebDriver.cs b/Wabbajack.Lib/WebAutomation/IWebDriver.cs index 0672aef5..529a04cb 100644 --- a/Wabbajack.Lib/WebAutomation/IWebDriver.cs +++ b/Wabbajack.Lib/WebAutomation/IWebDriver.cs @@ -13,6 +13,6 @@ namespace Wabbajack.Lib.WebAutomation Task NavigateTo(Uri uri); Task EvaluateJavaScript(string text); Task GetCookies(string domainPrefix); - public Action DownloadHandler { get; set; } + public Action? DownloadHandler { get; set; } } } diff --git a/Wabbajack.Lib/WebAutomation/WebAutomation.cs b/Wabbajack.Lib/WebAutomation/WebAutomation.cs index 09eba17a..d906c968 100644 --- a/Wabbajack.Lib/WebAutomation/WebAutomation.cs +++ b/Wabbajack.Lib/WebAutomation/WebAutomation.cs @@ -24,13 +24,13 @@ namespace Wabbajack.Lib.WebAutomation return driver; } - public async Task NavigateTo(Uri uri) + public async Task NavigateTo(Uri uri) { await _driver.NavigateTo(uri); return await GetLocation(); } - public async ValueTask GetLocation() + public async ValueTask GetLocation() { try { diff --git a/Wabbajack.Lib/zEditIntegration.cs b/Wabbajack.Lib/zEditIntegration.cs index 5590ddf8..ba2d1845 100644 --- a/Wabbajack.Lib/zEditIntegration.cs +++ b/Wabbajack.Lib/zEditIntegration.cs @@ -9,7 +9,6 @@ using Directory = Alphaleonis.Win32.Filesystem.Directory; using File = Alphaleonis.Win32.Filesystem.File; using Path = Alphaleonis.Win32.Filesystem.Path; using System.Threading.Tasks; -#nullable enable namespace Wabbajack.Lib { @@ -151,7 +150,7 @@ namespace Wabbajack.Lib return inline; } var result = source.EvolveTo(); - result.Sources = merge.plugins.Select(f => + result.Sources.SetTo(merge.plugins.Select(f => { var origPath = (AbsolutePath)Path.Combine(f.dataFolder, f.filename); var paths = new[] @@ -172,10 +171,11 @@ namespace Wabbajack.Lib try { hash = _compiler.VFS.Index.ByRootPath[absPath].Hash; - } catch (KeyNotFoundException e) + } + catch (KeyNotFoundException e) { - Utils.ErrorThrow(e, $"Could not find the key {absPath} in the VFS Index dictionary!"); - return null; + Utils.Error(e, $"Could not find the key {absPath} in the VFS Index dictionary!"); + throw; } return new SourcePatch @@ -183,7 +183,7 @@ namespace Wabbajack.Lib RelativePath = absPath.RelativeTo(_mo2Compiler.MO2Folder), Hash = hash }; - }).ToList(); + })); var srcData = result.Sources.Select(f => _mo2Compiler.MO2Folder.Combine(f.RelativePath).ReadAllBytes()) .ConcatArrays(); diff --git a/Wabbajack.Test/ContentRightsManagementTests.cs b/Wabbajack.Test/ContentRightsManagementTests.cs index 0d915da4..7da956cc 100644 --- a/Wabbajack.Test/ContentRightsManagementTests.cs +++ b/Wabbajack.Test/ContentRightsManagementTests.cs @@ -48,15 +48,15 @@ namespace Wabbajack.Test GameType = Game.Skyrim, Archives = new List { - new Archive - { - State = new NexusDownloader.State + new Archive( + new NexusDownloader.State { Game = Game.Skyrim, Author = "bill", ModID = 42, FileID = 33, - }, + }) + { Hash = Hash.FromLong(42) } }, @@ -71,9 +71,8 @@ namespace Wabbajack.Test }; // Error due to file downloaded from 3rd party modlist.GameType = Game.Skyrim; - modlist.Archives[0] = new Archive() + modlist.Archives[0] = new Archive(new HTTPDownloader.State("https://somebadplace.com")) { - State = new HTTPDownloader.State("https://somebadplace.com"), Hash = Hash.FromLong(42) }; var errors = await validate.Validate(modlist); @@ -81,9 +80,8 @@ namespace Wabbajack.Test // Ok due to file downloaded from whitelisted 3rd party modlist.GameType = Game.Skyrim; - modlist.Archives[0] = new Archive + modlist.Archives[0] = new Archive(new HTTPDownloader.State("https://somegoodplace.com/baz.7z")) { - State = new HTTPDownloader.State("https://somegoodplace.com/baz.7z"), Hash = Hash.FromLong(42) }; errors = await validate.Validate(modlist); @@ -92,9 +90,8 @@ namespace Wabbajack.Test // Error due to file downloaded from bad 3rd party modlist.GameType = Game.Skyrim; - modlist.Archives[0] = new Archive + modlist.Archives[0] = new Archive(new GoogleDriveDownloader.State("bleg")) { - State = new GoogleDriveDownloader.State("bleg"), Hash = Hash.FromLong(42) }; errors = await validate.Validate(modlist); @@ -102,9 +99,8 @@ namespace Wabbajack.Test // Ok due to file downloaded from good google site modlist.GameType = Game.Skyrim; - modlist.Archives[0] = new Archive + modlist.Archives[0] = new Archive(new GoogleDriveDownloader.State("googleDEADBEEF")) { - State = new GoogleDriveDownloader.State("googleDEADBEEF"), Hash = Hash.FromLong(42) }; errors = await validate.Validate(modlist); diff --git a/Wabbajack.Test/DownloaderTests.cs b/Wabbajack.Test/DownloaderTests.cs index 08614e99..b6787fe1 100644 --- a/Wabbajack.Test/DownloaderTests.cs +++ b/Wabbajack.Test/DownloaderTests.cs @@ -67,13 +67,13 @@ namespace Wabbajack.Test var converted = RoundTripState(state); - Assert.True(await converted.Verify(new Archive{Size = 20})); + Assert.True(await converted.Verify(new Archive(state: null!){Size = 20})); using var filename = new TempFile(); Assert.True(converted.IsWhitelisted(new ServerWhitelist {AllowedPrefixes = new List{"https://mega.nz/#!CsMSFaaJ!-uziC4mbJPRy2e4pPk8Gjb3oDT_38Be9fzZ6Ld4NL-k" } })); Assert.False(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List{ "blerg" }})); - await converted.Download(new Archive {Name = "MEGA Test.txt"}, filename.Path); + await converted.Download(new Archive(state: null!) {Name = "MEGA Test.txt"}, filename.Path); Assert.Equal(Hash.FromBase64("eSIyd+KOG3s="), await filename.Path.FileHashAsync()); @@ -97,13 +97,13 @@ namespace Wabbajack.Test ((HTTPDownloader.State)url_state).Url); var converted = RoundTripState(state); - Assert.True(await converted.Verify(new Archive{Size = 20})); + Assert.True(await converted.Verify(new Archive(state: null!){Size = 20})); using var filename = new TempFile(); Assert.True(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List { "https://www.dropbox.com/s/5hov3m2pboppoc2/WABBAJACK_TEST_FILE.txt?" } })); Assert.False(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List { "blerg" } })); - await converted.Download(new Archive { Name = "MEGA Test.txt" }, filename.Path); + await converted.Download(new Archive(state: null!) { Name = "MEGA Test.txt" }, filename.Path); Assert.Equal(Hash.FromBase64("eSIyd+KOG3s="), await filename.Path.FileHashAsync()); @@ -127,13 +127,13 @@ namespace Wabbajack.Test ((GoogleDriveDownloader.State)url_state).Id); var converted = RoundTripState(state); - Assert.True(await converted.Verify(new Archive{Size = 20})); + Assert.True(await converted.Verify(new Archive(state: null!) { Size = 20})); using var filename = new TempFile(); Assert.True(converted.IsWhitelisted(new ServerWhitelist { GoogleIDs = new List { "1grLRTrpHxlg7VPxATTFNfq2OkU_Plvh_" } })); Assert.False(converted.IsWhitelisted(new ServerWhitelist { GoogleIDs = new List()})); - await converted.Download(new Archive { Name = "MEGA Test.txt" }, filename.Path); + await converted.Download(new Archive(state: null!) { Name = "MEGA Test.txt" }, filename.Path); Assert.Equal(Hash.FromBase64("eSIyd+KOG3s="), await filename.Path.FileHashAsync()); @@ -156,13 +156,13 @@ namespace Wabbajack.Test ((HTTPDownloader.State)url_state).Url); var converted = RoundTripState(state); - Assert.True(await converted.Verify(new Archive{Size = 20})); + Assert.True(await converted.Verify(new Archive(state: null!) { Size = 20})); using var filename = new TempFile(); Assert.True(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List { "http://build.wabbajack.org/" } })); Assert.False(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List() })); - await converted.Download(new Archive { Name = "MEGA Test.txt" }, filename.Path); + await converted.Download(new Archive(state: null!) { Name = "MEGA Test.txt" }, filename.Path); Assert.Equal(Hash.FromBase64("eSIyd+KOG3s="), await filename.Path.FileHashAsync()); @@ -180,7 +180,7 @@ namespace Wabbajack.Test Assert.NotNull(state); var converted = RoundTripState(state); - Assert.True(await converted.Verify(new Archive{Size = 20})); + Assert.True(await converted.Verify(new Archive(state: null!) { Size = 20})); using var filename = new TempFile(); Assert.True(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List { "http://build.wabbajack.org/" } })); @@ -226,37 +226,27 @@ namespace Wabbajack.Test [Fact] public async Task NexusDownload() { - var old_val = NexusApiClient.CacheMethod; - try - { - NexusApiClient.CacheMethod = null; - var ini = @"[General] + var ini = @"[General] gameName=SkyrimSE modID = 12604 fileID=35407"; - var state = (AbstractDownloadState)await DownloadDispatcher.ResolveArchive(ini.LoadIniString()); + var state = (AbstractDownloadState)await DownloadDispatcher.ResolveArchive(ini.LoadIniString()); - Assert.NotNull(state); + Assert.NotNull(state); - var converted = RoundTripState(state); - Assert.True(await converted.Verify(new Archive{Size = 20})); - // Exercise the cache code - Assert.True(await converted.Verify(new Archive{Size = 20})); - using var filename = new TempFile(); + var converted = RoundTripState(state); + Assert.True(await converted.Verify(new Archive(state: null!) { Size = 20 })); + // Exercise the cache code + Assert.True(await converted.Verify(new Archive(state: null!) { Size = 20 })); + using var filename = new TempFile(); - Assert.True(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List () })); + Assert.True(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List() })); - await converted.Download(new Archive { Name = "SkyUI.7z" }, filename.Path); + await converted.Download(new Archive(state: null!) { Name = "SkyUI.7z" }, filename.Path); - Assert.Equal(Hash.FromBase64("dF2yafV2Oks="),await filename.Path.FileHashAsync()); - - } - finally - { - NexusApiClient.CacheMethod = old_val; - } + Assert.Equal(Hash.FromBase64("dF2yafV2Oks="), await filename.Path.FileHashAsync()); } [Fact] @@ -276,12 +266,12 @@ namespace Wabbajack.Test ((ModDBDownloader.State)url_state).Url); var converted = RoundTripState(state); - Assert.True(await converted.Verify(new Archive{Size = 20})); + Assert.True(await converted.Verify(new Archive(state: null!) { Size = 20})); using var filename = new TempFile(); Assert.True(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List() })); - await converted.Download(new Archive { Name = "moddbtest.7z" }, filename.Path); + await converted.Download(new Archive(state: null!) { Name = "moddbtest.7z" }, filename.Path); Assert.Equal(Hash.FromBase64("2lZt+1h6wxM="), await filename.Path.FileHashAsync()); } @@ -302,12 +292,12 @@ namespace Wabbajack.Test ((HTTPDownloader.State)url_state).Url); */ var converted = RoundTripState(state); - Assert.True(await converted.Verify(new Archive{Size = 20})); + Assert.True(await converted.Verify(new Archive(state: null!) { Size = 20})); using var filename = new TempFile(); Assert.True(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List() })); - await converted.Download(new Archive { Name = "LoversLab Test.txt" }, filename.Path); + await converted.Download(new Archive(state: null!) { Name = "LoversLab Test.txt" }, filename.Path); Assert.Equal(Hash.FromBase64("eSIyd+KOG3s="), await filename.Path.FileHashAsync()); @@ -330,12 +320,12 @@ namespace Wabbajack.Test ((HTTPDownloader.State)url_state).Url); */ var converted = RoundTripState(state); - Assert.True(await converted.Verify(new Archive{Size = 20})); + Assert.True(await converted.Verify(new Archive(state: null!) { Size = 20})); using var filename = new TempFile(); Assert.True(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List() })); - await converted.Download(new Archive { Name = "Vector Plexus Test.zip" }, filename.Path); + await converted.Download(new Archive(state: null!) { Name = "Vector Plexus Test.zip" }, filename.Path); Assert.Equal(Hash.FromBase64("eSIyd+KOG3s="), await filename.Path.FileHashAsync()); @@ -355,12 +345,12 @@ namespace Wabbajack.Test Assert.NotNull(state); var converted = RoundTripState(state); - Assert.True(await converted.Verify(new Archive{Size = 20})); + Assert.True(await converted.Verify(new Archive(state: null!) { Size = 20})); using var filename = new TempFile(); Assert.True(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List() })); - await converted.Download(new Archive { Name = "TESAlliance Test.zip" }, filename.Path); + await converted.Download(new Archive(state: null!) { Name = "TESAlliance Test.zip" }, filename.Path); Assert.Equal(Hash.FromBase64("eSIyd+KOG3s="), await filename.Path.FileHashAsync()); @@ -407,12 +397,12 @@ namespace Wabbajack.Test Assert.NotNull(state); var converted = RoundTripState(state); - Assert.True(await converted.Verify(new Archive{Size = 20})); + Assert.True(await converted.Verify(new Archive(state: null!) { Size = 20})); using var filename = new TempFile(); Assert.True(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List() })); - await converted.Download(new Archive { Name = "Update.esm" }, filename.Path); + await converted.Download(new Archive(state: null!) { Name = "Update.esm" }, filename.Path); Assert.Equal(Hash.FromBase64("/DLG/LjdGXI="), await Utils.FileHashAsync(filename.Path)); Assert.Equal(await filename.Path.ReadAllBytesAsync(), await Game.SkyrimSpecialEdition.MetaData().GameLocation().Combine("Data/Update.esm").ReadAllBytesAsync()); @@ -434,11 +424,11 @@ namespace Wabbajack.Test Assert.NotNull(state); var converted = state.ViaJSON(); - Assert.True(await converted.Verify(new Archive {Name = "mod.ckm"})); + Assert.True(await converted.Verify(new Archive(state: null!) { Name = "mod.ckm"})); Assert.True(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List() })); - await converted.Download(new Archive { Name = "mod.zip" }, filename.Path); + await converted.Download(new Archive(state: null!) { Name = "mod.zip" }, filename.Path); await using var fs = filename.Path.OpenRead(); using var archive = new ZipArchive(fs); @@ -463,12 +453,12 @@ namespace Wabbajack.Test var converted = RoundTripState(state); - Assert.True(await converted.Verify(new Archive {Name = "yt_test.zip"})); + Assert.True(await converted.Verify(new Archive(state: null!) { Name = "yt_test.zip"})); Assert.True(converted.IsWhitelisted(new ServerWhitelist { AllowedPrefixes = new List() })); using var tempFile = new TempFile(); - await converted.Download(new Archive {Name = "yt_test.zip"}, tempFile.Path); + await converted.Download(new Archive(state: null!) { Name = "yt_test.zip"}, tempFile.Path); Assert.Equal(Hash.FromBase64("kD36zbA2X9Q="), await tempFile.Path.FileHashAsync()); } @@ -497,12 +487,12 @@ namespace Wabbajack.Test var archivesa = new List() { - new Archive {Hash = statea.Hash, Name = "Download.esm", State = statea} + new Archive(statea) {Hash = statea.Hash, Name = "Download.esm" } }; var archivesb = new List() { - new Archive {Hash = stateb.Hash, Name = "Download.esm", State = stateb} + new Archive(stateb) {Hash = stateb.Hash, Name = "Download.esm" } }; var folder = ((RelativePath)"DownloadTests").RelativeToEntryPoint(); @@ -537,16 +527,16 @@ namespace Wabbajack.Test { await using var folder = new TempFolder(); var dest = folder.Dir.Combine("Cori.7z"); - var archive = new Archive - { - Name = "Cori.7z", - Hash = Hash.FromBase64("gCRVrvzDNH0="), - State = new NexusDownloader.State + var archive = new Archive( + new NexusDownloader.State { Game = Game.SkyrimSpecialEdition, ModID = 24808, FileID = 123501 - } + }) + { + Name = "Cori.7z", + Hash = Hash.FromBase64("gCRVrvzDNH0="), }; Assert.True(await DownloadDispatcher.DownloadWithPossibleUpgrade(archive, dest)); Assert.Equal(Hash.FromBase64("gCRVrvzDNH0="), await dest.FileHashCachedAsync()); diff --git a/Wabbajack.Test/EndToEndTests.cs b/Wabbajack.Test/EndToEndTests.cs index 70caa696..d71c4cae 100644 --- a/Wabbajack.Test/EndToEndTests.cs +++ b/Wabbajack.Test/EndToEndTests.cs @@ -97,7 +97,7 @@ namespace Wabbajack.Test if (!src.Exists) { var state = DownloadDispatcher.ResolveArchive(url); - await state.Download(new Archive { Name = "Unknown"}, src); + await state.Download(new Archive(state: null!) { Name = "Unknown"}, src); } utils.DownloadsFolder.CreateDirectory(); diff --git a/Wabbajack.Test/ModlistMetadataTests.cs b/Wabbajack.Test/ModlistMetadataTests.cs index f05f8ef2..6facd767 100644 --- a/Wabbajack.Test/ModlistMetadataTests.cs +++ b/Wabbajack.Test/ModlistMetadataTests.cs @@ -26,7 +26,7 @@ namespace Wabbajack.Test { var logoState = DownloadDispatcher.ResolveArchive(modlist.ImageUri); Assert.NotNull(logoState); - Assert.True(await logoState.Verify(new Archive{Size = 0}), $"{modlist.ImageUri} is not valid"); + Assert.True(await logoState.Verify(new Archive(state: null){Size = 0}), $"{modlist.ImageUri} is not valid"); } } diff --git a/Wabbajack/View Models/Gallery/ModListMetadataVM.cs b/Wabbajack/View Models/Gallery/ModListMetadataVM.cs index 1decb1b4..4eb1a17f 100644 --- a/Wabbajack/View Models/Gallery/ModListMetadataVM.cs +++ b/Wabbajack/View Models/Gallery/ModListMetadataVM.cs @@ -155,7 +155,7 @@ namespace Wabbajack try { var downloader = DownloadDispatcher.ResolveArchive(Metadata.Links.Download); - var result = await downloader.Download(new Archive { Name = Metadata.Title, Size = Metadata.DownloadMetadata?.Size ?? 0 }, Location); + var result = await downloader.Download(new Archive(state: null!) { Name = Metadata.Title, Size = Metadata.DownloadMetadata?.Size ?? 0 }, Location); // Want to rehash to current file, even if failed? Location.FileHashCached(); tcs.SetResult(result);