Enabled Nullable

This commit is contained in:
erri120 2020-04-06 14:04:40 +02:00
parent 9454bcaa5f
commit 9a3a3448d0
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
11 changed files with 120 additions and 22 deletions

View File

@ -121,4 +121,67 @@ csharp_preserve_single_line_blocks = true
# CS4014: Task not awaited
dotnet_diagnostic.CS4014.severity = error
# CS1998: Async function does not contain await
dotnet_diagnostic.CS1998.severity = silent
dotnet_diagnostic.CS1998.severity = silent
###############################
# C# Nullability #
###############################
# CS8602: Dereference of a possibly null reference.
dotnet_diagnostic.CS8602.severity = error
# CS8600: Converting null literal or possible null value to non-nullable type.
dotnet_diagnostic.CS8600.severity = error
# CS8619: Nullability of reference types in value doesn't match target type.
dotnet_diagnostic.CS8619.severity = error
# CS8603: Possible null reference return.
dotnet_diagnostic.CS8603.severity = error
# CS8625: Cannot convert null literal to non-nullable reference type.
dotnet_diagnostic.CS8625.severity = error
# CS8653: A default expression introduces a null value for a type parameter.
dotnet_diagnostic.CS8653.severity = silent
# CS8601: Possible null reference assignment.
dotnet_diagnostic.CS8601.severity = error
# CS8604: Possible null reference argument.
dotnet_diagnostic.CS8604.severity = error
# CS8622: Nullability of reference types in type of parameter doesn't match the target delegate.
dotnet_diagnostic.CS8622.severity = error
# CS8610: Nullability of reference types in type of parameter doesn't match overridden member.
dotnet_diagnostic.CS8610.severity = error
# CS8618: Non-nullable field is uninitialized. Consider declaring as nullable.
dotnet_diagnostic.CS8618.severity = error
# CS8629: Nullable value type may be null.
dotnet_diagnostic.CS8629.severity = error
# CS8620: Argument cannot be used for parameter due to differences in the nullability of reference types.
dotnet_diagnostic.CS8620.severity = error
# CS8614: Nullability of reference types in type of parameter doesn't match implicitly implemented member.
dotnet_diagnostic.CS8614.severity = error
# CS8617: Nullability of reference types in type of parameter doesn't match implemented member.
dotnet_diagnostic.CS8617.severity = error
# CS8611: Nullability of reference types in type of parameter doesn't match partial method declaration.
dotnet_diagnostic.CS8611.severity = error
# CS8597: Thrown value may be null.
dotnet_diagnostic.CS8597.severity = error
# CS8609: Nullability of reference types in return type doesn't match overridden member.
dotnet_diagnostic.CS8609.severity = error
# CS8714: The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'notnull' constraint.
dotnet_diagnostic.CS8714.severity = error
# CS8605: Unboxing a possibly null value.
dotnet_diagnostic.CS8605.severity = error

View File

