Fixed more warnings

This commit is contained in:
Halgari 2022-10-07 16:57:12 -06:00
parent 1511b69b4f
commit 13abba9c1e
21 changed files with 65 additions and 36 deletions

View File

@ -15,9 +15,11 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- <IncludeSymbolsInSingleFile>true</IncludeSymbolsInSingleFile> --> <!-- <IncludeSymbolsInSingleFile>true</IncludeSymbolsInSingleFile> -->
<AssemblyName>Wabbajack</AssemblyName> <AssemblyName>Wabbajack</AssemblyName>
<NoWarn>CS8600</NoWarn> </PropertyGroup>
<NoWarn>CS8601</NoWarn>
<NoWarn>CS8618</NoWarn>
<PropertyGroup>
<NoWarn>CS8600,CS8601,CS8618,CS8604,CS8632</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>

View File

@ -25,6 +25,10 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<PropertyGroup>
<NoWarn>CS8600,CS8601,CS8618,CS8604</NoWarn>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Wabbajack.Compiler\Wabbajack.Compiler.csproj" /> <ProjectReference Include="..\Wabbajack.Compiler\Wabbajack.Compiler.csproj" />

View File

@ -10,10 +10,10 @@ public class DropAll : ACompilationStep
{ {
} }
public override async ValueTask<Directive?> Run(RawSourceFile source) public override ValueTask<Directive?> Run(RawSourceFile source)
{ {
var result = source.EvolveTo<NoMatch>(); var result = source.EvolveTo<NoMatch>();
result.Reason = "No Match in Stack"; result.Reason = "No Match in Stack";
return result; return ValueTask.FromResult<Directive?>(result);
} }
} }

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
@ -12,6 +13,7 @@ using Xunit;
namespace Wabbajack.Compression.BSA.Test; namespace Wabbajack.Compression.BSA.Test;
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public class CompressionTests public class CompressionTests
{ {
private readonly ILogger<CompressionTests> _logger; private readonly ILogger<CompressionTests> _logger;

View File

@ -48,7 +48,7 @@ public class Reader : IReader
return rdr; return rdr;
} }
private async Task LoadHeaders() private Task LoadHeaders()
{ {
_headerMagic = Encoding.ASCII.GetString(_rdr.ReadBytes(4)); _headerMagic = Encoding.ASCII.GetString(_rdr.ReadBytes(4));
@ -91,5 +91,7 @@ public class Reader : IReader
Files = files; Files = files;
_stream?.Dispose(); _stream?.Dispose();
_rdr.Dispose(); _rdr.Dispose();
return Task.CompletedTask;
} }
} }

View File

@ -71,8 +71,8 @@ public class Builder : IBuilder
} }
} }
public async ValueTask DisposeAsync() public ValueTask DisposeAsync()
{ {
return; return ValueTask.CompletedTask;
} }
} }

View File

@ -76,8 +76,9 @@ public class Reader : IReader
return rdr; return rdr;
} }
public async ValueTask DisposeAsync() public ValueTask DisposeAsync()
{ {
return ValueTask.CompletedTask;
} }
public void Dump(Action<string> print) public void Dump(Action<string> print)

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -14,6 +15,7 @@ using Xunit;
namespace Wabbajack.Downloaders.Dispatcher.Test; namespace Wabbajack.Downloaders.Dispatcher.Test;
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
public class DownloaderTests public class DownloaderTests
{ {
private readonly DownloadDispatcher _dispatcher; private readonly DownloadDispatcher _dispatcher;

View File

@ -46,9 +46,9 @@ public class NexusDownloader : ADownloader<Nexus>, IUrlDownloader
_interventionLimiter = interventionLimiter; _interventionLimiter = interventionLimiter;
} }
public override async Task<bool> Prepare() public override Task<bool> Prepare()
{ {
return _api.ApiKey.HaveToken(); return Task.FromResult(_api.ApiKey.HaveToken());
} }
public override bool IsAllowed(ServerAllowList allowList, IDownloadState state) public override bool IsAllowed(ServerAllowList allowList, IDownloadState state)

