Merge pull request #1238 from wabbajack-tools/net-5.0

Net 5.0
This commit is contained in:
Timothy Baldridge 2021-01-01 17:33:33 -07:00 committed by GitHub
commit 978383f23d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 70 additions and 61 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 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

View File

@ -28,14 +28,14 @@ namespace Wabbajack.CLI.Verbs
case CleanedESM esm:
{
var entry = arch.GetEntry(esm.SourceDataID.ToString());
return (entry.Length, d);
return (entry!.Length, d);
}
case InlineFile inlined:
return (inlined.Size, d);
case PatchedFromArchive pfa:
{
var entry = arch.GetEntry(pfa.PatchID.ToString());
return (entry.Length, d);
return (entry!.Length, d);
}
default:
return (0, d);

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<AssemblyName>wabbajack-cli</AssemblyName>
<Company>Wabbajack</Company>
<Platforms>x64</Platforms>

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

@ -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

@ -20,7 +20,7 @@ namespace Wabbajack.Common.Exceptions
$"Http Error {response.StatusCode} - {response.ReasonPhrase}")
{
Code = (int)response.StatusCode;
Reason = response.ReasonPhrase;
Reason = response.ReasonPhrase ?? "Unknown";
}
}
}

View File

@ -186,18 +186,18 @@ namespace Wabbajack.Common
public class GameRegistry
{
public static GameMetaData GetByMO2ArchiveName(string gameName)
public static GameMetaData? GetByMO2ArchiveName(string gameName)
{
gameName = gameName.ToLower();
return Games.Values.FirstOrDefault(g => g.MO2ArchiveName?.ToLower() == gameName);
}
public static GameMetaData GetByNexusName(string gameName)
public static GameMetaData? GetByNexusName(string gameName)
{
return Games.Values.FirstOrDefault(g => g.NexusName == gameName.ToLower());
}
public static GameMetaData GetBySteamID(int id)
public static GameMetaData? GetBySteamID(int id)
{
return Games.Values
.FirstOrDefault(g => g.SteamIDs != null && g.SteamIDs.Count > 0 && g.SteamIDs.Any(i => i == id));

View File

@ -146,7 +146,7 @@ namespace Wabbajack.Common
using var i = new MemoryStream(Encoding.UTF8.GetBytes(s));
i.CopyTo(o);
}
return sha.Hash.ToHex();
return sha.Hash!.ToHex();
}
public static Hash xxHash(this byte[] data)

View File