@ -1,9 +1,21 @@
using System;
using Wabbajack.CLI.Verbs;
namespace Wabbajack.CLI
{
[AttributeUsage(AttributeTargets.Property)]
internal class FileAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Property)]
internal class DirectoryAttribute : Attribute { }
internal static class CLIUtils
{
internal static bool VerifyArguments(AVerb verb)
{
return true;
}
internal static void Log(string msg, bool newLine = true)
{
//TODO: maybe also write to a log file?

View File

@ -1,6 +1,4 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks;
namespace Wabbajack.CLI.Verbs
{

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
@ -18,16 +19,16 @@ namespace Wabbajack.CLI.Verbs
public class ChangeDownload : AVerb
{
[Option("input", Required = true, HelpText = "Input folder containing the downloads you want to move")]
public string Input { get; set; }
public string? Input { get; set; }
[Option("output", Required = true, HelpText = "Output folder the downloads should be transferred to")]
public string Output { get; set; }
public string? Output { get; set; }
[Option("modlist", Required = true, HelpText = "The Modlist, can either be a .wabbajack or a modlist.txt file")]
public string Modlist { get; set; }
public string? Modlist { get; set; }
[Option("mods", Required = false, HelpText = "Mods folder location if the provided modlist file is an MO2 modlist.txt")]
public string Mods { get; set; }
public string? Mods { get; set; }
[Option("copy", Default = true, HelpText = "Whether to copy the files", SetName = "copy")]
public bool Copy { get; set; }
@ -69,13 +70,13 @@ namespace Wabbajack.CLI.Verbs
Directory.CreateDirectory(Output);
}
if (!Modlist.EndsWith(Consts.ModListExtension) && !Modlist.EndsWith("modlist.txt"))
if (Modlist != null && (!Modlist.EndsWith(Consts.ModListExtension) && !Modlist.EndsWith("modlist.txt")))
return CLIUtils.Exit($"The file {Modlist} is not a valid modlist file!", -1);
if (Copy && Move)
return CLIUtils.Exit("You can't set both copy and move flags!", -1);
var isModlist = Modlist.EndsWith(Consts.ModListExtension);
var isModlist = Modlist != null && Modlist.EndsWith(Consts.ModListExtension);
var list = new List<TransferFile>();

View File

@ -0,0 +1,24 @@
using System;
using System.Threading.Tasks;
using CommandLine;
namespace Wabbajack.CLI.Verbs
{
[Verb("changelog", HelpText = "Generate a changelog using two different versions of the same Modlist.")]
public class Changelog : AVerb
{
[Option("original", Required = true, HelpText = "The original/previous modlist")]
public string? Original { get; set; }
[Option("update", Required = true, HelpText = "The current/updated modlist")]
public string? Update { get; set; }
[Option('o', "output", Required = false, HelpText = "The output file")]
public string? Output { get; set; }
protected override Task<int> Run()
{
throw new NotImplementedException();
}
}
}

View File

@ -9,11 +9,11 @@ namespace Wabbajack.CLI.Verbs
public class Decrypt : AVerb
{
[Option('n', "name", Required = true, HelpText = @"Credential to encrypt and store in AppData\Local\Wabbajack")]
public string Name { get; set; }
public string? Name { get; set; }
[Option('o', "output", Required = true, HelpText = @"Output file for the decrypted data")]
public string Output { get; set; }
public string? Output { get; set; }
protected override async Task<int> Run()
{

View File

@ -9,7 +9,8 @@ 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; }
protected override async Task<int> Run()
{
Console.WriteLine(await AuthorAPI.DeleteFile(Name));

View File

@ -14,10 +14,10 @@ namespace Wabbajack.CLI.Verbs
public class DownloadUrl : AVerb
{
[Option('u', "url", Required = true, HelpText = "Url to download")]
public Uri Url { get; set; }
public Uri? Url { get; set; }
[Option('o', "output", Required = true, HelpText = "Output file name")]
public string Output { get; set; }
public string? Output { get; set; }
protected override async Task<int> Run()
{

View File

@ -9,10 +9,10 @@ namespace Wabbajack.CLI.Verbs
public class Encrypt : AVerb
{
[Option('n', "name", Required = true, HelpText = @"Credential to encrypt and store in AppData\Local\Wabbajack")]
public string Name { get; set; }
public string? Name { get; set; }
[Option('i', "input", Required = true, HelpText = @"Source data file name")]
public string Input { get; set; }
public string? Input { get; set; }
protected override async Task<int> Run()
{

View File

@ -1,11 +1,9 @@
using System;
using System.Reactive.Linq;
using System.Threading.Tasks;
using CommandLine;
using Wabbajack.Common;
using Wabbajack.Lib;
using Wabbajack.Lib.Validation;
using Wabbajack.VirtualFileSystem;
using File = Alphaleonis.Win32.Filesystem.File;
namespace Wabbajack.CLI.Verbs
@ -14,12 +12,11 @@ namespace Wabbajack.CLI.Verbs
public class Validate : AVerb
{
[Option('i', "input", Required = true, HelpText = @"Modlist file")]
public string Input { get; set; }
public string? Input { get; set; }
/// <summary>
/// Runs the Validation of a Modlist
/// </summary>
/// <param name="opts"></param>
/// <returns>
/// <para>
/// <c>-1</c> bad Input
@ -33,7 +30,7 @@ namespace Wabbajack.CLI.Verbs
return CLIUtils.Exit($"The file {Input} does not exist!", -1);
if (!Input.EndsWith(Consts.ModListExtension))
if (Input != null && !Input.EndsWith(Consts.ModListExtension))
return CLIUtils.Exit($"The file {Input} does not end with {Consts.ModListExtension}!", -1);
ModList modlist;

View File

@ -12,6 +12,8 @@
<Description>An automated ModList installer</Description>
<PublishReadyToRun>true</PublishReadyToRun>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>