View File

@ -6,6 +6,11 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AssemblyName>Wabbajack</AssemblyName> <AssemblyName>Wabbajack</AssemblyName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<NoWarn>CS8600,CS8601,CS8618,CS8604</NoWarn>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<AvaloniaResource Include="Assets\**" /> <AvaloniaResource Include="Assets\**" />
</ItemGroup> </ItemGroup>

View File

@ -15,7 +15,6 @@ using Wabbajack.DTOs.Logins;
using Wabbajack.Networking.Http; using Wabbajack.Networking.Http;
using Wabbajack.Networking.Http.Interfaces; using Wabbajack.Networking.Http.Interfaces;
using Wabbajack.Networking.NexusApi.DTOs; using Wabbajack.Networking.NexusApi.DTOs;
using Wabbajack.Paths;
using Wabbajack.Paths.IO; using Wabbajack.Paths.IO;
using Wabbajack.RateLimiter; using Wabbajack.RateLimiter;
using Wabbajack.Server.DTOs; using Wabbajack.Server.DTOs;
@ -245,7 +244,7 @@ public class NexusApi
throw new HttpException(result); throw new HttpException(result);
var response = await result.Content.ReadFromJsonAsync<ChunkStatusResult>(_jsonOptions); var response = await result.Content.ReadFromJsonAsync<ChunkStatusResult>(_jsonOptions);
return response; return response!;
} }
public async Task UploadFile(UploadDefinition d) public async Task UploadFile(UploadDefinition d)
{ {
@ -327,7 +326,7 @@ public class NexusApi
_logger.LogInformation("Checking file status of {Uuid}", chunkStatus.UUID); _logger.LogInformation("Checking file status of {Uuid}", chunkStatus.UUID);
var data = await _client.GetFromJsonAsync<FileStatusResult>( var data = await _client.GetFromJsonAsync<FileStatusResult>(
$"https://upload.nexusmods.com/uploads/check_status?id={chunkStatus.UUID}"); $"https://upload.nexusmods.com/uploads/check_status?id={chunkStatus.UUID}");
if (data.FileChunksAssembled) if (data!.FileChunksAssembled)
return data; return data;
await Task.Delay(TimeSpan.FromSeconds(5)); await Task.Delay(TimeSpan.FromSeconds(5));
} }

View File

@ -36,7 +36,7 @@ public class ProxiedNexusApi : NexusApi
} }
protected override async ValueTask<HttpRequestMessage> GenerateMessage(HttpMethod method, string uri, protected override async ValueTask<HttpRequestMessage> GenerateMessage(HttpMethod method, string uri,
params object[] parameters) params object?[] parameters)
{ {
var msg = await base.GenerateMessage(method, uri, parameters); var msg = await base.GenerateMessage(method, uri, parameters);
if (ProxiedEndpoints.Contains(uri)) if (ProxiedEndpoints.Contains(uri))

View File

@ -6,6 +6,10 @@
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression> <PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<Version>$(VERSION)</Version> <Version>$(VERSION)</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<NoWarn>CS8600,CS8601,CS8618,CS8604</NoWarn>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.2-mauipre.1.22102.15" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.2-mauipre.1.22102.15" />

View File

@ -40,18 +40,18 @@ public class CesiVFSCache : IVfsCache
} }
catch (Exception exception) catch (Exception exception)
{ {
_logger.LogInformation("Requesting CESI Information for: {Hash} - Not Found", hash.ToHex()); _logger.LogInformation(exception, "Requesting CESI Information for: {Hash} - Not Found", hash.ToHex());
return null; return null;
} }
} }
public async Task Put(IndexedVirtualFile file, CancellationToken token) public Task Put(IndexedVirtualFile file, CancellationToken token)
{ {
return; return Task.CompletedTask;
} }
public async Task Clean() public Task Clean()
{ {
return; return Task.CompletedTask;
} }
} }

View File