@ -265,7 +265,7 @@ namespace Wabbajack.Common
{
public override void WriteJson(JsonWriter writer, [AllowNull] IPath value, JsonSerializer serializer)
{
writer.WriteValue(Enum.GetName(typeof(Game), value));
writer.WriteValue(value == null ? "" : value.ToString());
}
public override IPath ReadJson(JsonReader reader, Type objectType, [AllowNull] IPath existingValue, bool hasExistingValue, JsonSerializer serializer)

View File

@ -87,11 +87,11 @@ namespace Wabbajack.Common.StoreHandlers
{
var files = d.EnumerateFiles();
var game = GameRegistry.Games.Values
.FirstOrDefault(g => g.RequiredFiles.All(f =>
.FirstOrDefault(g => g.RequiredFiles?.All(f =>
{
var absPath = new RelativePath(f).RelativeTo(d);
return files.Contains(absPath);
}));
}) ?? true);
if (game != null)
{

View File

@ -49,7 +49,7 @@ namespace Wabbajack.Common.StoreHandlers
}
}
catch (NullReferenceException ex)
catch (NullReferenceException)
{
Utils.Log("Epic Game Store is does not appear to be installed");
return false;

View File

@ -34,7 +34,7 @@ namespace Wabbajack.Common
public TempFile(FileInfo file, bool deleteAfter = true, bool createFolder = true)
{
this.File = file;
if (createFolder && !file.Directory.Exists)
if (createFolder && file.Directory != null && !file.Directory!.Exists)
{
file.Directory.Create();
}

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>
<Nullable>enable</Nullable>

View File

@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<AssemblyVersion>2.3.6.2</AssemblyVersion>
<FileVersion>2.3.6.2</FileVersion>
@ -13,7 +13,8 @@
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<AssemblyName>Wabbajack</AssemblyName>
<RootNamespace>Wabbajack</RootNamespace>
<IncludeSymbolsInSingleFile>true</IncludeSymbolsInSingleFile>
<IncludeSymbolsInSingleFile>false</IncludeSymbolsInSingleFile>
<TrimMode>CopyUsed</TrimMode>
</PropertyGroup>
<PropertyGroup>

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

@ -78,6 +78,7 @@ namespace Wabbajack
/// Removes outdated key events from a changeset, only leaving the last relevent change for each key.
/// </summary>
public static IObservable<IChangeSet<TObject, TKey>> EnsureUniqueChanges<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source)
where TKey : notnull
{
return source.Select(EnsureUniqueChanges);
}
@ -86,6 +87,8 @@ namespace Wabbajack
/// Removes outdated key events from a changeset, only leaving the last relevent change for each key.
/// </summary>
public static IChangeSet<TObject, TKey> EnsureUniqueChanges<TObject, TKey>(this IChangeSet<TObject, TKey> input)
where TKey : notnull
{
var changes = input
.GroupBy(kvp => kvp.Key)
@ -107,7 +110,7 @@ namespace Wabbajack
.ToProperty(vm, property, initialValue, deferSubscription, RxApp.MainThreadScheduler)
.DisposeWith(vm.CompositeDisposable)!;
}
/*
public static void ToGuiProperty<TRet>(
this IObservable<TRet> source,
ViewModel vm,
@ -116,11 +119,14 @@ namespace Wabbajack
TRet initialValue = default,
bool deferSubscription = false)
{
source.ToProperty(vm, property, out result!, initialValue, deferSubscription, RxApp.MainThreadScheduler)
.DisposeWith(vm.CompositeDisposable);
}
}*/
internal static Optional<Change<TObject, TKey>> Reduce<TObject, TKey>(Optional<Change<TObject, TKey>> previous, Change<TObject, TKey> next)
where TKey : notnull
{
if (!previous.HasValue)
{

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 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<IsPackable>false</IsPackable>
</PropertyGroup>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<AssemblyVersion>2.3.6.2</AssemblyVersion>
<FileVersion>2.3.6.2</FileVersion>
<Copyright>Copyright © 2019-2020</Copyright>

View File

@ -49,7 +49,6 @@ namespace Wabbajack.Test
/// </summary>
public void Stop()
{
_serverThread.Abort();
_listener.Stop();
}
@ -79,6 +78,7 @@ namespace Wabbajack.Test
_port = port;
_serverThread = new Thread(this.Listen);
_serverThread.Start();
_serverThread.IsBackground = true;
}
public void Dispose()

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>
</PropertyGroup>

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>
<Platforms>x64</Platforms>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

View File

@ -10,7 +10,7 @@ namespace Wabbajack
{
public static class IViewForExt
{
public static IReactiveBinding<TView, TViewModel, TProp> OneWayBindStrict<TViewModel, TView, TProp>(
public static IReactiveBinding<TView, TProp> OneWayBindStrict<TViewModel, TView, TProp>(
this TView view,
TViewModel viewModel,
Expression<Func<TViewModel, TProp>> vmProperty,
@ -24,7 +24,7 @@ namespace Wabbajack
viewProperty: viewProperty);
}
public static IReactiveBinding<TView, TViewModel, TOut> OneWayBindStrict<TViewModel, TView, TProp, TOut>(
public static IReactiveBinding<TView, TOut> OneWayBindStrict<TViewModel, TView, TProp, TOut>(
this TView view,
TViewModel viewModel,
Expression<Func<TViewModel, TProp>> vmProperty,
@ -40,7 +40,7 @@ namespace Wabbajack
selector: selector);
}
public static IReactiveBinding<TView, TViewModel, (object view, bool isViewModel)> BindStrict<TViewModel, TView, TProp>(
public static IReactiveBinding<TView, (object view, bool isViewModel)> BindStrict<TViewModel, TView, TProp>(
this TView view,
TViewModel viewModel,
Expression<Func<TViewModel, TProp>> vmProperty,
@ -54,7 +54,7 @@ namespace Wabbajack
viewProperty: viewProperty);
}
public static IReactiveBinding<TView, TViewModel, (object view, bool isViewModel)> BindStrict<TViewModel, TView, TVMProp, TVProp, TDontCare>(
public static IReactiveBinding<TView, (object view, bool isViewModel)> BindStrict<TViewModel, TView, TVMProp, TVProp, TDontCare>(
this TView view,
TViewModel viewModel,
Expression<Func<TViewModel, TVMProp>> vmProperty,
@ -74,7 +74,7 @@ namespace Wabbajack
viewToVmConverter: viewToVmConverter);
}
public static IReactiveBinding<TView, TViewModel, (object view, bool isViewModel)> BindStrict<TViewModel, TView, TVMProp, TVProp>(
public static IReactiveBinding<TView, (object view, bool isViewModel)> BindStrict<TViewModel, TView, TVMProp, TVProp>(
this TView view,
TViewModel viewModel,
Expression<Func<TViewModel, TVMProp>> vmProperty,

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<Platforms>x64</Platforms>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
@ -56,7 +56,7 @@
<ItemGroup>
<PackageReference Include="CefSharp.Wpf" Version="86.0.241" />
<PackageReference Include="DynamicData" Version="6.17.14" />
<PackageReference Include="DynamicData" Version="7.1.1" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.0.1" />
<PackageReference Include="Fody" Version="6.3.0">
<PrivateAssets>all</PrivateAssets>
@ -71,9 +71,9 @@
<PackageReference Include="MahApps.Metro.IconPacks" Version="4.8.0" />
<PackageReference Include="PInvoke.Gdi32" Version="0.7.78" />
<PackageReference Include="PInvoke.User32" Version="0.7.78" />
<PackageReference Include="ReactiveUI" Version="12.1.5" />
<PackageReference Include="ReactiveUI.Fody" Version="12.1.5" />
<PackageReference Include="ReactiveUI.WPF" Version="12.1.5" />
<PackageReference Include="ReactiveUI" Version="13.0.27" />
<PackageReference Include="ReactiveUI.Fody" Version="13.0.27" />
<PackageReference Include="ReactiveUI.WPF" Version="13.0.27" />
<PackageReference Include="SharpDX.DXGI" Version="4.2.0" />
<PackageReference Include="WindowsAPICodePack-Shell" Version="1.1.1" />
<PackageReference Include="WPFThemes.DarkBlend" Version="1.0.8" />