diff --git a/CHANGELIST.md b/CHANGELIST.md index b4e6668c..c6c7bcd8 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -7,6 +7,7 @@ - Add generic drive flag for Redumper - Handle numeric disc titles as issue numbers - Unify handling of enable/disable events +- Enable nullability in Check ### 2.7.0 (2023-10-11) diff --git a/MPF.Check/MPF.Check.csproj b/MPF.Check/MPF.Check.csproj index d78c09a9..e4016cda 100644 --- a/MPF.Check/MPF.Check.csproj +++ b/MPF.Check/MPF.Check.csproj @@ -11,6 +11,10 @@ 2.7.0 + + enable + + diff --git a/MPF.Check/Program.cs b/MPF.Check/Program.cs index 9116cdc5..ee75f033 100644 --- a/MPF.Check/Program.cs +++ b/MPF.Check/Program.cs @@ -21,7 +21,7 @@ namespace MPF.Check } // Try processing the common arguments - (bool success, MediaType mediaType, RedumpSystem? knownSystem, string error) = OptionsLoader.ProcessCommonArguments(args); + (bool success, MediaType mediaType, RedumpSystem? knownSystem, var error) = OptionsLoader.ProcessCommonArguments(args); if (!success) { DisplayHelp(error); @@ -29,11 +29,7 @@ namespace MPF.Check } // Loop through and process options -#if NET48 - (Core.Data.Options options, SubmissionInfo seedInfo, string path, int startIndex) = OptionsLoader.LoadFromArguments(args, startIndex: 2); -#else - (Core.Data.Options options, SubmissionInfo? seedInfo, string? path, int startIndex) = OptionsLoader.LoadFromArguments(args, startIndex: 2); -#endif + (var options, var seedInfo, var path, int startIndex) = OptionsLoader.LoadFromArguments(args, startIndex: 2); if (options.InternalProgram == InternalProgram.NONE) { DisplayHelp("A program name needs to be provided"); @@ -50,7 +46,7 @@ namespace MPF.Check #if NET48 (bool? _, string message) = RedumpWebClient.ValidateCredentials(options?.RedumpUsername, options?.RedumpPassword); #else - (bool? _, string message) = RedumpHttpClient.ValidateCredentials(options?.RedumpUsername, options?.RedumpPassword).ConfigureAwait(false).GetAwaiter().GetResult(); + (bool? _, string? message) = RedumpHttpClient.ValidateCredentials(options.RedumpUsername ?? string.Empty, options.RedumpPassword ?? string.Empty).ConfigureAwait(false).GetAwaiter().GetResult(); #endif if (!string.IsNullOrWhiteSpace(message)) Console.WriteLine(message); @@ -69,7 +65,11 @@ namespace MPF.Check string filepath = Path.GetFullPath(args[i].Trim('"')); // Now populate an environment +#if NET48 Drive drive = null; +#else + Drive? drive = null; +#endif if (!string.IsNullOrWhiteSpace(path)) drive = Drive.Create(null, path); @@ -85,7 +85,11 @@ namespace MPF.Check /// Display help for MPF.Check /// /// Error string to prefix the help text with +#if NET48 private static void DisplayHelp(string error = null) +#else + private static void DisplayHelp(string? error = null) +#endif { if (error != null) Console.WriteLine(error); diff --git a/MPF.Core/ConsoleLogger.cs b/MPF.Core/ConsoleLogger.cs index c7082961..107c214e 100644 --- a/MPF.Core/ConsoleLogger.cs +++ b/MPF.Core/ConsoleLogger.cs @@ -9,7 +9,11 @@ namespace MPF.Core /// /// Simple process counter to write to console /// +#if NET48 public static void ProgressUpdated(object sender, Result value) +#else + public static void ProgressUpdated(object? sender, Result value) +#endif { Console.WriteLine(value.Message); } @@ -17,7 +21,11 @@ namespace MPF.Core /// /// Simple process counter to write to console /// +#if NET48 public static void ProgressUpdated(object sender, ProtectionProgress value) +#else + public static void ProgressUpdated(object? sender, ProtectionProgress value) +#endif { Console.WriteLine($"{value.Percentage * 100:N2}%: {value.Filename} - {value.Protection}"); } diff --git a/MPF.Core/DumpEnvironment.cs b/MPF.Core/DumpEnvironment.cs index cb9b925e..c8274410 100644 --- a/MPF.Core/DumpEnvironment.cs +++ b/MPF.Core/DumpEnvironment.cs @@ -123,7 +123,11 @@ namespace MPF.Core RedumpSystem? system, MediaType? type, InternalProgram? internalProgram, +#if NET48 string parameters) +#else + string? parameters) +#endif { // Set options object this.Options = options; @@ -194,7 +198,11 @@ namespace MPF.Core /// Set the parameters object based on the internal program and parameters string /// /// String representation of the parameters +#if NET48 public void SetParameters(string parameters) +#else + public void SetParameters(string? parameters) +#endif { switch (this.InternalProgram) { @@ -284,7 +292,7 @@ namespace MPF.Core return null; } - #endregion +#endregion #region Dumping diff --git a/MPF.Core/Modules/Aaru/Parameters.cs b/MPF.Core/Modules/Aaru/Parameters.cs index aa6f1b07..41e455ce 100644 --- a/MPF.Core/Modules/Aaru/Parameters.cs +++ b/MPF.Core/Modules/Aaru/Parameters.cs @@ -256,7 +256,11 @@ namespace MPF.Core.Modules.Aaru #endregion /// +#if NET48 public Parameters(string parameters) : base(parameters) { } +#else + public Parameters(string? parameters) : base(parameters) { } +#endif /// public Parameters(RedumpSystem? system, MediaType? type, char driveLetter, string filename, int? driveSpeed, Options options) @@ -1814,7 +1818,11 @@ namespace MPF.Core.Modules.Aaru } /// +#if NET48 protected override bool ValidateAndSetParameters(string parameters) +#else + protected override bool ValidateAndSetParameters(string? parameters) +#endif { BaseCommand = CommandStrings.NONE; diff --git a/MPF.Core/Modules/BaseParameters.cs b/MPF.Core/Modules/BaseParameters.cs index 246488fe..fda68a07 100644 --- a/MPF.Core/Modules/BaseParameters.cs +++ b/MPF.Core/Modules/BaseParameters.cs @@ -148,7 +148,11 @@ namespace MPF.Core.Modules /// Populate a Parameters object from a param string /// /// String possibly representing a set of parameters +#if NET48 public BaseParameters(string parameters) +#else + public BaseParameters(string? parameters) +#endif { // If any parameters are not valid, wipe out everything if (!ValidateAndSetParameters(parameters)) @@ -290,7 +294,11 @@ namespace MPF.Core.Modules /// /// String possibly representing parameters /// True if the parameters were set correctly, false otherwise +#if NET48 protected virtual bool ValidateAndSetParameters(string parameters) => !string.IsNullOrWhiteSpace(parameters); +#else + protected virtual bool ValidateAndSetParameters(string? parameters) => !string.IsNullOrWhiteSpace(parameters); +#endif #endregion diff --git a/MPF.Core/Modules/CleanRIp/Parameters.cs b/MPF.Core/Modules/CleanRIp/Parameters.cs index 42b4b663..e18a56a1 100644 --- a/MPF.Core/Modules/CleanRIp/Parameters.cs +++ b/MPF.Core/Modules/CleanRIp/Parameters.cs @@ -22,7 +22,11 @@ namespace MPF.Core.Modules.CleanRip #endregion /// +#if NET48 public Parameters(string parameters) : base(parameters) { } +#else + public Parameters(string? parameters) : base(parameters) { } +#endif /// public Parameters(RedumpSystem? system, MediaType? type, char driveLetter, string filename, int? driveSpeed, Options options) diff --git a/MPF.Core/Modules/DiscImageCreator/Parameters.cs b/MPF.Core/Modules/DiscImageCreator/Parameters.cs index 8f0409dc..82ec09c4 100644 --- a/MPF.Core/Modules/DiscImageCreator/Parameters.cs +++ b/MPF.Core/Modules/DiscImageCreator/Parameters.cs @@ -187,7 +187,11 @@ namespace MPF.Core.Modules.DiscImageCreator #endregion /// +#if NET48 public Parameters(string parameters) : base(parameters) { } +#else + public Parameters(string? parameters) : base(parameters) { } +#endif /// public Parameters(RedumpSystem? system, MediaType? type, char driveLetter, string filename, int? driveSpeed, Options options) @@ -2074,7 +2078,11 @@ namespace MPF.Core.Modules.DiscImageCreator } /// +#if NET48 protected override bool ValidateAndSetParameters(string parameters) +#else + protected override bool ValidateAndSetParameters(string? parameters) +#endif { BaseCommand = CommandStrings.NONE; diff --git a/MPF.Core/Modules/Redumper/Parameters.cs b/MPF.Core/Modules/Redumper/Parameters.cs index 909d78b0..78534739 100644 --- a/MPF.Core/Modules/Redumper/Parameters.cs +++ b/MPF.Core/Modules/Redumper/Parameters.cs @@ -209,7 +209,11 @@ namespace MPF.Core.Modules.Redumper #endregion /// +#if NET48 public Parameters(string parameters) : base(parameters) { } +#else + public Parameters(string? parameters) : base(parameters) { } +#endif /// public Parameters(RedumpSystem? system, MediaType? type, char driveLetter, string filename, int? driveSpeed, Options options) @@ -1060,7 +1064,11 @@ namespace MPF.Core.Modules.Redumper } /// +#if NET48 protected override bool ValidateAndSetParameters(string parameters) +#else + protected override bool ValidateAndSetParameters(string? parameters) +#endif { BaseCommand = CommandStrings.NONE; diff --git a/MPF.Core/Modules/UmdImageCreator/Parameters.cs b/MPF.Core/Modules/UmdImageCreator/Parameters.cs index 9ab584a8..16fd069a 100644 --- a/MPF.Core/Modules/UmdImageCreator/Parameters.cs +++ b/MPF.Core/Modules/UmdImageCreator/Parameters.cs @@ -21,7 +21,11 @@ namespace MPF.Core.Modules.UmdImageCreator #endregion /// +#if NET48 public Parameters(string parameters) : base(parameters) { } +#else + public Parameters(string? parameters) : base(parameters) { } +#endif /// public Parameters(RedumpSystem? system, MediaType? type, char driveLetter, string filename, int? driveSpeed, Options options)