@ -45,7 +45,6 @@ public class Client
private readonly IResource<Client> _hashLimiter; private readonly IResource<Client> _hashLimiter;
private readonly IResource<HttpClient> _limiter; private readonly IResource<HttpClient> _limiter;
private readonly ILogger<Client> _logger; private readonly ILogger<Client> _logger;
private readonly ParallelOptions _parallelOptions;
private readonly ITokenProvider<WabbajackApiState> _token; private readonly ITokenProvider<WabbajackApiState> _token;
@ -461,7 +460,7 @@ public class Client
var result = await _client.SendAsync(msg); var result = await _client.SendAsync(msg);
return result.IsSuccessStatusCode; return result.IsSuccessStatusCode;
} }
catch (Exception ex) catch (Exception)
{ {
return false; return false;
} }

View File

@ -4,6 +4,10 @@
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<NoWarn>CS8600,CS8601,CS8618,CS8604</NoWarn>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Wabbajack.Common\Wabbajack.Common.csproj" /> <ProjectReference Include="..\Wabbajack.Common\Wabbajack.Common.csproj" />

View File

@ -144,8 +144,8 @@ public class VFSTests : IDisposable
await AddFile(_archiveTestTxt, "This is a test"); await AddFile(_archiveTestTxt, "This is a test");
await ZipUpFolder(_archiveTestTxt.Parent, _testZip); await ZipUpFolder(_archiveTestTxt.Parent, _testZip);
var inner_dir = @"archive\other\dir".ToRelativePath().RelativeTo(_vfsTestDir); var innerDir = @"archive\other\dir".ToRelativePath().RelativeTo(_vfsTestDir);
inner_dir.CreateDirectory(); innerDir.CreateDirectory();
await _testZip.MoveToAsync(@"archive\other\dir\nested.zip".ToRelativePath().RelativeTo(_vfsTestDir), true, await _testZip.MoveToAsync(@"archive\other\dir\nested.zip".ToRelativePath().RelativeTo(_vfsTestDir), true,
CancellationToken.None); CancellationToken.None);
await ZipUpFolder(_archiveTestTxt.Parent, _testZip); await ZipUpFolder(_archiveTestTxt.Parent, _testZip);
@ -168,9 +168,10 @@ public class VFSTests : IDisposable
await filename.WriteAllTextAsync(text); await filename.WriteAllTextAsync(text);
} }
private static async Task ZipUpFolder(AbsolutePath folder, AbsolutePath output) private static Task ZipUpFolder(AbsolutePath folder, AbsolutePath output)
{ {
ZipFile.CreateFromDirectory(folder.ToString(), output.ToString()); ZipFile.CreateFromDirectory(folder.ToString(), output.ToString());
folder.DeleteDirectory(); folder.DeleteDirectory();
return Task.CompletedTask;
} }
} }

View File

@ -132,7 +132,7 @@ public class Context
token, token,
fileNames.Keys.ToHashSet()); fileNames.Keys.ToHashSet());
} }
catch (Exception ex) catch (Exception)
{ {
await using var stream = await sfn.GetStream(); await using var stream = await sfn.GetStream();
var hash = await stream.HashingCopy(Stream.Null, token); var hash = await stream.HashingCopy(Stream.Null, token);

View File

@ -37,7 +37,7 @@ public class IndexRoot
public IReadOnlyList<VirtualFile> AllFiles { get; } public IReadOnlyList<VirtualFile> AllFiles { get; }
public IDictionary<FullPath, VirtualFile> ByFullPath { get; } public IDictionary<FullPath, VirtualFile> ByFullPath { get; }
public ILookup<Hash, VirtualFile> ByHash { get; } public ILookup<Hash, VirtualFile> ByHash { get; }
public ILookup<IPath, VirtualFile> ByName { get; set; } public ILookup<IPath?, VirtualFile> ByName { get; set; }
public IDictionary<AbsolutePath, VirtualFile> ByRootPath { get; } public IDictionary<AbsolutePath, VirtualFile> ByRootPath { get; }
public async Task<IndexRoot> Integrate(IEnumerable<VirtualFile> files) public async Task<IndexRoot> Integrate(IEnumerable<VirtualFile> files)
@ -77,7 +77,7 @@ public class IndexRoot
public static class EmptyLookup<TKey, TElement> public static class EmptyLookup<TKey, TElement>
{ {
public static ILookup<TKey, TElement> Instance { get; } = public static ILookup<TKey?, TElement> Instance { get; } =
Enumerable.Empty<TElement>().ToLookup(x => default(TKey)); Enumerable.Empty<TElement>().ToLookup(x => default(TKey));
} }
} }

