From 0d694c1bdecdecb66747295982db3cefc588d68f Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 27 Sep 2023 00:38:00 -0400 Subject: [PATCH] Address some warnings and infos --- CHANGELIST.md | 1 + MPF.Core/Data/Drive.cs | 17 ++--- MPF.Library/InfoTool.cs | 70 ++++++++++------- MPF.Modules/Aaru/Parameters.cs | 3 + MPF.Modules/BaseParameters.cs | 43 ++++++----- MPF.Modules/DiscImageCreator/Parameters.cs | 81 ++++++++++---------- MPF.Modules/Redumper/Parameters.cs | 89 +++++++++++++++++++--- MPF.UI.Core/MPF.UI.Core.csproj | 2 +- MPF/MPF.csproj | 2 +- 9 files changed, 195 insertions(+), 113 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index 228011be..9dd07e27 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -6,6 +6,7 @@ - Add placeholders for release builds - Fully sync AppVeyor build with script - Stop compiling Chime finally +- Address some warnings and infos ### 2.6.5 (2023-09-27) diff --git a/MPF.Core/Data/Drive.cs b/MPF.Core/Data/Drive.cs index d10a7e3a..a098c2ca 100644 --- a/MPF.Core/Data/Drive.cs +++ b/MPF.Core/Data/Drive.cs @@ -113,7 +113,11 @@ namespace MPF.Core.Data // Sanitize a Windows-formatted long device path if (devicePath.StartsWith("\\\\.\\")) +#if NET48 devicePath = devicePath.Substring("\\\\.\\".Length); +#else + devicePath = devicePath["\\\\.\\".Length..]; +#endif // Create and validate the drive info object var driveInfo = new DriveInfo(devicePath); @@ -184,7 +188,7 @@ namespace MPF.Core.Data #if NET6_0_OR_GREATER else return GetMediaTypeFromSize(); -#endif +#else // Get the current drive information string deviceId = null; @@ -208,8 +212,6 @@ namespace MPF.Core.Data else if (!loaded) return (null, "Device is not reporting media loaded"); -#if NETFRAMEWORK - MsftDiscMaster2 discMaster = new MsftDiscMaster2(); deviceId = deviceId.ToLower().Replace('\\', '#').Replace('/', '#'); string id = null; @@ -237,17 +239,12 @@ namespace MPF.Core.Data var media = dataWriter.CurrentPhysicalMediaType; return (media.IMAPIToMediaType(), null); - -#else - - return (null, "IMAPI2 recorder not supported"); - -#endif } catch (Exception ex) { return (null, ex.Message); } +#endif } /// @@ -605,7 +602,7 @@ namespace MPF.Core.Data // https://github.com/aaru-dps/Aaru/blob/5164a154e2145941472f2ee0aeb2eff3338ecbb3/Aaru.Devices/Windows/ListDevices.cs#L66 // Create an output drive list - List drives = new List(); + var drives = new List(); // Get all standard supported drive types try diff --git a/MPF.Library/InfoTool.cs b/MPF.Library/InfoTool.cs index 21947cfc..e6c9d952 100644 --- a/MPF.Library/InfoTool.cs +++ b/MPF.Library/InfoTool.cs @@ -13,7 +13,6 @@ using MPF.Core.Data; using MPF.Core.Utilities; using MPF.Modules; using Newtonsoft.Json; -using SabreTools.Models.PIC; using SabreTools.RedumpLib.Data; using SabreTools.RedumpLib.Web; using Formatting = Newtonsoft.Json.Formatting; @@ -68,7 +67,7 @@ namespace MPF.Library // Create the SubmissionInfo object with all user-inputted values by default string combinedBase = Path.Combine(outputDirectory, outputFilename); - SubmissionInfo info = new SubmissionInfo() + var info = new SubmissionInfo() { CommonDiscInfo = new CommonDiscInfoSection() { @@ -520,11 +519,11 @@ namespace MPF.Library if (string.IsNullOrWhiteSpace(hashData)) return false; - Regex hashreg = new Regex(@" output = new List { "Common Disc Info:" }; + var output = new List { "Common Disc Info:" }; AddIfExists(output, Template.TitleField, info.CommonDiscInfo.Title, 1); AddIfExists(output, Template.ForeignTitleField, info.CommonDiscInfo.ForeignTitleNonLatin, 1); AddIfExists(output, Template.DiscNumberField, info.CommonDiscInfo.DiscNumberLetter, 1); @@ -691,7 +691,7 @@ namespace MPF.Library AddIfExists(output, Template.PartiallyMatchingIDsField, info.PartiallyMatchedIDs, 1); AddIfExists(output, Template.RegionField, info.CommonDiscInfo.Region.LongName() ?? "SPACE! (CHANGE THIS)", 1); AddIfExists(output, Template.LanguagesField, (info.CommonDiscInfo.Languages ?? new Language?[] { null }).Select(l => l.LongName() ?? "SILENCE! (CHANGE THIS)").ToArray(), 1); - AddIfExists(output, Template.PlaystationLanguageSelectionViaField, (info.CommonDiscInfo.LanguageSelection ?? new LanguageSelection?[] { }).Select(l => l.LongName()).ToArray(), 1); + AddIfExists(output, Template.PlaystationLanguageSelectionViaField, (info.CommonDiscInfo.LanguageSelection ?? Array.Empty()).Select(l => l.LongName()).ToArray(), 1); AddIfExists(output, Template.DiscSerialField, info.CommonDiscInfo.Serial, 1); // All ringcode information goes in an indented area @@ -1016,7 +1016,7 @@ namespace MPF.Library // Now write out to a generic file try { - using (StreamWriter sw = new StreamWriter(File.Open(Path.Combine(outputDirectory, "!submissionInfo.txt"), FileMode.Create, FileAccess.Write))) + using (var sw = new StreamWriter(File.Open(Path.Combine(outputDirectory, "!submissionInfo.txt"), FileMode.Create, FileAccess.Write))) { foreach (string line in lines) { @@ -1070,7 +1070,7 @@ namespace MPF.Library } } } - catch (Exception ex) + catch { // We don't care what the error is right now return false; @@ -1094,7 +1094,7 @@ namespace MPF.Library // Now write out to a generic file try { - using (StreamWriter sw = new StreamWriter(File.Open(Path.Combine(outputDirectory, "!protectionInfo.txt"), FileMode.Create, FileAccess.Write))) + using (var sw = new StreamWriter(File.Open(Path.Combine(outputDirectory, "!protectionInfo.txt"), FileMode.Create, FileAccess.Write))) { foreach (var kvp in info.CopyProtection.FullProtections) { @@ -1102,7 +1102,7 @@ namespace MPF.Library } } } - catch (Exception ex) + catch { // We don't care what the error is right now return false; @@ -1144,7 +1144,11 @@ namespace MPF.Library // If the value contains a newline value = value.Replace("\r\n", "\n"); +#if NET48 if (value.Contains("\n")) +#else + if (value.Contains('\n')) +#endif { output.Add(prefix + key + ":"); output.Add(""); string[] values = value.Split('\n'); @@ -1187,7 +1191,7 @@ namespace MPF.Library private static void AddIfExists(List output, string key, List value, int indent) { // If there's no valid value to write - if (value == null || value.Count() == 0) + if (value == null || value.Count == 0) return; AddIfExists(output, key, string.Join(", ", value.Select(o => o.ToString())), indent); @@ -1200,7 +1204,7 @@ namespace MPF.Library /// List of all log file paths, empty otherwise private static List GetGeneratedFilePaths(string outputDirectory) { - List files = new List(); + var files = new List(); if (File.Exists(Path.Combine(outputDirectory, "!submissionInfo.txt"))) files.Add(Path.Combine(outputDirectory, "!submissionInfo.txt")); @@ -1214,7 +1218,7 @@ namespace MPF.Library return files; } - #endregion +#endregion #region Normalization @@ -1588,7 +1592,7 @@ namespace MPF.Library // Insert the first item if we have a `:` or `-` bool itemInserted = false; - StringBuilder newTitleBuilder = new StringBuilder(); + var newTitleBuilder = new StringBuilder(); for (int i = 1; i < splitTitle.Length; i++) { string segment = splitTitle[i]; @@ -1726,7 +1730,7 @@ namespace MPF.Library /// Not currently working private static SubmissionInfo CreateFromID(string discData) { - SubmissionInfo info = new SubmissionInfo() + var info = new SubmissionInfo() { CommonDiscInfo = new CommonDiscInfoSection(), VersionAndEditions = new VersionAndEditionsSection(), @@ -1739,7 +1743,7 @@ namespace MPF.Library try { // Load the current disc page into an XML document - XmlDocument redumpPage = new XmlDocument() { PreserveWhitespace = true }; + var redumpPage = new XmlDocument() { PreserveWhitespace = true }; redumpPage.LoadXml(discData); // If the current page isn't valid, we can't parse it @@ -1925,9 +1929,13 @@ namespace MPF.Library int firstParenLocation = title.IndexOf(" ("); if (firstParenLocation >= 0) { +#if NET48 info.CommonDiscInfo.Title = title.Substring(0, firstParenLocation); +#else + info.CommonDiscInfo.Title = title[..firstParenLocation]; +#endif var subMatches = SabreTools.RedumpLib.Data.Constants.DiscNumberLetterRegex.Matches(title); - foreach (Match subMatch in subMatches) + foreach (Match subMatch in subMatches.Cast()) { var subMatchValue = subMatch.Groups[1].Value; @@ -1973,9 +1981,11 @@ namespace MPF.Library var matches = SabreTools.RedumpLib.Data.Constants.LanguagesRegex.Matches(discData); if (matches.Count > 0) { - List tempLanguages = new List(); - foreach (Match submatch in matches) + var tempLanguages = new List(); + foreach (Match submatch in matches.Cast()) + { tempLanguages.Add(Extensions.ToLanguage(submatch.Groups[1].Value)); + } info.CommonDiscInfo.Languages = tempLanguages.Where(l => l != null).ToArray(); } @@ -2007,15 +2017,17 @@ namespace MPF.Library if (matches.Count > 0) { // Start with any currently listed dumpers - List tempDumpers = new List(); + var tempDumpers = new List(); if (info.DumpersAndStatus.Dumpers.Length > 0) { foreach (string dumper in info.DumpersAndStatus.Dumpers) tempDumpers.Add(dumper); } - foreach (Match submatch in matches) + foreach (Match submatch in matches.Cast()) + { tempDumpers.Add(WebUtility.HtmlDecode(submatch.Groups[1].Value)); + } info.DumpersAndStatus.Dumpers = tempDumpers.ToArray(); } @@ -2267,9 +2279,9 @@ namespace MPF.Library info.PartiallyMatchedIDs = new List(); #if NET48 - using (RedumpWebClient wc = new RedumpWebClient()) + using (var wc = new RedumpWebClient()) #else - using (RedumpHttpClient wc = new RedumpHttpClient()) + using (var wc = new RedumpHttpClient()) #endif { // Login to Redump @@ -2410,7 +2422,7 @@ namespace MPF.Library // Clear out fully matched IDs from the partial list if (info.FullyMatchedID.HasValue) { - if (info.PartiallyMatchedIDs.Count() == 1) + if (info.PartiallyMatchedIDs.Count == 1) info.PartiallyMatchedIDs = null; else info.PartiallyMatchedIDs.Remove(info.FullyMatchedID.Value); @@ -2466,7 +2478,7 @@ namespace MPF.Library private async static Task> ListSearchResults(RedumpHttpClient wc, string query, bool filterForwardSlashes = true) #endif { - List ids = new List(); + var ids = new List(); // Strip quotes query = query.Trim('"', '\''); @@ -2575,7 +2587,11 @@ namespace MPF.Library } // Format the universal hash for finding within the comments +#if NET48 universalHash = $"{universalHash.Substring(0, universalHash.Length - 1)}/comments/only"; +#else + universalHash = $"{universalHash[..^1]}/comments/only"; +#endif // Get all matching IDs for the hash #if NET48 @@ -2641,7 +2657,7 @@ namespace MPF.Library return localCount == remoteCount; } - #endregion +#endregion #region Helpers diff --git a/MPF.Modules/Aaru/Parameters.cs b/MPF.Modules/Aaru/Parameters.cs index 3fb1a0e1..f594a14c 100644 --- a/MPF.Modules/Aaru/Parameters.cs +++ b/MPF.Modules/Aaru/Parameters.cs @@ -13,6 +13,9 @@ using SabreTools.Models.CueSheets; using SabreTools.RedumpLib.Data; using Schemas; +// Ignore "Type or member is obsolete" +#pragma warning disable CS0618 + namespace MPF.Modules.Aaru { /// diff --git a/MPF.Modules/BaseParameters.cs b/MPF.Modules/BaseParameters.cs index 03078eda..eec435ea 100644 --- a/MPF.Modules/BaseParameters.cs +++ b/MPF.Modules/BaseParameters.cs @@ -278,8 +278,8 @@ namespace MPF.Modules // Start processing tasks, if necessary if (!separateWindow) { - Logging.OutputToLog(process.StandardOutput, this, ReportStatus); - Logging.OutputToLog(process.StandardError, this, ReportStatus); + _ = Logging.OutputToLog(process.StandardOutput, this, ReportStatus); + _ = Logging.OutputToLog(process.StandardError, this, ReportStatus); } process.WaitForExit(); @@ -1107,8 +1107,7 @@ namespace MPF.Modules datString += $"\n"; } - datString.TrimEnd('\n'); - return datString; + return datString.TrimEnd('\n'); } catch { @@ -1149,7 +1148,7 @@ namespace MPF.Modules if (xtr == null) return null; - XmlSerializer serializer = new XmlSerializer(typeof(Datafile)); + var serializer = new XmlSerializer(typeof(Datafile)); Datafile obj = serializer.Deserialize(xtr) as Datafile; return obj; @@ -1203,7 +1202,7 @@ namespace MPF.Modules try { // Get a list of hashers to run over the buffer - List hashers = new List + var hashers = new List { new Hasher(Hash.CRC), new Hasher(Hash.MD5), @@ -1275,7 +1274,7 @@ namespace MPF.Modules return true; } - catch (IOException ex) + catch (IOException) { return false; } @@ -1283,8 +1282,6 @@ namespace MPF.Modules { input.Dispose(); } - - return false; } /// @@ -1317,11 +1314,11 @@ namespace MPF.Modules // TODO: Use deserialization to Rom instead of Regex - Regex hashreg = new Regex(@"(bytes, offset, 0x04); byte[] rev = span.ToArray(); @@ -1498,8 +1499,8 @@ namespace MPF.Modules return false; // Fix the Y2K timestamp issue - FileInfo fi = new FileInfo(exePath); - DateTime dt = new DateTime(fi.LastWriteTimeUtc.Year >= 1900 && fi.LastWriteTimeUtc.Year < 1920 ? 2000 + fi.LastWriteTimeUtc.Year % 100 : fi.LastWriteTimeUtc.Year, + var fi = new FileInfo(exePath); + var dt = new DateTime(fi.LastWriteTimeUtc.Year >= 1900 && fi.LastWriteTimeUtc.Year < 1920 ? 2000 + fi.LastWriteTimeUtc.Year % 100 : fi.LastWriteTimeUtc.Year, fi.LastWriteTimeUtc.Month, fi.LastWriteTimeUtc.Day); date = dt.ToString("yyyy-MM-dd"); @@ -1558,7 +1559,7 @@ namespace MPF.Modules // Let's try reading PARAM.SFO to find the serial at the end of the file try { - using (BinaryReader br = new BinaryReader(File.OpenRead(paramSfoPath))) + using (var br = new BinaryReader(File.OpenRead(paramSfoPath))) { br.BaseStream.Seek(-0x18, SeekOrigin.End); return new string(br.ReadChars(9)); @@ -1595,7 +1596,7 @@ namespace MPF.Modules // Let's try reading PARAM.SFO to find the version at the end of the file try { - using (BinaryReader br = new BinaryReader(File.OpenRead(paramSfoPath))) + using (var br = new BinaryReader(File.OpenRead(paramSfoPath))) { br.BaseStream.Seek(-0x08, SeekOrigin.End); return new string(br.ReadChars(5)); @@ -1632,7 +1633,7 @@ namespace MPF.Modules // Let's try reading param.sfo to find the serial at the end of the file try { - using (BinaryReader br = new BinaryReader(File.OpenRead(paramSfoPath))) + using (var br = new BinaryReader(File.OpenRead(paramSfoPath))) { br.BaseStream.Seek(-0x14, SeekOrigin.End); return new string(br.ReadChars(9)); @@ -1669,7 +1670,7 @@ namespace MPF.Modules // Let's try reading param.sfo to find the version at the end of the file try { - using (BinaryReader br = new BinaryReader(File.OpenRead(paramSfoPath))) + using (var br = new BinaryReader(File.OpenRead(paramSfoPath))) { br.BaseStream.Seek(-0x08, SeekOrigin.End); return new string(br.ReadChars(5)); @@ -1706,7 +1707,7 @@ namespace MPF.Modules // Let's try reading param.json to find the serial in the unencrypted JSON try { - using (BinaryReader br = new BinaryReader(File.OpenRead(paramJsonPath))) + using (var br = new BinaryReader(File.OpenRead(paramJsonPath))) { br.BaseStream.Seek(0x82E, SeekOrigin.Begin); return new string(br.ReadChars(9)); @@ -1743,7 +1744,7 @@ namespace MPF.Modules // Let's try reading param.json to find the version in the unencrypted JSON try { - using (BinaryReader br = new BinaryReader(File.OpenRead(paramJsonPath))) + using (var br = new BinaryReader(File.OpenRead(paramJsonPath))) { br.BaseStream.Seek(0x89E, SeekOrigin.Begin); return new string(br.ReadChars(5)); @@ -1756,7 +1757,7 @@ namespace MPF.Modules } } - #endregion +#endregion #region Category Extraction diff --git a/MPF.Modules/DiscImageCreator/Parameters.cs b/MPF.Modules/DiscImageCreator/Parameters.cs index 60f86000..90211585 100644 --- a/MPF.Modules/DiscImageCreator/Parameters.cs +++ b/MPF.Modules/DiscImageCreator/Parameters.cs @@ -281,32 +281,31 @@ namespace MPF.Modules.DiscImageCreator } // Removed or inconsistent files - if (false) - { - // Doesn't output on Linux - if (!File.Exists($"{basePath}.c2")) - missingFiles.Add($"{basePath}.c2"); + //{ + // // Doesn't output on Linux + // if (!File.Exists($"{basePath}.c2")) + // missingFiles.Add($"{basePath}.c2"); - // Doesn't output on Linux - if (!File.Exists($"{basePath}_c2Error.txt")) - missingFiles.Add($"{basePath}_c2Error.txt"); + // // Doesn't output on Linux + // if (!File.Exists($"{basePath}_c2Error.txt")) + // missingFiles.Add($"{basePath}_c2Error.txt"); - // Replaced by timestamp-named file - if (!File.Exists($"{basePath}_cmd.txt")) - missingFiles.Add($"{basePath}_cmd.txt"); + // // Replaced by timestamp-named file + // if (!File.Exists($"{basePath}_cmd.txt")) + // missingFiles.Add($"{basePath}_cmd.txt"); - // Not guaranteed output - if (!File.Exists($"{basePath}_subIntention.txt")) - missingFiles.Add($"{basePath}_subIntention.txt"); + // // Not guaranteed output + // if (!File.Exists($"{basePath}_subIntention.txt")) + // missingFiles.Add($"{basePath}_subIntention.txt"); - // Not guaranteed output - if (File.Exists($"{basePath}_suppl.dat")) - missingFiles.Add($"{basePath}_suppl.dat"); + // // Not guaranteed output + // if (File.Exists($"{basePath}_suppl.dat")) + // missingFiles.Add($"{basePath}_suppl.dat"); - // Not guaranteed output (at least PCE) - if (!File.Exists($"{basePath}.toc")) - missingFiles.Add($"{basePath}.toc"); - } + // // Not guaranteed output (at least PCE) + // if (!File.Exists($"{basePath}.toc")) + // missingFiles.Add($"{basePath}.toc"); + //} break; @@ -332,24 +331,23 @@ namespace MPF.Modules.DiscImageCreator } // Removed or inconsistent files - if (false) - { - // Replaced by timestamp-named file - if (!File.Exists($"{basePath}_cmd.txt")) - missingFiles.Add($"{basePath}_cmd.txt"); + //{ + // // Replaced by timestamp-named file + // if (!File.Exists($"{basePath}_cmd.txt")) + // missingFiles.Add($"{basePath}_cmd.txt"); - // Not guaranteed output - if (File.Exists($"{basePath}_CSSKey.txt")) - missingFiles.Add($"{basePath}_CSSKey.txt"); + // // Not guaranteed output + // if (File.Exists($"{basePath}_CSSKey.txt")) + // missingFiles.Add($"{basePath}_CSSKey.txt"); - // Only output for some parameters - if (File.Exists($"{basePath}.raw")) - missingFiles.Add($"{basePath}.raw"); + // // Only output for some parameters + // if (File.Exists($"{basePath}.raw")) + // missingFiles.Add($"{basePath}.raw"); - // Not guaranteed output - if (File.Exists($"{basePath}_suppl.dat")) - missingFiles.Add($"{basePath}_suppl.dat"); - } + // // Not guaranteed output + // if (File.Exists($"{basePath}_suppl.dat")) + // missingFiles.Add($"{basePath}_suppl.dat"); + //} break; @@ -365,12 +363,11 @@ namespace MPF.Modules.DiscImageCreator } // Removed or inconsistent files - if (false) - { - // Replaced by timestamp-named file - if (!File.Exists($"{basePath}_cmd.txt")) - missingFiles.Add($"{basePath}_cmd.txt"); - } + //{ + // // Replaced by timestamp-named file + // if (!File.Exists($"{basePath}_cmd.txt")) + // missingFiles.Add($"{basePath}_cmd.txt"); + //} break; diff --git a/MPF.Modules/Redumper/Parameters.cs b/MPF.Modules/Redumper/Parameters.cs index 72699b38..87f58dde 100644 --- a/MPF.Modules/Redumper/Parameters.cs +++ b/MPF.Modules/Redumper/Parameters.cs @@ -181,7 +181,7 @@ namespace MPF.Modules.Redumper /// public override (bool, List) CheckAllOutputFilesExist(string basePath, bool preCheck) { - List missingFiles = new List(); + var missingFiles = new List(); switch (this.Type) { @@ -208,12 +208,11 @@ namespace MPF.Modules.Redumper } // Removed or inconsistent files - if (false) - { - // Depends on the disc - if (!File.Exists($"{basePath}.cdtext")) - missingFiles.Add($"{basePath}.cdtext"); - } + //{ + // // Depends on the disc + // if (!File.Exists($"{basePath}.cdtext")) + // missingFiles.Add($"{basePath}.cdtext"); + //} break; @@ -351,7 +350,7 @@ namespace MPF.Modules.Redumper break; case RedumpSystem.SegaMegaCDSegaCD: - info.Extras.Header = GetSegaCDHeader($"{basePath}.log", out string scdBuildDate, out string scdSerial, out string scdRegion) ?? string.Empty; + info.Extras.Header = GetSegaCDHeader($"{basePath}.log", out string scdBuildDate, out string scdSerial, out string _) ?? string.Empty; info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = scdSerial ?? string.Empty; info.CommonDiscInfo.EXEDateBuildDate = scdBuildDate ?? string.Empty; // TODO: Support region setting from parsed value @@ -477,10 +476,14 @@ namespace MPF.Modules.Redumper /// public override string GenerateParameters() { - List parameters = new List(); + var parameters = new List(); +#if NET48 if (ModeValues == null) ModeValues = new List { CommandStrings.NONE }; +#else + ModeValues ??= new List { CommandStrings.NONE }; +#endif // Modes parameters.AddRange(ModeValues); @@ -759,7 +762,7 @@ namespace MPF.Modules.Redumper /// public override List GetLogFilePaths(string basePath) { - List logFiles = new List(); + var logFiles = new List(); switch (this.Type) { @@ -1264,17 +1267,29 @@ namespace MPF.Modules.Redumper { if (line.StartsWith("protection system type")) { +#if NET48 copyrightProtectionSystemType = line.Substring("protection system type: ".Length); +#else + copyrightProtectionSystemType = line["protection system type: ".Length..]; +#endif if (copyrightProtectionSystemType == "none" || copyrightProtectionSystemType == "") copyrightProtectionSystemType = "No"; } else if (line.StartsWith("region management information:")) { +#if NET48 region = line.Substring("region management information: ".Length); +#else + region = line["region management information: ".Length..]; +#endif } else if (line.StartsWith("disc key")) { +#if NET48 decryptedDiscKey = line.Substring("disc key: ".Length).Replace(':', ' '); +#else + decryptedDiscKey = line["disc key: ".Length..].Replace(':', ' '); +#endif } else if (line.StartsWith("title keys")) { @@ -1416,7 +1431,11 @@ namespace MPF.Modules.Redumper else if (line.StartsWith("layer break:")) { // layer break: +#if NET48 layerbreak = line.Substring("layer break: ".Length).Trim(); +#else + layerbreak = line["layer break: ".Length..].Trim(); +#endif } // Dual-layer discs have a regular layerbreak (old) @@ -1424,7 +1443,11 @@ namespace MPF.Modules.Redumper { // data { LBA: .. , length: , hLBA: .. } string[] split = line.Split(' ').Where(s => !string.IsNullOrEmpty(s)).ToArray(); - layerbreak = layerbreak == null ? split[7].TrimEnd(',') : layerbreak; +#if NET48 + layerbreak = layerbreak ?? split[7].TrimEnd(','); +#else + layerbreak ??= split[7].TrimEnd(','); +#endif } } @@ -1471,11 +1494,19 @@ namespace MPF.Modules.Redumper // Store the first session range if (line.Contains("session 1:")) +#if NET48 firstSession = line.Substring("session 1: ".Length).Trim(); +#else + firstSession = line["session 1: ".Length..].Trim(); +#endif // Store the secomd session range else if (line.Contains("session 2:")) +#if NET48 secondSession = line.Substring("session 2: ".Length).Trim(); +#else + secondSession = line["session 2: ".Length..].Trim(); +#endif } // If either is blank, we don't have multisession @@ -1710,7 +1741,11 @@ namespace MPF.Modules.Redumper { line = sr.ReadLine().TrimStart(); if (line.StartsWith("non-zero data sample range")) +#if NET48 return line.Substring("non-zero data sample range: [".Length).Trim().Split(' ')[0]; +#else + return line["non-zero data sample range: [".Length..].Trim().Split(' ')[0]; +#endif } // We couldn't detect it then @@ -1742,11 +1777,19 @@ namespace MPF.Modules.Redumper try { string[] header = segaHeader.Split('\n'); +#if NET48 string serialVersionLine = header[2].Substring(58); string dateLine = header[3].Substring(58); serial = serialVersionLine.Substring(0, 10).Trim(); version = serialVersionLine.Substring(10, 6).TrimStart('V', 'v'); date = dateLine.Substring(0, 8); +#else + string serialVersionLine = header[2][58..]; + string dateLine = header[3][58..]; + serial = serialVersionLine[..10].Trim(); + version = serialVersionLine.Substring(10, 6).TrimStart('V', 'v'); + date = dateLine[..8]; +#endif date = $"{date[0]}{date[1]}{date[2]}{date[3]}-{date[4]}{date[5]}-{date[6]}{date[7]}"; return true; } @@ -1835,19 +1878,35 @@ namespace MPF.Modules.Redumper line = sr.ReadLine().TrimStart(); if (line.StartsWith("build date:")) { +#if NET48 buildDate = line.Substring("build date: ".Length).Trim(); +#else + buildDate = line["build date: ".Length..].Trim(); +#endif } else if (line.StartsWith("serial:")) { +#if NET48 serial = line.Substring("serial: ".Length).Trim(); +#else + serial = line["serial: ".Length..].Trim(); +#endif } else if (line.StartsWith("region:")) { +#if NET48 region = line.Substring("region: ".Length).Trim(); +#else + region = line["region: ".Length..].Trim(); +#endif } else if (line.StartsWith("regions:")) { +#if NET48 region = line.Substring("regions: ".Length).Trim(); +#else + region = line["regions: ".Length..].Trim(); +#endif } else if (line.StartsWith("header:")) { @@ -1895,7 +1954,11 @@ namespace MPF.Modules.Redumper { line = sr.ReadLine().TrimStart(); if (line.StartsWith("Universal Hash")) +#if NET48 return line.Substring("Universal Hash (SHA-1): ".Length).Trim(); +#else + return line["Universal Hash (SHA-1): ".Length..].Trim(); +#endif } // We couldn't detect it then @@ -1930,7 +1993,11 @@ namespace MPF.Modules.Redumper { line = sr.ReadLine().TrimStart(); if (line.StartsWith("disc write offset")) +#if NET48 return line.Substring("disc write offset: ".Length).Trim(); +#else + return line["disc write offset: ".Length..].Trim(); +#endif } // We couldn't detect it then diff --git a/MPF.UI.Core/MPF.UI.Core.csproj b/MPF.UI.Core/MPF.UI.Core.csproj index f577417a..c2a98b1c 100644 --- a/MPF.UI.Core/MPF.UI.Core.csproj +++ b/MPF.UI.Core/MPF.UI.Core.csproj @@ -31,7 +31,7 @@ - + diff --git a/MPF/MPF.csproj b/MPF/MPF.csproj index edaf8b42..9f34f389 100644 --- a/MPF/MPF.csproj +++ b/MPF/MPF.csproj @@ -35,7 +35,7 @@ - +