From ecee44966e3d6501d6ef92f4fbbd2d49ca97ff87 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 12 Oct 2023 01:19:47 -0400 Subject: [PATCH] Gate some switch expressions --- CHANGELIST.md | 1 + MPF.Core/DumpEnvironment.cs | 128 +++++++++++------- MPF.Core/InfoTool.cs | 28 ++++ MPF.Core/Modules/Aaru/Parameters.cs | 80 +++++++++++ MPF.Core/Modules/BaseParameters.cs | 33 ++++- .../Modules/DiscImageCreator/Parameters.cs | 59 ++++++++ MPF.Core/Modules/Redumper/Parameters.cs | 10 +- MPF.Core/Utilities/Tools.cs | 30 ++++ 8 files changed, 318 insertions(+), 51 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index 7fa3ca2b..97f0878f 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -2,6 +2,7 @@ - Fix options loading for Check - Cleanup and gated code +- Gate some switch expressions ### 2.7.1 (2023-10-11) diff --git a/MPF.Core/DumpEnvironment.cs b/MPF.Core/DumpEnvironment.cs index 499b58bd..9075ae80 100644 --- a/MPF.Core/DumpEnvironment.cs +++ b/MPF.Core/DumpEnvironment.cs @@ -130,16 +130,16 @@ namespace MPF.Core #endif { // Set options object - this.Options = options; + Options = options; // Output paths - this.OutputPath = InfoTool.NormalizeOutputPaths(outputPath, true); + OutputPath = InfoTool.NormalizeOutputPaths(outputPath, true); // UI information - this.Drive = drive; - this.System = system ?? options.DefaultSystem; - this.Type = type ?? MediaType.NONE; - this.InternalProgram = internalProgram ?? options.InternalProgram; + Drive = drive; + System = system ?? options.DefaultSystem; + Type = type ?? MediaType.NONE; + InternalProgram = internalProgram ?? options.InternalProgram; // Dumping program SetParameters(parameters); @@ -153,13 +153,13 @@ namespace MPF.Core public void AdjustPathsForDiscImageCreator() { // Only DiscImageCreator has issues with paths - if (this.Parameters?.InternalProgram != InternalProgram.DiscImageCreator) + if (Parameters?.InternalProgram != InternalProgram.DiscImageCreator) return; try { // Normalize the output path - string outputPath = InfoTool.NormalizeOutputPaths(this.OutputPath, true); + string outputPath = InfoTool.NormalizeOutputPaths(OutputPath, true); // Replace all instances in the output directory var outputDirectory = Path.GetDirectoryName(outputPath); @@ -176,20 +176,20 @@ namespace MPF.Core if (string.IsNullOrWhiteSpace(outputDirectory)) { if (string.IsNullOrWhiteSpace(outputExtension)) - this.OutputPath = outputFilename; + OutputPath = outputFilename; else - this.OutputPath = $"{outputFilename}.{outputExtension}"; + OutputPath = $"{outputFilename}.{outputExtension}"; } else { if (string.IsNullOrWhiteSpace(outputExtension)) - this.OutputPath = Path.Combine(outputDirectory, outputFilename); + OutputPath = Path.Combine(outputDirectory, outputFilename); else - this.OutputPath = Path.Combine(outputDirectory, $"{outputFilename}.{outputExtension}"); + OutputPath = Path.Combine(outputDirectory, $"{outputFilename}.{outputExtension}"); } // Assign the path to the filename as well for dumping - ((Modules.DiscImageCreator.Parameters)this.Parameters).Filename = this.OutputPath; + ((Modules.DiscImageCreator.Parameters)Parameters).Filename = OutputPath; } catch { } } @@ -204,45 +204,63 @@ namespace MPF.Core public void SetParameters(string? parameters) #endif { - switch (this.InternalProgram) +#if NET48 + switch (InternalProgram) { // Dumping support case InternalProgram.Aaru: - this.Parameters = new Modules.Aaru.Parameters(parameters) { ExecutablePath = Options.AaruPath }; + Parameters = new Modules.Aaru.Parameters(parameters) { ExecutablePath = Options.AaruPath }; break; case InternalProgram.DiscImageCreator: - this.Parameters = new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath }; + Parameters = new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath }; break; case InternalProgram.Redumper: - this.Parameters = new Modules.Redumper.Parameters(parameters) { ExecutablePath = Options.RedumperPath }; + Parameters = new Modules.Redumper.Parameters(parameters) { ExecutablePath = Options.RedumperPath }; break; // Verification support only case InternalProgram.CleanRip: - this.Parameters = new Modules.CleanRip.Parameters(parameters) { ExecutablePath = null }; + Parameters = new Modules.CleanRip.Parameters(parameters) { ExecutablePath = null }; break; case InternalProgram.DCDumper: - this.Parameters = null; // TODO: Create correct parameter type when supported + Parameters = null; // TODO: Create correct parameter type when supported break; case InternalProgram.UmdImageCreator: - this.Parameters = new Modules.UmdImageCreator.Parameters(parameters) { ExecutablePath = null }; + Parameters = new Modules.UmdImageCreator.Parameters(parameters) { ExecutablePath = null }; break; // This should never happen, but it needs a fallback default: - this.Parameters = new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath }; + Parameters = new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath }; break; } +#else + Parameters = InternalProgram switch + { + // Dumping support + InternalProgram.Aaru => new Modules.Aaru.Parameters(parameters) { ExecutablePath = Options.AaruPath }, + InternalProgram.DiscImageCreator => new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath }, + InternalProgram.Redumper => new Modules.Redumper.Parameters(parameters) { ExecutablePath = Options.RedumperPath }, + + // Verification support only + InternalProgram.CleanRip => new Modules.CleanRip.Parameters(parameters) { ExecutablePath = null }, + InternalProgram.DCDumper => null, // TODO: Create correct parameter type when supported + InternalProgram.UmdImageCreator => new Modules.UmdImageCreator.Parameters(parameters) { ExecutablePath = null }, + + // This should never happen, but it needs a fallback + _ => new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath }, + }; +#endif // Set system and type - if (this.Parameters != null) + if (Parameters != null) { - this.Parameters.System = this.System; - this.Parameters.Type = this.Type; + Parameters.System = System; + Parameters.Type = Type; } } @@ -265,25 +283,37 @@ namespace MPF.Core return null; // Set the proper parameters - switch (this.InternalProgram) +#if NET48 + switch (InternalProgram) { case InternalProgram.Aaru: - Parameters = new Modules.Aaru.Parameters(System, Type, Drive.Letter, this.OutputPath, driveSpeed, Options); + Parameters = new Modules.Aaru.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options); break; case InternalProgram.DiscImageCreator: - Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, this.OutputPath, driveSpeed, Options); + Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options); break; case InternalProgram.Redumper: - Parameters = new Modules.Redumper.Parameters(System, Type, Drive.Letter, this.OutputPath, driveSpeed, Options); + Parameters = new Modules.Redumper.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options); break; // This should never happen, but it needs a fallback default: - Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, this.OutputPath, driveSpeed, Options); + Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options); break; } +#else + Parameters = InternalProgram switch + { + InternalProgram.Aaru => new Modules.Aaru.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options), + InternalProgram.DiscImageCreator => new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options), + InternalProgram.Redumper => new Modules.Redumper.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options), + + // This should never happen, but it needs a fallback + _ => new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options), + }; +#endif // Generate and return the param string return Parameters.GenerateParameters(); @@ -292,7 +322,7 @@ namespace MPF.Core return null; } - #endregion +#endregion #region Dumping @@ -332,7 +362,7 @@ namespace MPF.Core #endif { // If we don't have parameters - if (this.Parameters == null) + if (Parameters == null) return Result.Failure("Error! Current configuration is not supported!"); // Check that we have the basics for dumping @@ -349,14 +379,14 @@ namespace MPF.Core } // Execute internal tool - progress?.Report(Result.Success($"Executing {this.InternalProgram}... {(Options.ToolsInSeparateWindow ? "please wait!" : "see log for output!")}")); + progress?.Report(Result.Success($"Executing {InternalProgram}... {(Options.ToolsInSeparateWindow ? "please wait!" : "see log for output!")}")); - var directoryName = Path.GetDirectoryName(this.OutputPath); + var directoryName = Path.GetDirectoryName(OutputPath); if (!string.IsNullOrWhiteSpace(directoryName)) Directory.CreateDirectory(directoryName); await Task.Run(() => Parameters.ExecuteInternalProgram(Options.ToolsInSeparateWindow)); - progress?.Report(Result.Success($"{this.InternalProgram} has finished!")); + progress?.Report(Result.Success($"{InternalProgram} has finished!")); // Remove event handler if needed if (!Options.ToolsInSeparateWindow) @@ -392,11 +422,11 @@ namespace MPF.Core resultProgress?.Report(Result.Success("Gathering submission information... please wait!")); // Get the output directory and filename separately - var outputDirectory = Path.GetDirectoryName(this.OutputPath); - var outputFilename = Path.GetFileName(this.OutputPath); + var outputDirectory = Path.GetDirectoryName(OutputPath); + var outputFilename = Path.GetFileName(OutputPath); // Check to make sure that the output had all the correct files - (bool foundFiles, List missingFiles) = InfoTool.FoundAllFiles(outputDirectory, outputFilename, this.Parameters, false); + (bool foundFiles, List missingFiles) = InfoTool.FoundAllFiles(outputDirectory, outputFilename, Parameters, false); if (!foundFiles) { resultProgress?.Report(Result.Failure($"There were files missing from the output:\n{string.Join("\n", missingFiles)}")); @@ -406,12 +436,12 @@ namespace MPF.Core // Extract the information from the output files resultProgress?.Report(Result.Success("Extracting output information from output files...")); var submissionInfo = await InfoTool.ExtractOutputInformation( - this.OutputPath, - this.Drive, - this.System, - this.Type, - this.Options, - this.Parameters, + OutputPath, + Drive, + System, + Type, + Options, + Parameters, resultProgress, protectionProgress); resultProgress?.Report(Result.Success("Extracting information complete!")); @@ -432,7 +462,7 @@ namespace MPF.Core } // Reset the drive automatically if configured to - if (this.InternalProgram == InternalProgram.DiscImageCreator && Options.DICResetDriveAfterDump) + if (InternalProgram == InternalProgram.DiscImageCreator && Options.DICResetDriveAfterDump) { resultProgress?.Report(Result.Success($"Resetting drive {Drive?.Letter}")); await ResetDrive(); @@ -459,7 +489,7 @@ namespace MPF.Core // Format the information for the text output resultProgress?.Report(Result.Success("Formatting information...")); - (var formattedValues, var formatResult) = InfoTool.FormatOutputData(submissionInfo, this.Options); + (var formattedValues, var formatResult) = InfoTool.FormatOutputData(submissionInfo, Options); if (formattedValues == null) resultProgress?.Report(Result.Success(formatResult)); else @@ -499,7 +529,7 @@ namespace MPF.Core if (Options.CompressLogFiles) { resultProgress?.Report(Result.Success("Compressing log files...")); - (bool compressSuccess, string compressResult) = InfoTool.CompressLogFiles(outputDirectory, outputFilename, this.Parameters); + (bool compressSuccess, string compressResult) = InfoTool.CompressLogFiles(outputDirectory, outputFilename, Parameters); if (compressSuccess) resultProgress?.Report(Result.Success(compressResult)); else @@ -647,14 +677,14 @@ namespace MPF.Core private Result IsValidForDump() { // Validate that everything is good - if (this.Parameters == null || !ParametersValid()) + if (Parameters == null || !ParametersValid()) return Result.Failure("Error! Current configuration is not supported!"); // Fix the output paths, just in case - this.OutputPath = InfoTool.NormalizeOutputPaths(this.OutputPath, true); + OutputPath = InfoTool.NormalizeOutputPaths(OutputPath, true); // Validate that the output path isn't on the dumping drive - if (Drive != null && this.OutputPath[0] == Drive.Letter) + if (Drive != null && OutputPath[0] == Drive.Letter) return Result.Failure("Error! Cannot output to same drive that is being dumped!"); // Validate that the required program exists diff --git a/MPF.Core/InfoTool.cs b/MPF.Core/InfoTool.cs index 5a757f58..418a61f7 100644 --- a/MPF.Core/InfoTool.cs +++ b/MPF.Core/InfoTool.cs @@ -3266,6 +3266,7 @@ namespace MPF.Core /// TODO: This should move to Extensions at some point private static bool IsBoolean(SiteCode? siteCode) { +#if NET48 switch (siteCode) { case SiteCode.PostgapType: @@ -3274,6 +3275,14 @@ namespace MPF.Core default: return false; } +#else + return siteCode switch + { + SiteCode.PostgapType => true, + SiteCode.VCD => true, + _ => false, + }; +#endif } /// @@ -3284,6 +3293,7 @@ namespace MPF.Core /// TODO: This should move to Extensions at some point private static bool IsMultiLine(SiteCode? siteCode) { +#if NET48 switch (siteCode) { case SiteCode.Extras: @@ -3302,6 +3312,24 @@ namespace MPF.Core default: return false; } +#else + return siteCode switch + { + SiteCode.Extras => true, + SiteCode.Filename => true, + SiteCode.Games => true, + SiteCode.GameFootage => true, + SiteCode.Multisession => true, + SiteCode.NetYarozeGames => true, + SiteCode.Patches => true, + SiteCode.PlayableDemos => true, + SiteCode.RollingDemos => true, + SiteCode.Savegames => true, + SiteCode.TechDemos => true, + SiteCode.Videos => true, + _ => false, + }; +#endif } /// diff --git a/MPF.Core/Modules/Aaru/Parameters.cs b/MPF.Core/Modules/Aaru/Parameters.cs index 123ea8db..91900c28 100644 --- a/MPF.Core/Modules/Aaru/Parameters.cs +++ b/MPF.Core/Modules/Aaru/Parameters.cs @@ -2446,6 +2446,7 @@ namespace MPF.Core.Modules.Aaru case CommandStrings.ArchivePrefixShort: case CommandStrings.ArchivePrefixLong: family = CommandStrings.ArchivePrefixLong; +#if NET48 switch (splitCommand[1]) { case CommandStrings.ArchiveInfo: @@ -2455,11 +2456,19 @@ namespace MPF.Core.Modules.Aaru command = null; break; } +#else + command = splitCommand[1] switch + { + CommandStrings.ArchiveInfo => CommandStrings.ArchiveInfo, + _ => null, + }; +#endif break; case CommandStrings.DatabasePrefixShort: case CommandStrings.DatabasePrefixLong: family = CommandStrings.DatabasePrefixLong; +#if NET48 switch (splitCommand[1]) { case CommandStrings.DatabaseStats: @@ -2472,12 +2481,21 @@ namespace MPF.Core.Modules.Aaru command = null; break; } +#else + command = splitCommand[1] switch + { + CommandStrings.DatabaseStats => CommandStrings.DatabaseStats, + CommandStrings.DatabaseUpdate => CommandStrings.DatabaseUpdate, + _ => null, + }; +#endif break; case CommandStrings.DevicePrefixShort: case CommandStrings.DevicePrefixLong: family = CommandStrings.DevicePrefixLong; +#if NET48 switch (splitCommand[1]) { case CommandStrings.DeviceInfo: @@ -2493,6 +2511,15 @@ namespace MPF.Core.Modules.Aaru command = null; break; } +#else + command = splitCommand[1] switch + { + CommandStrings.DeviceInfo => CommandStrings.DeviceInfo, + CommandStrings.DeviceList => CommandStrings.DeviceList, + CommandStrings.DeviceReport => CommandStrings.DeviceReport, + _ => null, + }; +#endif break; @@ -2500,6 +2527,7 @@ namespace MPF.Core.Modules.Aaru case CommandStrings.FilesystemPrefixShortAlt: case CommandStrings.FilesystemPrefixLong: family = CommandStrings.FilesystemPrefixLong; +#if NET48 switch (splitCommand[1]) { case CommandStrings.FilesystemExtract: @@ -2519,12 +2547,24 @@ namespace MPF.Core.Modules.Aaru command = null; break; } +#else + command = splitCommand[1] switch + { + CommandStrings.FilesystemExtract => CommandStrings.FilesystemExtract, + CommandStrings.FilesystemInfo => CommandStrings.FilesystemInfo, + CommandStrings.FilesystemListShort => CommandStrings.FilesystemListLong, + CommandStrings.FilesystemListLong => CommandStrings.FilesystemListLong, + CommandStrings.FilesystemOptions => CommandStrings.FilesystemOptions, + _ => null, + }; +#endif break; case CommandStrings.ImagePrefixShort: case CommandStrings.ImagePrefixLong: family = CommandStrings.ImagePrefixLong; +#if NET48 switch (splitCommand[1]) { case CommandStrings.ImageChecksumShort: @@ -2563,12 +2603,31 @@ namespace MPF.Core.Modules.Aaru command = null; break; } +#else + command = splitCommand[1] switch + { + CommandStrings.ImageChecksumShort => CommandStrings.ImageChecksumLong, + CommandStrings.ImageChecksumLong => CommandStrings.ImageChecksumLong, + CommandStrings.ImageCompareShort => CommandStrings.ImageCompareLong, + CommandStrings.ImageCompareLong => CommandStrings.ImageCompareLong, + CommandStrings.ImageConvert => CommandStrings.ImageConvert, + CommandStrings.ImageCreateSidecar => CommandStrings.ImageCreateSidecar, + CommandStrings.ImageDecode => CommandStrings.ImageDecode, + CommandStrings.ImageEntropy => CommandStrings.ImageEntropy, + CommandStrings.ImageInfo => CommandStrings.ImageInfo, + CommandStrings.ImageOptions => CommandStrings.ImageOptions, + CommandStrings.ImagePrint => CommandStrings.ImagePrint, + CommandStrings.ImageVerify => CommandStrings.ImageVerify, + _ => null, + }; +#endif break; case CommandStrings.MediaPrefixShort: case CommandStrings.MediaPrefixLong: family = CommandStrings.MediaPrefixLong; +#if NET48 switch (splitCommand[1]) { case CommandStrings.MediaDump: @@ -2584,6 +2643,15 @@ namespace MPF.Core.Modules.Aaru command = null; break; } +#else + command = splitCommand[1] switch + { + CommandStrings.MediaDump => CommandStrings.MediaDump, + CommandStrings.MediaInfo => CommandStrings.MediaInfo, + CommandStrings.MediaScan => CommandStrings.MediaScan, + _ => null, + }; +#endif break; @@ -2598,6 +2666,7 @@ namespace MPF.Core.Modules.Aaru else { family = null; +#if NET48 switch (splitCommand[0]) { case CommandStrings.Configure: @@ -2619,6 +2688,17 @@ namespace MPF.Core.Modules.Aaru command = null; break; } +#else + command = splitCommand[0] switch + { + CommandStrings.Configure => CommandStrings.Configure, + CommandStrings.Formats => CommandStrings.Formats, + CommandStrings.ListEncodings => CommandStrings.ListEncodings, + CommandStrings.ListNamespaces => CommandStrings.ListNamespaces, + CommandStrings.Remote => CommandStrings.Remote, + _ => null, + }; +#endif } // If the command itself is invalid, then return null diff --git a/MPF.Core/Modules/BaseParameters.cs b/MPF.Core/Modules/BaseParameters.cs index b8ee3b29..4efb6897 100644 --- a/MPF.Core/Modules/BaseParameters.cs +++ b/MPF.Core/Modules/BaseParameters.cs @@ -1951,6 +1951,7 @@ namespace MPF.Core.Modules /// Category, if possible protected static DiscCategory? GetUMDCategory(string category) { +#if NET48 switch (category) { case "GAME": return DiscCategory.Games; @@ -1958,6 +1959,15 @@ namespace MPF.Core.Modules case "AUDIO": return DiscCategory.Audio; default: return null; } +#else + return category switch + { + "GAME" => DiscCategory.Games, + "VIDEO" => DiscCategory.Video, + "AUDIO" => DiscCategory.Audio, + _ => null, + }; +#endif } #endregion @@ -1989,16 +1999,28 @@ namespace MPF.Core.Modules { case 'S': // Check first two digits of S_PS serial +#if NET48 switch (serial.Substring(5, 2)) { case "46": return Region.SouthKorea; - case "56": return Region.SouthKorea; case "51": return Region.Asia; + case "56": return Region.SouthKorea; case "55": return Region.Asia; default: return Region.Japan; } +#else + return serial.Substring(5, 2) switch + { + "46" => Region.SouthKorea, + "51" => Region.Asia, + "56" => Region.SouthKorea, + "55" => Region.Asia, + _ => Region.Japan, + }; +#endif case 'M': // Check first three digits of S_PM serial +#if NET48 switch (serial.Substring(5, 3)) { case "645": return Region.SouthKorea; @@ -2006,6 +2028,15 @@ namespace MPF.Core.Modules case "885": return Region.SouthKorea; default: return Region.Japan; // Remaining S_PM serials may be Japan or Asia } +#else + return serial.Substring(5, 3) switch + { + "645" => Region.SouthKorea, + "675" => Region.SouthKorea, + "885" => Region.SouthKorea, + _ => Region.Japan, // Remaining S_PM serials may be Japan or Asia + }; +#endif default: return Region.Japan; } } diff --git a/MPF.Core/Modules/DiscImageCreator/Parameters.cs b/MPF.Core/Modules/DiscImageCreator/Parameters.cs index 822e49a9..53051582 100644 --- a/MPF.Core/Modules/DiscImageCreator/Parameters.cs +++ b/MPF.Core/Modules/DiscImageCreator/Parameters.cs @@ -1991,6 +1991,7 @@ namespace MPF.Core.Modules.DiscImageCreator /// public override bool IsDumpingCommand() { +#if NET48 switch (BaseCommand) { case CommandStrings.Audio: @@ -2013,6 +2014,27 @@ namespace MPF.Core.Modules.DiscImageCreator default: return false; } +#else + return BaseCommand switch + { + CommandStrings.Audio + or CommandStrings.BluRay + or CommandStrings.CompactDisc + or CommandStrings.Data + or CommandStrings.DigitalVideoDisc + or CommandStrings.Disk + or CommandStrings.Floppy + or CommandStrings.GDROM + or CommandStrings.SACD + or CommandStrings.Swap + or CommandStrings.Tape + or CommandStrings.XBOX + or CommandStrings.XBOXSwap + or CommandStrings.XGD2Swap + or CommandStrings.XGD3Swap => true, + _ => false, + }; +#endif } /// @@ -2061,6 +2083,7 @@ namespace MPF.Core.Modules.DiscImageCreator this[FlagStrings.DisableBeep] = true; // Set the C2 reread count +#if NET48 switch (options.DICRereadCount) { case -1: @@ -2073,8 +2096,17 @@ namespace MPF.Core.Modules.DiscImageCreator C2OpcodeValue[0] = options.DICRereadCount; break; } +#else + C2OpcodeValue[0] = options.DICRereadCount switch + { + -1 => null, + 0 => 20, + _ => options.DICRereadCount, + }; +#endif // Set the DVD/HD-DVD/BD reread count +#if NET48 switch (options.DICDVDRereadCount) { case -1: @@ -2087,6 +2119,14 @@ namespace MPF.Core.Modules.DiscImageCreator DVDRereadValue = options.DICDVDRereadCount; break; } +#else + DVDRereadValue = options.DICDVDRereadCount switch + { + -1 => null, + 0 => 10, + _ => options.DICDVDRereadCount, + }; +#endif // Now sort based on disc type switch (this.Type) @@ -3850,6 +3890,7 @@ namespace MPF.Core.Modules.DiscImageCreator #endif string month = dateSplit[1]; +#if NET48 switch (month) { case "JAN": @@ -3892,6 +3933,24 @@ namespace MPF.Core.Modules.DiscImageCreator dateSplit[1] = "00"; break; } +#else + dateSplit[1] = month switch + { + "JAN" => "01", + "FEB" => "02", + "MAR" => "03", + "APR" => "04", + "MAY" => "05", + "JUN" => "06", + "JUL" => "07", + "AUG" => "08", + "SEP" => "09", + "OCT" => "10", + "NOV" => "11", + "DEC" => "12", + _ => "00", + }; +#endif date = string.Join("-", dateSplit); diff --git a/MPF.Core/Modules/Redumper/Parameters.cs b/MPF.Core/Modules/Redumper/Parameters.cs index 831c89b6..fb16de1c 100644 --- a/MPF.Core/Modules/Redumper/Parameters.cs +++ b/MPF.Core/Modules/Redumper/Parameters.cs @@ -1030,6 +1030,7 @@ namespace MPF.Core.Modules.Redumper switch (this.Type) { case MediaType.CDROM: +#if NET48 switch (this.System) { case RedumpSystem.SuperAudioCD: @@ -1039,6 +1040,13 @@ namespace MPF.Core.Modules.Redumper ModeValues = new List { CommandStrings.CD }; break; } +#else + ModeValues = this.System switch + { + RedumpSystem.SuperAudioCD => new List { CommandStrings.SACD }, + _ => new List { CommandStrings.CD }, + }; +#endif break; case MediaType.DVD: ModeValues = new List { CommandStrings.DVD }; @@ -1343,7 +1351,7 @@ namespace MPF.Core.Modules.Redumper return true; } - #endregion +#endregion #region Information Extraction Methods diff --git a/MPF.Core/Utilities/Tools.cs b/MPF.Core/Utilities/Tools.cs index 0aefece8..1ac20f33 100644 --- a/MPF.Core/Utilities/Tools.cs +++ b/MPF.Core/Utilities/Tools.cs @@ -84,6 +84,7 @@ namespace MPF.Core.Utilities return Result.Failure("Please select a valid system"); // If we're on an unsupported type, update the status accordingly +#if NET48 switch (type) { // Fully supported types @@ -116,6 +117,35 @@ namespace MPF.Core.Utilities default: return Result.Failure($"{type.LongName()} media are not supported for dumping"); } +#else + return type switch + { + // Fully supported types + MediaType.BluRay + or MediaType.CDROM + or MediaType.DVD + or MediaType.FloppyDisk + or MediaType.HardDisk + or MediaType.CompactFlash + or MediaType.SDCard + or MediaType.FlashDrive + or MediaType.HDDVD => Result.Success($"{type.LongName()} ready to dump"), + + // Partially supported types + MediaType.GDROM + or MediaType.NintendoGameCubeGameDisc + or MediaType.NintendoWiiOpticalDisc => Result.Success($"{type.LongName()} partially supported for dumping"), + + // Special case for other supported tools + MediaType.UMD => Result.Failure($"{type.LongName()} supported for submission info parsing"), + + // Specifically unknown type + MediaType.NONE => Result.Failure($"Please select a valid media type"), + + // Undumpable but recognized types + _ => Result.Failure($"{type.LongName()} media are not supported for dumping"), + }; +#endif } #endregion