View File

@ -26,7 +26,7 @@ public class VirtualFile
private static readonly SignatureChecker DDSSig = new(FileType.DDS); private static readonly SignatureChecker DDSSig = new(FileType.DDS);
private IEnumerable<VirtualFile> _thisAndAllChildren; private IEnumerable<VirtualFile>? _thisAndAllChildren;
public IPath Name { get; internal set; } public IPath Name { get; internal set; }
@ -45,7 +45,7 @@ public class VirtualFile
public ulong LastAnalyzed { get; internal set; } public ulong LastAnalyzed { get; internal set; }
public VirtualFile Parent { get; internal set; } public VirtualFile? Parent { get; internal set; }
public Context Context { get; set; } public Context Context { get; set; }
@ -107,7 +107,7 @@ public class VirtualFile
} }
public VirtualFile TopParent => IsNative ? this : Parent.TopParent; public VirtualFile TopParent => IsNative ? this : Parent!.TopParent;
public T ThisAndAllChildrenReduced<T>(T acc, Func<T, VirtualFile, T> fn) public T ThisAndAllChildrenReduced<T>(T acc, Func<T, VirtualFile, T> fn)
@ -193,7 +193,7 @@ public class VirtualFile
{ {
Context = context, Context = context,
Name = relPath, Name = relPath,
Parent = parent, Parent = parent!,
Size = stream.Length, Size = stream.Length,
LastModified = extractedFile.LastModifiedUtc.AsUnixTime(), LastModified = extractedFile.LastModifiedUtc.AsUnixTime(),
LastAnalyzed = DateTime.Now.AsUnixTime(), LastAnalyzed = DateTime.Now.AsUnixTime(),
@ -277,11 +277,11 @@ public class VirtualFile
var self = this; var self = this;
for (var idx = depth; idx != 0; idx -= 1) for (var idx = depth; idx != 0; idx -= 1)
{ {
paths[idx - 1] = self.RelativeName; paths[idx - 1] = self!.RelativeName;
self = self.Parent; self = self.Parent;
} }
FullPath = new FullPath(self.AbsoluteName, paths); FullPath = new FullPath(self!.AbsoluteName, paths);
} }
} }
@ -304,7 +304,7 @@ public class VirtualFile
return Read(context, null, br); return Read(context, null, br);
} }
private static VirtualFile Read(Context context, VirtualFile parent, BinaryReader br) private static VirtualFile Read(Context context, VirtualFile? parent, BinaryReader br)
{ {
var vf = new VirtualFile var vf = new VirtualFile
{ {
@ -371,7 +371,7 @@ public class VirtualFile
return path; return path;
} }
public VirtualFile InSameFolder(RelativePath relativePath) public VirtualFile? InSameFolder(RelativePath relativePath)
{ {
var newPath = FullPath.InSameFolder(relativePath); var newPath = FullPath.InSameFolder(relativePath);
return Context.Index.ByFullPath.TryGetValue(newPath, out var found) ? found : null; return Context.Index.ByFullPath.TryGetValue(newPath, out var found) ? found : null;

View File

@ -6,6 +6,10 @@
<Version>$(VERSION)</Version> <Version>$(VERSION)</Version>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression> <PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<NoWarn>CS8600,CS8601,CS8618,CS8604</NoWarn>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.2" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.2" />