WIP getting .LIB to compile with 5.0

This commit is contained in:
Timothy Baldridge 2020-12-31 17:06:56 -07:00
parent 0638612e0d
commit 90280e8b6f
18 changed files with 28 additions and 26 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<Platforms>x64</Platforms>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<IsPackable>false</IsPackable>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Platforms>x64</Platforms>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<Platforms>x64</Platforms>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
</PropertyGroup>

View File

@ -62,7 +62,7 @@
<PackageReference Include="System.Reactive" Version="5.0.0" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="5.0.0" />
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />
<PackageReference Include="YamlDotNet" Version="8.1.2" />
<PackageReference Include="YamlDotNet" Version="9.1.0" />
</ItemGroup>
<ItemGroup>
<Compile Update="Serialization\PrimitiveHandlers.cs">

View File

@ -84,8 +84,10 @@ namespace Wabbajack.Lib
if (entry == null)
{
entry = ar.GetEntry("modlist.json");
using (var e = entry.Open())
return e.FromJson<ModList>();
if (entry == null)
throw new Exception("Invalid Wabbajack Installer");
using var e = entry.Open();
return e.FromJson<ModList>();
}
using (var e = entry.Open())
return e.FromJson<ModList>();

View File

@ -33,7 +33,7 @@ namespace Wabbajack.Lib.CompilationSteps
.OrderBy(f => GetFilePriority(_compiler, f))
.ThenBy(f => f.NestingFactor)
.FirstOrDefault()
?? found.OrderBy(f => f.NestingFactor).FirstOrDefault();
?? found.OrderBy(f => f.NestingFactor).First();
result.ArchiveHashPath = match.MakeRelativePaths();

View File

@ -19,7 +19,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
var mo2Compiler = (MO2Compiler)compiler;
_isGenericGame = mo2Compiler.CompilingGame.IsGenericMO2Plugin;
_game = (SteamGame)StoreHandler.Instance.SteamHandler.Games.FirstOrDefault(x =>
_game = (SteamGame?)StoreHandler.Instance.SteamHandler.Games.FirstOrDefault(x =>
mo2Compiler.CompilingGame.SteamIDs!.Contains(x.ID));
}

View File

@ -85,11 +85,11 @@ namespace Wabbajack.Lib.Downloaders
{
var id2 = HttpUtility.ParseQueryString(url.Query)["r"];
var parsed = HttpUtility.ParseQueryString(url.Query);
var name = parsed[null].Split("/", StringSplitOptions.RemoveEmptyEntries).Last();
var name = parsed[null]!.Split("/", StringSplitOptions.RemoveEmptyEntries).Last();
return new TState
{
FullURL = url.AbsolutePath,
FileID = id2,
FileID = id2!,
FileName = name
};
}
@ -129,7 +129,7 @@ namespace Wabbajack.Lib.Downloaders
return new TState
{
FullURL = url.AbsolutePath,
FileID = id,
FileID = id!,
FileName = file
};
}
@ -240,7 +240,7 @@ namespace Wabbajack.Lib.Downloaders
var contentType = streamResult.Content.Headers.ContentType;
if (contentType.MediaType != "application/json")
if (contentType!.MediaType != "application/json")
{
var headerVar = a.Size == 0 ? "1" : a.Size.ToString();
long headerContentSize = 0;

View File

@ -67,10 +67,10 @@ namespace Wabbajack.Lib.Downloaders
return inst;
}
public static async Task<AbstractDownloadState> ResolveArchive(dynamic ini, bool quickMode = false)
public static async Task<AbstractDownloadState?> ResolveArchive(dynamic ini, bool quickMode = false)
{
var states = await Task.WhenAll(Downloaders.Select(d =>
(Task<AbstractDownloadState>)d.GetDownloaderState(ini, quickMode)));
(Task<AbstractDownloadState?>)d.GetDownloaderState(ini, quickMode)));
return states.FirstOrDefault(result => result != null);
}

View File

