diff --git a/CHANGELIST.md b/CHANGELIST.md
index 95c278e0..0ad2541b 100644
--- a/CHANGELIST.md
+++ b/CHANGELIST.md
@@ -25,6 +25,7 @@
- Use rolling release, not AppVeyor, in issue templates
- Update BinaryObjectScanner to 3.1.15
- Remove unused IndexRange library
+- Remove unnecessary System.ValueTuple usage
### 3.2.2 (2024-09-24)
diff --git a/MPF.ExecutionContexts/BaseExecutionContext.cs b/MPF.ExecutionContexts/BaseExecutionContext.cs
index 40f56c84..d6a1ee9d 100644
--- a/MPF.ExecutionContexts/BaseExecutionContext.cs
+++ b/MPF.ExecutionContexts/BaseExecutionContext.cs
@@ -332,7 +332,7 @@ namespace MPF.ExecutionContexts
/// True if it's a valid byte, false otherwise
protected static bool IsValidInt8(string parameter, sbyte lowerBound = -1, sbyte upperBound = -1)
{
- (string value, long _) = ExtractFactorFromValue(parameter);
+ string value = ExtractFactorFromValue(parameter, out _);
if (!sbyte.TryParse(value, out sbyte temp))
return false;
else if (lowerBound != -1 && temp < lowerBound)
@@ -352,7 +352,7 @@ namespace MPF.ExecutionContexts
/// True if it's a valid Int16, false otherwise
protected static bool IsValidInt16(string parameter, short lowerBound = -1, short upperBound = -1)
{
- (string value, long _) = ExtractFactorFromValue(parameter);
+ string value = ExtractFactorFromValue(parameter, out _);
if (!short.TryParse(value, out short temp))
return false;
else if (lowerBound != -1 && temp < lowerBound)
@@ -372,7 +372,7 @@ namespace MPF.ExecutionContexts
/// True if it's a valid Int32, false otherwise
protected static bool IsValidInt32(string parameter, int lowerBound = -1, int upperBound = -1)
{
- (string value, long _) = ExtractFactorFromValue(parameter);
+ string value = ExtractFactorFromValue(parameter, out _);
if (!int.TryParse(value, out int temp))
return false;
else if (lowerBound != -1 && temp < lowerBound)
@@ -392,7 +392,7 @@ namespace MPF.ExecutionContexts
/// True if it's a valid Int64, false otherwise
protected static bool IsValidInt64(string parameter, long lowerBound = -1, long upperBound = -1)
{
- (string value, long _) = ExtractFactorFromValue(parameter);
+ string value = ExtractFactorFromValue(parameter, out _);
if (!long.TryParse(value, out long temp))
return false;
else if (lowerBound != -1 && temp < lowerBound)
@@ -568,7 +568,7 @@ namespace MPF.ExecutionContexts
this[longFlagString] = true;
i++;
- (string value, long factor) = ExtractFactorFromValue(parts[i]);
+ string value = ExtractFactorFromValue(parts[i], out long factor);
if (sbyte.TryParse(value, out sbyte sByteValue))
return (sbyte)(sByteValue * factor);
string hexValue = RemoveHexIdentifier(value);
@@ -588,7 +588,7 @@ namespace MPF.ExecutionContexts
string valuePart = commandParts[1];
this[longFlagString] = true;
- (string value, long factor) = ExtractFactorFromValue(valuePart);
+ string value = ExtractFactorFromValue(valuePart, out long factor);
if (sbyte.TryParse(value, out sbyte sByteValue))
return (sbyte)(sByteValue * factor);
string hexValue = RemoveHexIdentifier(value);
@@ -655,7 +655,7 @@ namespace MPF.ExecutionContexts
this[longFlagString] = true;
i++;
- (string value, long factor) = ExtractFactorFromValue(parts[i]);
+ string value = ExtractFactorFromValue(parts[i], out long factor);
if (short.TryParse(value, out short shortValue))
return (short)(shortValue * factor);
string hexValue = RemoveHexIdentifier(value);
@@ -675,7 +675,7 @@ namespace MPF.ExecutionContexts
string valuePart = commandParts[1];
this[longFlagString] = true;
- (string value, long factor) = ExtractFactorFromValue(valuePart);
+ string value = ExtractFactorFromValue(valuePart, out long factor);
if (short.TryParse(value, out short shortValue))
return (short)(shortValue * factor);
string hexValue = RemoveHexIdentifier(value);
@@ -742,7 +742,7 @@ namespace MPF.ExecutionContexts
this[longFlagString] = true;
i++;
- (string value, long factor) = ExtractFactorFromValue(parts[i]);
+ string value = ExtractFactorFromValue(parts[i], out long factor);
if (int.TryParse(value, out int intValue))
return (int)(intValue * factor);
string hexValue = RemoveHexIdentifier(value);
@@ -762,7 +762,7 @@ namespace MPF.ExecutionContexts
string valuePart = commandParts[1];
this[longFlagString] = true;
- (string value, long factor) = ExtractFactorFromValue(valuePart);
+ string value = ExtractFactorFromValue(valuePart, out long factor);
if (int.TryParse(value, out int intValue))
return (int)(intValue * factor);
string hexValue = RemoveHexIdentifier(value);
@@ -829,7 +829,7 @@ namespace MPF.ExecutionContexts
this[longFlagString] = true;
i++;
- (string value, long factor) = ExtractFactorFromValue(parts[i]);
+ string value = ExtractFactorFromValue(parts[i], out long factor);
if (long.TryParse(value, out long longValue))
return (long)(longValue * factor);
string hexValue = RemoveHexIdentifier(value);
@@ -849,7 +849,7 @@ namespace MPF.ExecutionContexts
string valuePart = commandParts[1];
this[longFlagString] = true;
- (string value, long factor) = ExtractFactorFromValue(valuePart);
+ string value = ExtractFactorFromValue(valuePart, out long factor);
if (long.TryParse(value, out long longValue))
return (long)(longValue * factor);
string hexValue = RemoveHexIdentifier(value);
@@ -990,7 +990,7 @@ namespace MPF.ExecutionContexts
this[longFlagString] = true;
i++;
- (string value, long factor) = ExtractFactorFromValue(parts[i]);
+ string value = ExtractFactorFromValue(parts[i], out long factor);
if (byte.TryParse(value, out byte byteValue))
return (byte)(byteValue * factor);
string hexValue = RemoveHexIdentifier(value);
@@ -1010,7 +1010,7 @@ namespace MPF.ExecutionContexts
string valuePart = commandParts[1];
this[longFlagString] = true;
- (string value, long factor) = ExtractFactorFromValue(valuePart);
+ string value = ExtractFactorFromValue(valuePart, out long factor);
if (byte.TryParse(value, out byte byteValue))
return (byte)(byteValue * factor);
string hexValue = RemoveHexIdentifier(value);
@@ -1027,10 +1027,10 @@ namespace MPF.ExecutionContexts
///
/// String value to treat as suffixed number
/// Trimmed value and multiplication factor
- private static (string trimmed, long factor) ExtractFactorFromValue(string value)
+ private static string ExtractFactorFromValue(string value, out long factor)
{
value = value.Trim('"');
- long factor = 1;
+ factor = 1;
// Characters
if (value.EndsWith("c", StringComparison.Ordinal))
@@ -1081,7 +1081,7 @@ namespace MPF.ExecutionContexts
value = value.TrimEnd('G');
}
- return (value, factor);
+ return value;
}
///
diff --git a/MPF.ExecutionContexts/MPF.ExecutionContexts.csproj b/MPF.ExecutionContexts/MPF.ExecutionContexts.csproj
index 17da9a40..a23140ef 100644
--- a/MPF.ExecutionContexts/MPF.ExecutionContexts.csproj
+++ b/MPF.ExecutionContexts/MPF.ExecutionContexts.csproj
@@ -48,9 +48,6 @@
-
-
-
diff --git a/MPF.Frontend/DumpEnvironment.cs b/MPF.Frontend/DumpEnvironment.cs
index f4c0ade8..22f4277d 100644
--- a/MPF.Frontend/DumpEnvironment.cs
+++ b/MPF.Frontend/DumpEnvironment.cs
@@ -158,22 +158,22 @@ namespace MPF.Frontend
if (programFound == null && _internalProgram != InternalProgram.Aaru)
{
var processor = new Processors.Aaru(_system, _type);
- (bool foundOtherFiles, _) = processor.FoundAllFiles(outputDirectory, outputFilename);
- if (foundOtherFiles)
+ var missingFiles = processor.FoundAllFiles(outputDirectory, outputFilename);
+ if (missingFiles.Count == 0)
programFound = InternalProgram.Aaru;
}
if (programFound == null && _internalProgram != InternalProgram.DiscImageCreator)
{
var processor = new Processors.DiscImageCreator(_system, _type);
- (bool foundOtherFiles, _) = processor.FoundAllFiles(outputDirectory, outputFilename);
- if (foundOtherFiles)
+ var missingFiles = processor.FoundAllFiles(outputDirectory, outputFilename);
+ if (missingFiles.Count == 0)
programFound = InternalProgram.DiscImageCreator;
}
if (programFound == null && _internalProgram != InternalProgram.Redumper)
{
var processor = new Processors.Redumper(_system, _type);
- (bool foundOtherFiles, _) = processor.FoundAllFiles(outputDirectory, outputFilename);
- if (foundOtherFiles)
+ var missingFiles = processor.FoundAllFiles(outputDirectory, outputFilename);
+ if (missingFiles.Count == 0)
programFound = InternalProgram.Redumper;
}
@@ -300,7 +300,7 @@ namespace MPF.Frontend
if (_processor == null)
return false;
- return _processor.FoundAllFiles(outputDirectory, outputFilename).Item1;
+ return _processor.FoundAllFiles(outputDirectory, outputFilename).Count == 0;
}
///
@@ -437,8 +437,8 @@ namespace MPF.Frontend
var outputFilename = Path.GetFileName(OutputPath);
// Check to make sure that the output had all the correct files
- (bool foundFiles, List missingFiles) = _processor.FoundAllFiles(outputDirectory, outputFilename);
- if (!foundFiles)
+ List missingFiles = _processor.FoundAllFiles(outputDirectory, outputFilename);
+ if (missingFiles.Count > 0)
{
resultProgress?.Report(ResultEventArgs.Failure($"There were files missing from the output:\n{string.Join("\n", [.. missingFiles])}"));
return ResultEventArgs.Failure("Error! Please check output directory as dump may be incomplete!");
@@ -532,22 +532,36 @@ namespace MPF.Frontend
if (_options.CompressLogFiles)
{
resultProgress?.Report(ResultEventArgs.Success("Compressing log files..."));
- (bool compressSuccess, string compressResult) = _processor?.CompressLogFiles(outputDirectory, filenameSuffix, outputFilename) ?? (false, "No processor provided!");
- if (compressSuccess)
- resultProgress?.Report(ResultEventArgs.Success(compressResult));
+ if (_processor == null)
+ {
+ resultProgress?.Report(ResultEventArgs.Failure("No processor provided!"));
+ }
else
- resultProgress?.Report(ResultEventArgs.Failure(compressResult));
+ {
+ bool compressSuccess = _processor.CompressLogFiles(outputDirectory, filenameSuffix, outputFilename, out string compressResult);
+ if (compressSuccess)
+ resultProgress?.Report(ResultEventArgs.Success(compressResult));
+ else
+ resultProgress?.Report(ResultEventArgs.Failure(compressResult));
+ }
}
// Delete unnecessary files, if required
if (_options.DeleteUnnecessaryFiles)
{
resultProgress?.Report(ResultEventArgs.Success("Deleting unnecessary files..."));
- (bool deleteSuccess, string deleteResult) = _processor?.DeleteUnnecessaryFiles(outputDirectory, outputFilename) ?? (false, "No processor provided!");
- if (deleteSuccess)
- resultProgress?.Report(ResultEventArgs.Success(deleteResult));
+ if (_processor == null)
+ {
+ resultProgress?.Report(ResultEventArgs.Failure("No processor provided!"));
+ }
else
- resultProgress?.Report(ResultEventArgs.Failure(deleteResult));
+ {
+ bool deleteSuccess = _processor.DeleteUnnecessaryFiles(outputDirectory, outputFilename, out string deleteResult);
+ if (deleteSuccess)
+ resultProgress?.Report(ResultEventArgs.Success(deleteResult));
+ else
+ resultProgress?.Report(ResultEventArgs.Failure(deleteResult));
+ }
}
// Create PS3 IRD, if required
diff --git a/MPF.Frontend/Tools/SubmissionGenerator.cs b/MPF.Frontend/Tools/SubmissionGenerator.cs
index 5a636420..5b450cbe 100644
--- a/MPF.Frontend/Tools/SubmissionGenerator.cs
+++ b/MPF.Frontend/Tools/SubmissionGenerator.cs
@@ -57,8 +57,8 @@ namespace MPF.Frontend.Tools
string outputFilename = Path.GetFileName(outputPath);
// Check that all of the relevant files are there
- (bool foundFiles, List missingFiles) = processor.FoundAllFiles(outputDirectory, outputFilename);
- if (!foundFiles)
+ List missingFiles = processor.FoundAllFiles(outputDirectory, outputFilename);
+ if (missingFiles.Count > 0)
{
resultProgress?.Report(ResultEventArgs.Failure($"There were files missing from the output:\n{string.Join("\n", [.. missingFiles])}"));
resultProgress?.Report(ResultEventArgs.Failure($"This may indicate an issue with the hardware or media, including unsupported devices.\nPlease see dumping program documentation for more details."));
diff --git a/MPF.Processors/BaseProcessor.cs b/MPF.Processors/BaseProcessor.cs
index bc0da5d1..d11ea91a 100644
--- a/MPF.Processors/BaseProcessor.cs
+++ b/MPF.Processors/BaseProcessor.cs
@@ -72,10 +72,11 @@ namespace MPF.Processors
/// Output filename to use as the base path
/// Processor object representing how to process the outputs
/// True if the process succeeded, false otherwise
- public (bool, string) CompressLogFiles(string? outputDirectory, string? filenameSuffix, string outputFilename)
+ public bool CompressLogFiles(string? outputDirectory, string? filenameSuffix, string outputFilename, out string status)
{
#if NET20 || NET35 || NET40
- return (false, "Log compression is not available for this framework version");
+ status = "Log compression is not available for this framework version";
+ return false;
#else
// Prepare the necessary paths
outputFilename = Path.GetFileNameWithoutExtension(outputFilename);
@@ -94,7 +95,10 @@ namespace MPF.Processors
// Don't create an archive if there are no paths
if (!zippableFiles.Any() && !generatedFiles.Any())
- return (true, "No files to compress!");
+ {
+ status = "No files to compress!";
+ return true;
+ }
// If the file already exists, we want to delete the old one
try
@@ -104,7 +108,8 @@ namespace MPF.Processors
}
catch
{
- return (false, "Could not delete old archive!");
+ status = "Could not delete old archive!";
+ return false;
}
// Add the log files to the archive and delete the uncompressed file after
@@ -116,11 +121,13 @@ namespace MPF.Processors
_ = AddToArchive(zf, zippableFiles, outputDirectory, true);
_ = AddToArchive(zf, generatedFiles, outputDirectory, false);
- return (true, "Compression complete!");
+ status = "Compression complete!";
+ return true;
}
catch (Exception ex)
{
- return (false, $"Compression could not complete: {ex}");
+ status = $"Compression could not complete: {ex}";
+ return false;
}
finally
{
@@ -136,7 +143,7 @@ namespace MPF.Processors
/// Output filename to use as the base path
/// Processor object representing how to process the outputs
/// True if the process succeeded, false otherwise
- public (bool, string) DeleteUnnecessaryFiles(string? outputDirectory, string outputFilename)
+ public bool DeleteUnnecessaryFiles(string? outputDirectory, string outputFilename, out string status)
{
// Prepare the necessary paths
outputFilename = Path.GetFileNameWithoutExtension(outputFilename);
@@ -150,7 +157,10 @@ namespace MPF.Processors
var files = GetDeleteableFilePaths(combinedBase);
if (!files.Any())
- return (true, "No files to delete!");
+ {
+ status = "No files to delete!";
+ return true;
+ }
// Attempt to delete all of the files
foreach (string file in files)
@@ -162,7 +172,8 @@ namespace MPF.Processors
catch { }
}
- return (true, "Deletion complete!");
+ status = "Deletion complete!";
+ return true;
}
///
@@ -171,8 +182,8 @@ namespace MPF.Processors
/// Output folder to write to
/// Output filename to use as the base path
/// Processor object representing how to process the outputs
- /// Tuple of true if all required files exist, false otherwise and a list representing missing files
- public (bool, List) FoundAllFiles(string? outputDirectory, string outputFilename)
+ /// A list representing missing files, empty if none
+ public List FoundAllFiles(string? outputDirectory, string outputFilename)
{
// Sanitize the output filename to strip off any potential extension
outputFilename = Path.GetFileNameWithoutExtension(outputFilename);
@@ -317,8 +328,8 @@ namespace MPF.Processors
/// Validate if all required output files exist
///
/// Base filename and path to use for checking
- /// Tuple of true if all required files exist, false otherwise and a list representing missing files
- private (bool, List) CheckRequiredFiles(string basePath)
+ /// A list representing missing files, empty if none
+ private List CheckRequiredFiles(string basePath)
{
// Split the base path for matching
string? baseDirectory = Path.GetDirectoryName(basePath);
@@ -327,7 +338,7 @@ namespace MPF.Processors
// Get the list of output files
var outputFiles = GetOutputFiles(baseDirectory, baseFilename);
if (outputFiles.Count == 0)
- return (false, ["Media and system combination not supported"]);
+ return ["Media and system combination not supported"];
// Check for the log file
bool logArchiveExists = false;
@@ -382,7 +393,7 @@ namespace MPF.Processors
#endif
}
- return (missingFiles.Count == 0, missingFiles);
+ return missingFiles;
}
///
diff --git a/MPF.Processors/DiscImageCreator.cs b/MPF.Processors/DiscImageCreator.cs
index 213a529d..b5efd7d9 100644
--- a/MPF.Processors/DiscImageCreator.cs
+++ b/MPF.Processors/DiscImageCreator.cs
@@ -75,7 +75,7 @@ namespace MPF.Processors
info = Builder.EnsureAllSections(info);
// Get the dumping program and version
- var (dicCmd, dicVersion) = GetCommandFilePathAndVersion(basePath);
+ var dicVersion = GetCommandFilePathAndVersion(basePath, out var dicCmd);
info.DumpingInfo!.DumpingProgram ??= string.Empty;
info.DumpingInfo.DumpingProgram += $" {dicVersion ?? "Unknown Version"}";
info.DumpingInfo.DumpingDate = ProcessingTool.GetFileModifiedDate(dicCmd)?.ToString("yyyy-MM-dd HH:mm:ss");
@@ -728,12 +728,13 @@ namespace MPF.Processors
/// Get the command file path and extract the version from it
///
/// Base filename and path to use for checking
- /// Tuple of file path and version as strings, both null on error
- private static (string?, string?) GetCommandFilePathAndVersion(string basePath)
+ /// The version as a string, both null on error
+ private static string? GetCommandFilePathAndVersion(string basePath, out string? commandPath)
{
// If we have an invalid base path, we can do nothing
+ commandPath = null;
if (string.IsNullOrEmpty(basePath))
- return (null, null);
+ return null;
// Generate the matching regex based on the base path
string baseFilename = Path.GetFileName(basePath);
@@ -742,17 +743,16 @@ namespace MPF.Processors
// Find the first match for the command file
var parentDirectory = Path.GetDirectoryName(basePath);
if (string.IsNullOrEmpty(parentDirectory))
- return (null, null);
+ return null;
var currentFiles = Directory.GetFiles(parentDirectory);
- var commandPath = currentFiles.FirstOrDefault(f => cmdFilenameRegex.IsMatch(f));
- if (string.IsNullOrEmpty(commandPath))
- return (null, null);
+ commandPath = currentFiles.FirstOrDefault(f => cmdFilenameRegex.IsMatch(f));
+ if (string.IsNullOrEmpty(value: commandPath))
+ return null;
// Extract the version string
var match = cmdFilenameRegex.Match(commandPath);
- string version = match.Groups[1].Value;
- return (commandPath, version);
+ return match.Groups[1].Value;
}
#endregion