Address some warnings and infos

This commit is contained in:
Matt Nadareski
2023-09-27 00:38:00 -04:00
parent 47f45fa46f
commit 0d694c1bde
9 changed files with 195 additions and 113 deletions

View File

@@ -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)

View File

@@ -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
}
/// <summary>
@@ -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<Drive> drives = new List<Drive>();
var drives = new List<Drive>();
// Get all standard supported drive types
try

View File

@@ -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(@"<rom name="".*?"" size=""(.*?)"" crc=""(.*?)"" md5=""(.*?)"" sha1=""(.*?)""");
var hashreg = new Regex(@"<rom name="".*?"" size=""(.*?)"" crc=""(.*?)"" md5=""(.*?)"" sha1=""(.*?)""");
Match m = hashreg.Match(hashData);
if (m.Success)
{
Int64.TryParse(m.Groups[1].Value, out size);
_ = Int64.TryParse(m.Groups[1].Value, out size);
crc32 = m.Groups[2].Value;
md5 = m.Groups[3].Value;
sha1 = m.Groups[4].Value;
@@ -623,10 +622,11 @@ namespace MPF.Library
zf = ZipFile.Open(archiveName, ZipArchiveMode.Create);
foreach (string file in files)
{
string entryName = file.Substring(outputDirectory.Length).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
#if NET48
string entryName = file.Substring(outputDirectory.Length).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
zf.CreateEntryFromFile(file, entryName, CompressionLevel.Optimal);
#else
string entryName = file[outputDirectory.Length..].TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
zf.CreateEntryFromFile(file, entryName, CompressionLevel.SmallestSize);
#endif
@@ -672,7 +672,7 @@ namespace MPF.Library
bool reverseOrder = system.HasReversedRingcodes();
// Common Disc Info section
List<string> output = new List<string> { "Common Disc Info:" };
var output = new List<string> { "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<LanguageSelection?>()).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<string> output, string key, List<int> 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
/// <returns>List of all log file paths, empty otherwise</returns>
private static List<string> GetGeneratedFilePaths(string outputDirectory)
{
List<string> files = new List<string>();
var files = new List<string>();
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
/// <remarks>Not currently working</remarks>
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<Match>())
{
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<Language?> tempLanguages = new List<Language?>();
foreach (Match submatch in matches)
var tempLanguages = new List<Language?>();
foreach (Match submatch in matches.Cast<Match>())
{
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<string> tempDumpers = new List<string>();
var tempDumpers = new List<string>();
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<Match>())
{
tempDumpers.Add(WebUtility.HtmlDecode(submatch.Groups[1].Value));
}
info.DumpersAndStatus.Dumpers = tempDumpers.ToArray();
}
@@ -2267,9 +2279,9 @@ namespace MPF.Library
info.PartiallyMatchedIDs = new List<int>();
#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<List<int>> ListSearchResults(RedumpHttpClient wc, string query, bool filterForwardSlashes = true)
#endif
{
List<int> ids = new List<int>();
var ids = new List<int>();
// 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

View File

@@ -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
{
/// <summary>

View File

@@ -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 += $"<rom name=\"{rom.Name}\" size=\"{rom.Size}\" crc=\"{rom.Crc}\" md5=\"{rom.Md5}\" sha1=\"{rom.Sha1}\" />\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<Hasher> hashers = new List<Hasher>
var hashers = new List<Hasher>
{
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;
}
/// <summary>
@@ -1317,11 +1314,11 @@ namespace MPF.Modules
// TODO: Use deserialization to Rom instead of Regex
Regex hashreg = new Regex(@"<rom name="".*?"" size=""(.*?)"" crc=""(.*?)"" md5=""(.*?)"" sha1=""(.*?)""");
var hashreg = new Regex(@"<rom name="".*?"" size=""(.*?)"" crc=""(.*?)"" md5=""(.*?)"" sha1=""(.*?)""");
Match m = hashreg.Match(hashData);
if (m.Success)
{
Int64.TryParse(m.Groups[1].Value, out size);
_ = Int64.TryParse(m.Groups[1].Value, out size);
crc32 = m.Groups[2].Value;
md5 = m.Groups[3].Value;
sha1 = m.Groups[4].Value;
@@ -1347,7 +1344,7 @@ namespace MPF.Modules
var rom = datafile.Games[0].Roms[0];
Int64.TryParse(rom.Size, out size);
_ = Int64.TryParse(rom.Size, out size);
crc32 = rom.Crc;
md5 = rom.Md5;
sha1 = rom.Sha1;
@@ -1369,7 +1366,11 @@ namespace MPF.Modules
if (di?.Units == null || di.Units.Length <= 1)
return false;
#if NET48
int ReadFromArrayBigEndian(byte[] bytes, int offset)
#else
static int ReadFromArrayBigEndian(byte[] bytes, int offset)
#endif
{
var span = new ReadOnlySpan<byte>(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

View File

@@ -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;

View File

@@ -181,7 +181,7 @@ namespace MPF.Modules.Redumper
/// <inheritdoc/>
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck)
{
List<string> missingFiles = new List<string>();
var missingFiles = new List<string>();
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
/// </remarks>
public override string GenerateParameters()
{
List<string> parameters = new List<string>();
var parameters = new List<string>();
#if NET48
if (ModeValues == null)
ModeValues = new List<string> { CommandStrings.NONE };
#else
ModeValues ??= new List<string> { CommandStrings.NONE };
#endif
// Modes
parameters.AddRange(ModeValues);
@@ -759,7 +762,7 @@ namespace MPF.Modules.Redumper
/// <inheritdoc/>
public override List<string> GetLogFilePaths(string basePath)
{
List<string> logFiles = new List<string>();
var logFiles = new List<string>();
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 == "<none>")
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: <layerbreak>
#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: <startLBA> .. <endLBA>, length: <length>, hLBA: <startLBA> .. <endLBA> }
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

View File

@@ -31,7 +31,7 @@
<ProjectReference Include="..\MPF.Library\MPF.Library.csproj" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net48'">
<Reference Include="PresentationFramework.Aero" />
</ItemGroup>

View File

@@ -35,7 +35,7 @@
<ProjectReference Include="..\MPF.UI.Core\MPF.UI.Core.csproj" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net48'">
<Reference Include="PresentationFramework.Aero" />
</ItemGroup>