@ -63,7 +63,7 @@ namespace Wabbajack.Lib.Downloaders
var client = new Wabbajack.Lib.Http.Client();
using var response = await client.GetAsync(initialURL);
if (!response.IsSuccessStatusCode)
throw new HttpException((int)response.StatusCode, response.ReasonPhrase);
throw new HttpException((int)response.StatusCode, response.ReasonPhrase ?? "Unknown");
var regex = new Regex("(?<=/uc\\?export=download&amp;confirm=).*(?=;id=)");
var confirm = regex.Match(await response.Content.ReadAsStringAsync());
var url = $"https://drive.google.com/uc?export=download&confirm={confirm}&id={Id}";

View File

@ -49,7 +49,7 @@ namespace Wabbajack.Lib.Downloaders
_fileEvents.OnNext(new FileEvent
{
Size = new FileInfo(e.FullPath).Length,
Name = e.Name,
Name = e.Name!,
FullPath = e.FullPath
});
}

View File

@ -56,7 +56,7 @@ namespace Wabbajack.Lib.Downloaders
if (!result.IsSuccessStatusCode)
return null;
if (result.Content.Headers.ContentType.MediaType.StartsWith("text/html",
if (result.Content.Headers.ContentType!.MediaType!.StartsWith("text/html",
StringComparison.OrdinalIgnoreCase))
{
var body = await client.GetHtmlAsync(Url);

View File

@ -267,7 +267,7 @@ namespace Wabbajack.Lib.Downloaders
var oldFile = files.files.FirstOrDefault(f => f.file_id == FileID);
var nl = new Levenshtein();
var newFile = files.files.Where(f => f.category_name != null)
.OrderBy(f => nl.Distance(oldFile.name.ToLowerInvariant(), f.name.ToLowerInvariant())).FirstOrDefault();
.OrderBy(f => nl.Distance(oldFile!.name.ToLowerInvariant(), f.name.ToLowerInvariant())).FirstOrDefault();
if (!mod.available || oldFile == default || newFile == default)
{

View File

@ -109,7 +109,7 @@ namespace Wabbajack.Lib.Downloaders
{
"[General]",
$"itemID={Item.ItemID}",
$"steamID={Item.Game.Game.MetaData().SteamIDs.First()}",
$"steamID={Item.Game.Game.MetaData().SteamIDs!.First()}",
$"itemSize={Item.Size}"
};
}

View File

@ -91,7 +91,7 @@ namespace Wabbajack.Lib.Downloaders
var builder = new UriBuilder(Url) {Host = remap};
using var response = await client.GetAsync($"{builder}/parts/{part.Index}");
if (!response.IsSuccessStatusCode)
throw new HttpException((int)response.StatusCode, response.ReasonPhrase);
throw new HttpException((int)response.StatusCode, response.ReasonPhrase ?? "Unknown");
await response.Content.CopyToAsync(ostream);
}
@ -99,7 +99,7 @@ namespace Wabbajack.Lib.Downloaders
{
using var response = await GetWithMirroredRetry(client, $"{Url}/parts/{part.Index}");
if (!response.IsSuccessStatusCode)
throw new HttpException((int)response.StatusCode, response.ReasonPhrase);
throw new HttpException((int)response.StatusCode, response.ReasonPhrase ?? "Unknown");
await response.Content.CopyToAsync(ostream);
}

View File

@ -267,7 +267,7 @@ namespace Wabbajack.Lib.NexusApi
await UpdateRemaining(response);
if (!response.IsSuccessStatusCode)
{
Utils.Log($"Nexus call failed: {response.RequestMessage.RequestUri}");
Utils.Log($"Nexus call failed: {response.RequestMessage!.RequestUri}");
throw new HttpException(response);
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<Platforms>x64</Platforms>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<Nullable>enable</Nullable>
@ -37,10 +37,10 @@
<Version>2.1.1</Version>
</PackageReference>
<PackageReference Include="ReactiveUI">
<Version>12.1.5</Version>
<Version>13.0.27</Version>
</PackageReference>
<PackageReference Include="ReactiveUI.Fody">
<Version>12.1.5</Version>
<Version>13.0.27</Version>
</PackageReference>
<PackageReference Include="SharpCompress">
<Version>0.26.0</Version>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<Platforms>x64</Platforms>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>