mirror of
https://github.com/SabreTools/MPF.git
synced 2026-04-05 22:01:16 +00:00
Add editorconfig, fix issues
This commit is contained in:
169
.editorconfig
169
.editorconfig
@@ -1,4 +1,167 @@
|
||||
[*.cs]
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# SYSLIB1045: Convert to 'GeneratedRegexAttribute'.
|
||||
dotnet_diagnostic.SYSLIB1045.severity = silent
|
||||
# C# files
|
||||
[*.cs]
|
||||
|
||||
# Indentation and spacing
|
||||
charset = utf-8
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
tab_width = 4
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
# New line preferences
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
max_line_length = unset
|
||||
|
||||
# using directive preferences
|
||||
csharp_using_directive_placement = outside_namespace
|
||||
dotnet_diagnostic.IDE0005.severity = error
|
||||
|
||||
# Code-block preferences
|
||||
csharp_style_namespace_declarations = block_scoped
|
||||
csharp_style_prefer_method_group_conversion = true
|
||||
csharp_style_prefer_top_level_statements = false
|
||||
|
||||
# Expression-level preferences
|
||||
csharp_prefer_simple_default_expression = true
|
||||
csharp_style_inlined_variable_declaration = true
|
||||
csharp_style_unused_value_assignment_preference = discard_variable
|
||||
csharp_style_unused_value_expression_statement_preference = discard_variable
|
||||
dotnet_diagnostic.IDE0001.severity = warning
|
||||
dotnet_diagnostic.IDE0002.severity = warning
|
||||
dotnet_diagnostic.IDE0004.severity = warning
|
||||
dotnet_diagnostic.IDE0010.severity = error
|
||||
dotnet_diagnostic.IDE0051.severity = warning
|
||||
dotnet_diagnostic.IDE0052.severity = warning
|
||||
dotnet_diagnostic.IDE0072.severity = warning
|
||||
dotnet_diagnostic.IDE0080.severity = warning
|
||||
dotnet_diagnostic.IDE0100.severity = error
|
||||
dotnet_diagnostic.IDE0110.severity = error
|
||||
dotnet_diagnostic.IDE0120.severity = warning
|
||||
dotnet_diagnostic.IDE0121.severity = warning
|
||||
dotnet_diagnostic.IDE0240.severity = error
|
||||
dotnet_diagnostic.IDE0241.severity = error
|
||||
dotnet_style_coalesce_expression = true
|
||||
dotnet_style_namespace_match_folder = false
|
||||
dotnet_style_null_propagation = true
|
||||
dotnet_style_prefer_auto_properties = true
|
||||
dotnet_style_prefer_collection_expression = when_types_loosely_match
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true
|
||||
dotnet_style_prefer_compound_assignment = true
|
||||
csharp_style_prefer_simple_property_accessors = true
|
||||
dotnet_style_prefer_simplified_interpolation = true
|
||||
dotnet_style_prefer_simplified_boolean_expressions = true
|
||||
csharp_style_prefer_unbound_generic_type_in_nameof = true
|
||||
|
||||
# Field preferences
|
||||
dotnet_diagnostic.IDE0044.severity = warning
|
||||
dotnet_style_readonly_field = true
|
||||
|
||||
# Language keyword vs. framework types preferences
|
||||
dotnet_diagnostic.IDE0049.severity = error
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true
|
||||
dotnet_style_predefined_type_for_member_access = true
|
||||
|
||||
# Modifier preferences
|
||||
csharp_prefer_static_local_function = true
|
||||
csharp_style_prefer_readonly_struct = true
|
||||
dotnet_diagnostic.IDE0036.severity = warning
|
||||
dotnet_diagnostic.IDE0040.severity = error
|
||||
dotnet_diagnostic.IDE0380.severity = error
|
||||
dotnet_style_require_accessibility_modifiers = always
|
||||
|
||||
# New-line preferences
|
||||
dotnet_diagnostic.IDE2000.severity = warning
|
||||
dotnet_diagnostic.IDE2002.severity = warning
|
||||
dotnet_diagnostic.IDE2003.severity = warning
|
||||
dotnet_diagnostic.IDE2004.severity = warning
|
||||
dotnet_diagnostic.IDE2005.severity = warning
|
||||
dotnet_diagnostic.IDE2006.severity = warning
|
||||
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false
|
||||
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false
|
||||
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false
|
||||
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
|
||||
dotnet_style_allow_multiple_blank_lines_experimental = false
|
||||
dotnet_style_allow_statement_immediately_after_block_experimental = false
|
||||
|
||||
# Null-checking preferences
|
||||
csharp_style_conditional_delegate_call = true
|
||||
|
||||
# Parameter preferences
|
||||
dotnet_code_quality_unused_parameters = all
|
||||
dotnet_diagnostic.IDE0280.severity = error
|
||||
|
||||
# Parentheses preferences
|
||||
dotnet_diagnostic.IDE0047.severity = warning
|
||||
dotnet_diagnostic.IDE0048.severity = warning
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
|
||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
|
||||
dotnet_style_parentheses_in_other_operators = always_for_clarity
|
||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
|
||||
|
||||
# Pattern-matching preferences
|
||||
dotnet_diagnostic.IDE0019.severity = warning
|
||||
dotnet_diagnostic.IDE0020.severity = warning
|
||||
dotnet_diagnostic.IDE0038.severity = warning
|
||||
dotnet_diagnostic.IDE0066.severity = none
|
||||
dotnet_diagnostic.IDE0083.severity = warning
|
||||
dotnet_diagnostic.IDE0260.severity = warning
|
||||
csharp_style_pattern_matching_over_as_with_null_check = true
|
||||
csharp_style_pattern_matching_over_is_with_cast_check = true
|
||||
csharp_style_prefer_not_pattern = true
|
||||
csharp_style_prefer_pattern_matching = true
|
||||
|
||||
# this. and Me. preferences
|
||||
dotnet_style_qualification_for_event = false
|
||||
dotnet_style_qualification_for_field = false
|
||||
dotnet_style_qualification_for_method = false
|
||||
dotnet_style_qualification_for_property = false
|
||||
|
||||
# var preferences
|
||||
csharp_style_var_for_built_in_types = false
|
||||
csharp_style_var_when_type_is_apparent = true
|
||||
|
||||
# .NET formatting options
|
||||
dotnet_separate_import_directive_groups = false
|
||||
dotnet_sort_system_directives_first = true
|
||||
|
||||
# C# formatting options
|
||||
csharp_indent_block_contents = true
|
||||
csharp_indent_braces = false
|
||||
csharp_indent_case_contents = true
|
||||
csharp_indent_case_contents_when_block = false
|
||||
csharp_indent_labels = one_less_than_current
|
||||
csharp_indent_switch_labels = true
|
||||
csharp_new_line_before_catch = true
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_finally = true
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_open_brace = all
|
||||
csharp_new_line_between_query_expression_clauses = true
|
||||
csharp_preserve_single_line_blocks = true
|
||||
csharp_preserve_single_line_statements = true
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_after_comma = true
|
||||
csharp_space_after_dot = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = true
|
||||
csharp_space_after_semicolon_in_for_statement = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_around_declaration_statements = false
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_before_comma = false
|
||||
csharp_space_before_dot = false
|
||||
csharp_space_before_open_square_brackets = false
|
||||
csharp_space_before_semicolon_in_for_statement = false
|
||||
csharp_space_between_empty_square_brackets = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = false
|
||||
csharp_space_between_square_brackets = false
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
- Add default subfolder to CLI outputs
|
||||
- Update DIC to 20260101
|
||||
- Update Redumper to build 683
|
||||
- Add editorconfig, fix issues
|
||||
|
||||
### 3.6.0 (2025-11-28)
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ namespace MPF.CLI.Features
|
||||
}
|
||||
|
||||
// Validate the internal program
|
||||
#pragma warning disable IDE0010
|
||||
switch (Options.InternalProgram)
|
||||
{
|
||||
case InternalProgram.Aaru:
|
||||
@@ -122,6 +123,7 @@ namespace MPF.CLI.Features
|
||||
Console.Error.WriteLine("A path needs to be supplied in config.json for Aaru, exiting...");
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case InternalProgram.DiscImageCreator:
|
||||
@@ -130,6 +132,7 @@ namespace MPF.CLI.Features
|
||||
Console.Error.WriteLine("A path needs to be supplied in config.json for DIC, exiting...");
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case InternalProgram.Redumper:
|
||||
@@ -138,29 +141,32 @@ namespace MPF.CLI.Features
|
||||
Console.Error.WriteLine("A path needs to be supplied in config.json for Redumper, exiting...");
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
Console.Error.WriteLine($"{Options.InternalProgram} is not a supported dumping program, exiting...");
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
|
||||
// Ensure we have the values we need
|
||||
if (CustomParams == null && DevicePath == null)
|
||||
if (CustomParams is null && DevicePath is null)
|
||||
{
|
||||
Console.Error.WriteLine("Either custom parameters or a device path need to be provided, exiting...");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Options.InternalProgram == InternalProgram.DiscImageCreator
|
||||
&& CustomParams == null
|
||||
&& (MediaType == null || MediaType == SabreTools.RedumpLib.Data.MediaType.NONE))
|
||||
&& CustomParams is null
|
||||
&& (MediaType is null || MediaType == SabreTools.RedumpLib.Data.MediaType.NONE))
|
||||
{
|
||||
Console.Error.WriteLine("Media type is required for DiscImageCreator, exiting...");
|
||||
return false;
|
||||
}
|
||||
|
||||
// If no media type is provided, use a default
|
||||
if (CustomParams == null && (MediaType == null || MediaType == SabreTools.RedumpLib.Data.MediaType.NONE))
|
||||
if (CustomParams is null && (MediaType is null || MediaType == SabreTools.RedumpLib.Data.MediaType.NONE))
|
||||
{
|
||||
// Get reasonable default values based on the current system
|
||||
var mediaTypes = System.MediaTypes();
|
||||
@@ -172,14 +178,15 @@ namespace MPF.CLI.Features
|
||||
}
|
||||
|
||||
// Normalize the file path
|
||||
if (DevicePath != null && FilePath == null)
|
||||
if (DevicePath is not null && FilePath is null)
|
||||
{
|
||||
string defaultFileName = $"track_{DateTime.Now:yyyyMMdd-HHmm}";
|
||||
FilePath = Path.Combine(defaultFileName, $"{defaultFileName}.bin");
|
||||
if (Options.DefaultOutputPath != null)
|
||||
if (Options.DefaultOutputPath is not null)
|
||||
FilePath = Path.Combine(Options.DefaultOutputPath, FilePath);
|
||||
}
|
||||
if (FilePath != null)
|
||||
|
||||
if (FilePath is not null)
|
||||
FilePath = FrontendTool.NormalizeOutputPaths(FilePath, getFullPath: true);
|
||||
|
||||
// Get the speed from the options
|
||||
@@ -221,7 +228,7 @@ namespace MPF.CLI.Features
|
||||
}
|
||||
|
||||
// If we have a mounted path, replace the environment
|
||||
if (MountedPath != null && Directory.Exists(MountedPath))
|
||||
if (MountedPath is not null && Directory.Exists(MountedPath))
|
||||
{
|
||||
drive = Drive.Create(null, MountedPath);
|
||||
env = new DumpEnvironment(Options,
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace MPF.CLI.Features
|
||||
public override bool ProcessArgs(string[] args, int index)
|
||||
{
|
||||
// If we have no arguments, just return
|
||||
if (args == null || args.Length == 0)
|
||||
if (args is null || args.Length == 0)
|
||||
return true;
|
||||
|
||||
// Read the options from config, if possible
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace MPF.CLI
|
||||
var commandSet = CreateCommands(mainFeature);
|
||||
|
||||
// If we have no args, show the help and quit
|
||||
if (args == null || args.Length == 0)
|
||||
if (args is null || args.Length == 0)
|
||||
{
|
||||
BaseFeature.DisplayHelp();
|
||||
return;
|
||||
@@ -62,6 +62,7 @@ namespace MPF.CLI
|
||||
BaseFeature.DisplayHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!interactive.Execute())
|
||||
{
|
||||
BaseFeature.DisplayHelp();
|
||||
@@ -77,6 +78,7 @@ namespace MPF.CLI
|
||||
BaseFeature.DisplayHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mainFeature.Execute())
|
||||
{
|
||||
BaseFeature.DisplayHelp();
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace MPF.Check.Features
|
||||
hideDriveLetters = false;
|
||||
|
||||
// If we have no arguments, just return
|
||||
if (args == null || args.Length == 0)
|
||||
if (args is null || args.Length == 0)
|
||||
return true;
|
||||
|
||||
// Read the options from config, if possible
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace MPF.Check
|
||||
var commandSet = CreateCommands(mainFeature);
|
||||
|
||||
// If we have no args, show the help and quit
|
||||
if (args == null || args.Length == 0)
|
||||
if (args is null || args.Length == 0)
|
||||
{
|
||||
BaseFeature.DisplayHelp();
|
||||
return;
|
||||
@@ -48,12 +48,14 @@ namespace MPF.Check
|
||||
BaseFeature.DisplayHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!interactive.VerifyInputs())
|
||||
{
|
||||
Console.Error.WriteLine("At least one input is required");
|
||||
BaseFeature.DisplayHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!interactive.Execute())
|
||||
{
|
||||
BaseFeature.DisplayHelp();
|
||||
@@ -69,12 +71,14 @@ namespace MPF.Check
|
||||
BaseFeature.DisplayHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mainFeature.VerifyInputs())
|
||||
{
|
||||
Console.Error.WriteLine("At least one input is required");
|
||||
BaseFeature.DisplayHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mainFeature.Execute())
|
||||
{
|
||||
BaseFeature.DisplayHelp();
|
||||
|
||||
@@ -511,6 +511,7 @@ namespace MPF.ExecutionContexts.Aaru
|
||||
}
|
||||
|
||||
// Handle filenames based on command, if necessary
|
||||
#pragma warning disable IDE0010
|
||||
switch (BaseCommand)
|
||||
{
|
||||
// Input value only (file path)
|
||||
@@ -586,6 +587,7 @@ namespace MPF.ExecutionContexts.Aaru
|
||||
parameters.Append($"\"{RemoteHostValue}\" ");
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
|
||||
return parameters.ToString().TrimEnd();
|
||||
}
|
||||
@@ -636,7 +638,7 @@ namespace MPF.ExecutionContexts.Aaru
|
||||
InputValue = drivePath;
|
||||
OutputValue = filename;
|
||||
|
||||
if (driveSpeed != null)
|
||||
if (driveSpeed is not null)
|
||||
{
|
||||
this[FlagStrings.SpeedLong] = true;
|
||||
(_inputs[FlagStrings.SpeedLong] as Int8Input)?.SetValue((sbyte)driveSpeed);
|
||||
@@ -656,16 +658,19 @@ namespace MPF.ExecutionContexts.Aaru
|
||||
this[FlagStrings.DebugLong] = true;
|
||||
_preCommandInputs[FlagStrings.DebugLong].SetValue(true);
|
||||
}
|
||||
|
||||
if (GetBooleanSetting(options, SettingConstants.EnableVerbose, SettingConstants.EnableVerboseDefault))
|
||||
{
|
||||
this[FlagStrings.VerboseLong] = true;
|
||||
_preCommandInputs[FlagStrings.VerboseLong].SetValue(true);
|
||||
}
|
||||
|
||||
if (GetBooleanSetting(options, SettingConstants.ForceDumping, SettingConstants.ForceDumpingDefault))
|
||||
{
|
||||
this[FlagStrings.ForceLong] = true;
|
||||
(_inputs[FlagStrings.ForceLong] as BooleanInput)?.SetValue(true);
|
||||
}
|
||||
|
||||
if (GetBooleanSetting(options, SettingConstants.StripPersonalData, SettingConstants.StripPersonalDataDefault))
|
||||
{
|
||||
this[FlagStrings.PrivateLong] = true;
|
||||
@@ -757,6 +762,7 @@ namespace MPF.ExecutionContexts.Aaru
|
||||
}
|
||||
|
||||
// Handle filenames based on command, if necessary
|
||||
#pragma warning disable IDE0010
|
||||
switch (BaseCommand)
|
||||
{
|
||||
// Input value only
|
||||
@@ -823,6 +829,7 @@ namespace MPF.ExecutionContexts.Aaru
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
|
||||
// If we didn't reach the end for some reason, it failed
|
||||
if (i != parts.Length)
|
||||
@@ -854,7 +861,7 @@ namespace MPF.ExecutionContexts.Aaru
|
||||
var normalized = NormalizeCommand($"{partOne} {partTwo}".Trim());
|
||||
|
||||
// Null normalization means invalid command
|
||||
if (normalized == null)
|
||||
if (normalized is null)
|
||||
return null;
|
||||
|
||||
// Determine if start should be incremented
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace MPF.ExecutionContexts
|
||||
/// Returns if the current Parameter object is valid
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsValid() => GenerateParameters() != null;
|
||||
public bool IsValid() => GenerateParameters() is not null;
|
||||
|
||||
/// <summary>
|
||||
/// Reset all special variables to have default values
|
||||
@@ -222,7 +222,7 @@ namespace MPF.ExecutionContexts
|
||||
{
|
||||
try
|
||||
{
|
||||
while (process != null && !process.HasExited)
|
||||
while (process is not null && !process.HasExited)
|
||||
{
|
||||
process.Kill();
|
||||
}
|
||||
@@ -331,9 +331,9 @@ namespace MPF.ExecutionContexts
|
||||
/// <returns>True if the flag value is supported, false otherwise</returns>
|
||||
protected bool IsFlagSupported(string flag)
|
||||
{
|
||||
if (CommandSupport == null)
|
||||
if (CommandSupport is null)
|
||||
return false;
|
||||
if (BaseCommand == null)
|
||||
if (BaseCommand is null)
|
||||
return false;
|
||||
if (!CommandSupport.TryGetValue(BaseCommand, out var supported))
|
||||
return false;
|
||||
@@ -360,9 +360,9 @@ namespace MPF.ExecutionContexts
|
||||
string value = ExtractFactorFromValue(parameter, out _);
|
||||
if (!sbyte.TryParse(value, out sbyte temp))
|
||||
return false;
|
||||
else if (lowerBound != null && temp < lowerBound)
|
||||
else if (lowerBound is not null && temp < lowerBound)
|
||||
return false;
|
||||
else if (upperBound != null && temp > upperBound)
|
||||
else if (upperBound is not null && temp > upperBound)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -380,9 +380,9 @@ namespace MPF.ExecutionContexts
|
||||
string value = ExtractFactorFromValue(parameter, out _);
|
||||
if (!short.TryParse(value, out short temp))
|
||||
return false;
|
||||
else if (lowerBound != null && temp < lowerBound)
|
||||
else if (lowerBound is not null && temp < lowerBound)
|
||||
return false;
|
||||
else if (upperBound != null && temp > upperBound)
|
||||
else if (upperBound is not null && temp > upperBound)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -400,9 +400,9 @@ namespace MPF.ExecutionContexts
|
||||
string value = ExtractFactorFromValue(parameter, out _);
|
||||
if (!int.TryParse(value, out int temp))
|
||||
return false;
|
||||
else if (lowerBound != null && temp < lowerBound)
|
||||
else if (lowerBound is not null && temp < lowerBound)
|
||||
return false;
|
||||
else if (upperBound != null && temp > upperBound)
|
||||
else if (upperBound is not null && temp > upperBound)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -420,9 +420,9 @@ namespace MPF.ExecutionContexts
|
||||
string value = ExtractFactorFromValue(parameter, out _);
|
||||
if (!long.TryParse(value, out long temp))
|
||||
return false;
|
||||
else if (lowerBound != null && temp < lowerBound)
|
||||
else if (lowerBound is not null && temp < lowerBound)
|
||||
return false;
|
||||
else if (upperBound != null && temp > upperBound)
|
||||
else if (upperBound is not null && temp > upperBound)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -448,7 +448,7 @@ namespace MPF.ExecutionContexts
|
||||
/// <returns>True if the parameter was processed successfully or skipped, false otherwise</returns>
|
||||
protected bool ProcessFlagParameter(string[] parts, string? shortFlagString, string longFlagString, ref int i)
|
||||
{
|
||||
if (parts == null)
|
||||
if (parts is null)
|
||||
return false;
|
||||
|
||||
if (parts[i] == shortFlagString || parts[i] == longFlagString)
|
||||
@@ -484,7 +484,7 @@ namespace MPF.ExecutionContexts
|
||||
/// <returns>True if the parameter was processed successfully or skipped, false otherwise</returns>
|
||||
protected bool ProcessBooleanParameter(string[] parts, string? shortFlagString, string longFlagString, ref int i, bool missingAllowed = false)
|
||||
{
|
||||
if (parts == null)
|
||||
if (parts is null)
|
||||
return false;
|
||||
|
||||
if (parts[i] == shortFlagString || parts[i] == longFlagString)
|
||||
@@ -559,7 +559,7 @@ namespace MPF.ExecutionContexts
|
||||
/// <returns>SByte value if success, SByte.MinValue if skipped, null on error/returns>
|
||||
protected sbyte? ProcessInt8Parameter(string[] parts, string? shortFlagString, string longFlagString, ref int i, bool missingAllowed = false)
|
||||
{
|
||||
if (parts == null)
|
||||
if (parts is null)
|
||||
return null;
|
||||
|
||||
if (parts[i] == shortFlagString || parts[i] == longFlagString)
|
||||
@@ -622,7 +622,7 @@ namespace MPF.ExecutionContexts
|
||||
return null;
|
||||
}
|
||||
|
||||
return SByte.MinValue;
|
||||
return sbyte.MinValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -647,7 +647,7 @@ namespace MPF.ExecutionContexts
|
||||
/// <returns>Int16 value if success, Int16.MinValue if skipped, null on error/returns>
|
||||
protected short? ProcessInt16Parameter(string[] parts, string? shortFlagString, string longFlagString, ref int i, bool missingAllowed = false)
|
||||
{
|
||||
if (parts == null)
|
||||
if (parts is null)
|
||||
return null;
|
||||
|
||||
if (parts[i] == shortFlagString || parts[i] == longFlagString)
|
||||
@@ -709,7 +709,7 @@ namespace MPF.ExecutionContexts
|
||||
return null;
|
||||
}
|
||||
|
||||
return Int16.MinValue;
|
||||
return short.MinValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -734,7 +734,7 @@ namespace MPF.ExecutionContexts
|
||||
/// <returns>Int32 value if success, Int32.MinValue if skipped, null on error/returns>
|
||||
protected int? ProcessInt32Parameter(string[] parts, string? shortFlagString, string longFlagString, ref int i, bool missingAllowed = false)
|
||||
{
|
||||
if (parts == null)
|
||||
if (parts is null)
|
||||
return null;
|
||||
|
||||
if (parts[i] == shortFlagString || parts[i] == longFlagString)
|
||||
@@ -821,7 +821,7 @@ namespace MPF.ExecutionContexts
|
||||
/// <returns>Int64 value if success, Int64.MinValue if skipped, null on error/returns>
|
||||
protected long? ProcessInt64Parameter(string[] parts, string? shortFlagString, string longFlagString, ref int i, bool missingAllowed = false)
|
||||
{
|
||||
if (parts == null)
|
||||
if (parts is null)
|
||||
return null;
|
||||
|
||||
if (parts[i] == shortFlagString || parts[i] == longFlagString)
|
||||
@@ -856,10 +856,10 @@ namespace MPF.ExecutionContexts
|
||||
i++;
|
||||
string value = ExtractFactorFromValue(parts[i], out long factor);
|
||||
if (long.TryParse(value, out long longValue))
|
||||
return (long)(longValue * factor);
|
||||
return longValue * factor;
|
||||
string hexValue = RemoveHexIdentifier(value);
|
||||
if (long.TryParse(hexValue, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out long longHexValue))
|
||||
return (long)(longHexValue * factor);
|
||||
return longHexValue * factor;
|
||||
return null;
|
||||
}
|
||||
else if (parts[i].StartsWith(shortFlagString + "=") || parts[i].StartsWith(longFlagString + "="))
|
||||
@@ -876,10 +876,10 @@ namespace MPF.ExecutionContexts
|
||||
this[longFlagString] = true;
|
||||
string value = ExtractFactorFromValue(valuePart, out long factor);
|
||||
if (long.TryParse(value, out long longValue))
|
||||
return (long)(longValue * factor);
|
||||
return longValue * factor;
|
||||
string hexValue = RemoveHexIdentifier(value);
|
||||
if (long.TryParse(hexValue, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out long longHexValue))
|
||||
return (long)(longHexValue * factor);
|
||||
return longHexValue * factor;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -908,7 +908,7 @@ namespace MPF.ExecutionContexts
|
||||
/// <returns>String value if possible, string.Empty on missing, null on error</returns>
|
||||
protected string? ProcessStringParameter(string[] parts, string? shortFlagString, string longFlagString, ref int i, bool missingAllowed = false)
|
||||
{
|
||||
if (parts == null)
|
||||
if (parts is null)
|
||||
return null;
|
||||
|
||||
if (parts[i] == shortFlagString || parts[i] == longFlagString)
|
||||
@@ -981,7 +981,7 @@ namespace MPF.ExecutionContexts
|
||||
/// <returns>Byte value if success, Byte.MinValue if skipped, null on error/returns>
|
||||
protected byte? ProcessUInt8Parameter(string[] parts, string? shortFlagString, string longFlagString, ref int i, bool missingAllowed = false)
|
||||
{
|
||||
if (parts == null)
|
||||
if (parts is null)
|
||||
return null;
|
||||
|
||||
if (parts[i] == shortFlagString || parts[i] == longFlagString)
|
||||
@@ -1044,7 +1044,7 @@ namespace MPF.ExecutionContexts
|
||||
return null;
|
||||
}
|
||||
|
||||
return Byte.MinValue;
|
||||
return byte.MinValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
public override string Format(bool useEquals)
|
||||
{
|
||||
// Do not output if there is no value
|
||||
if (Value == null)
|
||||
if (Value is null)
|
||||
return string.Empty;
|
||||
|
||||
// Build the output format
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
public override string Format(bool useEquals)
|
||||
{
|
||||
// Do not output if there is no value
|
||||
if (Value == false)
|
||||
if (!Value)
|
||||
return string.Empty;
|
||||
|
||||
// Build the output format
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
public T? Value { get; protected set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool ValueSet => Value != null;
|
||||
public override bool ValueSet => Value is not null;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
public override string Format(bool useEquals)
|
||||
{
|
||||
// Do not output if there is no value
|
||||
if (Value == null)
|
||||
if (Value is null)
|
||||
return string.Empty;
|
||||
|
||||
// Build the output format
|
||||
@@ -95,25 +95,25 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (index + 1 >= parts.Length)
|
||||
{
|
||||
Value = _required ? null : short.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(parts[index + 1], out short? value) && value != null)
|
||||
if (ParseValue(parts[index + 1], out short? value) && value is not null)
|
||||
{
|
||||
index++;
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : short.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
@@ -129,24 +129,24 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (string.IsNullOrEmpty(val))
|
||||
{
|
||||
Value = _required ? null : short.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(val, out short? value) && value != null)
|
||||
if (ParseValue(val, out short? value) && value is not null)
|
||||
{
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : short.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
public override string Format(bool useEquals)
|
||||
{
|
||||
// Do not output if there is no value
|
||||
if (Value == null)
|
||||
if (Value is null)
|
||||
return string.Empty;
|
||||
|
||||
// Build the output format
|
||||
@@ -70,7 +70,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
builder.Append(Name);
|
||||
|
||||
// Only output separator and value if needed
|
||||
if (_required || (!_required && Value != null))
|
||||
if (_required || (!_required && Value is not null))
|
||||
{
|
||||
// Separator
|
||||
if (useEquals)
|
||||
@@ -79,7 +79,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
builder.Append(' ');
|
||||
|
||||
// Value
|
||||
int?[] nonNull = Array.FindAll(Value, i => i != null);
|
||||
int?[] nonNull = Array.FindAll(Value, i => i is not null);
|
||||
string[] stringValues = Array.ConvertAll(nonNull, i => i.ToString() ?? string.Empty);
|
||||
builder.Append(string.Join(" ", stringValues));
|
||||
}
|
||||
@@ -106,12 +106,12 @@ namespace MPF.ExecutionContexts.Data
|
||||
return !_required;
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(parts[index + 1], out int? value) && value != null)
|
||||
if (ParseValue(parts[index + 1], out int? value) && value is not null)
|
||||
{
|
||||
index++;
|
||||
Value[i] = value;
|
||||
Value[i] = (MinValue != null && Value[i] < MinValue) ? MinValue : Value[i];
|
||||
Value[i] = (MaxValue != null && Value[i] > MaxValue) ? MaxValue : Value[i];
|
||||
Value[i] = (MinValue is not null && Value[i] < MinValue) ? MinValue : Value[i];
|
||||
Value[i] = (MaxValue is not null && Value[i] > MaxValue) ? MaxValue : Value[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
public override string Format(bool useEquals)
|
||||
{
|
||||
// Do not output if there is no value
|
||||
if (Value == null)
|
||||
if (Value is null)
|
||||
return string.Empty;
|
||||
|
||||
// Build the output format
|
||||
@@ -95,25 +95,25 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (index + 1 >= parts.Length)
|
||||
{
|
||||
Value = _required ? null : int.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(parts[index + 1], out int? value) && value != null)
|
||||
if (ParseValue(parts[index + 1], out int? value) && value is not null)
|
||||
{
|
||||
index++;
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : int.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
@@ -129,24 +129,24 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (string.IsNullOrEmpty(val))
|
||||
{
|
||||
Value = _required ? null : int.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(val, out int? value) && value != null)
|
||||
if (ParseValue(val, out int? value) && value is not null)
|
||||
{
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : int.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
public override string Format(bool useEquals)
|
||||
{
|
||||
// Do not output if there is no value
|
||||
if (Value == null)
|
||||
if (Value is null)
|
||||
return string.Empty;
|
||||
|
||||
// Build the output format
|
||||
@@ -95,25 +95,25 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (index + 1 >= parts.Length)
|
||||
{
|
||||
Value = _required ? null : long.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(parts[index + 1], out long? value) && value != null)
|
||||
if (ParseValue(parts[index + 1], out long? value) && value is not null)
|
||||
{
|
||||
index++;
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : long.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
@@ -129,24 +129,24 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (string.IsNullOrEmpty(val))
|
||||
{
|
||||
Value = _required ? null : long.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(val, out long? value) && value != null)
|
||||
if (ParseValue(val, out long? value) && value is not null)
|
||||
{
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : long.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
string baseVal = ExtractFactorFromValue(str, out long factor);
|
||||
if (long.TryParse(baseVal, out value))
|
||||
{
|
||||
output = (long)(value * factor);
|
||||
output = value * factor;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
string hexValue = RemoveHexIdentifier(baseVal);
|
||||
if (long.TryParse(hexValue, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out value))
|
||||
{
|
||||
output = (long)(value * factor);
|
||||
output = value * factor;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
public override string Format(bool useEquals)
|
||||
{
|
||||
// Do not output if there is no value
|
||||
if (Value == null)
|
||||
if (Value is null)
|
||||
return string.Empty;
|
||||
|
||||
// Build the output format
|
||||
@@ -95,25 +95,25 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (index + 1 >= parts.Length)
|
||||
{
|
||||
Value = _required ? null : sbyte.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(parts[index + 1], out sbyte? value) && value != null)
|
||||
if (ParseValue(parts[index + 1], out sbyte? value) && value is not null)
|
||||
{
|
||||
index++;
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : sbyte.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
@@ -129,24 +129,24 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (string.IsNullOrEmpty(val))
|
||||
{
|
||||
Value = _required ? null : sbyte.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(val, out sbyte? value) && value != null)
|
||||
if (ParseValue(val, out sbyte? value) && value is not null)
|
||||
{
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : sbyte.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
public override string Format(bool useEquals)
|
||||
{
|
||||
// Do not output if there is no value
|
||||
if (Value == null)
|
||||
if (Value is null)
|
||||
return string.Empty;
|
||||
|
||||
// Build the output format
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
public override string Format(bool useEquals)
|
||||
{
|
||||
// Do not output if there is no value
|
||||
if (Value == null)
|
||||
if (Value is null)
|
||||
return string.Empty;
|
||||
|
||||
// Build the output format
|
||||
@@ -95,25 +95,25 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (index + 1 >= parts.Length)
|
||||
{
|
||||
Value = _required ? null : ushort.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(parts[index + 1], out ushort? value) && value != null)
|
||||
if (ParseValue(parts[index + 1], out ushort? value) && value is not null)
|
||||
{
|
||||
index++;
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : ushort.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
@@ -129,24 +129,24 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (string.IsNullOrEmpty(val))
|
||||
{
|
||||
Value = _required ? null : ushort.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(val, out ushort? value) && value != null)
|
||||
if (ParseValue(val, out ushort? value) && value is not null)
|
||||
{
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : ushort.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
public override string Format(bool useEquals)
|
||||
{
|
||||
// Do not output if there is no value
|
||||
if (Value == null)
|
||||
if (Value is null)
|
||||
return string.Empty;
|
||||
|
||||
// Build the output format
|
||||
@@ -95,25 +95,25 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (index + 1 >= parts.Length)
|
||||
{
|
||||
Value = _required ? null : uint.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(parts[index + 1], out uint? value) && value != null)
|
||||
if (ParseValue(parts[index + 1], out uint? value) && value is not null)
|
||||
{
|
||||
index++;
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : uint.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
@@ -129,24 +129,24 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (string.IsNullOrEmpty(val))
|
||||
{
|
||||
Value = _required ? null : uint.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(val, out uint? value) && value != null)
|
||||
if (ParseValue(val, out uint? value) && value is not null)
|
||||
{
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : uint.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
public override string Format(bool useEquals)
|
||||
{
|
||||
// Do not output if there is no value
|
||||
if (Value == null)
|
||||
if (Value is null)
|
||||
return string.Empty;
|
||||
|
||||
// Build the output format
|
||||
@@ -95,25 +95,25 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (index + 1 >= parts.Length)
|
||||
{
|
||||
Value = _required ? null : ulong.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(parts[index + 1], out ulong? value) && value != null)
|
||||
if (ParseValue(parts[index + 1], out ulong? value) && value is not null)
|
||||
{
|
||||
index++;
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : ulong.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
@@ -129,24 +129,24 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (string.IsNullOrEmpty(val))
|
||||
{
|
||||
Value = _required ? null : ulong.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(val, out ulong? value) && value != null)
|
||||
if (ParseValue(val, out ulong? value) && value is not null)
|
||||
{
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : ulong.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
string baseVal = ExtractFactorFromValue(str, out long factor);
|
||||
if (ulong.TryParse(baseVal, out value))
|
||||
{
|
||||
output = (ulong)(value * (ulong)factor);
|
||||
output = value * (ulong)factor;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
string hexValue = RemoveHexIdentifier(baseVal);
|
||||
if (ulong.TryParse(hexValue, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out value))
|
||||
{
|
||||
output = (ulong)(value * (ulong)factor);
|
||||
output = value * (ulong)factor;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace MPF.ExecutionContexts.Data
|
||||
public override string Format(bool useEquals)
|
||||
{
|
||||
// Do not output if there is no value
|
||||
if (Value == null)
|
||||
if (Value is null)
|
||||
return string.Empty;
|
||||
|
||||
// Build the output format
|
||||
@@ -95,25 +95,25 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (index + 1 >= parts.Length)
|
||||
{
|
||||
Value = _required ? null : byte.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(parts[index + 1], out byte? value) && value != null)
|
||||
if (ParseValue(parts[index + 1], out byte? value) && value is not null)
|
||||
{
|
||||
index++;
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : byte.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
@@ -129,24 +129,24 @@ namespace MPF.ExecutionContexts.Data
|
||||
if (string.IsNullOrEmpty(val))
|
||||
{
|
||||
Value = _required ? null : byte.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
// If the next value is valid
|
||||
if (ParseValue(val, out byte? value) && value != null)
|
||||
if (ParseValue(val, out byte? value) && value is not null)
|
||||
{
|
||||
Value = value;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return value based on required flag
|
||||
Value = _required ? null : byte.MinValue;
|
||||
Value = (MinValue != null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue != null && Value > MaxValue) ? MaxValue : Value;
|
||||
Value = (MinValue is not null && Value < MinValue) ? MinValue : Value;
|
||||
Value = (MaxValue is not null && Value > MaxValue) ? MaxValue : Value;
|
||||
return !_required;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
/// <returns>Valid extension (with leading '.'), null on error</returns>
|
||||
public static string? Extension(MediaType? type)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return type switch
|
||||
{
|
||||
MediaType.CDROM
|
||||
@@ -93,6 +94,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
MediaType.Cassette => ".wav",
|
||||
_ => null,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -441,7 +441,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
|| BaseCommand == CommandStrings.XGD2Swap
|
||||
|| BaseCommand == CommandStrings.XGD3Swap)
|
||||
{
|
||||
if (DrivePath != null)
|
||||
if (DrivePath is not null)
|
||||
{
|
||||
#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
|
||||
if (DrivePath.Contains(' '))
|
||||
@@ -478,7 +478,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
|| BaseCommand == CommandStrings.XGD2Swap
|
||||
|| BaseCommand == CommandStrings.XGD3Swap)
|
||||
{
|
||||
if (Filename != null)
|
||||
if (Filename is not null)
|
||||
parameters.Append($"\"{Filename.Trim('"')}\" ");
|
||||
else
|
||||
return null;
|
||||
@@ -487,7 +487,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
// Optiarc Filename
|
||||
if (BaseCommand == CommandStrings.Merge)
|
||||
{
|
||||
if (OptiarcFilename != null)
|
||||
if (OptiarcFilename is not null)
|
||||
parameters.Append($"\"{OptiarcFilename.Trim('"')}\" ");
|
||||
else
|
||||
return null;
|
||||
@@ -507,7 +507,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
|| BaseCommand == CommandStrings.XGD2Swap
|
||||
|| BaseCommand == CommandStrings.XGD3Swap)
|
||||
{
|
||||
if (DriveSpeed != null)
|
||||
if (DriveSpeed is not null)
|
||||
parameters.Append($"{DriveSpeed} ");
|
||||
else
|
||||
return null;
|
||||
@@ -517,7 +517,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (BaseCommand == CommandStrings.Audio
|
||||
|| BaseCommand == CommandStrings.Data)
|
||||
{
|
||||
if (StartLBAValue != null && EndLBAValue != null)
|
||||
if (StartLBAValue is not null && EndLBAValue is not null)
|
||||
{
|
||||
parameters.Append($"{StartLBAValue} ");
|
||||
parameters.Append($"{EndLBAValue} ");
|
||||
@@ -532,7 +532,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (this[FlagStrings.AddOffset] == true)
|
||||
{
|
||||
parameters.Append($"{FlagStrings.AddOffset} ");
|
||||
if (AddOffsetValue != null)
|
||||
if (AddOffsetValue is not null)
|
||||
parameters.Append($"{AddOffsetValue} ");
|
||||
}
|
||||
}
|
||||
@@ -557,7 +557,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (this[FlagStrings.BEOpcode] == true)
|
||||
{
|
||||
parameters.Append($"{FlagStrings.BEOpcode} ");
|
||||
if (BEOpcodeValue != null)
|
||||
if (BEOpcodeValue is not null)
|
||||
parameters.Append($"{BEOpcodeValue} ");
|
||||
}
|
||||
}
|
||||
@@ -568,22 +568,25 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (this[FlagStrings.C2Opcode] == true)
|
||||
{
|
||||
parameters.Append($"{FlagStrings.C2Opcode} ");
|
||||
if (C2OpcodeValue[0] != null)
|
||||
if (C2OpcodeValue[0] is not null)
|
||||
{
|
||||
if (C2OpcodeValue[0] > 0)
|
||||
parameters.Append($"{C2OpcodeValue[0]} ");
|
||||
else
|
||||
return null;
|
||||
}
|
||||
if (C2OpcodeValue[1] != null)
|
||||
|
||||
if (C2OpcodeValue[1] is not null)
|
||||
{
|
||||
parameters.Append($"{C2OpcodeValue[1]} ");
|
||||
}
|
||||
if (C2OpcodeValue[2] != null)
|
||||
|
||||
if (C2OpcodeValue[2] is not null)
|
||||
{
|
||||
parameters.Append($"{C2OpcodeValue[2]} ");
|
||||
}
|
||||
if (C2OpcodeValue[3] != null)
|
||||
|
||||
if (C2OpcodeValue[3] is not null)
|
||||
{
|
||||
if (C2OpcodeValue[3] == 0)
|
||||
{
|
||||
@@ -592,7 +595,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
else if (C2OpcodeValue[3] == 1)
|
||||
{
|
||||
parameters.Append($"{C2OpcodeValue[3]} ");
|
||||
if (C2OpcodeValue[4] != null && C2OpcodeValue[5] != null)
|
||||
if (C2OpcodeValue[4] is not null && C2OpcodeValue[5] is not null)
|
||||
{
|
||||
if (C2OpcodeValue[4] > 0 && C2OpcodeValue[5] > 0)
|
||||
{
|
||||
@@ -619,7 +622,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (this[FlagStrings.C2OpcodeNew] == true)
|
||||
{
|
||||
parameters.Append($"{FlagStrings.C2OpcodeNew} ");
|
||||
if (C2OpcodeValue[0] != null)
|
||||
if (C2OpcodeValue[0] is not null)
|
||||
{
|
||||
if (C2OpcodeValue[0] > 0)
|
||||
parameters.Append($"{C2OpcodeValue[0]} ");
|
||||
@@ -663,7 +666,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (this[FlagStrings.DVDReread] == true)
|
||||
{
|
||||
parameters.Append($"{FlagStrings.DVDReread} ");
|
||||
if (DVDRereadValue != null)
|
||||
if (DVDRereadValue is not null)
|
||||
parameters.Append($"{DVDRereadValue} ");
|
||||
}
|
||||
}
|
||||
@@ -681,7 +684,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (this[FlagStrings.Fix] == true)
|
||||
{
|
||||
parameters.Append($"{FlagStrings.Fix} ");
|
||||
if (FixValue != null)
|
||||
if (FixValue is not null)
|
||||
parameters.Append($"{FixValue} ");
|
||||
else
|
||||
return null;
|
||||
@@ -694,7 +697,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (this[FlagStrings.ForceDescrambleSector] == true)
|
||||
{
|
||||
parameters.Append($"{FlagStrings.ForceDescrambleSector} ");
|
||||
if (ForceDescrambleSectorValue != null)
|
||||
if (ForceDescrambleSectorValue is not null)
|
||||
parameters.Append($"{ForceDescrambleSectorValue} ");
|
||||
else
|
||||
return null;
|
||||
@@ -707,7 +710,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (this[FlagStrings.ForceUnitAccess] == true)
|
||||
{
|
||||
parameters.Append($"{FlagStrings.ForceUnitAccess} ");
|
||||
if (ForceUnitAccessValue != null)
|
||||
if (ForceUnitAccessValue is not null)
|
||||
parameters.Append($"{ForceUnitAccessValue} ");
|
||||
}
|
||||
}
|
||||
@@ -725,7 +728,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (this[FlagStrings.MultiSectorRead] == true)
|
||||
{
|
||||
parameters.Append($"{FlagStrings.MultiSectorRead} ");
|
||||
if (MultiSectorReadValue != null)
|
||||
if (MultiSectorReadValue is not null)
|
||||
parameters.Append($"{MultiSectorReadValue} ");
|
||||
}
|
||||
}
|
||||
@@ -771,7 +774,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (this[FlagStrings.NoSkipSS] == true)
|
||||
{
|
||||
parameters.Append($"{FlagStrings.NoSkipSS} ");
|
||||
if (NoSkipSecuritySectorValue != null)
|
||||
if (NoSkipSecuritySectorValue is not null)
|
||||
parameters.Append($"{NoSkipSecuritySectorValue} ");
|
||||
}
|
||||
}
|
||||
@@ -782,7 +785,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (this[FlagStrings.PadSector] == true)
|
||||
{
|
||||
parameters.Append($"{FlagStrings.PadSector} ");
|
||||
if (PadSectorValue != null)
|
||||
if (PadSectorValue is not null)
|
||||
parameters.Append($"{PadSectorValue} ");
|
||||
}
|
||||
}
|
||||
@@ -796,7 +799,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
|
||||
if (BaseCommand == CommandStrings.DigitalVideoDisc)
|
||||
{
|
||||
if (RangeStartLBAValue == null || RangeEndLBAValue == null)
|
||||
if (RangeStartLBAValue is null || RangeEndLBAValue is null)
|
||||
return null;
|
||||
|
||||
parameters.Append($"{RangeStartLBAValue} ");
|
||||
@@ -828,7 +831,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
|
||||
if (BaseCommand == CommandStrings.DigitalVideoDisc)
|
||||
{
|
||||
if (ReverseStartLBAValue == null || ReverseEndLBAValue == null)
|
||||
if (ReverseStartLBAValue is null || ReverseEndLBAValue is null)
|
||||
return null;
|
||||
|
||||
parameters.Append($"{ReverseStartLBAValue} ");
|
||||
@@ -850,7 +853,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (this[FlagStrings.ScanFileProtect] == true)
|
||||
{
|
||||
parameters.Append($"{FlagStrings.ScanFileProtect} ");
|
||||
if (ScanFileProtectValue != null)
|
||||
if (ScanFileProtectValue is not null)
|
||||
{
|
||||
if (ScanFileProtectValue > 0)
|
||||
parameters.Append($"{ScanFileProtectValue} ");
|
||||
@@ -880,14 +883,15 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (this[FlagStrings.SkipSector] == true)
|
||||
{
|
||||
parameters.Append($"{FlagStrings.SkipSector} ");
|
||||
if (SkipSectorValue[0] != null)
|
||||
if (SkipSectorValue[0] is not null)
|
||||
{
|
||||
if (SkipSectorValue[0] > 0)
|
||||
parameters.Append($"{SkipSectorValue[0]} ");
|
||||
else
|
||||
return null;
|
||||
}
|
||||
if (SkipSectorValue[1] != null)
|
||||
|
||||
if (SkipSectorValue[1] is not null)
|
||||
{
|
||||
if (SkipSectorValue[1] == 0)
|
||||
parameters.Append($"{SkipSectorValue[1]} ");
|
||||
@@ -901,7 +905,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (this[FlagStrings.SubchannelReadLevel] == true)
|
||||
{
|
||||
parameters.Append($"{FlagStrings.SubchannelReadLevel} ");
|
||||
if (SubchannelReadLevelValue != null)
|
||||
if (SubchannelReadLevelValue is not null)
|
||||
{
|
||||
if (SubchannelReadLevelValue >= 0 && SubchannelReadLevelValue <= 2)
|
||||
parameters.Append($"{SubchannelReadLevelValue} ");
|
||||
@@ -945,7 +949,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
if (this[FlagStrings.VideoNow] == true)
|
||||
{
|
||||
parameters.Append($"{FlagStrings.VideoNow} ");
|
||||
if (VideoNowValue != null)
|
||||
if (VideoNowValue is not null)
|
||||
{
|
||||
if (VideoNowValue >= 0)
|
||||
parameters.Append($"{VideoNowValue} ");
|
||||
@@ -1070,6 +1074,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
};
|
||||
|
||||
// Now sort based on disc type
|
||||
#pragma warning disable IDE0010
|
||||
switch (MediaType)
|
||||
{
|
||||
case SabreTools.RedumpLib.Data.MediaType.CDROM:
|
||||
@@ -1105,6 +1110,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
this[FlagStrings.NoFixSubQLibCrypt] = true;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case SabreTools.RedumpLib.Data.MediaType.DVD:
|
||||
this[FlagStrings.CopyrightManagementInformation] = GetBooleanSetting(options, SettingConstants.UseCMIFlag, SettingConstants.UseCMIFlagDefault);
|
||||
@@ -1138,6 +1144,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
// Currently no defaults set
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -1543,7 +1550,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
|
||||
// Add Offset
|
||||
intValue = ProcessInt32Parameter(parts, FlagStrings.AddOffset, ref i, missingAllowed: true);
|
||||
if (intValue != null && intValue != int.MinValue)
|
||||
if (intValue is not null && intValue != int.MinValue)
|
||||
AddOffsetValue = intValue;
|
||||
|
||||
// AMSF
|
||||
@@ -1621,7 +1628,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
|
||||
// DVD/HD-DVD/BD Reread
|
||||
intValue = ProcessInt32Parameter(parts, FlagStrings.DVDReread, ref i, missingAllowed: true);
|
||||
if (intValue != null && intValue != int.MinValue)
|
||||
if (intValue is not null && intValue != int.MinValue)
|
||||
DVDRereadValue = intValue;
|
||||
|
||||
// Extract MS-CAB
|
||||
@@ -1629,7 +1636,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
|
||||
// Fix
|
||||
intValue = ProcessInt32Parameter(parts, FlagStrings.Fix, ref i);
|
||||
if (intValue != null && intValue != int.MinValue)
|
||||
if (intValue is not null && intValue != int.MinValue)
|
||||
FixValue = intValue;
|
||||
|
||||
// Force Descramble Sector
|
||||
@@ -1691,7 +1698,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
|
||||
// Force Unit Access
|
||||
intValue = ProcessInt32Parameter(parts, FlagStrings.ForceUnitAccess, ref i, missingAllowed: true);
|
||||
if (intValue != null && intValue != int.MinValue && intValue >= 0)
|
||||
if (intValue is not null && intValue != int.MinValue && intValue >= 0)
|
||||
ForceUnitAccessValue = intValue;
|
||||
|
||||
// Full TOC
|
||||
@@ -1699,7 +1706,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
|
||||
// Multi-Sector Read
|
||||
intValue = ProcessInt32Parameter(parts, FlagStrings.MultiSectorRead, ref i, missingAllowed: true);
|
||||
if (intValue != null && intValue != int.MinValue && intValue >= 0)
|
||||
if (intValue is not null && intValue != int.MinValue && intValue >= 0)
|
||||
MultiSectorReadValue = intValue;
|
||||
|
||||
// NoFixSubP
|
||||
@@ -1719,12 +1726,12 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
|
||||
// NoSkipSS
|
||||
intValue = ProcessInt32Parameter(parts, FlagStrings.NoSkipSS, ref i, missingAllowed: true);
|
||||
if (intValue != null && intValue != int.MinValue && intValue >= 0)
|
||||
if (intValue is not null && intValue != int.MinValue && intValue >= 0)
|
||||
NoSkipSecuritySectorValue = intValue;
|
||||
|
||||
// PadSector
|
||||
byteValue = ProcessUInt8Parameter(parts, FlagStrings.PadSector, ref i, missingAllowed: true);
|
||||
if (byteValue != null)
|
||||
if (byteValue is not null)
|
||||
PadSectorValue = byteValue;
|
||||
|
||||
// Range
|
||||
@@ -1776,7 +1783,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
|
||||
// ScanFileProtect
|
||||
intValue = ProcessInt32Parameter(parts, FlagStrings.ScanFileProtect, ref i, missingAllowed: true);
|
||||
if (intValue != null && intValue != int.MinValue && intValue >= 0)
|
||||
if (intValue is not null && intValue != int.MinValue && intValue >= 0)
|
||||
ScanFileProtectValue = intValue;
|
||||
|
||||
// ScanSectorProtect
|
||||
@@ -1817,7 +1824,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
|
||||
// SubchannelReadLevel
|
||||
intValue = ProcessInt32Parameter(parts, FlagStrings.SubchannelReadLevel, ref i, missingAllowed: true);
|
||||
if (intValue != null && intValue != int.MinValue && intValue >= 0 && intValue <= 2)
|
||||
if (intValue is not null && intValue != int.MinValue && intValue >= 0 && intValue <= 2)
|
||||
SubchannelReadLevelValue = intValue;
|
||||
|
||||
// Tages
|
||||
@@ -1834,7 +1841,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
|
||||
// VideoNow
|
||||
intValue = ProcessInt32Parameter(parts, FlagStrings.VideoNow, ref i, missingAllowed: true);
|
||||
if (intValue != null && intValue != int.MinValue && intValue >= 0)
|
||||
if (intValue is not null && intValue != int.MinValue && intValue >= 0)
|
||||
VideoNowValue = intValue;
|
||||
|
||||
// VideoNowColor
|
||||
@@ -1866,6 +1873,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
return;
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0010
|
||||
switch (type)
|
||||
{
|
||||
case SabreTools.RedumpLib.Data.MediaType.CDROM:
|
||||
@@ -1881,6 +1889,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
BaseCommand = CommandStrings.XBOX;
|
||||
return;
|
||||
}
|
||||
|
||||
BaseCommand = CommandStrings.DigitalVideoDisc;
|
||||
return;
|
||||
case SabreTools.RedumpLib.Data.MediaType.GDROM:
|
||||
@@ -1915,6 +1924,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
|
||||
BaseCommand = null;
|
||||
return;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace MPF.ExecutionContexts.Redumper
|
||||
/// <returns>Valid extension (with leading '.'), null on error</returns>
|
||||
public static string? Extension(MediaType? type)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return type switch
|
||||
{
|
||||
MediaType.CDROM
|
||||
@@ -25,6 +26,7 @@ namespace MPF.ExecutionContexts.Redumper
|
||||
MediaType.NintendoWiiUOpticalDisc => ".wud",
|
||||
_ => null,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace MPF.ExecutionContexts.Redumper
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && value > 0)
|
||||
if (value is not null && value > 0)
|
||||
{
|
||||
this[FlagStrings.Speed] = true;
|
||||
(_inputs[FlagStrings.Speed] as Int32Input)?.SetValue(value);
|
||||
@@ -295,13 +295,13 @@ namespace MPF.ExecutionContexts.Redumper
|
||||
{
|
||||
BaseCommand = CommandStrings.Disc;
|
||||
|
||||
if (drivePath != null)
|
||||
if (drivePath is not null)
|
||||
{
|
||||
this[FlagStrings.Drive] = true;
|
||||
(_inputs[FlagStrings.Drive] as StringInput)?.SetValue(drivePath);
|
||||
}
|
||||
|
||||
if (driveSpeed != null && driveSpeed > 0)
|
||||
if (driveSpeed is not null && driveSpeed > 0)
|
||||
{
|
||||
this[FlagStrings.Speed] = true;
|
||||
(_inputs[FlagStrings.Speed] as Int32Input)?.SetValue(driveSpeed);
|
||||
@@ -318,8 +318,10 @@ namespace MPF.ExecutionContexts.Redumper
|
||||
this[FlagStrings.Verbose] = true;
|
||||
(_inputs[FlagStrings.Verbose] as FlagInput)?.SetValue(true);
|
||||
}
|
||||
|
||||
if (GetBooleanSetting(options, SettingConstants.EnableSkeleton, SettingConstants.EnableSkeletonDefault))
|
||||
{
|
||||
#pragma warning disable IDE0010
|
||||
switch (RedumpSystem)
|
||||
{
|
||||
// Systems known to have significant data outside the ISO9660 filesystem
|
||||
@@ -341,11 +343,12 @@ namespace MPF.ExecutionContexts.Redumper
|
||||
{
|
||||
case SabreTools.RedumpLib.Data.MediaType.CDROM:
|
||||
case SabreTools.RedumpLib.Data.MediaType.DVD:
|
||||
{
|
||||
this[FlagStrings.Skeleton] = true;
|
||||
(_inputs[FlagStrings.Skeleton] as FlagInput)?.SetValue(true);
|
||||
}
|
||||
break;
|
||||
{
|
||||
this[FlagStrings.Skeleton] = true;
|
||||
(_inputs[FlagStrings.Skeleton] as FlagInput)?.SetValue(true);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// If the type is unknown, also enable
|
||||
case null:
|
||||
@@ -356,8 +359,10 @@ namespace MPF.ExecutionContexts.Redumper
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
string? readMethod = GetStringSetting(options, SettingConstants.ReadMethod, SettingConstants.ReadMethodDefault);
|
||||
@@ -473,7 +478,7 @@ namespace MPF.ExecutionContexts.Redumper
|
||||
case CommandStrings.DebugFlip:
|
||||
case CommandStrings.DriveTest:
|
||||
// Only allow one mode per command
|
||||
if (BaseCommand != null)
|
||||
if (BaseCommand is not null)
|
||||
continue;
|
||||
|
||||
BaseCommand = part;
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace MPF.Frontend.Test
|
||||
string? actual = lang.LongName();
|
||||
Assert.Equal(expected, actual);
|
||||
|
||||
if (lang != null)
|
||||
if (lang is not null)
|
||||
{
|
||||
actual = EnumExtensions.GetLongName(lang);
|
||||
Assert.Equal(expected, actual);
|
||||
@@ -56,7 +56,7 @@ namespace MPF.Frontend.Test
|
||||
string? actual = prog.LongName();
|
||||
Assert.Equal(expected, actual);
|
||||
|
||||
if (prog != null)
|
||||
if (prog is not null)
|
||||
{
|
||||
actual = EnumExtensions.GetLongName(prog);
|
||||
Assert.Equal(expected, actual);
|
||||
@@ -73,7 +73,7 @@ namespace MPF.Frontend.Test
|
||||
string? actual = comp.LongName();
|
||||
Assert.Equal(expected, actual);
|
||||
|
||||
if (comp != null)
|
||||
if (comp is not null)
|
||||
{
|
||||
actual = EnumExtensions.GetLongName(comp);
|
||||
Assert.Equal(expected, actual);
|
||||
@@ -90,7 +90,7 @@ namespace MPF.Frontend.Test
|
||||
string? actual = method.LongName();
|
||||
Assert.Equal(expected, actual);
|
||||
|
||||
if (method != null)
|
||||
if (method is not null)
|
||||
{
|
||||
actual = EnumExtensions.GetLongName(method);
|
||||
Assert.Equal(expected, actual);
|
||||
@@ -109,7 +109,7 @@ namespace MPF.Frontend.Test
|
||||
string? actual = order.LongName();
|
||||
Assert.Equal(expected, actual);
|
||||
|
||||
if (order != null)
|
||||
if (order is not null)
|
||||
{
|
||||
actual = EnumExtensions.GetLongName(order);
|
||||
Assert.Equal(expected, actual);
|
||||
@@ -131,7 +131,7 @@ namespace MPF.Frontend.Test
|
||||
string? actual = type.LongName();
|
||||
Assert.Equal(expected, actual);
|
||||
|
||||
if (type != null)
|
||||
if (type is not null)
|
||||
{
|
||||
actual = EnumExtensions.GetLongName(type);
|
||||
Assert.Equal(expected, actual);
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace MPF.Frontend.ComboBoxItems
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Element<TEnum>? other)
|
||||
{
|
||||
if (other == null)
|
||||
if (other is null)
|
||||
return false;
|
||||
|
||||
return Name == other.Name;
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
/// <summary>
|
||||
/// Display name for the combo box element
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
public string Name { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace MPF.Frontend.ComboBoxItems
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(RedumpSystemComboBoxItem? other)
|
||||
{
|
||||
if (other == null)
|
||||
if (other is null)
|
||||
return false;
|
||||
|
||||
return Value == other.Value;
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace MPF.Frontend
|
||||
|
||||
// Create and validate the drive info object
|
||||
var driveInfo = new DriveInfo(devicePath);
|
||||
if (driveInfo == null || driveInfo == default)
|
||||
if (driveInfo is null || driveInfo == default)
|
||||
return null;
|
||||
|
||||
// Fill in the rest of the data
|
||||
@@ -110,7 +110,7 @@ namespace MPF.Frontend
|
||||
private void PopulateFromDriveInfo(DriveInfo? driveInfo)
|
||||
{
|
||||
// If we have an invalid DriveInfo, just return
|
||||
if (driveInfo == null || driveInfo == default)
|
||||
if (driveInfo is null || driveInfo == default)
|
||||
return;
|
||||
|
||||
// Populate the data fields
|
||||
@@ -142,8 +142,8 @@ namespace MPF.Frontend
|
||||
var drives = GetDriveList(ignoreFixedDrives);
|
||||
drives.Sort((d1, d2) =>
|
||||
{
|
||||
string d1Name = d1?.Name == null ? "\0" : d1.Name;
|
||||
string d2Name = d2?.Name == null ? "\0" : d2.Name;
|
||||
string d1Name = d1?.Name is null ? "\0" : d1.Name;
|
||||
string d2Name = d2?.Name is null ? "\0" : d2.Name;
|
||||
return d1Name.CompareTo(d2Name);
|
||||
});
|
||||
return [.. drives];
|
||||
@@ -156,6 +156,7 @@ namespace MPF.Frontend
|
||||
/// <returns>The detected media type, if possible</returns>
|
||||
public MediaType? GetMediaType(RedumpSystem? system)
|
||||
{
|
||||
#pragma warning disable IDE0010
|
||||
// Take care of the non-optical stuff first
|
||||
switch (InternalDriveType)
|
||||
{
|
||||
@@ -215,6 +216,7 @@ namespace MPF.Frontend
|
||||
case RedumpSystem.SonyPlayStationPortable:
|
||||
return MediaType.UMD;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
|
||||
// Handle optical media by size and filesystem
|
||||
if (TotalSize >= 0 && TotalSize <= 800_000_000 && (DriveFormat == "CDFS" || DriveFormat == "UDF"))
|
||||
@@ -286,12 +288,12 @@ namespace MPF.Frontend
|
||||
{
|
||||
CimKeyedCollection<CimProperty> properties = instance.CimInstanceProperties;
|
||||
uint? mediaType = properties["MediaType"]?.Value as uint?;
|
||||
if (mediaType != null && ((mediaType > 0 && mediaType < 11) || (mediaType > 12 && mediaType < 22)))
|
||||
if (mediaType is not null && ((mediaType > 0 && mediaType < 11) || (mediaType > 12 && mediaType < 22)))
|
||||
{
|
||||
char devId = (properties["Caption"].Value as string ?? string.Empty)[0];
|
||||
Array.ForEach(drives, d =>
|
||||
{
|
||||
if (d?.Name != null && d.Name[0] == devId)
|
||||
if (d?.Name is not null && d.Name[0] == devId)
|
||||
d.InternalDriveType = Frontend.InternalDriveType.Floppy;
|
||||
});
|
||||
}
|
||||
@@ -313,6 +315,7 @@ namespace MPF.Frontend
|
||||
/// <returns>InternalDriveType, if possible, null on error</returns>
|
||||
internal static InternalDriveType? ToInternalDriveType(DriveType driveType)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return driveType switch
|
||||
{
|
||||
DriveType.CDRom => (InternalDriveType?)Frontend.InternalDriveType.Optical,
|
||||
@@ -320,6 +323,7 @@ namespace MPF.Frontend
|
||||
DriveType.Removable => (InternalDriveType?)Frontend.InternalDriveType.Removable,
|
||||
_ => null,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -133,23 +133,25 @@ namespace MPF.Frontend
|
||||
{
|
||||
// If a complete dump exists from a different program
|
||||
InternalProgram? programFound = null;
|
||||
if (programFound == null && _internalProgram != InternalProgram.Redumper)
|
||||
if (programFound is null && _internalProgram != InternalProgram.Redumper)
|
||||
{
|
||||
var processor = new Processors.Redumper(_system);
|
||||
var processor = new Redumper(_system);
|
||||
var missingFiles = processor.FoundAllFiles(mediaType, outputDirectory, outputFilename);
|
||||
if (missingFiles.Count == 0)
|
||||
programFound = InternalProgram.Redumper;
|
||||
}
|
||||
if (programFound == null && _internalProgram != InternalProgram.DiscImageCreator)
|
||||
|
||||
if (programFound is null && _internalProgram != InternalProgram.DiscImageCreator)
|
||||
{
|
||||
var processor = new Processors.DiscImageCreator(_system);
|
||||
var processor = new DiscImageCreator(_system);
|
||||
var missingFiles = processor.FoundAllFiles(mediaType, outputDirectory, outputFilename);
|
||||
if (missingFiles.Count == 0)
|
||||
programFound = InternalProgram.DiscImageCreator;
|
||||
}
|
||||
if (programFound == null && _internalProgram != InternalProgram.Aaru)
|
||||
|
||||
if (programFound is null && _internalProgram != InternalProgram.Aaru)
|
||||
{
|
||||
var processor = new Processors.Aaru(_system);
|
||||
var processor = new Aaru(_system);
|
||||
var missingFiles = processor.FoundAllFiles(mediaType, outputDirectory, outputFilename);
|
||||
if (missingFiles.Count == 0)
|
||||
programFound = InternalProgram.Aaru;
|
||||
@@ -165,21 +167,23 @@ namespace MPF.Frontend
|
||||
{
|
||||
// If a complete dump exists from a different program
|
||||
InternalProgram? programFound = null;
|
||||
if (programFound == null && _internalProgram != InternalProgram.Redumper)
|
||||
if (programFound is null && _internalProgram != InternalProgram.Redumper)
|
||||
{
|
||||
var processor = new Processors.Redumper(_system);
|
||||
var processor = new Redumper(_system);
|
||||
if (processor.FoundAnyFiles(mediaType, outputDirectory, outputFilename))
|
||||
programFound = InternalProgram.Redumper;
|
||||
}
|
||||
if (programFound == null && _internalProgram != InternalProgram.DiscImageCreator)
|
||||
|
||||
if (programFound is null && _internalProgram != InternalProgram.DiscImageCreator)
|
||||
{
|
||||
var processor = new Processors.DiscImageCreator(_system);
|
||||
var processor = new DiscImageCreator(_system);
|
||||
if (processor.FoundAnyFiles(mediaType, outputDirectory, outputFilename))
|
||||
programFound = InternalProgram.DiscImageCreator;
|
||||
}
|
||||
if (programFound == null && _internalProgram != InternalProgram.Aaru)
|
||||
|
||||
if (programFound is null && _internalProgram != InternalProgram.Aaru)
|
||||
{
|
||||
var processor = new Processors.Aaru(_system);
|
||||
var processor = new Aaru(_system);
|
||||
if (processor.FoundAnyFiles(mediaType, outputDirectory, outputFilename))
|
||||
programFound = InternalProgram.Aaru;
|
||||
}
|
||||
@@ -194,6 +198,7 @@ namespace MPF.Frontend
|
||||
/// <param name="parameters">String representation of the parameters</param>
|
||||
public bool SetExecutionContext(MediaType? mediaType, string? parameters)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
_executionContext = _internalProgram switch
|
||||
{
|
||||
InternalProgram.Aaru => new ExecutionContexts.Aaru.ExecutionContext(parameters) { ExecutablePath = _options.AaruPath },
|
||||
@@ -204,9 +209,10 @@ namespace MPF.Frontend
|
||||
InternalProgram.NONE => null,
|
||||
_ => null,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
|
||||
// Set system, type, and drive
|
||||
if (_executionContext != null)
|
||||
if (_executionContext is not null)
|
||||
{
|
||||
_executionContext.RedumpSystem = _system;
|
||||
_executionContext.MediaType = mediaType;
|
||||
@@ -216,7 +222,7 @@ namespace MPF.Frontend
|
||||
_drive ??= Drive.Create(InternalDriveType.Optical, _executionContext.InputPath!);
|
||||
}
|
||||
|
||||
return _executionContext != null;
|
||||
return _executionContext is not null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -226,7 +232,7 @@ namespace MPF.Frontend
|
||||
{
|
||||
_processor = _internalProgram switch
|
||||
{
|
||||
InternalProgram.Aaru => new Processors.Aaru(_system),
|
||||
InternalProgram.Aaru => new Aaru(_system),
|
||||
InternalProgram.CleanRip => new CleanRip(_system),
|
||||
InternalProgram.DiscImageCreator => new DiscImageCreator(_system),
|
||||
InternalProgram.PS3CFW => new PS3CFW(_system),
|
||||
@@ -239,7 +245,7 @@ namespace MPF.Frontend
|
||||
_ => null,
|
||||
};
|
||||
|
||||
return _processor != null;
|
||||
return _processor is not null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -251,12 +257,13 @@ namespace MPF.Frontend
|
||||
public string? GetFullParameters(MediaType? mediaType, int? driveSpeed)
|
||||
{
|
||||
// Populate with the correct params for inputs (if we're not on the default option)
|
||||
if (_system != null && mediaType != MediaType.NONE)
|
||||
if (_system is not null && mediaType != MediaType.NONE)
|
||||
{
|
||||
// If drive letter is invalid, skip this
|
||||
if (_drive == null)
|
||||
if (_drive is null)
|
||||
return null;
|
||||
|
||||
#pragma warning disable IDE0072
|
||||
// Set the proper parameters
|
||||
_executionContext = _internalProgram switch
|
||||
{
|
||||
@@ -268,6 +275,7 @@ namespace MPF.Frontend
|
||||
InternalProgram.NONE => null,
|
||||
_ => null,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
|
||||
// Generate and return the param string
|
||||
return _executionContext?.GenerateParameters();
|
||||
@@ -290,6 +298,7 @@ namespace MPF.Frontend
|
||||
/// <returns>True if the media has variable dumping speeds, false otherwise</returns>
|
||||
public static bool DoesSupportDriveSpeed(MediaType? mediaType)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return mediaType switch
|
||||
{
|
||||
MediaType.CDROM
|
||||
@@ -302,12 +311,13 @@ namespace MPF.Frontend
|
||||
or MediaType.NintendoWiiUOpticalDisc => true,
|
||||
_ => false,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="BaseProcessor.FoundAllFiles(MediaType?, string?, string)"/>
|
||||
public bool FoundAllFiles(MediaType? mediaType, string? outputDirectory, string outputFilename)
|
||||
{
|
||||
if (_processor == null)
|
||||
if (_processor is null)
|
||||
return false;
|
||||
|
||||
return _processor.FoundAllFiles(mediaType, outputDirectory, outputFilename).Count == 0;
|
||||
@@ -316,7 +326,7 @@ namespace MPF.Frontend
|
||||
/// <inheritdoc cref="BaseProcessor.FoundAnyFiles(MediaType?, string?, string)"/>
|
||||
public bool FoundAnyFiles(MediaType? mediaType, string? outputDirectory, string outputFilename)
|
||||
{
|
||||
if (_processor == null)
|
||||
if (_processor is null)
|
||||
return false;
|
||||
|
||||
return _processor.FoundAnyFiles(mediaType, outputDirectory, outputFilename);
|
||||
@@ -325,7 +335,7 @@ namespace MPF.Frontend
|
||||
/// <inheritdoc cref="BaseExecutionContext.GetDefaultExtension(MediaType?)"/>
|
||||
public string? GetDefaultExtension(MediaType? mediaType)
|
||||
{
|
||||
if (_executionContext == null)
|
||||
if (_executionContext is null)
|
||||
return null;
|
||||
|
||||
return _executionContext.GetDefaultExtension(mediaType);
|
||||
@@ -334,7 +344,7 @@ namespace MPF.Frontend
|
||||
/// <inheritdoc cref="BaseExecutionContext.GetMediaType()"/>
|
||||
public MediaType? GetMediaType()
|
||||
{
|
||||
if (_executionContext == null)
|
||||
if (_executionContext is null)
|
||||
return null;
|
||||
|
||||
return _executionContext.GetMediaType();
|
||||
@@ -346,9 +356,10 @@ namespace MPF.Frontend
|
||||
public ResultEventArgs GetSupportStatus(MediaType? mediaType)
|
||||
{
|
||||
// No system chosen, update status
|
||||
if (_system == null)
|
||||
if (_system is null)
|
||||
return ResultEventArgs.Failure("Please select a valid system");
|
||||
|
||||
#pragma warning disable IDE0072
|
||||
// If we're on an unsupported type, update the status accordingly
|
||||
return mediaType switch
|
||||
{
|
||||
@@ -381,12 +392,13 @@ namespace MPF.Frontend
|
||||
// Undumpable but recognized types
|
||||
_ => ResultEventArgs.Failure($"{mediaType.LongName()} media are not supported for dumping"),
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="BaseExecutionContext.IsDumpingCommand()"/>
|
||||
public bool IsDumpingCommand()
|
||||
{
|
||||
if (_executionContext == null)
|
||||
if (_executionContext is null)
|
||||
return false;
|
||||
|
||||
return _executionContext.IsDumpingCommand();
|
||||
@@ -412,11 +424,11 @@ namespace MPF.Frontend
|
||||
public async Task<ResultEventArgs> Run(MediaType? mediaType, IProgress<ResultEventArgs>? progress = null)
|
||||
{
|
||||
// If we don't have parameters
|
||||
if (_executionContext == null)
|
||||
if (_executionContext is null)
|
||||
return ResultEventArgs.Failure("Error! Current configuration is not supported!");
|
||||
|
||||
// Build default console progress indicators if none exist
|
||||
if (progress == null)
|
||||
if (progress is null)
|
||||
{
|
||||
var temp = new Progress<ResultEventArgs>();
|
||||
temp.ProgressChanged += ConsoleLogger.ProgressUpdated;
|
||||
@@ -459,17 +471,18 @@ namespace MPF.Frontend
|
||||
ProcessUserInfoDelegate? processUserInfo = null,
|
||||
SubmissionInfo? seedInfo = null)
|
||||
{
|
||||
if (_processor == null)
|
||||
if (_processor is null)
|
||||
return ResultEventArgs.Failure("Error! Current configuration is not supported!");
|
||||
|
||||
// Build default console progress indicators if none exist
|
||||
if (resultProgress == null)
|
||||
if (resultProgress is null)
|
||||
{
|
||||
var temp = new Progress<ResultEventArgs>();
|
||||
temp.ProgressChanged += ConsoleLogger.ProgressUpdated;
|
||||
resultProgress = temp;
|
||||
}
|
||||
if (protectionProgress == null)
|
||||
|
||||
if (protectionProgress is null)
|
||||
{
|
||||
var temp = new Progress<ProtectionProgress>();
|
||||
temp.ProgressChanged += ConsoleLogger.ProgressUpdated;
|
||||
@@ -495,7 +508,7 @@ namespace MPF.Frontend
|
||||
|
||||
// Determine the media type from the processor
|
||||
MediaType? mediaType = _processor.DetermineMediaType(outputDirectory, outputFilename);
|
||||
if (mediaType == null)
|
||||
if (mediaType is null)
|
||||
return ResultEventArgs.Failure("Could not determine the media type from output files...");
|
||||
|
||||
// Extract the information from the output files
|
||||
@@ -509,13 +522,13 @@ namespace MPF.Frontend
|
||||
_processor,
|
||||
resultProgress,
|
||||
protectionProgress);
|
||||
if (submissionInfo == null)
|
||||
if (submissionInfo is null)
|
||||
return ResultEventArgs.Failure("There was an issue extracting information!");
|
||||
else
|
||||
resultProgress.Report(ResultEventArgs.Success("Extracting information complete!"));
|
||||
|
||||
// Inject seed submission info data, if necessary
|
||||
if (seedInfo != null)
|
||||
if (seedInfo is not null)
|
||||
{
|
||||
resultProgress.Report(ResultEventArgs.Success("Injecting user-supplied information..."));
|
||||
submissionInfo = Builder.InjectSubmissionInformation(submissionInfo, seedInfo);
|
||||
@@ -523,7 +536,7 @@ namespace MPF.Frontend
|
||||
}
|
||||
|
||||
// Get user-modifiable information if configured to
|
||||
if (_options.PromptForDiscInformation && processUserInfo != null)
|
||||
if (_options.PromptForDiscInformation && processUserInfo is not null)
|
||||
{
|
||||
resultProgress.Report(ResultEventArgs.Success("Waiting for additional media information..."));
|
||||
bool? filledInfo = processUserInfo.Invoke(_options, ref submissionInfo);
|
||||
@@ -541,7 +554,7 @@ namespace MPF.Frontend
|
||||
// Format the information for the text output
|
||||
resultProgress.Report(ResultEventArgs.Success("Formatting information..."));
|
||||
var formattedValues = Formatter.FormatOutputData(submissionInfo, _options.EnableRedumpCompatibility, out string? formatResult);
|
||||
if (formattedValues == null)
|
||||
if (formattedValues is null)
|
||||
resultProgress.Report(ResultEventArgs.Failure(formatResult));
|
||||
else
|
||||
resultProgress.Report(ResultEventArgs.Success(formatResult));
|
||||
@@ -558,7 +571,7 @@ namespace MPF.Frontend
|
||||
resultProgress.Report(ResultEventArgs.Failure(txtResult));
|
||||
|
||||
// Write the copy protection output
|
||||
if (submissionInfo?.CopyProtection?.FullProtections != null && submissionInfo.CopyProtection.FullProtections.Count > 0)
|
||||
if (submissionInfo?.CopyProtection?.FullProtections is not null && submissionInfo.CopyProtection.FullProtections.Count > 0)
|
||||
{
|
||||
if (_options.ScanForProtection)
|
||||
{
|
||||
@@ -635,7 +648,7 @@ namespace MPF.Frontend
|
||||
internal bool ParametersValid(MediaType? mediaType)
|
||||
{
|
||||
// Missing drive means it can never be valid
|
||||
if (_drive == null)
|
||||
if (_drive is null)
|
||||
return false;
|
||||
|
||||
bool parametersValid = _executionContext?.IsValid() ?? false;
|
||||
@@ -655,14 +668,14 @@ namespace MPF.Frontend
|
||||
private ResultEventArgs IsValidForDump(MediaType? mediaType)
|
||||
{
|
||||
// Validate that everything is good
|
||||
if (_executionContext == null || !ParametersValid(mediaType))
|
||||
if (_executionContext is null || !ParametersValid(mediaType))
|
||||
return ResultEventArgs.Failure("Error! Current configuration is not supported!");
|
||||
|
||||
// Fix the output paths, just in case
|
||||
OutputPath = FrontendTool.NormalizeOutputPaths(OutputPath, false);
|
||||
|
||||
// Validate that the output path isn't on the dumping drive
|
||||
if (_drive?.Name != null && OutputPath.StartsWith(_drive.Name))
|
||||
if (_drive?.Name is not null && OutputPath.StartsWith(_drive.Name))
|
||||
return ResultEventArgs.Failure("Error! Cannot output to same drive that is being dumped!");
|
||||
|
||||
// Validate that the required program exists
|
||||
@@ -671,7 +684,7 @@ namespace MPF.Frontend
|
||||
|
||||
// Validate that the dumping drive doesn't contain the executable
|
||||
string fullExecutablePath = Path.GetFullPath(_executionContext.ExecutablePath!);
|
||||
if (_drive?.Name != null && fullExecutablePath.StartsWith(_drive.Name))
|
||||
if (_drive?.Name is not null && fullExecutablePath.StartsWith(_drive.Name))
|
||||
return ResultEventArgs.Failure("Error! Cannot dump same drive that executable resides on!");
|
||||
|
||||
// Validate that the current configuration is supported
|
||||
@@ -692,7 +705,7 @@ namespace MPF.Frontend
|
||||
private static bool WriteOutputData(string? outputDirectory, string? filenameSuffix, string? lines, out string status)
|
||||
{
|
||||
// Check to see if the inputs are valid
|
||||
if (lines == null)
|
||||
if (lines is null)
|
||||
{
|
||||
status = "No formatted data found to write!";
|
||||
return false;
|
||||
@@ -737,7 +750,7 @@ namespace MPF.Frontend
|
||||
private static bool WriteOutputData(string? outputDirectory, string? filenameSuffix, SubmissionInfo? info, bool includedArtifacts)
|
||||
{
|
||||
// Check to see if the input is valid
|
||||
if (info == null)
|
||||
if (info is null)
|
||||
return false;
|
||||
|
||||
try
|
||||
@@ -797,7 +810,7 @@ namespace MPF.Frontend
|
||||
private static bool WriteProtectionData(string? outputDirectory, string? filenameSuffix, SubmissionInfo? info, bool hideDriveLetters)
|
||||
{
|
||||
// Check to see if the inputs are valid
|
||||
if (info?.CopyProtection?.FullProtections == null || info.CopyProtection.FullProtections.Count == 0)
|
||||
if (info?.CopyProtection?.FullProtections is null || info.CopyProtection.FullProtections.Count == 0)
|
||||
return true;
|
||||
|
||||
// Now write out to a generic file
|
||||
@@ -830,7 +843,7 @@ namespace MPF.Frontend
|
||||
|
||||
List<string>? scanResult = info.CopyProtection.FullProtections[key];
|
||||
|
||||
if (scanResult == null)
|
||||
if (scanResult is null)
|
||||
sw.WriteLine($"{scanPath}: None");
|
||||
else
|
||||
sw.WriteLine($"{scanPath}: {string.Join(", ", [.. scanResult])}");
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace MPF.Frontend
|
||||
#endif
|
||||
}
|
||||
|
||||
if (method != null)
|
||||
if (method is not null)
|
||||
return method.Invoke(null, [value]) as string ?? string.Empty;
|
||||
else
|
||||
return string.Empty;
|
||||
@@ -540,11 +540,13 @@ namespace MPF.Frontend
|
||||
/// </summary>
|
||||
public static bool SupportsAntiModchipScans(this RedumpSystem? system)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return system switch
|
||||
{
|
||||
RedumpSystem.SonyPlayStation => true,
|
||||
_ => false,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -552,6 +554,7 @@ namespace MPF.Frontend
|
||||
/// </summary>
|
||||
public static bool SupportsCopyProtectionScans(this RedumpSystem? system)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return system switch
|
||||
{
|
||||
RedumpSystem.AppleMacintosh => true,
|
||||
@@ -564,6 +567,7 @@ namespace MPF.Frontend
|
||||
RedumpSystem.SonyElectronicBook => true,
|
||||
_ => false,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace MPF.Frontend
|
||||
/// <returns>Read-only list of drive speeds</returns>
|
||||
public static List<int> GetSpeedsForMediaType(MediaType? type)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return type switch
|
||||
{
|
||||
MediaType.CDROM
|
||||
@@ -54,6 +55,7 @@ namespace MPF.Frontend
|
||||
// Default to CD speed range
|
||||
_ => CD,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,14 @@ namespace MPF.Frontend
|
||||
{
|
||||
get
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
string executableName = Environment.OSVersion.Platform switch
|
||||
{
|
||||
PlatformID.Unix => "aaru",
|
||||
PlatformID.MacOSX => "aaru",
|
||||
_ => "aaru.exe"
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
|
||||
#if NET20 || NET35
|
||||
return Path.Combine("Programs", Path.Combine("Aaru", executableName));
|
||||
@@ -45,12 +47,14 @@ namespace MPF.Frontend
|
||||
{
|
||||
get
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
string executableName = Environment.OSVersion.Platform switch
|
||||
{
|
||||
PlatformID.Unix => "DiscImageCreator.out",
|
||||
PlatformID.MacOSX => "DiscImageCreator",
|
||||
_ => "DiscImageCreator.exe"
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
|
||||
#if NET20 || NET35
|
||||
return Path.Combine("Programs", Path.Combine("Creator", executableName));
|
||||
@@ -67,12 +71,14 @@ namespace MPF.Frontend
|
||||
{
|
||||
get
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
string executableName = Environment.OSVersion.Platform switch
|
||||
{
|
||||
PlatformID.Unix => "redumper",
|
||||
PlatformID.MacOSX => "redumper",
|
||||
_ => "redumper.exe"
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
|
||||
#if NET20 || NET35
|
||||
return Path.Combine("Programs", Path.Combine("Redumper", executableName));
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace MPF.Frontend
|
||||
// Capture the current synchronization context.
|
||||
// If there is no current context, we use a default instance targeting the ThreadPool.
|
||||
_synchronizationContext = SynchronizationContext.Current ?? ProgressStatics.DefaultContext;
|
||||
Debug.Assert(_synchronizationContext != null);
|
||||
Debug.Assert(_synchronizationContext is not null);
|
||||
_invokeHandlers = new SendOrPostCallback(InvokeHandlers);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace MPF.Frontend
|
||||
// an event handler is removed between now and then.
|
||||
Action<T>? handler = _handler;
|
||||
EventHandler<T>? changedEvent = ProgressChanged;
|
||||
if (handler != null || changedEvent != null)
|
||||
if (handler is not null || changedEvent is not null)
|
||||
{
|
||||
// Post the processing to the sync context.
|
||||
// (If T is a value type, it will get boxed here.)
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace MPF.Frontend.Tools
|
||||
/// </summary>
|
||||
public static int GetDefaultSpeedForMediaType(MediaType? mediaType, Options options)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return mediaType switch
|
||||
{
|
||||
// CD dump speed
|
||||
@@ -37,6 +38,7 @@ namespace MPF.Frontend.Tools
|
||||
// Default
|
||||
_ => options.PreferredDumpSpeedCD,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -117,7 +119,7 @@ namespace MPF.Frontend.Tools
|
||||
public static string? NormalizeDiscTitle(string? title, Language?[]? languages)
|
||||
{
|
||||
// If we have no set languages, then assume English
|
||||
if (languages == null || languages.Length == 0)
|
||||
if (languages is null || languages.Length == 0)
|
||||
languages = [Language.English];
|
||||
|
||||
// Loop through all of the given languages
|
||||
@@ -591,7 +593,7 @@ namespace MPF.Frontend.Tools
|
||||
{
|
||||
// Get current assembly version
|
||||
var assemblyVersion = Assembly.GetEntryAssembly()?.GetName()?.Version;
|
||||
if (assemblyVersion == null)
|
||||
if (assemblyVersion is null)
|
||||
{
|
||||
different = false;
|
||||
message = "Assembly version could not be determined";
|
||||
@@ -603,7 +605,7 @@ namespace MPF.Frontend.Tools
|
||||
|
||||
// Get the latest tag from GitHub
|
||||
_ = GetRemoteVersionAndUrl(out string? tag, out url);
|
||||
different = version != tag && tag != null;
|
||||
different = version != tag && tag is not null;
|
||||
|
||||
message = $"Local version: {version}"
|
||||
+ $"{Environment.NewLine}Remote version: {tag}"
|
||||
@@ -627,7 +629,7 @@ namespace MPF.Frontend.Tools
|
||||
try
|
||||
{
|
||||
var assembly = Assembly.GetEntryAssembly();
|
||||
if (assembly == null)
|
||||
if (assembly is null)
|
||||
return null;
|
||||
|
||||
var assemblyVersion = Attribute.GetCustomAttribute(assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;
|
||||
@@ -660,11 +662,11 @@ namespace MPF.Frontend.Tools
|
||||
message.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0");
|
||||
var latestReleaseJsonString = hc.SendAsync(message)?.ConfigureAwait(false).GetAwaiter().GetResult()
|
||||
.Content?.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
if (latestReleaseJsonString == null)
|
||||
if (latestReleaseJsonString is null)
|
||||
return false;
|
||||
|
||||
var latestReleaseJson = Newtonsoft.Json.Linq.JObject.Parse(latestReleaseJsonString);
|
||||
if (latestReleaseJson == null)
|
||||
if (latestReleaseJson is null)
|
||||
return false;
|
||||
|
||||
tag = latestReleaseJson["tag_name"]?.ToString();
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace MPF.Frontend.Tools
|
||||
try
|
||||
{
|
||||
// Fail on a missing disc key
|
||||
if (discKey == null)
|
||||
if (discKey is null)
|
||||
return false;
|
||||
|
||||
// Output IRD file path
|
||||
@@ -79,9 +79,9 @@ namespace MPF.Frontend.Tools
|
||||
new LibIRD.ReIRD(isoPath, discKey, layerbreak, uid));
|
||||
|
||||
// Set optional fields if valid
|
||||
if (pic != null)
|
||||
if (pic is not null)
|
||||
ird.PIC = pic;
|
||||
if (discID != null && ird.DiscID[15] != 0x00)
|
||||
if (discID is not null && ird.DiscID[15] != 0x00)
|
||||
ird.DiscID = discID;
|
||||
|
||||
// Write IRD to file
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace MPF.Frontend.Tools
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_configPath != null)
|
||||
if (_configPath is not null)
|
||||
return _configPath;
|
||||
|
||||
_configPath = GetConfigurationPath();
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace MPF.Frontend.Tools
|
||||
|
||||
// Fix the Y2K timestamp issue, if required
|
||||
if (fixTwoDigitYear)
|
||||
year = year >= 1900 && year < 1920 ? 2000 + year % 100 : year;
|
||||
year = year >= 1900 && year < 1920 ? 2000 + (year % 100) : year;
|
||||
|
||||
// Format and return the string
|
||||
var dt = new DateTime(year, month, day);
|
||||
@@ -71,7 +71,7 @@ namespace MPF.Frontend.Tools
|
||||
/// <returns>Byte array of first sector of data, null on error</returns>
|
||||
public static byte[]? GetFirstBytes(Drive? drive, int numBytes)
|
||||
{
|
||||
if (drive == null || drive.Letter == null || drive.Letter == '\0')
|
||||
if (drive is null || drive.Letter is null || drive.Letter == '\0')
|
||||
return null;
|
||||
|
||||
// Must read between 1 and 2048 bytes
|
||||
@@ -549,7 +549,7 @@ namespace MPF.Frontend.Tools
|
||||
var appPkgHeaderDeserializer = new SabreTools.Serialization.Readers.AppPkgHeader();
|
||||
var appPkgHeader = appPkgHeaderDeserializer.Deserialize(fileStream);
|
||||
|
||||
if (appPkgHeader != null)
|
||||
if (appPkgHeader is not null)
|
||||
pkgInfo += $"{appPkgHeader.ContentID}{Environment.NewLine}";
|
||||
}
|
||||
|
||||
@@ -574,7 +574,7 @@ namespace MPF.Frontend.Tools
|
||||
{
|
||||
// Attempt to get the param.json file
|
||||
var json = GetPlayStation5ParamsJsonFromDrive(drive);
|
||||
if (json == null)
|
||||
if (json is null)
|
||||
return null;
|
||||
|
||||
try
|
||||
@@ -597,7 +597,7 @@ namespace MPF.Frontend.Tools
|
||||
{
|
||||
// Attempt to get the param.json file
|
||||
var json = GetPlayStation5ParamsJsonFromDrive(drive);
|
||||
if (json == null)
|
||||
if (json is null)
|
||||
return null;
|
||||
|
||||
try
|
||||
@@ -700,7 +700,7 @@ namespace MPF.Frontend.Tools
|
||||
var appPkgHeaderDeserializer = new SabreTools.Serialization.Readers.AppPkgHeader();
|
||||
var appPkgHeader = appPkgHeaderDeserializer.Deserialize(fileStream);
|
||||
|
||||
if (appPkgHeader != null)
|
||||
if (appPkgHeader is not null)
|
||||
pkgInfo += $"{appPkgHeader.ContentID}{Environment.NewLine}";
|
||||
}
|
||||
|
||||
@@ -782,17 +782,17 @@ namespace MPF.Frontend.Tools
|
||||
try
|
||||
{
|
||||
var catalog = new SabreTools.Serialization.Readers.Catalog().Deserialize(catalogjs);
|
||||
if (catalog == null)
|
||||
if (catalog is null)
|
||||
return null;
|
||||
if (!string.IsNullOrEmpty(catalog.TitleID))
|
||||
return catalog.TitleID;
|
||||
if (catalog.Packages == null)
|
||||
if (catalog.Packages is null)
|
||||
return null;
|
||||
|
||||
List<string> titleIDs = [];
|
||||
foreach (var package in catalog.Packages)
|
||||
{
|
||||
if (package?.TitleID != null)
|
||||
if (package?.TitleID is not null)
|
||||
titleIDs.Add(package.TitleID);
|
||||
}
|
||||
|
||||
@@ -816,11 +816,11 @@ namespace MPF.Frontend.Tools
|
||||
/// <returns>Detected RedumpSystem if detected, null otherwise</returns>
|
||||
public static RedumpSystem? DetectSegaSystem(Drive? drive)
|
||||
{
|
||||
if (drive == null)
|
||||
if (drive is null)
|
||||
return null;
|
||||
|
||||
byte[]? firstSector = GetFirstBytes(drive, 0x10);
|
||||
if (firstSector == null || firstSector.Length < 0x10)
|
||||
if (firstSector is null || firstSector.Length < 0x10)
|
||||
return null;
|
||||
|
||||
string systemType = Encoding.ASCII.GetString(firstSector, 0x00, 0x10);
|
||||
@@ -850,11 +850,11 @@ namespace MPF.Frontend.Tools
|
||||
/// <returns>RedumpSystem.Panasonic3DOInteractiveMultiplayer if detected, null otherwise</returns>
|
||||
public static RedumpSystem? Detect3DOSystem(Drive? drive)
|
||||
{
|
||||
if (drive == null)
|
||||
if (drive is null)
|
||||
return null;
|
||||
|
||||
byte[]? firstSector = GetFirstBytes(drive, 0xC0);
|
||||
if (firstSector == null || firstSector.Length < 0xC0)
|
||||
if (firstSector is null || firstSector.Length < 0xC0)
|
||||
return null;
|
||||
|
||||
string systemType = Encoding.ASCII.GetString(firstSector, 0xB0, 0x10);
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
using BinaryObjectScanner;
|
||||
using SabreTools.IO.Extensions;
|
||||
|
||||
#pragma warning disable SYSLIB1045 // Convert to 'GeneratedRegexAttribute'
|
||||
namespace MPF.Frontend.Tools
|
||||
{
|
||||
public static class ProtectionTool
|
||||
@@ -73,7 +74,7 @@ namespace MPF.Frontend.Tools
|
||||
/// <param name="drive">Drive object representing the current drive</param>
|
||||
/// <param name="options">Options object that determines what to scan</param>
|
||||
/// <param name="progress">Optional progress callback</param>
|
||||
public async static Task<Dictionary<string, List<string>>> RunCombinedProtectionScans(string basePath,
|
||||
public static async Task<Dictionary<string, List<string>>> RunCombinedProtectionScans(string basePath,
|
||||
Drive? drive,
|
||||
Options options,
|
||||
IProgress<ProtectionProgress>? protectionProgress = null)
|
||||
@@ -122,7 +123,7 @@ namespace MPF.Frontend.Tools
|
||||
}
|
||||
|
||||
// Scan the mounted drive path
|
||||
if (drive?.Name != null)
|
||||
if (drive?.Name is not null)
|
||||
{
|
||||
var driveProtections = await RunProtectionScanOnPath(drive.Name, options, protectionProgress);
|
||||
MergeDictionaries(protections, driveProtections);
|
||||
@@ -160,7 +161,7 @@ namespace MPF.Frontend.Tools
|
||||
});
|
||||
|
||||
// If nothing was returned, return
|
||||
if (found == null || found.Count == 0)
|
||||
if (found is null || found.Count == 0)
|
||||
return [];
|
||||
|
||||
// Return the filtered set of protections
|
||||
@@ -196,7 +197,7 @@ namespace MPF.Frontend.Tools
|
||||
});
|
||||
|
||||
// If nothing was returned, return
|
||||
if (found == null || found.Count == 0)
|
||||
if (found is null || found.Count == 0)
|
||||
return [];
|
||||
|
||||
// Return the filtered set of protections
|
||||
@@ -212,11 +213,11 @@ namespace MPF.Frontend.Tools
|
||||
public static string? FormatProtections(Dictionary<string, List<string>>? protections, Drive? drive)
|
||||
{
|
||||
// If the filtered list is empty in some way, return
|
||||
if (protections == null)
|
||||
if (protections is null)
|
||||
return "[EXTERNAL SCAN NEEDED]";
|
||||
else if (protections.Count == 0 && drive?.Name == null)
|
||||
else if (protections.Count == 0 && drive?.Name is null)
|
||||
return "Mounted disc path missing [EXTERNAL SCAN NEEDED]";
|
||||
else if (protections.Count == 0 && drive?.Name != null)
|
||||
else if (protections.Count == 0 && drive?.Name is not null)
|
||||
return "None found [OMIT FROM SUBMISSION]";
|
||||
|
||||
// Sanitize context-sensitive protections
|
||||
@@ -306,7 +307,7 @@ namespace MPF.Frontend.Tools
|
||||
string[] paths = [.. protections.Keys];
|
||||
foreach (var path in paths)
|
||||
{
|
||||
if (!protections.TryGetValue(path, out var values) || values == null || values.Count == 0)
|
||||
if (!protections.TryGetValue(path, out var values) || values is null || values.Count == 0)
|
||||
continue;
|
||||
|
||||
// Always copy the values if they're valid
|
||||
@@ -331,7 +332,7 @@ namespace MPF.Frontend.Tools
|
||||
// Loop through the matching paths
|
||||
foreach (var path in matchingPaths)
|
||||
{
|
||||
if (!filtered.TryGetValue(path, out var values) || values == null || values.Count == 0)
|
||||
if (!filtered.TryGetValue(path, out var values) || values is null || values.Count == 0)
|
||||
continue;
|
||||
|
||||
if (values.Exists(s => !s.Contains("GitHub") &&
|
||||
@@ -368,6 +369,7 @@ namespace MPF.Frontend.Tools
|
||||
foundProtections = foundProtections.FindAll(p => !p.StartsWith("[Exception opening file") && !p.StartsWith("[Access issue when opening file"));
|
||||
foundProtections.Add("Exception occurred while scanning [RESCAN NEEDED]");
|
||||
}
|
||||
|
||||
if (foundProtections.Exists(p => p.StartsWith("[Access issue when opening file")))
|
||||
{
|
||||
foundProtections = foundProtections.FindAll(p => !p.StartsWith("[Exception opening file") && !p.StartsWith("[Access issue when opening file"));
|
||||
@@ -546,8 +548,8 @@ namespace MPF.Frontend.Tools
|
||||
}
|
||||
|
||||
// Next best case for SafeDisc 1: A SafeDisc version range is found from "SECDRV.SYS".
|
||||
else if (foundProtections.Exists(p => p.StartsWith("Macrovision Security Driver")
|
||||
&& Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}-[1-2]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)
|
||||
else if (foundProtections.Exists(p => (p.StartsWith("Macrovision Security Driver")
|
||||
&& Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}-[1-2]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled))
|
||||
|| Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}$")))
|
||||
{
|
||||
foundProtections = foundProtections.FindAll(p => !p.StartsWith("Macrovision Protection File"))
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace MPF.Frontend.Tools
|
||||
|
||||
// Add the volume label to comments, if possible or necessary
|
||||
string? volLabels = FormatVolumeLabels(drive?.VolumeLabel, processor.VolumeLabels);
|
||||
if (volLabels != null)
|
||||
if (volLabels is not null)
|
||||
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.VolumeLabel] = volLabels;
|
||||
|
||||
// Extract info based generically on MediaType
|
||||
@@ -119,7 +119,7 @@ namespace MPF.Frontend.Tools
|
||||
ProcessSystem(info, system, drive, options.AddPlaceholders, processor is DiscImageCreator, basePath);
|
||||
|
||||
// Run anti-modchip check, if necessary
|
||||
if (drive != null && system.SupportsAntiModchipScans() && info.CopyProtection.AntiModchip == YesNo.NULL)
|
||||
if (drive is not null && system.SupportsAntiModchipScans() && info.CopyProtection.AntiModchip == YesNo.NULL)
|
||||
{
|
||||
resultProgress?.Report(ResultEventArgs.Success("Checking for anti-modchip strings... this might take a while!"));
|
||||
info.CopyProtection.AntiModchip = await ProtectionTool.GetPlayStationAntiModchipDetected(drive?.Name) ? YesNo.Yes : YesNo.No;
|
||||
@@ -137,7 +137,7 @@ namespace MPF.Frontend.Tools
|
||||
if (options.ScanForProtection)
|
||||
{
|
||||
// Explicitly note missing/invalid device paths
|
||||
if (drive?.Name == null)
|
||||
if (drive?.Name is null)
|
||||
resultProgress?.Report(ResultEventArgs.Success("No mounted device path found, protection outputs may be incomplete!"));
|
||||
|
||||
protections = await ProtectionTool.RunCombinedProtectionScans(basePath, drive, options, protectionProgress);
|
||||
@@ -177,7 +177,7 @@ namespace MPF.Frontend.Tools
|
||||
/// <param name="options">Options object representing user-defined options</param>
|
||||
/// <param name="info">Existing SubmissionInfo object to fill</param>
|
||||
/// <param name="resultProgress">Optional result progress callback</param>
|
||||
public async static Task<bool> FillFromRedump(Options options,
|
||||
public static async Task<bool> FillFromRedump(Options options,
|
||||
SubmissionInfo info,
|
||||
IProgress<ResultEventArgs>? resultProgress = null)
|
||||
{
|
||||
@@ -194,7 +194,7 @@ namespace MPF.Frontend.Tools
|
||||
if (!string.IsNullOrEmpty(options.RedumpUsername) && !string.IsNullOrEmpty(options.RedumpPassword))
|
||||
{
|
||||
bool? loggedIn = await wc.Login(options.RedumpUsername!, options.RedumpPassword!);
|
||||
if (loggedIn == null)
|
||||
if (loggedIn is null)
|
||||
{
|
||||
resultProgress?.Report(ResultEventArgs.Failure("There was an unknown error connecting to Redump, skipping..."));
|
||||
return false;
|
||||
@@ -266,9 +266,9 @@ namespace MPF.Frontend.Tools
|
||||
}
|
||||
|
||||
var foundIds = await Validator.ValidateSingleTrack(wc, info, sha1);
|
||||
if (foundIds != null && foundIds.Count == 1)
|
||||
if (foundIds is not null && foundIds.Count == 1)
|
||||
resultProgress?.Report(ResultEventArgs.Success($"Single match found for {sha1}"));
|
||||
else if (foundIds != null && foundIds.Count != 1)
|
||||
else if (foundIds is not null && foundIds.Count != 1)
|
||||
resultProgress?.Report(ResultEventArgs.Success($"Multiple matches found for {sha1}"));
|
||||
else
|
||||
resultProgress?.Report(ResultEventArgs.Failure($"No matches found for {sha1}"));
|
||||
@@ -277,7 +277,7 @@ namespace MPF.Frontend.Tools
|
||||
foundIdSets.Add(foundIds?.ToArray() ?? []);
|
||||
|
||||
// Ensure that all tracks are found
|
||||
allFound &= (foundIds != null && foundIds.Count >= 1);
|
||||
allFound &= foundIds is not null && foundIds.Count >= 1;
|
||||
}
|
||||
|
||||
// If all tracks were found, check if there are any fully-matched IDs
|
||||
@@ -288,7 +288,7 @@ namespace MPF.Frontend.Tools
|
||||
foreach (var set in foundIdSets)
|
||||
{
|
||||
// First track is always all IDs
|
||||
if (fullyMatchedIdsSet == null)
|
||||
if (fullyMatchedIdsSet is null)
|
||||
{
|
||||
fullyMatchedIdsSet = [.. set];
|
||||
continue;
|
||||
@@ -306,25 +306,25 @@ namespace MPF.Frontend.Tools
|
||||
{
|
||||
string sha1 = info.CommonDiscInfo.CommentsSpecialFields[SiteCode.UniversalHash];
|
||||
var foundIds = await Validator.ValidateUniversalHash(wc, info);
|
||||
if (foundIds != null && foundIds.Count == 1)
|
||||
if (foundIds is not null && foundIds.Count == 1)
|
||||
resultProgress?.Report(ResultEventArgs.Success($"Single match found for universal hash {sha1}"));
|
||||
else if (foundIds != null && foundIds.Count != 1)
|
||||
else if (foundIds is not null && foundIds.Count != 1)
|
||||
resultProgress?.Report(ResultEventArgs.Success($"Multiple matches found for universal hash {sha1}"));
|
||||
else
|
||||
resultProgress?.Report(ResultEventArgs.Failure($"No matches found for universal hash {sha1}"));
|
||||
|
||||
// Ensure that the hash is found
|
||||
allFound = (foundIds != null && foundIds.Count == 1);
|
||||
allFound = foundIds is not null && foundIds.Count == 1;
|
||||
|
||||
// If we found a match, then the disc is a match
|
||||
if (foundIds != null && foundIds.Count == 1)
|
||||
if (foundIds is not null && foundIds.Count == 1)
|
||||
fullyMatchedIdsSet = [.. foundIds];
|
||||
else
|
||||
fullyMatchedIdsSet = [];
|
||||
}
|
||||
|
||||
// Get a list version of the fully matched IDs
|
||||
List<int> fullyMatchedIdsList = fullyMatchedIdsSet != null ? [.. fullyMatchedIdsSet] : [];
|
||||
List<int> fullyMatchedIdsList = fullyMatchedIdsSet is not null ? [.. fullyMatchedIdsSet] : [];
|
||||
|
||||
// Make sure we only have unique IDs
|
||||
var partiallyMatchedIds = new HashSet<int>();
|
||||
@@ -332,12 +332,12 @@ namespace MPF.Frontend.Tools
|
||||
info.PartiallyMatchedIDs = [.. partiallyMatchedIds];
|
||||
info.PartiallyMatchedIDs.Sort();
|
||||
|
||||
resultProgress?.Report(ResultEventArgs.Success("Match finding complete! " + (fullyMatchedIdsList != null && fullyMatchedIdsList.Count > 0
|
||||
resultProgress?.Report(ResultEventArgs.Success("Match finding complete! " + (fullyMatchedIdsList is not null && fullyMatchedIdsList.Count > 0
|
||||
? "Fully Matched IDs: " + string.Join(",", [.. fullyMatchedIdsList.ConvertAll(i => i.ToString())])
|
||||
: "No matches found")));
|
||||
|
||||
// Exit early if one failed or there are no matched IDs
|
||||
if (!allFound || fullyMatchedIdsList == null || fullyMatchedIdsList.Count == 0)
|
||||
if (!allFound || fullyMatchedIdsList is null || fullyMatchedIdsList.Count == 0)
|
||||
return false;
|
||||
|
||||
// Find the first matched ID where the track count matches, we can grab a bunch of info from it
|
||||
@@ -421,7 +421,7 @@ namespace MPF.Frontend.Tools
|
||||
// Map to the internal program
|
||||
InternalProgram? internalProgram = processor switch
|
||||
{
|
||||
Processors.Aaru => InternalProgram.Aaru,
|
||||
Aaru => InternalProgram.Aaru,
|
||||
CleanRip => InternalProgram.CleanRip,
|
||||
DiscImageCreator => InternalProgram.DiscImageCreator,
|
||||
PS3CFW => InternalProgram.PS3CFW,
|
||||
@@ -443,7 +443,7 @@ namespace MPF.Frontend.Tools
|
||||
private static string? SimplifyVolumeLabel(string? label)
|
||||
{
|
||||
// Ignore empty labels
|
||||
if (label == null || label.Length == 0)
|
||||
if (label is null || label.Length == 0)
|
||||
return null;
|
||||
|
||||
// Take only ASCII alphanumeric characters
|
||||
@@ -460,7 +460,7 @@ namespace MPF.Frontend.Tools
|
||||
|
||||
// Ignore non-ASCII labels
|
||||
string? simpleLabel = labelBuilder.ToString();
|
||||
if (simpleLabel == null || simpleLabel.Length == 0)
|
||||
if (simpleLabel is null || simpleLabel.Length == 0)
|
||||
return null;
|
||||
|
||||
return simpleLabel;
|
||||
@@ -474,23 +474,23 @@ namespace MPF.Frontend.Tools
|
||||
private static string? FormatVolumeLabels(string? driveLabel, Dictionary<string, List<string>>? labels)
|
||||
{
|
||||
// Treat empty label as null
|
||||
if (driveLabel != null && driveLabel.Length == 0)
|
||||
if (driveLabel is not null && driveLabel.Length == 0)
|
||||
driveLabel = null;
|
||||
|
||||
// Treat "path" labels as null -- Indicates a mounted path
|
||||
// This can over-match if a label contains a directory separator somehow
|
||||
if (driveLabel != null && (driveLabel.Contains("/") || driveLabel.Contains("\\")))
|
||||
if (driveLabel is not null && (driveLabel.Contains("/") || driveLabel.Contains("\\")))
|
||||
driveLabel = null;
|
||||
|
||||
// Must have at least one label to format
|
||||
if (driveLabel == null && (labels == null || labels.Count == 0))
|
||||
if (driveLabel is null && (labels is null || labels.Count == 0))
|
||||
return null;
|
||||
|
||||
// If no labels given, use drive label
|
||||
if (labels == null || labels.Count == 0)
|
||||
if (labels is null || labels.Count == 0)
|
||||
{
|
||||
// Ignore common volume labels
|
||||
if (FrontendTool.GetRedumpSystemFromVolumeLabel(driveLabel) != null)
|
||||
if (FrontendTool.GetRedumpSystemFromVolumeLabel(driveLabel) is not null)
|
||||
return null;
|
||||
|
||||
return driveLabel;
|
||||
@@ -499,7 +499,7 @@ namespace MPF.Frontend.Tools
|
||||
// Get the default label to compare against
|
||||
// TODO: Full pairwise comparison of all labels, not just comparing against drive/UDF label.
|
||||
string? defaultLabel = null;
|
||||
if (driveLabel != null && driveLabel.Length != 0)
|
||||
if (driveLabel is not null && driveLabel.Length != 0)
|
||||
{
|
||||
defaultLabel = SimplifyVolumeLabel(driveLabel);
|
||||
}
|
||||
@@ -514,7 +514,7 @@ namespace MPF.Frontend.Tools
|
||||
#endif
|
||||
|
||||
// Remove duplicate/useless volume labels
|
||||
if (defaultLabel != null && defaultLabel.Length != 0)
|
||||
if (defaultLabel is not null && defaultLabel.Length != 0)
|
||||
{
|
||||
List<string> keys = [.. labels.Keys];
|
||||
foreach (var label in keys)
|
||||
@@ -528,7 +528,7 @@ namespace MPF.Frontend.Tools
|
||||
|
||||
// Get upper-case ASCII variant of the label
|
||||
string? tempLabel = SimplifyVolumeLabel(label);
|
||||
if (tempLabel == null)
|
||||
if (tempLabel is null)
|
||||
continue;
|
||||
|
||||
// Remove duplicate volume labels
|
||||
@@ -538,10 +538,10 @@ namespace MPF.Frontend.Tools
|
||||
}
|
||||
|
||||
// If no labels are left, use drive label
|
||||
if (labels == null || labels.Count == 0)
|
||||
if (labels is null || labels.Count == 0)
|
||||
{
|
||||
// Ignore common volume labels
|
||||
if (FrontendTool.GetRedumpSystemFromVolumeLabel(driveLabel) != null)
|
||||
if (FrontendTool.GetRedumpSystemFromVolumeLabel(driveLabel) is not null)
|
||||
return null;
|
||||
|
||||
return driveLabel;
|
||||
@@ -554,10 +554,10 @@ namespace MPF.Frontend.Tools
|
||||
#else
|
||||
string firstLabel = labels.First().Key;
|
||||
#endif
|
||||
if (labels.Count == 1 && (firstLabel == driveLabel || driveLabel == null))
|
||||
if (labels.Count == 1 && (firstLabel == driveLabel || driveLabel is null))
|
||||
{
|
||||
// Ignore common volume labels
|
||||
if (FrontendTool.GetRedumpSystemFromVolumeLabel(firstLabel) != null)
|
||||
if (FrontendTool.GetRedumpSystemFromVolumeLabel(firstLabel) is not null)
|
||||
return null;
|
||||
|
||||
return firstLabel;
|
||||
@@ -567,14 +567,14 @@ namespace MPF.Frontend.Tools
|
||||
List<string> volLabels = [];
|
||||
|
||||
// Begin formatted output with the label from Windows, if it is unique and not a common volume label
|
||||
if (driveLabel != null && !labels.TryGetValue(driveLabel, out List<string>? value) && FrontendTool.GetRedumpSystemFromVolumeLabel(driveLabel) == null)
|
||||
if (driveLabel is not null && !labels.TryGetValue(driveLabel, out List<string>? value) && FrontendTool.GetRedumpSystemFromVolumeLabel(driveLabel) is null)
|
||||
volLabels.Add(driveLabel);
|
||||
|
||||
// Add remaining labels with their corresponding filesystems
|
||||
foreach (var kvp in labels)
|
||||
{
|
||||
// Ignore common volume labels
|
||||
if (FrontendTool.GetRedumpSystemFromVolumeLabel(kvp.Key) == null)
|
||||
if (FrontendTool.GetRedumpSystemFromVolumeLabel(kvp.Key) is null)
|
||||
volLabels.Add($"{kvp.Key} ({string.Join(", ", [.. kvp.Value])})");
|
||||
}
|
||||
|
||||
@@ -593,6 +593,7 @@ namespace MPF.Frontend.Tools
|
||||
/// </summary>
|
||||
private static bool ProcessMediaType(SubmissionInfo info, MediaType? mediaType, bool addPlaceholders)
|
||||
{
|
||||
#pragma warning disable IDE0010
|
||||
switch (mediaType)
|
||||
{
|
||||
case MediaType.CDROM:
|
||||
@@ -736,6 +737,7 @@ namespace MPF.Frontend.Tools
|
||||
info.TracksAndWriteOffsets.ClrMameProData = null;
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -745,6 +747,7 @@ namespace MPF.Frontend.Tools
|
||||
/// </summary>
|
||||
private static bool ProcessSystem(SubmissionInfo info, RedumpSystem? system, Drive? drive, bool addPlaceholders, bool isDiscImageCreator, string basePath)
|
||||
{
|
||||
#pragma warning disable IDE0010
|
||||
// Extract info based specifically on RedumpSystem
|
||||
switch (system)
|
||||
{
|
||||
@@ -984,6 +987,7 @@ namespace MPF.Frontend.Tools
|
||||
info.CopyProtection.Protection ??= addPlaceholders ? RequiredIfExistsValue : string.Empty;
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1006,7 +1010,7 @@ namespace MPF.Frontend.Tools
|
||||
private static bool CommentFieldExists(SubmissionInfo info, SiteCode key, out string? value)
|
||||
{
|
||||
// Ensure the comments fields exist
|
||||
if (info.CommonDiscInfo.CommentsSpecialFields == null)
|
||||
if (info.CommonDiscInfo.CommentsSpecialFields is null)
|
||||
info.CommonDiscInfo.CommentsSpecialFields = [];
|
||||
|
||||
// Check if the field exists
|
||||
@@ -1022,7 +1026,7 @@ namespace MPF.Frontend.Tools
|
||||
/// <summary>
|
||||
/// Set a comment field if it doesn't already have a value
|
||||
/// </summary>
|
||||
private static void SetCommentFieldIfNotExists(SubmissionInfo info, SiteCode key, Drive? drive, System.Func<Drive?, string?> valueFunc)
|
||||
private static void SetCommentFieldIfNotExists(SubmissionInfo info, SiteCode key, Drive? drive, Func<Drive?, string?> valueFunc)
|
||||
{
|
||||
// If the field has a valid value, skip
|
||||
if (CommentFieldExists(info, key, out _))
|
||||
@@ -1030,7 +1034,7 @@ namespace MPF.Frontend.Tools
|
||||
|
||||
// Set the value
|
||||
string? value = valueFunc(drive);
|
||||
if (value != null)
|
||||
if (value is not null)
|
||||
info.CommonDiscInfo.CommentsSpecialFields[key] = value;
|
||||
}
|
||||
|
||||
@@ -1040,7 +1044,7 @@ namespace MPF.Frontend.Tools
|
||||
private static bool ContentFieldExists(SubmissionInfo info, SiteCode key, out string? value)
|
||||
{
|
||||
// Ensure the contents fields exist
|
||||
if (info.CommonDiscInfo.ContentsSpecialFields == null)
|
||||
if (info.CommonDiscInfo.ContentsSpecialFields is null)
|
||||
info.CommonDiscInfo.ContentsSpecialFields = [];
|
||||
|
||||
// Check if the field exists
|
||||
@@ -1064,7 +1068,7 @@ namespace MPF.Frontend.Tools
|
||||
|
||||
// Set the value
|
||||
string? value = valueFunc(drive);
|
||||
if (value != null)
|
||||
if (value is not null)
|
||||
info.CommonDiscInfo.ContentsSpecialFields![key] = value;
|
||||
}
|
||||
|
||||
@@ -1089,7 +1093,7 @@ namespace MPF.Frontend.Tools
|
||||
private static Dictionary<string, List<string>?> ReformatProtectionDictionary(Dictionary<string, List<string>>? oldDict)
|
||||
{
|
||||
// Null or empty protections return empty
|
||||
if (oldDict == null || oldDict.Count == 0)
|
||||
if (oldDict is null || oldDict.Count == 0)
|
||||
return [];
|
||||
|
||||
// Reformat each set into a List
|
||||
|
||||
@@ -354,7 +354,7 @@ namespace MPF.Frontend.ViewModels
|
||||
|
||||
// Select the current default dumping program
|
||||
int currentIndex = InternalPrograms.FindIndex(m => m == internalProgram);
|
||||
CurrentProgram = (currentIndex > -1 ? InternalPrograms[currentIndex].Value : InternalPrograms[0].Value);
|
||||
CurrentProgram = currentIndex > -1 ? InternalPrograms[currentIndex].Value : InternalPrograms[0].Value;
|
||||
|
||||
// Reenable event handlers, if necessary
|
||||
if (cachedCanExecuteSelectionChanged) EnableEventHandlers();
|
||||
@@ -366,7 +366,7 @@ namespace MPF.Frontend.ViewModels
|
||||
|
||||
private bool ShouldEnableCheckDumpButton()
|
||||
{
|
||||
return CurrentSystem != null && !string.IsNullOrEmpty(InputPath);
|
||||
return CurrentSystem is not null && !string.IsNullOrEmpty(InputPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -570,7 +570,7 @@ namespace MPF.Frontend.ViewModels
|
||||
&& string.IsNullOrEmpty(DiscIDString)
|
||||
&& string.IsNullOrEmpty(PICString)
|
||||
&& string.IsNullOrEmpty(PICPath)
|
||||
&& Layerbreak == null;
|
||||
&& Layerbreak is null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -677,7 +677,7 @@ namespace MPF.Frontend.ViewModels
|
||||
LogPathBrowseButtonEnabled = false;
|
||||
|
||||
byte[]? id = ProcessingTool.ParseDiscID(DiscIDString);
|
||||
if (id != null)
|
||||
if (id is not null)
|
||||
{
|
||||
DiscID = id;
|
||||
DiscIDStatus = $"Using provided ID: {DiscIDString}";
|
||||
@@ -716,7 +716,7 @@ namespace MPF.Frontend.ViewModels
|
||||
HexKeyTextBoxEnabled = false;
|
||||
|
||||
byte[]? key = ProcessingTool.ParseKeyFile(KeyPath);
|
||||
if (key != null)
|
||||
if (key is not null)
|
||||
{
|
||||
Key = key;
|
||||
KeyStatus = $"Using key from file: {Path.GetFileName(KeyPath)}";
|
||||
@@ -760,7 +760,7 @@ namespace MPF.Frontend.ViewModels
|
||||
KeyPathBrowseButtonEnabled = false;
|
||||
|
||||
byte[]? key = ProcessingTool.ParseHexKey(HexKey);
|
||||
if (key != null)
|
||||
if (key is not null)
|
||||
{
|
||||
Key = key;
|
||||
KeyStatus = $"Using provided Key: {HexKey}";
|
||||
@@ -800,7 +800,7 @@ namespace MPF.Frontend.ViewModels
|
||||
LayerbreakTextBoxEnabled = false;
|
||||
|
||||
PIC = ProcessingTool.ParsePICFile(PICPath);
|
||||
if (PIC != null)
|
||||
if (PIC is not null)
|
||||
{
|
||||
PICStatus = $"Using PIC from file: {Path.GetFileName(PICPath)}";
|
||||
CreateIRDButtonEnabled = ShouldEnableCreateIRDButton();
|
||||
@@ -843,7 +843,7 @@ namespace MPF.Frontend.ViewModels
|
||||
LayerbreakTextBoxEnabled = false;
|
||||
|
||||
PIC = ProcessingTool.ParsePIC(PICString);
|
||||
if (PIC != null)
|
||||
if (PIC is not null)
|
||||
{
|
||||
PICStatus = "Using provided PIC";
|
||||
CreateIRDButtonEnabled = ShouldEnableCreateIRDButton();
|
||||
@@ -883,7 +883,7 @@ namespace MPF.Frontend.ViewModels
|
||||
PICTextBoxEnabled = false;
|
||||
|
||||
Layerbreak = ProcessingTool.ParseLayerbreak(LayerbreakString);
|
||||
if (Layerbreak != null)
|
||||
if (Layerbreak is not null)
|
||||
{
|
||||
PICStatus = $"Will generate a PIC using a Layerbreak of {Layerbreak}";
|
||||
CreateIRDButtonEnabled = ShouldEnableCreateIRDButton();
|
||||
@@ -1042,16 +1042,16 @@ namespace MPF.Frontend.ViewModels
|
||||
return $"{InputPath!.Trim('"')} is not a valid ISO path.";
|
||||
|
||||
// TODO: Implement pulling key from redump.org
|
||||
if (Key == null)
|
||||
if (Key is null)
|
||||
return "Pulling key from redump.org is currently not implemented.";
|
||||
|
||||
try
|
||||
{
|
||||
// Create Redump-style reproducible IRD
|
||||
LibIRD.ReIRD ird = new(InputPath, Key, Layerbreak);
|
||||
if (PIC != null)
|
||||
if (PIC is not null)
|
||||
ird.PIC = PIC;
|
||||
if (DiscID != null && ird.DiscID[15] != 0x00)
|
||||
if (DiscID is not null && ird.DiscID[15] != 0x00)
|
||||
ird.DiscID = DiscID;
|
||||
ird.Write(outputPath);
|
||||
CreateIRDStatus = "IRD Created Successfully";
|
||||
|
||||
@@ -658,7 +658,7 @@ namespace MPF.Frontend.ViewModels
|
||||
|
||||
// Check for the last selected drive, if possible
|
||||
int index = -1;
|
||||
if (lastSelectedDrive != null)
|
||||
if (lastSelectedDrive is not null)
|
||||
index = Drives.FindIndex(d => d.MarkedActive && (d.Name?[0] ?? '\0') == lastSelectedDrive);
|
||||
|
||||
// Check for active optical drives
|
||||
@@ -674,7 +674,7 @@ namespace MPF.Frontend.ViewModels
|
||||
index = Drives.FindIndex(d => d.MarkedActive);
|
||||
|
||||
// Set the selected index
|
||||
CurrentDrive = (index != -1 ? Drives[index] : Drives[0]);
|
||||
CurrentDrive = index != -1 ? Drives[index] : Drives[0];
|
||||
Status = "Valid drive found!";
|
||||
CopyProtectScanButtonEnabled = true;
|
||||
|
||||
@@ -706,16 +706,16 @@ namespace MPF.Frontend.ViewModels
|
||||
bool cachedCanExecuteSelectionChanged = CanExecuteSelectionChanged;
|
||||
DisableEventHandlers();
|
||||
|
||||
if (CurrentSystem != null)
|
||||
if (CurrentSystem is not null)
|
||||
{
|
||||
var mediaTypeValues = CurrentSystem.MediaTypes();
|
||||
int index = mediaTypeValues.FindIndex(m => m == CurrentMediaType);
|
||||
if (CurrentMediaType != null && index == -1)
|
||||
if (CurrentMediaType is not null && index == -1)
|
||||
VerboseLogLn($"Disc of type '{CurrentMediaType.LongName()}' found, but the current system does not support it!");
|
||||
|
||||
MediaTypes = mediaTypeValues.ConvertAll(m => new Element<MediaType>(m ?? MediaType.NONE));
|
||||
MediaTypeComboBoxEnabled = MediaTypes.Count > 1;
|
||||
CurrentMediaType = (index > -1 ? MediaTypes[index] : MediaTypes[0]);
|
||||
CurrentMediaType = index > -1 ? MediaTypes[index] : MediaTypes[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -738,7 +738,11 @@ namespace MPF.Frontend.ViewModels
|
||||
DisableEventHandlers();
|
||||
|
||||
// Create a static list of supported programs, not everything
|
||||
#if NET5_0_OR_GREATER
|
||||
var ipArr = Enum.GetValues<InternalProgram>();
|
||||
#else
|
||||
var ipArr = (InternalProgram[])Enum.GetValues(typeof(InternalProgram));
|
||||
#endif
|
||||
ipArr = Array.FindAll(ipArr, ip => InternalProgramExists(ip));
|
||||
InternalPrograms = [.. Array.ConvertAll(ipArr, ip => new Element<InternalProgram>(ip))];
|
||||
|
||||
@@ -754,7 +758,7 @@ namespace MPF.Frontend.ViewModels
|
||||
else
|
||||
{
|
||||
int currentIndex = InternalPrograms.FindIndex(m => m == internalProgram);
|
||||
CurrentProgram = (currentIndex > -1 ? InternalPrograms[currentIndex].Value : InternalPrograms[0].Value);
|
||||
CurrentProgram = currentIndex > -1 ? InternalPrograms[currentIndex].Value : InternalPrograms[0].Value;
|
||||
}
|
||||
|
||||
// Reenable event handlers, if necessary
|
||||
@@ -784,7 +788,7 @@ namespace MPF.Frontend.ViewModels
|
||||
public void ChangeMediaType(System.Collections.IList removedItems, System.Collections.IList addedItems)
|
||||
{
|
||||
// Only change the media type if the selection and not the list has changed
|
||||
if ((removedItems == null || removedItems.Count == 1) && (addedItems == null || addedItems.Count == 1))
|
||||
if ((removedItems is null || removedItems.Count == 1) && (addedItems is null || addedItems.Count == 1))
|
||||
SetSupportedDriveSpeed();
|
||||
|
||||
GetOutputNames(false);
|
||||
@@ -810,7 +814,7 @@ namespace MPF.Frontend.ViewModels
|
||||
FrontendTool.CheckForNewVersion(out different, out message, out url);
|
||||
|
||||
SecretLogLn(message);
|
||||
if (url == null)
|
||||
if (url is null)
|
||||
message = "An exception occurred while checking for versions, please try again later. See the log window for more details.";
|
||||
}
|
||||
|
||||
@@ -829,7 +833,7 @@ namespace MPF.Frontend.ViewModels
|
||||
|
||||
CommonDiscInfo = new CommonDiscInfoSection()
|
||||
{
|
||||
System = SabreTools.RedumpLib.Data.RedumpSystem.IBMPCcompatible,
|
||||
System = RedumpSystem.IBMPCcompatible,
|
||||
Media = DiscType.BD128,
|
||||
Title = "Game Title",
|
||||
ForeignTitleNonLatin = "Foreign Game Title",
|
||||
@@ -962,11 +966,11 @@ namespace MPF.Frontend.ViewModels
|
||||
public void ToggleStartStop()
|
||||
{
|
||||
// Dump or stop the dump
|
||||
if (StartStopButtonText as string == StartDumpingValue)
|
||||
if ((StartStopButtonText as string) == StartDumpingValue)
|
||||
{
|
||||
StartDumping();
|
||||
}
|
||||
else if (StartStopButtonText as string == StopDumpingValue)
|
||||
else if ((StartStopButtonText as string) == StopDumpingValue)
|
||||
{
|
||||
VerboseLogLn("Canceling dumping process...");
|
||||
_environment?.CancelDumping();
|
||||
@@ -1009,7 +1013,7 @@ namespace MPF.Frontend.ViewModels
|
||||
StartStopButtonEnabled = false;
|
||||
|
||||
// Safely check the parameters box, just in case
|
||||
if (ParametersCheckBoxEnabled == false)
|
||||
if (!ParametersCheckBoxEnabled)
|
||||
{
|
||||
bool cachedCanExecuteSelectionChanged = CanExecuteSelectionChanged;
|
||||
DisableEventHandlers();
|
||||
@@ -1064,7 +1068,7 @@ namespace MPF.Frontend.ViewModels
|
||||
StartStopButtonEnabled = false;
|
||||
|
||||
// Safely check the parameters box, just in case
|
||||
if (ParametersCheckBoxEnabled == false)
|
||||
if (!ParametersCheckBoxEnabled)
|
||||
{
|
||||
bool cachedCanExecuteSelectionChanged = CanExecuteSelectionChanged;
|
||||
DisableEventHandlers();
|
||||
@@ -1162,7 +1166,7 @@ namespace MPF.Frontend.ViewModels
|
||||
/// <param name="text">Text to write to the log</param>
|
||||
private void VerboseLog(string text)
|
||||
{
|
||||
if (_logger != null && Options.VerboseLogging)
|
||||
if (_logger is not null && Options.VerboseLogging)
|
||||
_logger(LogLevel.VERBOSE, text);
|
||||
}
|
||||
|
||||
@@ -1186,7 +1190,7 @@ namespace MPF.Frontend.ViewModels
|
||||
private void CacheCurrentDiscType()
|
||||
{
|
||||
// If the selected item is invalid, we just skip
|
||||
if (CurrentDrive == null)
|
||||
if (CurrentDrive is null)
|
||||
return;
|
||||
|
||||
// Get reasonable default values based on the current system
|
||||
@@ -1202,7 +1206,7 @@ namespace MPF.Frontend.ViewModels
|
||||
MediaType? detectedMediaType = CurrentDrive.GetMediaType(CurrentSystem);
|
||||
|
||||
// If we got either an error or no media, default to the current System default
|
||||
if (detectedMediaType == null)
|
||||
if (detectedMediaType is null)
|
||||
{
|
||||
VerboseLogLn($"Could not detect media type, defaulting to {defaultMediaType.LongName()}.");
|
||||
CurrentMediaType = defaultMediaType;
|
||||
@@ -1244,7 +1248,7 @@ namespace MPF.Frontend.ViewModels
|
||||
/// </summary>
|
||||
private void DetermineSystemType()
|
||||
{
|
||||
if (Drives == null || Drives.Count == 0 || CurrentDrive == null)
|
||||
if (Drives is null || Drives.Count == 0 || CurrentDrive is null)
|
||||
{
|
||||
VerboseLogLn("Skipping system type detection because no valid drives found!");
|
||||
}
|
||||
@@ -1252,16 +1256,16 @@ namespace MPF.Frontend.ViewModels
|
||||
{
|
||||
VerboseLog($"Trying to detect system for drive {CurrentDrive.Name}.. ");
|
||||
var currentSystem = GetRedumpSystem(CurrentDrive);
|
||||
if (currentSystem != null)
|
||||
if (currentSystem is not null)
|
||||
VerboseLogLn($"detected {currentSystem.LongName()}.");
|
||||
|
||||
// If undetected system on inactive drive, and PC is the default system, check for potential Mac disc
|
||||
if (currentSystem == null && CurrentDrive.MarkedActive == false && Options.DefaultSystem == RedumpSystem.IBMPCcompatible)
|
||||
if (currentSystem is null && !CurrentDrive.MarkedActive && Options.DefaultSystem == RedumpSystem.IBMPCcompatible)
|
||||
{
|
||||
try
|
||||
{
|
||||
// If disc is readable on inactive drive, assume it is a Mac disc
|
||||
if (PhysicalTool.GetFirstBytes(CurrentDrive, 1) != null)
|
||||
if (PhysicalTool.GetFirstBytes(CurrentDrive, 1) is not null)
|
||||
{
|
||||
currentSystem = RedumpSystem.AppleMacintosh;
|
||||
VerboseLogLn($"unable to detect, defaulting to {currentSystem.LongName()}.");
|
||||
@@ -1271,19 +1275,19 @@ namespace MPF.Frontend.ViewModels
|
||||
}
|
||||
|
||||
// Fallback to default system only if drive is active
|
||||
if (currentSystem == null && CurrentDrive.MarkedActive)
|
||||
if (currentSystem is null && CurrentDrive.MarkedActive)
|
||||
{
|
||||
currentSystem = Options.DefaultSystem;
|
||||
VerboseLogLn($"unable to detect, defaulting to {currentSystem.LongName()}.");
|
||||
}
|
||||
|
||||
if (currentSystem != null)
|
||||
if (currentSystem is not null)
|
||||
{
|
||||
int sysIndex = Systems.FindIndex(s => s == currentSystem);
|
||||
CurrentSystem = Systems[sysIndex];
|
||||
}
|
||||
}
|
||||
else if (Options.SkipSystemDetection && Options.DefaultSystem != null)
|
||||
else if (Options.SkipSystemDetection && Options.DefaultSystem is not null)
|
||||
{
|
||||
var currentSystem = Options.DefaultSystem;
|
||||
VerboseLogLn($"System detection disabled, defaulting to {currentSystem.LongName()}.");
|
||||
@@ -1365,7 +1369,7 @@ namespace MPF.Frontend.ViewModels
|
||||
if (ParametersCheckBoxEnabled)
|
||||
{
|
||||
var generated = _environment.GetFullParameters(CurrentMediaType, DriveSpeed);
|
||||
if (generated != null)
|
||||
if (generated is not null)
|
||||
Parameters = generated;
|
||||
}
|
||||
}
|
||||
@@ -1420,7 +1424,7 @@ namespace MPF.Frontend.ViewModels
|
||||
/// <param name="driveChanged">Force an updated name if the drive letter changes</param>
|
||||
public void GetOutputNames(bool driveChanged)
|
||||
{
|
||||
if (Drives == null || Drives.Count == 0 || CurrentDrive == null)
|
||||
if (Drives is null || Drives.Count == 0 || CurrentDrive is null)
|
||||
{
|
||||
VerboseLogLn("Skipping output name building because no valid drives found!");
|
||||
return;
|
||||
@@ -1480,24 +1484,24 @@ namespace MPF.Frontend.ViewModels
|
||||
private static RedumpSystem? GetRedumpSystem(Drive? drive)
|
||||
{
|
||||
// If the drive does not exist, we can't do anything
|
||||
if (drive == null || string.IsNullOrEmpty(drive.Name))
|
||||
if (drive is null || string.IsNullOrEmpty(drive.Name))
|
||||
return null;
|
||||
|
||||
// If we can't read the files in the drive, we can only perform physical checks
|
||||
if (drive.MarkedActive == false || !Directory.Exists(drive.Name))
|
||||
if (!drive.MarkedActive || !Directory.Exists(drive.Name))
|
||||
{
|
||||
try
|
||||
{
|
||||
// Check for Panasonic 3DO - filesystem not readable on Windows
|
||||
RedumpSystem? detected3DOSystem = PhysicalTool.Detect3DOSystem(drive);
|
||||
if (detected3DOSystem != null)
|
||||
if (detected3DOSystem is not null)
|
||||
{
|
||||
return detected3DOSystem;
|
||||
}
|
||||
|
||||
// Sega Saturn / Sega Dreamcast / Sega Mega-CD / Sega-CD
|
||||
RedumpSystem? detectedSegaSystem = PhysicalTool.DetectSegaSystem(drive);
|
||||
if (detectedSegaSystem != null)
|
||||
if (detectedSegaSystem is not null)
|
||||
{
|
||||
return detectedSegaSystem;
|
||||
}
|
||||
@@ -1514,7 +1518,7 @@ namespace MPF.Frontend.ViewModels
|
||||
|
||||
// Check volume labels first
|
||||
RedumpSystem? systemFromLabel = FrontendTool.GetRedumpSystemFromVolumeLabel(drive.VolumeLabel);
|
||||
if (systemFromLabel != null)
|
||||
if (systemFromLabel is not null)
|
||||
return systemFromLabel;
|
||||
|
||||
// Get a list of files for quicker checking
|
||||
@@ -1619,7 +1623,7 @@ namespace MPF.Frontend.ViewModels
|
||||
return RedumpSystem.MicrosoftXboxOne;
|
||||
|
||||
var catalog = new SabreTools.Serialization.Readers.Catalog().Deserialize(catalogjs);
|
||||
if (catalog != null && catalog.Version != null && catalog.Packages != null)
|
||||
if (catalog is not null && catalog.Version is not null && catalog.Packages is not null)
|
||||
{
|
||||
if (!double.TryParse(catalog.Version, out double version))
|
||||
return RedumpSystem.MicrosoftXboxOne;
|
||||
@@ -1654,7 +1658,7 @@ namespace MPF.Frontend.ViewModels
|
||||
{
|
||||
// Sega Saturn / Sega Dreamcast / Sega Mega-CD / Sega-CD
|
||||
RedumpSystem? segaSystem = PhysicalTool.DetectSegaSystem(drive);
|
||||
if (segaSystem != null)
|
||||
if (segaSystem is not null)
|
||||
{
|
||||
return segaSystem;
|
||||
}
|
||||
@@ -1886,7 +1890,7 @@ namespace MPF.Frontend.ViewModels
|
||||
{
|
||||
int driveIndex = Drives.ConvertAll(d => d.Name?[0] ?? '\0')
|
||||
.IndexOf(_environment.ContextInputPath?[0] ?? default);
|
||||
CurrentDrive = (driveIndex != -1 ? Drives[driveIndex] : Drives[0]);
|
||||
CurrentDrive = driveIndex != -1 ? Drives[driveIndex] : Drives[0];
|
||||
}
|
||||
catch { }
|
||||
|
||||
@@ -1901,13 +1905,13 @@ namespace MPF.Frontend.ViewModels
|
||||
|
||||
OutputPath = FrontendTool.NormalizeOutputPaths(_environment.ContextOutputPath, false);
|
||||
|
||||
if (MediaTypes != null)
|
||||
if (MediaTypes is not null)
|
||||
{
|
||||
MediaType? mediaType = _environment.GetMediaType();
|
||||
if (mediaType != null)
|
||||
if (mediaType is not null)
|
||||
{
|
||||
int mediaTypeIndex = MediaTypes.FindIndex(m => m == mediaType);
|
||||
CurrentMediaType = (mediaTypeIndex > -1 ? MediaTypes[mediaTypeIndex] : MediaTypes[0]);
|
||||
CurrentMediaType = mediaTypeIndex > -1 ? MediaTypes[mediaTypeIndex] : MediaTypes[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1924,7 +1928,7 @@ namespace MPF.Frontend.ViewModels
|
||||
_environment ??= DetermineEnvironment();
|
||||
|
||||
// If we don't have a valid drive
|
||||
if (CurrentDrive?.Name == null)
|
||||
if (CurrentDrive?.Name is null)
|
||||
{
|
||||
ErrorLogLn("No valid drive found!");
|
||||
return null;
|
||||
@@ -2002,7 +2006,7 @@ namespace MPF.Frontend.ViewModels
|
||||
private static string? GetFormattedVolumeLabel(Drive? drive)
|
||||
{
|
||||
// If the drive is invalid
|
||||
if (drive == null)
|
||||
if (drive is null)
|
||||
return null;
|
||||
|
||||
// If the drive is marked as inactive
|
||||
@@ -2011,6 +2015,7 @@ namespace MPF.Frontend.ViewModels
|
||||
|
||||
// Use internal serials where appropriate
|
||||
string? volumeLabel = string.IsNullOrEmpty(drive.VolumeLabel) ? null : drive.VolumeLabel!.Trim();
|
||||
#pragma warning disable IDE0010
|
||||
switch (GetRedumpSystem(drive))
|
||||
{
|
||||
case RedumpSystem.SonyPlayStation:
|
||||
@@ -2047,6 +2052,7 @@ namespace MPF.Frontend.ViewModels
|
||||
volumeLabel ??= $"track_{DateTime.Now:yyyyMMdd-HHmm}";
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
|
||||
foreach (char c in Path.GetInvalidFileNameChars())
|
||||
{
|
||||
@@ -2062,11 +2068,11 @@ namespace MPF.Frontend.ViewModels
|
||||
private void SetCurrentDiscType()
|
||||
{
|
||||
// If we don't have any selected media types, we don't care and return
|
||||
if (MediaTypes == null)
|
||||
if (MediaTypes is null)
|
||||
return;
|
||||
|
||||
// If we have a detected media type, use that first
|
||||
if (_detectedMediaType != null)
|
||||
if (_detectedMediaType is not null)
|
||||
{
|
||||
int detectedIndex = MediaTypes.FindIndex(kvp => kvp.Value == _detectedMediaType);
|
||||
if (detectedIndex > -1)
|
||||
@@ -2077,15 +2083,15 @@ namespace MPF.Frontend.ViewModels
|
||||
}
|
||||
|
||||
// If we have an invalid current type, we don't care and return
|
||||
if (CurrentMediaType == null || CurrentMediaType == MediaType.NONE)
|
||||
if (CurrentMediaType is null || CurrentMediaType == MediaType.NONE)
|
||||
return;
|
||||
|
||||
// Now set the selected item, if possible
|
||||
int index = MediaTypes.FindIndex(kvp => kvp.Value == CurrentMediaType);
|
||||
if (CurrentMediaType != null && index == -1)
|
||||
if (CurrentMediaType is not null && index == -1)
|
||||
VerboseLogLn($"Disc of type '{CurrentMediaType.LongName()}' found, but the current system does not support it!");
|
||||
|
||||
CurrentMediaType = (index > -1 ? MediaTypes[index] : MediaTypes[0]);
|
||||
CurrentMediaType = index > -1 ? MediaTypes[index] : MediaTypes[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2111,8 +2117,8 @@ namespace MPF.Frontend.ViewModels
|
||||
private bool ShouldEnableDumpingButton()
|
||||
{
|
||||
return Drives.Count > 0
|
||||
&& CurrentSystem != null
|
||||
&& CurrentMediaType != null
|
||||
&& CurrentSystem is not null
|
||||
&& CurrentMediaType is not null
|
||||
&& ProgramSupportsMedia();
|
||||
}
|
||||
|
||||
@@ -2122,9 +2128,10 @@ namespace MPF.Frontend.ViewModels
|
||||
private bool ProgramSupportsMedia()
|
||||
{
|
||||
// If the media type is not set, return false
|
||||
if (CurrentMediaType == null || CurrentMediaType == MediaType.NONE)
|
||||
if (CurrentMediaType is null || CurrentMediaType == MediaType.NONE)
|
||||
return false;
|
||||
|
||||
#pragma warning disable IDE0072
|
||||
return CurrentProgram switch
|
||||
{
|
||||
// Aaru
|
||||
@@ -2170,6 +2177,7 @@ namespace MPF.Frontend.ViewModels
|
||||
// Default
|
||||
_ => false,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2268,7 +2276,7 @@ namespace MPF.Frontend.ViewModels
|
||||
/// </summary>
|
||||
public void ToggleParameters()
|
||||
{
|
||||
if (ParametersCheckBoxEnabled == false)
|
||||
if (!ParametersCheckBoxEnabled)
|
||||
{
|
||||
OptionsMenuItemEnabled = false;
|
||||
|
||||
@@ -2316,20 +2324,20 @@ namespace MPF.Frontend.ViewModels
|
||||
/// <returns>True if dumping should start, false otherwise</returns>
|
||||
private bool ValidateBeforeDumping()
|
||||
{
|
||||
if (Parameters == null || _environment == null)
|
||||
if (Parameters is null || _environment is null)
|
||||
return false;
|
||||
|
||||
// Validate that we have an output path of any sort
|
||||
if (string.IsNullOrEmpty(_environment.OutputPath))
|
||||
{
|
||||
if (_displayUserMessage != null)
|
||||
if (_displayUserMessage is not null)
|
||||
_ = _displayUserMessage("Missing Path", "No output path was provided so dumping cannot continue.", 1, false);
|
||||
LogLn("Dumping aborted!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate that the user explicitly wants an inactive drive to be considered for dumping
|
||||
if (!_environment.DriveMarkedActive && _displayUserMessage != null)
|
||||
if (!_environment.DriveMarkedActive && _displayUserMessage is not null)
|
||||
{
|
||||
string message = "The currently selected drive does not appear to contain a disc! "
|
||||
+ (!_environment!.DetectedByWindows() ? $"This is normal for {_environment.SystemName} as the discs may not be readable on Windows. " : string.Empty)
|
||||
@@ -2349,7 +2357,7 @@ namespace MPF.Frontend.ViewModels
|
||||
|
||||
// If a complete or partial dump already exists
|
||||
bool foundAllFiles = _environment.FoundAllFiles(CurrentMediaType, outputDirectory, outputFilename);
|
||||
if (foundAllFiles && _displayUserMessage != null)
|
||||
if (foundAllFiles && _displayUserMessage is not null)
|
||||
{
|
||||
bool? mbresult = _displayUserMessage("Overwrite?", "A complete dump already exists! Are you sure you want to overwrite?", 2, true);
|
||||
if (mbresult != true)
|
||||
@@ -2362,7 +2370,7 @@ namespace MPF.Frontend.ViewModels
|
||||
{
|
||||
// If a partial dump exists
|
||||
bool foundAnyFiles = _environment.FoundAnyFiles(CurrentMediaType, outputDirectory, outputFilename);
|
||||
if (foundAnyFiles && _displayUserMessage != null)
|
||||
if (foundAnyFiles && _displayUserMessage is not null)
|
||||
{
|
||||
bool? mbresult = _displayUserMessage("Overwrite?", $"A partial dump already exists! Dumping here may cause issues. Are you sure you want to overwrite?", 2, true);
|
||||
if (mbresult != true)
|
||||
@@ -2375,7 +2383,7 @@ namespace MPF.Frontend.ViewModels
|
||||
{
|
||||
// If a complete dump exists from a different program
|
||||
InternalProgram? completeProgramFound = _environment.CheckForMatchingProgram(CurrentMediaType, outputDirectory, outputFilename);
|
||||
if (completeProgramFound != null && _displayUserMessage != null)
|
||||
if (completeProgramFound is not null && _displayUserMessage is not null)
|
||||
{
|
||||
bool? mbresult = _displayUserMessage("Overwrite?", $"A complete dump from {completeProgramFound} already exists! Dumping here may cause issues. Are you sure you want to overwrite?", 2, true);
|
||||
if (mbresult != true)
|
||||
@@ -2388,7 +2396,7 @@ namespace MPF.Frontend.ViewModels
|
||||
{
|
||||
// If a partial dump exists from a different program
|
||||
InternalProgram? partialProgramFound = _environment.CheckForPartialProgram(CurrentMediaType, outputDirectory, outputFilename);
|
||||
if (partialProgramFound != null && _displayUserMessage != null)
|
||||
if (partialProgramFound is not null && _displayUserMessage is not null)
|
||||
{
|
||||
bool? mbresult = _displayUserMessage("Overwrite?", $"A partial dump from {partialProgramFound} already exists! Dumping here may cause issues. Are you sure you want to overwrite?", 2, true);
|
||||
if (mbresult != true)
|
||||
@@ -2410,7 +2418,7 @@ namespace MPF.Frontend.ViewModels
|
||||
fullPath = Path.GetFullPath(outputDirectory);
|
||||
|
||||
var driveInfo = new DriveInfo(Path.GetPathRoot(fullPath) ?? string.Empty);
|
||||
if (driveInfo.AvailableFreeSpace < Math.Pow(2, 30) && _displayUserMessage != null)
|
||||
if (driveInfo.AvailableFreeSpace < Math.Pow(2, 30) && _displayUserMessage is not null)
|
||||
{
|
||||
bool? mbresult = _displayUserMessage("Low Space", "There is less than 1gb of space left on the target drive. Are you sure you want to continue?", 2, true);
|
||||
if (mbresult != true)
|
||||
@@ -2433,6 +2441,7 @@ namespace MPF.Frontend.ViewModels
|
||||
{
|
||||
try
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return program switch
|
||||
{
|
||||
InternalProgram.Redumper => File.Exists(Options.RedumperPath),
|
||||
@@ -2440,6 +2449,7 @@ namespace MPF.Frontend.ViewModels
|
||||
InternalProgram.DiscImageCreator => File.Exists(Options.DiscImageCreatorPath),
|
||||
_ => false,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -2453,7 +2463,7 @@ namespace MPF.Frontend.ViewModels
|
||||
/// <param name="translationStrings">Dictionary of keys and their translated string</param>
|
||||
public void TranslateStrings(Dictionary<string, string>? translationStrings)
|
||||
{
|
||||
if (translationStrings != null)
|
||||
if (translationStrings is not null)
|
||||
{
|
||||
// Cache current start dumping string
|
||||
var oldStartDumpingValue = StartDumpingValue;
|
||||
@@ -2465,7 +2475,7 @@ namespace MPF.Frontend.ViewModels
|
||||
StopDumpingValue = stopDumpingValue ?? StopDumpingValue;
|
||||
|
||||
// Set button text
|
||||
if (StartStopButtonText as string == oldStartDumpingValue)
|
||||
if ((StartStopButtonText as string) == oldStartDumpingValue)
|
||||
StartStopButtonText = StartDumpingValue;
|
||||
else
|
||||
StartStopButtonText = StopDumpingValue;
|
||||
@@ -2496,15 +2506,19 @@ namespace MPF.Frontend.ViewModels
|
||||
var message = value?.Message;
|
||||
|
||||
// Update the label with only the first line of output
|
||||
if (message != null && message.Contains("\n"))
|
||||
#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
|
||||
if (message is not null && message.Contains('\n'))
|
||||
#else
|
||||
if (message is not null && message.Contains("\n"))
|
||||
#endif
|
||||
Status = message.Split('\n')[0] + " (See log output)";
|
||||
else
|
||||
Status = message ?? string.Empty;
|
||||
|
||||
// Log based on success or failure
|
||||
if (value != null && value)
|
||||
if (value is not null && value)
|
||||
VerboseLogLn(message ?? string.Empty);
|
||||
else if (value != null && !value)
|
||||
else if (value is not null && !value)
|
||||
ErrorLogLn(message ?? string.Empty);
|
||||
}
|
||||
|
||||
|
||||
@@ -209,9 +209,9 @@ namespace MPF.Frontend.ViewModels
|
||||
/// TODO: Convert selected list item to binding
|
||||
public void Load()
|
||||
{
|
||||
if (SubmissionInfo.CommonDiscInfo?.Languages != null)
|
||||
if (SubmissionInfo.CommonDiscInfo?.Languages is not null)
|
||||
Languages.ForEach(l => l.IsChecked = Array.IndexOf(SubmissionInfo.CommonDiscInfo.Languages, l) > -1);
|
||||
if (SubmissionInfo.CommonDiscInfo?.LanguageSelection != null)
|
||||
if (SubmissionInfo.CommonDiscInfo?.LanguageSelection is not null)
|
||||
LanguageSelections.ForEach(ls => ls.IsChecked = Array.IndexOf(SubmissionInfo.CommonDiscInfo.LanguageSelection, ls) > -1);
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace MPF.Frontend.ViewModels
|
||||
/// TODO: Convert selected list item to binding
|
||||
public void Save()
|
||||
{
|
||||
if (SubmissionInfo.CommonDiscInfo == null)
|
||||
if (SubmissionInfo.CommonDiscInfo is null)
|
||||
SubmissionInfo.CommonDiscInfo = new CommonDiscInfoSection();
|
||||
SubmissionInfo.CommonDiscInfo.Languages = [.. Languages.FindAll(l => l.IsChecked).ConvertAll(l => l?.Value)];
|
||||
if (SubmissionInfo.CommonDiscInfo.Languages.Length == 0)
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace MPF.Processors
|
||||
sidecarEntry?.WriteToFile(sidecarPath, new ExtractionOptions { ExtractFullPath = false, Overwrite = true });
|
||||
}
|
||||
catch { }
|
||||
|
||||
logArchive?.Dispose();
|
||||
}
|
||||
#endif
|
||||
@@ -119,7 +120,7 @@ namespace MPF.Processors
|
||||
|
||||
// Get the error count
|
||||
long errorCount = GetErrorCount($"{basePath}.resume.xml");
|
||||
info.CommonDiscInfo.ErrorsCount = (errorCount == -1 ? "Error retrieving error count" : errorCount.ToString());
|
||||
info.CommonDiscInfo.ErrorsCount = errorCount == -1 ? "Error retrieving error count" : errorCount.ToString();
|
||||
|
||||
// Get the write offset, if it exists
|
||||
string? writeOffset = GetWriteOffset(sidecar);
|
||||
@@ -127,6 +128,7 @@ namespace MPF.Processors
|
||||
info.TracksAndWriteOffsets.OtherWriteOffsets = writeOffset;
|
||||
|
||||
// Extract info based generically on MediaType
|
||||
#pragma warning disable IDE0010
|
||||
switch (mediaType)
|
||||
{
|
||||
// TODO: Can this do GD-ROM?
|
||||
@@ -221,8 +223,10 @@ namespace MPF.Processors
|
||||
info.VersionAndEditions.Version = version360 ?? string.Empty;
|
||||
info.CommonDiscInfo.Region = region360;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -231,6 +235,7 @@ namespace MPF.Processors
|
||||
// Remove the extension by default
|
||||
outputFilename = Path.GetFileNameWithoutExtension(outputFilename);
|
||||
|
||||
#pragma warning disable IDE0010
|
||||
switch (mediaType)
|
||||
{
|
||||
case MediaType.CDROM:
|
||||
@@ -295,6 +300,7 @@ namespace MPF.Processors
|
||||
"resume"),
|
||||
];
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
|
||||
return [];
|
||||
}
|
||||
@@ -312,7 +318,7 @@ namespace MPF.Processors
|
||||
internal static string? GenerateCuesheet(CICMMetadataType? cicmSidecar, string basePath)
|
||||
{
|
||||
// If the object is null, we can't get information from it
|
||||
if (cicmSidecar == null)
|
||||
if (cicmSidecar is null)
|
||||
return null;
|
||||
|
||||
// Required variables
|
||||
@@ -324,18 +330,18 @@ namespace MPF.Processors
|
||||
};
|
||||
|
||||
// Only care about OpticalDisc types
|
||||
if (cicmSidecar.OpticalDisc == null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
if (cicmSidecar.OpticalDisc is null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
return null;
|
||||
|
||||
// Loop through each OpticalDisc in the metadata
|
||||
foreach (OpticalDiscType opticalDisc in cicmSidecar.OpticalDisc)
|
||||
{
|
||||
// Only capture the first total track count
|
||||
if (opticalDisc.Tracks != null && opticalDisc.Tracks.Length > 0)
|
||||
if (opticalDisc.Tracks is not null && opticalDisc.Tracks.Length > 0)
|
||||
totalTracks = opticalDisc.Tracks[0];
|
||||
|
||||
// If there are no tracks, we can't get a cuesheet
|
||||
if (opticalDisc.Track == null || opticalDisc.Track.Length == 0)
|
||||
if (opticalDisc.Track is null || opticalDisc.Track.Length == 0)
|
||||
continue;
|
||||
|
||||
// Get cuesheet-level information
|
||||
@@ -362,7 +368,7 @@ namespace MPF.Processors
|
||||
|
||||
// Add index data
|
||||
var cueTracks = new List<CueTrack>();
|
||||
if (track.Indexes != null && track.Indexes.Length > 0)
|
||||
if (track.Indexes is not null && track.Indexes.Length > 0)
|
||||
{
|
||||
var cueIndicies = new List<CueIndex>();
|
||||
|
||||
@@ -372,8 +378,8 @@ namespace MPF.Processors
|
||||
// Get timestamp from frame count
|
||||
int absoluteLength = Math.Abs(trackIndex.Value);
|
||||
int frames = absoluteLength % 75;
|
||||
int seconds = (absoluteLength / 75) % 60;
|
||||
int minutes = (absoluteLength / 75 / 60);
|
||||
int seconds = absoluteLength / 75 % 60;
|
||||
int minutes = absoluteLength / 75 / 60;
|
||||
string timeString = $"{minutes:D2}:{seconds:D2}:{frames:D2}";
|
||||
|
||||
// Pregap information
|
||||
@@ -430,10 +436,10 @@ namespace MPF.Processors
|
||||
|
||||
// If we have a cuesheet to write out, do so
|
||||
cueSheet.Files = [.. cueFiles];
|
||||
if (cueSheet != null && cueSheet != default)
|
||||
if (cueSheet is not null && cueSheet != default)
|
||||
{
|
||||
var ms = new SabreTools.Serialization.Writers.CueSheet().SerializeStream(cueSheet);
|
||||
if (ms == null)
|
||||
if (ms is null)
|
||||
return null;
|
||||
|
||||
using var sr = new StreamReader(ms);
|
||||
@@ -451,6 +457,7 @@ namespace MPF.Processors
|
||||
/// <returns>CueTrackDataType representing the input data</returns>
|
||||
private static CueTrackDataType ConvertToDataType(TrackTypeTrackType trackType, uint bytesPerSector)
|
||||
{
|
||||
#pragma warning disable IDE0010
|
||||
switch (trackType)
|
||||
{
|
||||
case TrackTypeTrackType.audio:
|
||||
@@ -473,6 +480,7 @@ namespace MPF.Processors
|
||||
default:
|
||||
return CueTrackDataType.MODE1_2352;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -482,7 +490,7 @@ namespace MPF.Processors
|
||||
/// <returns>CueTrackFlag representing the flags</returns>
|
||||
private static CueTrackFlag ConvertToTrackFlag(TrackFlagsType trackFlagsType)
|
||||
{
|
||||
if (trackFlagsType == null)
|
||||
if (trackFlagsType is null)
|
||||
return 0;
|
||||
|
||||
CueTrackFlag flag = 0;
|
||||
@@ -512,25 +520,25 @@ namespace MPF.Processors
|
||||
internal static Datafile? GenerateDatafile(CICMMetadataType? cicmSidecar, string basePath)
|
||||
{
|
||||
// If the object is null, we can't get information from it
|
||||
if (cicmSidecar == null)
|
||||
if (cicmSidecar is null)
|
||||
return null;
|
||||
|
||||
// Required variables
|
||||
var roms = new List<Rom>();
|
||||
|
||||
// Process OpticalDisc, if possible
|
||||
if (cicmSidecar.OpticalDisc != null && cicmSidecar.OpticalDisc.Length > 0)
|
||||
if (cicmSidecar.OpticalDisc is not null && cicmSidecar.OpticalDisc.Length > 0)
|
||||
{
|
||||
// Loop through each OpticalDisc in the metadata
|
||||
foreach (OpticalDiscType opticalDisc in cicmSidecar.OpticalDisc)
|
||||
{
|
||||
// Only capture the first total track count
|
||||
uint totalTracks = 0;
|
||||
if (opticalDisc.Tracks != null && opticalDisc.Tracks.Length > 0)
|
||||
if (opticalDisc.Tracks is not null && opticalDisc.Tracks.Length > 0)
|
||||
totalTracks = opticalDisc.Tracks[0];
|
||||
|
||||
// If there are no tracks, we can't get a datfile
|
||||
if (opticalDisc.Track == null || opticalDisc.Track.Length == 0)
|
||||
if (opticalDisc.Track is null || opticalDisc.Track.Length == 0)
|
||||
continue;
|
||||
|
||||
// Loop through each track
|
||||
@@ -543,12 +551,13 @@ namespace MPF.Processors
|
||||
string sha1 = string.Empty;
|
||||
|
||||
// If we don't have any checksums, we can't get a DAT for this track
|
||||
if (track.Checksums == null || track.Checksums.Length == 0)
|
||||
if (track.Checksums is null || track.Checksums.Length == 0)
|
||||
continue;
|
||||
|
||||
// Extract only relevant checksums
|
||||
foreach (ChecksumType checksum in track.Checksums)
|
||||
{
|
||||
#pragma warning disable IDE0010
|
||||
switch (checksum.type)
|
||||
{
|
||||
case ChecksumTypeType.crc32:
|
||||
@@ -561,6 +570,7 @@ namespace MPF.Processors
|
||||
sha1 = checksum.Value;
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
// Build the track datfile data and append
|
||||
@@ -571,7 +581,7 @@ namespace MPF.Processors
|
||||
}
|
||||
|
||||
// Process BlockMedia, if possible
|
||||
if (cicmSidecar.BlockMedia != null && cicmSidecar.BlockMedia.Length > 0)
|
||||
if (cicmSidecar.BlockMedia is not null && cicmSidecar.BlockMedia.Length > 0)
|
||||
{
|
||||
// Loop through each BlockMedia in the metadata
|
||||
foreach (BlockMediaType blockMedia in cicmSidecar.BlockMedia)
|
||||
@@ -582,12 +592,13 @@ namespace MPF.Processors
|
||||
string sha1 = string.Empty;
|
||||
|
||||
// If we don't have any checksums, we can't get a DAT for this track
|
||||
if (blockMedia.Checksums == null || blockMedia.Checksums.Length == 0)
|
||||
if (blockMedia.Checksums is null || blockMedia.Checksums.Length == 0)
|
||||
continue;
|
||||
|
||||
// Extract only relevant checksums
|
||||
foreach (ChecksumType checksum in blockMedia.Checksums)
|
||||
{
|
||||
#pragma warning disable IDE0010
|
||||
switch (checksum.type)
|
||||
{
|
||||
case ChecksumTypeType.crc32:
|
||||
@@ -600,6 +611,7 @@ namespace MPF.Processors
|
||||
sha1 = checksum.Value;
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
// Build the track datfile data and append
|
||||
@@ -658,11 +670,11 @@ namespace MPF.Processors
|
||||
internal static string? GeneratePVD(CICMMetadataType? cicmSidecar)
|
||||
{
|
||||
// If the object is null, we can't get information from it
|
||||
if (cicmSidecar == null)
|
||||
if (cicmSidecar is null)
|
||||
return null;
|
||||
|
||||
// Process OpticalDisc, if possible
|
||||
if (cicmSidecar.OpticalDisc != null && cicmSidecar.OpticalDisc.Length > 0)
|
||||
if (cicmSidecar.OpticalDisc is not null && cicmSidecar.OpticalDisc.Length > 0)
|
||||
{
|
||||
// Loop through each OpticalDisc in the metadata
|
||||
foreach (OpticalDiscType opticalDisc in cicmSidecar.OpticalDisc)
|
||||
@@ -670,7 +682,7 @@ namespace MPF.Processors
|
||||
var pvdData = GeneratePVDData(opticalDisc);
|
||||
|
||||
// If we got a null value, we skip this disc
|
||||
if (pvdData == null)
|
||||
if (pvdData is null)
|
||||
continue;
|
||||
|
||||
// Build each row in consecutive order
|
||||
@@ -704,21 +716,21 @@ namespace MPF.Processors
|
||||
DateTime effective = DateTime.MinValue;
|
||||
|
||||
// If there are no tracks, we can't get a PVD
|
||||
if (opticalDisc?.Track == null || opticalDisc.Track.Length == 0)
|
||||
if (opticalDisc?.Track is null || opticalDisc.Track.Length == 0)
|
||||
return null;
|
||||
|
||||
// Take the first track only
|
||||
TrackType track = opticalDisc.Track[0];
|
||||
|
||||
// If there are no partitions, we can't get a PVD
|
||||
if (track.FileSystemInformation == null || track.FileSystemInformation.Length == 0)
|
||||
if (track.FileSystemInformation is null || track.FileSystemInformation.Length == 0)
|
||||
return null;
|
||||
|
||||
// Loop through each Partition
|
||||
foreach (PartitionType partition in track.FileSystemInformation)
|
||||
{
|
||||
// If the partition has no file systems, we can't get a PVD
|
||||
if (partition.FileSystems == null || partition.FileSystems.Length == 0)
|
||||
if (partition.FileSystems is null || partition.FileSystems.Length == 0)
|
||||
continue;
|
||||
|
||||
// Loop through each FileSystem until we find a PVD
|
||||
@@ -837,7 +849,7 @@ namespace MPF.Processors
|
||||
private static string? GenerateSectorOutputLine(string row, byte[] bytes, int offset)
|
||||
{
|
||||
// If the data isn't correct, return null
|
||||
if (bytes == null || offset < 0 || offset >= bytes.Length || bytes.Length - offset < 16)
|
||||
if (bytes is null || offset < 0 || offset >= bytes.Length || bytes.Length - offset < 16)
|
||||
return null;
|
||||
|
||||
var pvdLine = new StringBuilder();
|
||||
@@ -886,7 +898,7 @@ namespace MPF.Processors
|
||||
});
|
||||
|
||||
// If the reader is null for some reason, we can't do anything
|
||||
if (xtr == null)
|
||||
if (xtr is null)
|
||||
return null;
|
||||
|
||||
var serializer = new XmlSerializer(typeof(CICMMetadataType));
|
||||
@@ -910,11 +922,11 @@ namespace MPF.Processors
|
||||
discType = null; discSubType = null;
|
||||
|
||||
// If the object is null, we can't get information from it
|
||||
if (cicmSidecar == null)
|
||||
if (cicmSidecar is null)
|
||||
return false;
|
||||
|
||||
// Only care about OpticalDisc types
|
||||
if (cicmSidecar.OpticalDisc == null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
if (cicmSidecar.OpticalDisc is null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
return false;
|
||||
|
||||
// Find and return the hardware info, if possible
|
||||
@@ -1088,11 +1100,11 @@ namespace MPF.Processors
|
||||
private static string? GetDVDProtection(CICMMetadataType? cicmSidecar)
|
||||
{
|
||||
// If the object is null, we can't get information from it
|
||||
if (cicmSidecar == null)
|
||||
if (cicmSidecar is null)
|
||||
return null;
|
||||
|
||||
// Only care about OpticalDisc types
|
||||
if (cicmSidecar.OpticalDisc == null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
if (cicmSidecar.OpticalDisc is null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
return null;
|
||||
|
||||
// Get an output for the copyright protection
|
||||
@@ -1161,7 +1173,7 @@ namespace MPF.Processors
|
||||
totalErrors = 0;
|
||||
else if (line.StartsWith("</BadBlocks>"))
|
||||
return totalErrors ?? -1;
|
||||
else if (line.StartsWith("<Block>") && totalErrors != null)
|
||||
else if (line.StartsWith("<Block>") && totalErrors is not null)
|
||||
totalErrors++;
|
||||
}
|
||||
|
||||
@@ -1186,24 +1198,24 @@ namespace MPF.Processors
|
||||
manufacturer = null; model = null; firmware = null;
|
||||
|
||||
// If the object is null, we can't get information from it
|
||||
if (cicmSidecar == null)
|
||||
if (cicmSidecar is null)
|
||||
return false;
|
||||
|
||||
// Only care about OpticalDisc types
|
||||
if (cicmSidecar.OpticalDisc == null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
if (cicmSidecar.OpticalDisc is null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
return false;
|
||||
|
||||
// Find and return the hardware info, if possible
|
||||
foreach (OpticalDiscType opticalDisc in cicmSidecar.OpticalDisc)
|
||||
{
|
||||
// If there's no hardware information, skip
|
||||
if (opticalDisc.DumpHardwareArray == null || opticalDisc.DumpHardwareArray.Length == 0)
|
||||
if (opticalDisc.DumpHardwareArray is null || opticalDisc.DumpHardwareArray.Length == 0)
|
||||
continue;
|
||||
|
||||
foreach (DumpHardwareType hardware in opticalDisc.DumpHardwareArray)
|
||||
{
|
||||
// If the hardware information is invalid, skip
|
||||
if (hardware == null)
|
||||
if (hardware is null)
|
||||
continue;
|
||||
|
||||
// Store the first instance of each value
|
||||
@@ -1227,11 +1239,11 @@ namespace MPF.Processors
|
||||
private static string? GetLayerbreak(CICMMetadataType? cicmSidecar)
|
||||
{
|
||||
// If the object is null, we can't get information from it
|
||||
if (cicmSidecar == null)
|
||||
if (cicmSidecar is null)
|
||||
return null;
|
||||
|
||||
// Only care about OpticalDisc types
|
||||
if (cicmSidecar.OpticalDisc == null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
if (cicmSidecar.OpticalDisc is null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
return null;
|
||||
|
||||
// Setup the layerbreak
|
||||
@@ -1241,7 +1253,7 @@ namespace MPF.Processors
|
||||
foreach (OpticalDiscType opticalDisc in cicmSidecar.OpticalDisc)
|
||||
{
|
||||
// If there's no layer information, skip
|
||||
if (opticalDisc.Layers == null)
|
||||
if (opticalDisc.Layers is null)
|
||||
continue;
|
||||
|
||||
// TODO: Determine how to find the layerbreak from the CICM or other outputs
|
||||
@@ -1258,11 +1270,11 @@ namespace MPF.Processors
|
||||
private static string? GetWriteOffset(CICMMetadataType? cicmSidecar)
|
||||
{
|
||||
// If the object is null, we can't get information from it
|
||||
if (cicmSidecar == null)
|
||||
if (cicmSidecar is null)
|
||||
return null;
|
||||
|
||||
// Only care about OpticalDisc types
|
||||
if (cicmSidecar.OpticalDisc == null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
if (cicmSidecar.OpticalDisc is null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
return null;
|
||||
|
||||
// Loop through each OpticalDisc in the metadata
|
||||
@@ -1288,28 +1300,28 @@ namespace MPF.Processors
|
||||
dmihash = null; pfihash = null; sshash = null; ss = null; ssver = null;
|
||||
|
||||
// If the object is null, we can't get information from it
|
||||
if (cicmSidecar == null)
|
||||
if (cicmSidecar is null)
|
||||
return false;
|
||||
|
||||
// Only care about OpticalDisc types
|
||||
if (cicmSidecar.OpticalDisc == null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
if (cicmSidecar.OpticalDisc is null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
return false;
|
||||
|
||||
// Loop through each OpticalDisc in the metadata
|
||||
foreach (OpticalDiscType opticalDisc in cicmSidecar.OpticalDisc)
|
||||
{
|
||||
// If the Xbox type isn't set, we can't extract information
|
||||
if (opticalDisc.Xbox == null)
|
||||
if (opticalDisc.Xbox is null)
|
||||
continue;
|
||||
|
||||
// Get the Xbox information
|
||||
XboxType xbox = opticalDisc.Xbox;
|
||||
|
||||
// DMI
|
||||
if (xbox.DMI != null)
|
||||
if (xbox.DMI is not null)
|
||||
{
|
||||
DumpType dmi = xbox.DMI;
|
||||
if (dmi.Checksums != null && dmi.Checksums.Length != 0)
|
||||
if (dmi.Checksums is not null && dmi.Checksums.Length != 0)
|
||||
{
|
||||
foreach (ChecksumType checksum in dmi.Checksums)
|
||||
{
|
||||
@@ -1324,10 +1336,10 @@ namespace MPF.Processors
|
||||
}
|
||||
|
||||
// PFI
|
||||
if (xbox.PFI != null)
|
||||
if (xbox.PFI is not null)
|
||||
{
|
||||
DumpType pfi = xbox.PFI;
|
||||
if (pfi.Checksums != null && pfi.Checksums.Length != 0)
|
||||
if (pfi.Checksums is not null && pfi.Checksums.Length != 0)
|
||||
{
|
||||
foreach (ChecksumType checksum in pfi.Checksums)
|
||||
{
|
||||
@@ -1342,12 +1354,12 @@ namespace MPF.Processors
|
||||
}
|
||||
|
||||
// SS
|
||||
if (xbox.SecuritySectors != null && xbox.SecuritySectors.Length > 0)
|
||||
if (xbox.SecuritySectors is not null && xbox.SecuritySectors.Length > 0)
|
||||
{
|
||||
foreach (XboxSecuritySectorsType securitySector in xbox.SecuritySectors)
|
||||
{
|
||||
DumpType security = securitySector.SecuritySectors;
|
||||
if (security.Checksums != null && security.Checksums.Length != 0)
|
||||
if (security.Checksums is not null && security.Checksums.Length != 0)
|
||||
{
|
||||
foreach (ChecksumType checksum in security.Checksums)
|
||||
{
|
||||
@@ -1364,7 +1376,7 @@ namespace MPF.Processors
|
||||
}
|
||||
|
||||
// If we got a hash, we can break
|
||||
if (sshash != null)
|
||||
if (sshash is not null)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1383,25 +1395,25 @@ namespace MPF.Processors
|
||||
serial = null; version = null; region = Region.World;
|
||||
|
||||
// If the object is null, we can't get information from it
|
||||
if (cicmSidecar == null)
|
||||
if (cicmSidecar is null)
|
||||
return false;
|
||||
|
||||
// Only care about OpticalDisc types
|
||||
if (cicmSidecar.OpticalDisc == null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
if (cicmSidecar.OpticalDisc is null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
return false;
|
||||
|
||||
// Loop through each OpticalDisc in the metadata
|
||||
foreach (OpticalDiscType opticalDisc in cicmSidecar.OpticalDisc)
|
||||
{
|
||||
// If the Xbox type isn't set, we can't extract information
|
||||
if (opticalDisc.Xbox == null)
|
||||
if (opticalDisc.Xbox is null)
|
||||
continue;
|
||||
|
||||
// Get the Xbox information
|
||||
XboxType xbox = opticalDisc.Xbox;
|
||||
|
||||
// DMI
|
||||
if (xbox.DMI != null)
|
||||
if (xbox.DMI is not null)
|
||||
{
|
||||
DumpType dmi = xbox.DMI;
|
||||
string image = dmi.Image;
|
||||
@@ -1431,25 +1443,25 @@ namespace MPF.Processors
|
||||
serial = null; version = null; region = Region.World;
|
||||
|
||||
// If the object is null, we can't get information from it
|
||||
if (cicmSidecar == null)
|
||||
if (cicmSidecar is null)
|
||||
return false;
|
||||
|
||||
// Only care about OpticalDisc types
|
||||
if (cicmSidecar.OpticalDisc == null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
if (cicmSidecar.OpticalDisc is null || cicmSidecar.OpticalDisc.Length == 0)
|
||||
return false;
|
||||
|
||||
// Loop through each OpticalDisc in the metadata
|
||||
foreach (OpticalDiscType opticalDisc in cicmSidecar.OpticalDisc)
|
||||
{
|
||||
// If the Xbox type isn't set, we can't extract information
|
||||
if (opticalDisc.Xbox == null)
|
||||
if (opticalDisc.Xbox is null)
|
||||
continue;
|
||||
|
||||
// Get the Xbox information
|
||||
XboxType xbox = opticalDisc.Xbox;
|
||||
|
||||
// DMI
|
||||
if (xbox.DMI != null)
|
||||
if (xbox.DMI is not null)
|
||||
{
|
||||
DumpType dmi = xbox.DMI;
|
||||
string image = dmi.Image;
|
||||
|
||||
@@ -402,7 +402,7 @@ namespace MPF.Processors
|
||||
foreach (var outputFile in outputFiles)
|
||||
{
|
||||
// Skip non-artifact files
|
||||
if (!outputFile.IsArtifact || outputFile.ArtifactKey == null)
|
||||
if (!outputFile.IsArtifact || outputFile.ArtifactKey is null)
|
||||
continue;
|
||||
|
||||
// Skip non-existent files
|
||||
@@ -744,7 +744,7 @@ namespace MPF.Processors
|
||||
internal static string? GetPIC(string? picPath, int trimLength = -1)
|
||||
{
|
||||
// If the file is invalid
|
||||
if (picPath == null)
|
||||
if (picPath is null)
|
||||
return null;
|
||||
|
||||
// If the file doesn't exist, we can't get the info
|
||||
@@ -758,7 +758,7 @@ namespace MPF.Processors
|
||||
try
|
||||
{
|
||||
var hex = ProcessingTool.GetFullFile(picPath, true);
|
||||
if (hex == null)
|
||||
if (hex is null)
|
||||
return null;
|
||||
|
||||
if (trimLength > -1 && trimLength < hex.Length)
|
||||
@@ -820,7 +820,7 @@ namespace MPF.Processors
|
||||
pvd = string.Empty;
|
||||
for (int i = 0; i < 96; i += 16)
|
||||
{
|
||||
pvd += $"{(0x0320 + i):X4} : {buf[i]:X2} {buf[i + 1]:X2} {buf[i + 2]:X2} {buf[i + 3]:X2} {buf[i + 4]:X2} {buf[i + 5]:X2} {buf[i + 6]:X2} {buf[i + 7]:X2} " +
|
||||
pvd += $"{0x0320 + i:X4} : {buf[i]:X2} {buf[i + 1]:X2} {buf[i + 2]:X2} {buf[i + 3]:X2} {buf[i + 4]:X2} {buf[i + 5]:X2} {buf[i + 6]:X2} {buf[i + 7]:X2} " +
|
||||
$"{buf[i + 8]:X2} {buf[i + 9]:X2} {buf[i + 10]:X2} {buf[i + 11]:X2} {buf[i + 12]:X2} {buf[i + 13]:X2} {buf[i + 14]:X2} {buf[i + 15]:X2} {pvdASCII.Substring(i, 16)}\n";
|
||||
}
|
||||
|
||||
@@ -869,7 +869,7 @@ namespace MPF.Processors
|
||||
internal static string SplitString(string? str, int count, bool trim = false)
|
||||
{
|
||||
// Ignore invalid inputs
|
||||
if (str == null || str.Length == 0)
|
||||
if (str is null || str.Length == 0)
|
||||
return string.Empty;
|
||||
|
||||
// Handle non-modifying counts
|
||||
|
||||
@@ -21,12 +21,14 @@ namespace MPF.Processors
|
||||
/// <inheritdoc/>
|
||||
public override MediaType? DetermineMediaType(string? outputDirectory, string outputFilename)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return System switch
|
||||
{
|
||||
RedumpSystem.NintendoGameCube => MediaType.NintendoGameCubeGameDisc,
|
||||
RedumpSystem.NintendoWii => MediaType.NintendoWiiOpticalDisc,
|
||||
_ => null,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -255,7 +257,7 @@ namespace MPF.Processors
|
||||
try
|
||||
{
|
||||
var hex = ProcessingTool.GetFullFile(bcaPath, true);
|
||||
if (hex == null)
|
||||
if (hex is null)
|
||||
return null;
|
||||
|
||||
// Separate into blocks of 4 hex digits and newlines
|
||||
@@ -342,6 +344,7 @@ namespace MPF.Processors
|
||||
// string gameid = serial[1] + serial[2];
|
||||
// string version = serial[4] + serial[5]
|
||||
|
||||
#pragma warning disable IDE0010
|
||||
switch (serial[3])
|
||||
{
|
||||
case 'A':
|
||||
@@ -393,6 +396,7 @@ namespace MPF.Processors
|
||||
region = null; // Not a real region code
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ Here are some notes about the various output files and what they represent:
|
||||
- toc - Binary representation of the table of contents
|
||||
- volDesc - Volume descriptor information
|
||||
*/
|
||||
|
||||
namespace MPF.Processors
|
||||
{
|
||||
/// <summary>
|
||||
@@ -98,12 +99,13 @@ namespace MPF.Processors
|
||||
discEntry?.WriteToFile(discPath, new ExtractionOptions { ExtractFullPath = false, Overwrite = true });
|
||||
}
|
||||
catch { }
|
||||
|
||||
logArchive?.Dispose();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Get the comma-separated list of values
|
||||
if (GetDiscType($"{basePath}_disc.txt", out var discType) && discType != null)
|
||||
if (GetDiscType($"{basePath}_disc.txt", out var discType) && discType is not null)
|
||||
{
|
||||
// CD-ROM
|
||||
if (discType.Contains("CD-DA or CD-ROM Disc"))
|
||||
@@ -213,6 +215,7 @@ namespace MPF.Processors
|
||||
VolumeLabels = volLabels;
|
||||
|
||||
// Extract info based generically on MediaType
|
||||
#pragma warning disable IDE0010
|
||||
switch (mediaType)
|
||||
{
|
||||
case MediaType.CDROM:
|
||||
@@ -232,7 +235,7 @@ namespace MPF.Processors
|
||||
else if (File.Exists($"{basePath}.img_EccEdc.txt"))
|
||||
errorCount = GetErrorCount($"{basePath}.img_EccEdc.txt");
|
||||
|
||||
info.CommonDiscInfo.ErrorsCount = (errorCount == -1 ? "Error retrieving error count" : errorCount.ToString());
|
||||
info.CommonDiscInfo.ErrorsCount = errorCount == -1 ? "Error retrieving error count" : errorCount.ToString();
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -262,13 +265,13 @@ namespace MPF.Processors
|
||||
info.SizeAndChecksums.PICIdentifier = ProcessingTool.GetPICIdentifier(di);
|
||||
if (ProcessingTool.GetLayerbreaks(di, out long? layerbreak1, out long? layerbreak2, out long? layerbreak3))
|
||||
{
|
||||
if (layerbreak1 != null && layerbreak1 * 2048 < info.SizeAndChecksums.Size)
|
||||
if (layerbreak1 is not null && layerbreak1 * 2048 < info.SizeAndChecksums.Size)
|
||||
info.SizeAndChecksums.Layerbreak = layerbreak1.Value;
|
||||
|
||||
if (layerbreak2 != null && layerbreak2 * 2048 < info.SizeAndChecksums.Size)
|
||||
if (layerbreak2 is not null && layerbreak2 * 2048 < info.SizeAndChecksums.Size)
|
||||
info.SizeAndChecksums.Layerbreak2 = layerbreak2.Value;
|
||||
|
||||
if (layerbreak3 != null && layerbreak3 * 2048 < info.SizeAndChecksums.Size)
|
||||
if (layerbreak3 is not null && layerbreak3 * 2048 < info.SizeAndChecksums.Size)
|
||||
info.SizeAndChecksums.Layerbreak3 = layerbreak3.Value;
|
||||
}
|
||||
}
|
||||
@@ -323,7 +326,7 @@ namespace MPF.Processors
|
||||
case RedumpSystem.MicrosoftXbox:
|
||||
string xmidString = ProcessingTool.GetXMID($"{basePath}_DMI.bin");
|
||||
var xmid = SabreTools.Serialization.Wrappers.XMID.Create(xmidString);
|
||||
if (xmid != null)
|
||||
if (xmid is not null)
|
||||
{
|
||||
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.XMID] = xmidString?.TrimEnd('\0') ?? string.Empty;
|
||||
info.CommonDiscInfo.Serial = xmid.Serial ?? string.Empty;
|
||||
@@ -366,7 +369,7 @@ namespace MPF.Processors
|
||||
case RedumpSystem.MicrosoftXbox360:
|
||||
string xemidString = ProcessingTool.GetXeMID($"{basePath}_DMI.bin");
|
||||
var xemid = SabreTools.Serialization.Wrappers.XeMID.Create(xemidString);
|
||||
if (xemid != null)
|
||||
if (xemid is not null)
|
||||
{
|
||||
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.XeMID] = xemidString?.TrimEnd('\0') ?? string.Empty;
|
||||
info.CommonDiscInfo.Serial = xemid.Serial ?? string.Empty;
|
||||
@@ -572,7 +575,7 @@ namespace MPF.Processors
|
||||
{
|
||||
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = ps3Serial ?? string.Empty;
|
||||
info.VersionAndEditions.Version = ps3Version ?? string.Empty;
|
||||
if (ps3FirmwareVersion != null)
|
||||
if (ps3FirmwareVersion is not null)
|
||||
info.CommonDiscInfo.ContentsSpecialFields![SiteCode.Patches] = $"PS3 Firmware {ps3FirmwareVersion}";
|
||||
}
|
||||
|
||||
@@ -957,7 +960,7 @@ namespace MPF.Processors
|
||||
string? exeDate = null;
|
||||
using var sr = File.OpenText(volDesc);
|
||||
var line = sr.ReadLine();
|
||||
while (line != null)
|
||||
while (line is not null)
|
||||
{
|
||||
// Trim the line for later use
|
||||
line = line.Trim();
|
||||
@@ -973,16 +976,16 @@ namespace MPF.Processors
|
||||
{
|
||||
// Account for Y2K date problem
|
||||
#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
|
||||
if (exeDate != null && exeDate[..2] == "19")
|
||||
if (exeDate is not null && exeDate[..2] == "19")
|
||||
#else
|
||||
if (exeDate != null && exeDate.Substring(0, 2) == "19")
|
||||
if (exeDate is not null && exeDate.Substring(0, 2) == "19")
|
||||
#endif
|
||||
{
|
||||
string decade = exeDate!.Substring(2, 1);
|
||||
|
||||
// Does only PSX need to account for 1920s-60s?
|
||||
if (decade == "0" || decade == "1" ||
|
||||
psx && (decade == "2" || decade == "3" || decade == "4" || decade == "5" || decade == "6"))
|
||||
(psx && (decade == "2" || decade == "3" || decade == "4" || decade == "5" || decade == "6")))
|
||||
{
|
||||
#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
|
||||
exeDate = $"20{exeDate[2..]}";
|
||||
@@ -1044,7 +1047,7 @@ namespace MPF.Processors
|
||||
|
||||
using var sr = File.OpenText(disc);
|
||||
var line = sr.ReadLine();
|
||||
while (line != null)
|
||||
while (line is not null)
|
||||
{
|
||||
// Trim the line for later use
|
||||
line = line.Trim();
|
||||
@@ -1142,7 +1145,7 @@ namespace MPF.Processors
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
while (line?.StartsWith("========== ManufacturingInformation ==========") == false)
|
||||
{
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
if (line.StartsWith("CopyrightProtectionType"))
|
||||
@@ -1174,7 +1177,7 @@ namespace MPF.Processors
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
if (line.StartsWith("DecryptedDiscKey"))
|
||||
@@ -1274,7 +1277,7 @@ namespace MPF.Processors
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
if (line.StartsWith("[NO ERROR]"))
|
||||
@@ -1374,7 +1377,7 @@ namespace MPF.Processors
|
||||
{
|
||||
using var sr = File.OpenText(drive);
|
||||
var line = sr.ReadLine();
|
||||
while (line != null)
|
||||
while (line is not null)
|
||||
{
|
||||
// Trim the line for later use
|
||||
line = line.Trim();
|
||||
@@ -1438,7 +1441,7 @@ namespace MPF.Processors
|
||||
{
|
||||
using var sr = File.OpenText(disc);
|
||||
var line = sr.ReadLine();
|
||||
while (line != null)
|
||||
while (line is not null)
|
||||
{
|
||||
// Trim the line for later use
|
||||
line = line.Trim();
|
||||
@@ -1538,12 +1541,12 @@ namespace MPF.Processors
|
||||
// Seek to the TOC data
|
||||
using var sr = File.OpenText(disc);
|
||||
var line = sr.ReadLine();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
if (!line.StartsWith("========== TOC"))
|
||||
while ((line = sr.ReadLine())?.StartsWith("========== TOC") == false) ;
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
// Create the required regex
|
||||
@@ -1558,12 +1561,12 @@ namespace MPF.Processors
|
||||
}
|
||||
|
||||
// Seek to the FULL TOC data
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
if (!line.StartsWith("========== FULL TOC"))
|
||||
while ((line = sr.ReadLine())?.StartsWith("========== FULL TOC") == false) ;
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
// Create the required regex
|
||||
@@ -1574,7 +1577,7 @@ namespace MPF.Processors
|
||||
var trackSessionMapping = new Dictionary<string, string>();
|
||||
while ((line = sr.ReadLine())?.StartsWith("========== OpCode") == false)
|
||||
{
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
var match = trackSessionRegex.Match(line);
|
||||
@@ -1594,7 +1597,7 @@ namespace MPF.Processors
|
||||
|
||||
// Seek to the multisession data
|
||||
line = sr.ReadLine()?.Trim();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
if (!line.StartsWith("Lead-out length"))
|
||||
@@ -1609,7 +1612,7 @@ namespace MPF.Processors
|
||||
var firstSessionLeadOutLengthString = line?.Substring("Lead-out length of 1st session: ".Length);
|
||||
#endif
|
||||
line = sr.ReadLine()?.Trim();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
// Read the second session lead-in, if it exists
|
||||
@@ -1691,7 +1694,7 @@ namespace MPF.Processors
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return false;
|
||||
|
||||
if (line.StartsWith("Detected anti-mod string"))
|
||||
@@ -1732,7 +1735,7 @@ namespace MPF.Processors
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return false;
|
||||
|
||||
// Determine the section we are in
|
||||
@@ -1847,7 +1850,7 @@ namespace MPF.Processors
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
var line = sr.ReadLine();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
if (line.Contains("mode 2 form 2"))
|
||||
@@ -1898,7 +1901,7 @@ namespace MPF.Processors
|
||||
// If we're in a new mainInfo, the location of the header changed
|
||||
using var sr = File.OpenText(mainInfo);
|
||||
var line = sr.ReadLine();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
if (line.StartsWith("========== OpCode")
|
||||
@@ -1912,25 +1915,25 @@ namespace MPF.Processors
|
||||
line = sr.ReadLine();
|
||||
}
|
||||
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
// Make sure we're in the area
|
||||
if (line.StartsWith("========== LBA") == false)
|
||||
if (!line.StartsWith("========== LBA"))
|
||||
while ((line = sr.ReadLine())?.StartsWith("========== LBA") == false) ;
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
// If we have a Sega disc, skip sector 0
|
||||
if (line.StartsWith("========== LBA[000000, 0000000]: Main Channel =========="))
|
||||
while ((line = sr.ReadLine())?.StartsWith("========== LBA") == false) ;
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
// If we have a PlayStation disc, skip sector 4
|
||||
if (line.StartsWith("========== LBA[000004, 0x00004]: Main Channel =========="))
|
||||
while ((line = sr.ReadLine())?.StartsWith("========== LBA") == false) ;
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
// Assume the first non-LBA0/4 sector listed is the proper one
|
||||
@@ -2130,7 +2133,7 @@ namespace MPF.Processors
|
||||
// If we're in a new mainInfo, the location of the header changed
|
||||
using var sr = File.OpenText(mainInfo);
|
||||
var line = sr.ReadLine();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
if (line.StartsWith("========== OpCode")
|
||||
@@ -2139,31 +2142,31 @@ namespace MPF.Processors
|
||||
{
|
||||
// Seek to unscrambled data
|
||||
while ((line = sr.ReadLine())?.Contains("Check MCN and/or ISRC") == false) ;
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
// Read the next line so the search goes properly
|
||||
line = sr.ReadLine();
|
||||
}
|
||||
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
// Make sure we're in the area
|
||||
if (!line.StartsWith("========== LBA"))
|
||||
while ((line = sr.ReadLine())?.StartsWith("========== LBA") == false) ;
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
// Make sure we're in the right sector
|
||||
if (!line.StartsWith("========== LBA[000000, 0000000]: Main Channel =========="))
|
||||
while ((line = sr.ReadLine())?.StartsWith("========== LBA[000000, 0000000]: Main Channel ==========") == false) ;
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
// Fast forward to the header
|
||||
while ((line = sr.ReadLine())?.Trim()?.StartsWith("+0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F") == false) ;
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
// Now that we're at the Header, read each line in and concatenate
|
||||
@@ -2201,7 +2204,7 @@ namespace MPF.Processors
|
||||
|
||||
string volType = "UNKNOWN";
|
||||
string label;
|
||||
while (line != null)
|
||||
while (line is not null)
|
||||
{
|
||||
// Trim the line for later use
|
||||
line = line.Trim();
|
||||
@@ -2247,7 +2250,7 @@ namespace MPF.Processors
|
||||
#endif
|
||||
|
||||
// Skip if label is blank, and skip Joliet (DIC Joliet parsing is broken?)
|
||||
if (label == null || label.Length <= 0 || volType == "Joliet")
|
||||
if (label is null || label.Length <= 0 || volType == "Joliet")
|
||||
{
|
||||
volType = "UNKNOWN";
|
||||
line = sr.ReadLine();
|
||||
@@ -2312,9 +2315,9 @@ namespace MPF.Processors
|
||||
// Now that we're at the offsets, attempt to get the sample offset
|
||||
var offsetLine = sr.ReadLine()?.Split(' ');
|
||||
#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
|
||||
string offset = offsetLine != null ? offsetLine[^1] : string.Empty;
|
||||
string offset = offsetLine is not null ? offsetLine[^1] : string.Empty;
|
||||
#else
|
||||
string offset = offsetLine != null ? offsetLine[offsetLine.Length - 1] : string.Empty;
|
||||
string offset = offsetLine is not null ? offsetLine[offsetLine.Length - 1] : string.Empty;
|
||||
#endif
|
||||
offsets.Add(offset);
|
||||
}
|
||||
@@ -2324,7 +2327,7 @@ namespace MPF.Processors
|
||||
var temp = new List<string>();
|
||||
foreach (var offset in offsets)
|
||||
{
|
||||
if (offset == null || offset.Length == 0)
|
||||
if (offset is null || offset.Length == 0)
|
||||
continue;
|
||||
if (!temp.Contains(offset))
|
||||
temp.Add(offset);
|
||||
@@ -2362,12 +2365,12 @@ namespace MPF.Processors
|
||||
dmihash = null; pfihash = null; sshash = null;
|
||||
|
||||
// If we don't have a valid datafile, we can't do anything
|
||||
if (suppl?.Game == null || suppl.Game.Length == 0)
|
||||
if (suppl?.Game is null || suppl.Game.Length == 0)
|
||||
return false;
|
||||
|
||||
// Try to extract the hash information
|
||||
var roms = suppl.Game[0].Rom;
|
||||
if (roms == null || roms.Length == 0)
|
||||
if (roms is null || roms.Length == 0)
|
||||
return false;
|
||||
|
||||
dmihash = Array.Find(roms, r => r.Name?.EndsWith("DMI.bin") == true)?.CRC?.ToUpperInvariant();
|
||||
@@ -2405,7 +2408,7 @@ namespace MPF.Processors
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
// XGD version (1 = Xbox, 2 = Xbox360)
|
||||
@@ -2427,7 +2430,7 @@ namespace MPF.Processors
|
||||
&& !line.StartsWith("========== Unlock 2 state(wxripper) =========="))
|
||||
{
|
||||
line = sr.ReadLine()?.Trim();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
// If we have a recognized line format, parse it
|
||||
@@ -2438,7 +2441,7 @@ namespace MPF.Processors
|
||||
}
|
||||
}
|
||||
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,56 +1,56 @@
|
||||
namespace MPF.Processors
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the type of compression used for logs
|
||||
/// </summary>
|
||||
public enum LogCompression
|
||||
{
|
||||
/// <summary>
|
||||
/// PKZIP using DEFLATE level 5
|
||||
/// </summary>
|
||||
DeflateDefault,
|
||||
|
||||
/// <summary>
|
||||
/// PKZIP using DEFLATE level 9
|
||||
/// </summary>
|
||||
DeflateMaximum,
|
||||
|
||||
/// <summary>
|
||||
/// PKZIP using Zstd level 19
|
||||
/// </summary>
|
||||
Zstd19,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enum for SecuROM scheme type
|
||||
/// </summary>
|
||||
internal enum SecuROMScheme
|
||||
{
|
||||
Unknown,
|
||||
|
||||
/// <summary>
|
||||
/// No SecuROM, 0 Sectors
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// SecuROM 1-2, 216 Sectors
|
||||
/// </summary>
|
||||
PreV3,
|
||||
|
||||
/// <summary>
|
||||
/// SecuROM 3, 90 Sectors
|
||||
/// </summary>
|
||||
V3,
|
||||
|
||||
/// <summary>
|
||||
/// SecuROM 4, 99 Sectors
|
||||
/// </summary>
|
||||
V4,
|
||||
|
||||
/// <summary>
|
||||
/// SecuROM 4+, 11 Sectors
|
||||
/// </summary>
|
||||
V4Plus,
|
||||
}
|
||||
}
|
||||
namespace MPF.Processors
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the type of compression used for logs
|
||||
/// </summary>
|
||||
public enum LogCompression
|
||||
{
|
||||
/// <summary>
|
||||
/// PKZIP using DEFLATE level 5
|
||||
/// </summary>
|
||||
DeflateDefault,
|
||||
|
||||
/// <summary>
|
||||
/// PKZIP using DEFLATE level 9
|
||||
/// </summary>
|
||||
DeflateMaximum,
|
||||
|
||||
/// <summary>
|
||||
/// PKZIP using Zstd level 19
|
||||
/// </summary>
|
||||
Zstd19,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enum for SecuROM scheme type
|
||||
/// </summary>
|
||||
internal enum SecuROMScheme
|
||||
{
|
||||
Unknown,
|
||||
|
||||
/// <summary>
|
||||
/// No SecuROM, 0 Sectors
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// SecuROM 1-2, 216 Sectors
|
||||
/// </summary>
|
||||
PreV3,
|
||||
|
||||
/// <summary>
|
||||
/// SecuROM 3, 90 Sectors
|
||||
/// </summary>
|
||||
V3,
|
||||
|
||||
/// <summary>
|
||||
/// SecuROM 4, 99 Sectors
|
||||
/// </summary>
|
||||
V4,
|
||||
|
||||
/// <summary>
|
||||
/// SecuROM 4+, 11 Sectors
|
||||
/// </summary>
|
||||
V4Plus,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,10 +33,11 @@ namespace MPF.Processors
|
||||
|
||||
// Get the Datafile information
|
||||
var datafile = GetDatafile(basePath);
|
||||
if (datafile != null)
|
||||
if (datafile is not null)
|
||||
info.TracksAndWriteOffsets.ClrMameProData = ProcessingTool.GenerateDatfile(datafile);
|
||||
|
||||
// Extract info based generically on MediaType
|
||||
#pragma warning disable IDE0010
|
||||
switch (mediaType)
|
||||
{
|
||||
case MediaType.CDROM:
|
||||
@@ -52,7 +53,7 @@ namespace MPF.Processors
|
||||
case MediaType.BluRay:
|
||||
case MediaType.UMD:
|
||||
var firstRom = datafile?.Game?[0]?.Rom?[0];
|
||||
if (firstRom != null)
|
||||
if (firstRom is not null)
|
||||
{
|
||||
info.SizeAndChecksums.Size = long.Parse(firstRom.Size ?? "0");
|
||||
info.SizeAndChecksums.CRC32 = firstRom.CRC;
|
||||
@@ -62,6 +63,7 @@ namespace MPF.Processors
|
||||
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -115,31 +117,31 @@ namespace MPF.Processors
|
||||
if (File.Exists($"{basePath}.bin"))
|
||||
{
|
||||
var rom = GetRom($"{basePath}.bin");
|
||||
if (rom != null)
|
||||
if (rom is not null)
|
||||
return GetDatafile(basePath, rom);
|
||||
}
|
||||
else if (File.Exists($"{basePath}.ima"))
|
||||
{
|
||||
var rom = GetRom($"{basePath}.ima");
|
||||
if (rom != null)
|
||||
if (rom is not null)
|
||||
return GetDatafile(basePath, rom);
|
||||
}
|
||||
else if (File.Exists($"{basePath}.img"))
|
||||
{
|
||||
var rom = GetRom($"{basePath}.img");
|
||||
if (rom != null)
|
||||
if (rom is not null)
|
||||
return GetDatafile(basePath, rom);
|
||||
}
|
||||
else if (File.Exists($"{basePath}.iso"))
|
||||
{
|
||||
var rom = GetRom($"{basePath}.iso");
|
||||
if (rom != null)
|
||||
if (rom is not null)
|
||||
return GetDatafile(basePath, rom);
|
||||
}
|
||||
else if (File.Exists($"{basePath}.mdf"))
|
||||
{
|
||||
var rom = GetRom($"{basePath}.mdf");
|
||||
if (rom != null)
|
||||
if (rom is not null)
|
||||
return GetDatafile(basePath, rom);
|
||||
}
|
||||
|
||||
@@ -150,7 +152,7 @@ namespace MPF.Processors
|
||||
|
||||
// Try Track 0
|
||||
var track0rom = GetRom($"{basePath} (Track 0).bin");
|
||||
if (track0rom != null)
|
||||
if (track0rom is not null)
|
||||
roms.Add(track0rom);
|
||||
|
||||
// Hash all found tracks
|
||||
@@ -158,7 +160,7 @@ namespace MPF.Processors
|
||||
{
|
||||
// Get the rom for the track
|
||||
var rom = GetRom($"{basePath} (Track {i}).bin");
|
||||
if (rom == null)
|
||||
if (rom is null)
|
||||
break;
|
||||
|
||||
// Add the track to the output
|
||||
@@ -167,7 +169,7 @@ namespace MPF.Processors
|
||||
|
||||
// Try Track A
|
||||
var trackArom = GetRom($"{basePath} (Track A).bin");
|
||||
if (trackArom != null)
|
||||
if (trackArom is not null)
|
||||
roms.Add(trackArom);
|
||||
|
||||
// Create and return if there are any tracks
|
||||
@@ -180,7 +182,7 @@ namespace MPF.Processors
|
||||
|
||||
// Try Track 00
|
||||
var track00rom = GetRom($"{basePath} (Track 00).bin");
|
||||
if (track00rom != null)
|
||||
if (track00rom is not null)
|
||||
roms.Add(track00rom);
|
||||
|
||||
// Hash all found tracks
|
||||
@@ -188,7 +190,7 @@ namespace MPF.Processors
|
||||
{
|
||||
// Get the rom for the track
|
||||
var rom = GetRom($"{basePath} (Track {i:D2}).bin");
|
||||
if (rom == null)
|
||||
if (rom is null)
|
||||
break;
|
||||
|
||||
// Add the track to the output
|
||||
@@ -197,7 +199,7 @@ namespace MPF.Processors
|
||||
|
||||
// Try Track AA
|
||||
var trackAArom = GetRom($"{basePath} (Track AA).bin");
|
||||
if (trackAArom != null)
|
||||
if (trackAArom is not null)
|
||||
roms.Add(trackAArom);
|
||||
|
||||
// Create and return if there are any tracks
|
||||
|
||||
@@ -206,13 +206,13 @@ namespace MPF.Processors.OutputFiles
|
||||
public virtual bool Exists(ZipArchive? archive)
|
||||
{
|
||||
// If the archive is invalid
|
||||
if (archive == null)
|
||||
if (archive is null)
|
||||
return false;
|
||||
|
||||
// Get list of all files in archive
|
||||
foreach (var entry in archive.Entries)
|
||||
{
|
||||
if (entry.Key == null)
|
||||
if (entry.Key is null)
|
||||
continue;
|
||||
|
||||
if (Array.Exists(Filenames, filename => entry.Key == filename))
|
||||
@@ -231,13 +231,13 @@ namespace MPF.Processors.OutputFiles
|
||||
public virtual bool Extract(ZipArchive? archive, string outputDirectory)
|
||||
{
|
||||
// If the archive is invalid
|
||||
if (archive == null)
|
||||
if (archive is null)
|
||||
return false;
|
||||
|
||||
// Get list of all files in archive
|
||||
foreach (var entry in archive.Entries)
|
||||
{
|
||||
if (entry.Key == null)
|
||||
if (entry.Key is null)
|
||||
continue;
|
||||
|
||||
var matches = Array.FindAll(Filenames, filename => entry.Key == filename);
|
||||
|
||||
@@ -69,13 +69,13 @@ namespace MPF.Processors.OutputFiles
|
||||
public override bool Exists(ZipArchive? archive)
|
||||
{
|
||||
// If the archive is invalid
|
||||
if (archive == null)
|
||||
if (archive is null)
|
||||
return false;
|
||||
|
||||
// Get list of all files in archive
|
||||
foreach (var entry in archive.Entries)
|
||||
{
|
||||
if (entry.Key == null)
|
||||
if (entry.Key is null)
|
||||
continue;
|
||||
|
||||
if (Array.Exists(Filenames, pattern => Regex.IsMatch(entry.Key, pattern)))
|
||||
@@ -89,13 +89,13 @@ namespace MPF.Processors.OutputFiles
|
||||
public override bool Extract(ZipArchive? archive, string outputDirectory)
|
||||
{
|
||||
// If the archive is invalid
|
||||
if (archive == null)
|
||||
if (archive is null)
|
||||
return false;
|
||||
|
||||
// Get list of all files in archive
|
||||
foreach (var entry in archive.Entries)
|
||||
{
|
||||
if (entry.Key == null)
|
||||
if (entry.Key is null)
|
||||
continue;
|
||||
|
||||
var matches = Array.FindAll(Filenames, pattern => Regex.IsMatch(entry.Key, pattern));
|
||||
@@ -128,7 +128,7 @@ namespace MPF.Processors.OutputFiles
|
||||
foreach (string file in directoryFiles)
|
||||
{
|
||||
var matches = Array.FindAll(Filenames, pattern => Regex.IsMatch(file, pattern));
|
||||
if (matches != null && matches.Length > 0)
|
||||
if (matches is not null && matches.Length > 0)
|
||||
paths.Add(file);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,13 +96,13 @@ namespace MPF.Processors
|
||||
info.SizeAndChecksums.PICIdentifier = ProcessingTool.GetPICIdentifier(di);
|
||||
if (ProcessingTool.GetLayerbreaks(di, out long? layerbreak1, out long? layerbreak2, out long? layerbreak3))
|
||||
{
|
||||
if (layerbreak1 != null && layerbreak1 * 2048 < info.SizeAndChecksums.Size)
|
||||
if (layerbreak1 is not null && layerbreak1 * 2048 < info.SizeAndChecksums.Size)
|
||||
info.SizeAndChecksums.Layerbreak = layerbreak1.Value;
|
||||
|
||||
if (layerbreak2 != null && layerbreak2 * 2048 < info.SizeAndChecksums.Size)
|
||||
if (layerbreak2 is not null && layerbreak2 * 2048 < info.SizeAndChecksums.Size)
|
||||
info.SizeAndChecksums.Layerbreak2 = layerbreak2.Value;
|
||||
|
||||
if (layerbreak3 != null && layerbreak3 * 2048 < info.SizeAndChecksums.Size)
|
||||
if (layerbreak3 is not null && layerbreak3 * 2048 < info.SizeAndChecksums.Size)
|
||||
info.SizeAndChecksums.Layerbreak3 = layerbreak3.Value;
|
||||
}
|
||||
|
||||
@@ -121,9 +121,9 @@ namespace MPF.Processors
|
||||
// Parse Disc Key, Disc ID, and PIC from the getkey.log file
|
||||
if (ProcessingTool.ParseGetKeyLog(getKeyPath, out string? key, out string? id, out string? pic))
|
||||
{
|
||||
if (key != null)
|
||||
if (key is not null)
|
||||
info.Extras.DiscKey = key.ToUpperInvariant();
|
||||
if (id != null)
|
||||
if (id is not null)
|
||||
#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
|
||||
info.Extras.DiscID = $"{id.ToUpperInvariant()[..24]}XXXXXXXX";
|
||||
#else
|
||||
|
||||
@@ -40,11 +40,11 @@ namespace MPF.Processors
|
||||
public static string? GenerateDatfile(Datafile? datafile)
|
||||
{
|
||||
// If we don't have a valid datafile, we can't do anything
|
||||
if (datafile?.Game == null || datafile.Game.Length == 0)
|
||||
if (datafile?.Game is null || datafile.Game.Length == 0)
|
||||
return null;
|
||||
|
||||
var roms = datafile.Game[0].Rom;
|
||||
if (roms == null || roms.Length == 0)
|
||||
if (roms is null || roms.Length == 0)
|
||||
return null;
|
||||
|
||||
// Otherwise, reconstruct the hash data with only the required info
|
||||
@@ -109,7 +109,7 @@ namespace MPF.Processors
|
||||
});
|
||||
|
||||
// If the reader is null for some reason, we can't do anything
|
||||
if (xtr == null)
|
||||
if (xtr is null)
|
||||
return null;
|
||||
|
||||
var serializer = new XmlSerializer(typeof(Datafile));
|
||||
@@ -191,11 +191,11 @@ namespace MPF.Processors
|
||||
{
|
||||
size = -1; crc32 = null; md5 = null; sha1 = null;
|
||||
|
||||
if (datafile?.Game == null || datafile.Game.Length == 0)
|
||||
if (datafile?.Game is null || datafile.Game.Length == 0)
|
||||
return false;
|
||||
|
||||
var roms = datafile.Game[0].Rom;
|
||||
if (roms == null || roms.Length == 0)
|
||||
if (roms is null || roms.Length == 0)
|
||||
return false;
|
||||
|
||||
var rom = roms[0];
|
||||
@@ -247,13 +247,13 @@ namespace MPF.Processors
|
||||
layerbreak1 = null; layerbreak2 = null; layerbreak3 = null;
|
||||
|
||||
// If we don't have valid disc information, we can't do anything
|
||||
if (di?.Units == null || di.Units.Length <= 1)
|
||||
if (di?.Units is null || di.Units.Length <= 1)
|
||||
return false;
|
||||
|
||||
// Wrap big-endian reading
|
||||
static int ReadFromArrayBigEndian(byte[]? bytes, int offset)
|
||||
{
|
||||
if (bytes == null || bytes.Length < offset + 4)
|
||||
if (bytes is null || bytes.Length < offset + 4)
|
||||
return default;
|
||||
|
||||
return bytes.ReadInt32BigEndian(ref offset);
|
||||
@@ -294,7 +294,7 @@ namespace MPF.Processors
|
||||
public static string? GetPICIdentifier(DiscInformation? di)
|
||||
{
|
||||
// If we don't have valid disc information, we can't do anything
|
||||
if (di?.Units == null || di.Units.Length < 1)
|
||||
if (di?.Units is null || di.Units.Length < 1)
|
||||
return null;
|
||||
|
||||
// Assume the identifier is consistent across all units
|
||||
@@ -309,7 +309,7 @@ namespace MPF.Processors
|
||||
public static string NormalizeShiftJIS(byte[]? contents)
|
||||
{
|
||||
// Invalid arrays are passed as-is
|
||||
if (contents == null || contents.Length == 0)
|
||||
if (contents is null || contents.Length == 0)
|
||||
return string.Empty;
|
||||
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
@@ -332,7 +332,7 @@ namespace MPF.Processors
|
||||
internal static bool BytesContainsShiftJIS(byte[] bytes)
|
||||
{
|
||||
// Invalid arrays do not count
|
||||
if (bytes == null || bytes.Length == 0)
|
||||
if (bytes is null || bytes.Length == 0)
|
||||
return false;
|
||||
|
||||
// Loop through and check each pair of bytes
|
||||
@@ -401,6 +401,7 @@ namespace MPF.Processors
|
||||
{
|
||||
// string publisher = serial[0] + serial[1];
|
||||
// char secondRegion = serial[3];
|
||||
#pragma warning disable IDE0010
|
||||
switch (serial[2])
|
||||
{
|
||||
case 'A': return Region.Asia;
|
||||
@@ -433,6 +434,7 @@ namespace MPF.Processors
|
||||
_ => (Region?)Region.Japan,
|
||||
};
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
// Japan-only special serial
|
||||
@@ -505,8 +507,8 @@ namespace MPF.Processors
|
||||
return false;
|
||||
|
||||
// Create conversion delegates
|
||||
byte _btoi(byte b) => (byte)(b / 16 * 10 + b % 16);
|
||||
byte _itob(byte i) => (byte)(i / 10 * 16 + i % 10);
|
||||
byte _btoi(byte b) => (byte)((b / 16 * 10) + (b % 16));
|
||||
byte _itob(byte i) => (byte)((i / 10 * 16) + (i % 10));
|
||||
|
||||
try
|
||||
{
|
||||
@@ -558,7 +560,7 @@ namespace MPF.Processors
|
||||
time++;
|
||||
|
||||
expected[3] = _itob((byte)(time / 60 / 75));
|
||||
expected[4] = _itob((byte)((time / 75) % 60));
|
||||
expected[4] = _itob((byte)(time / 75 % 60));
|
||||
expected[5] = _itob((byte)(time % 75));
|
||||
}
|
||||
|
||||
@@ -567,7 +569,7 @@ namespace MPF.Processors
|
||||
|
||||
// MSF2 [7-9]
|
||||
expected[7] = _itob((byte)(sector / 60 / 75));
|
||||
expected[8] = _itob((byte)((sector / 75) % 60));
|
||||
expected[8] = _itob((byte)(sector / 75 % 60));
|
||||
expected[9] = _itob((byte)(sector % 75));
|
||||
|
||||
// CRC-16 [10-11] -- TODO: Ensure byte order is correct
|
||||
@@ -625,15 +627,15 @@ namespace MPF.Processors
|
||||
|
||||
// Determine whether GetKey was successful
|
||||
string? line;
|
||||
while ((line = sr.ReadLine()) != null && line.Trim().StartsWith("get_dec_key succeeded!") == false) ;
|
||||
if (line == null)
|
||||
while ((line = sr.ReadLine()) is not null && !line.Trim().StartsWith("get_dec_key succeeded!")) ;
|
||||
if (line is null)
|
||||
return false;
|
||||
|
||||
// Look for Disc Key in log
|
||||
while ((line = sr.ReadLine()) != null && line.Trim().StartsWith("disc_key = ") == false) ;
|
||||
while ((line = sr.ReadLine()) is not null && !line.Trim().StartsWith("disc_key = ")) ;
|
||||
|
||||
// If end of file reached, no key found
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return false;
|
||||
|
||||
// Get Disc Key from log
|
||||
@@ -649,14 +651,14 @@ namespace MPF.Processors
|
||||
|
||||
// Convert Disc Key to byte array
|
||||
key = discKeyStr;
|
||||
if (key == null)
|
||||
if (key is null)
|
||||
return false;
|
||||
|
||||
// Read Disc ID
|
||||
while ((line = sr.ReadLine()) != null && line.Trim().StartsWith("disc_id = ") == false) ;
|
||||
while ((line = sr.ReadLine()) is not null && !line.Trim().StartsWith("disc_id = ")) ;
|
||||
|
||||
// If end of file reached, no ID found
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return false;
|
||||
|
||||
// Get Disc ID from log
|
||||
@@ -679,21 +681,21 @@ namespace MPF.Processors
|
||||
|
||||
// Convert Disc ID to byte array
|
||||
id = discIDStr;
|
||||
if (id == null)
|
||||
if (id is null)
|
||||
return false;
|
||||
|
||||
// Look for PIC in log
|
||||
while ((line = sr.ReadLine()) != null && line.Trim().StartsWith("PIC:") == false) ;
|
||||
while ((line = sr.ReadLine()) is not null && !line.Trim().StartsWith("PIC:")) ;
|
||||
|
||||
// If end of file reached, no PIC found
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return false;
|
||||
|
||||
// Get PIC from log
|
||||
string discPICStr = "";
|
||||
for (int i = 0; i < 9; i++)
|
||||
discPICStr += sr.ReadLine();
|
||||
if (discPICStr == null)
|
||||
if (discPICStr is null)
|
||||
return false;
|
||||
|
||||
// Validate PIC from log
|
||||
@@ -702,11 +704,11 @@ namespace MPF.Processors
|
||||
|
||||
// Convert PIC to byte array
|
||||
pic = discPICStr;
|
||||
if (pic == null)
|
||||
if (pic is null)
|
||||
return false;
|
||||
|
||||
// Double check for warnings in .getkey.log
|
||||
while ((line = sr.ReadLine()) != null)
|
||||
while ((line = sr.ReadLine()) is not null)
|
||||
{
|
||||
string t = line.Trim();
|
||||
if (t.StartsWith("WARNING"))
|
||||
@@ -952,10 +954,10 @@ namespace MPF.Processors
|
||||
return null;
|
||||
|
||||
byte[]? crc32 = inputCRC32.FromHexString();
|
||||
if (crc32 == null || crc32.Length != 4)
|
||||
if (crc32 is null || crc32.Length != 4)
|
||||
return null;
|
||||
|
||||
return (uint)(0x01000000 * crc32[0] + 0x00010000 * crc32[1] + 0x00000100 * crc32[2] + 0x00000001 * crc32[3]);
|
||||
return (uint)((0x01000000 * crc32[0]) + (0x00010000 * crc32[1]) + (0x00000100 * crc32[2]) + (0x00000001 * crc32[3]));
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -1162,6 +1164,7 @@ namespace MPF.Processors
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (emptyResponse)
|
||||
return true;
|
||||
}
|
||||
@@ -1439,33 +1442,32 @@ namespace MPF.Processors
|
||||
else
|
||||
numRanges = 4;
|
||||
|
||||
|
||||
uint[] startLBA = new uint[numRanges];
|
||||
uint[] endLBA = new uint[numRanges];
|
||||
for (uint i = 0; i < numRanges; i++)
|
||||
{
|
||||
// Determine range Physical Sector Number
|
||||
uint startPSN = (uint)((((ss[i * 9 + 1636] << 8) | ss[i * 9 + 1637]) << 8) | ss[i * 9 + 1638]);
|
||||
uint endPSN = (uint)((((ss[i * 9 + 1639] << 8) | ss[i * 9 + 1640]) << 8) | ss[i * 9 + 1641]);
|
||||
uint startPSN = (uint)((((ss[(i * 9) + 1636] << 8) | ss[(i * 9) + 1637]) << 8) | ss[(i * 9) + 1638]);
|
||||
uint endPSN = (uint)((((ss[(i * 9) + 1639] << 8) | ss[(i * 9) + 1640]) << 8) | ss[(i * 9) + 1641]);
|
||||
|
||||
// Determine range Logical Sector Number
|
||||
if (xgdType == 1 && startPSN >= (1913776 + 0x030000))
|
||||
{
|
||||
// Layer 1 of XGD1
|
||||
startLBA[i] = (1913776 + 0x030000) * 2 - (startPSN ^ 0xFFFFFF) - 0x030000 - 1;
|
||||
endLBA[i] = (1913776 + 0x030000) * 2 - (endPSN ^ 0xFFFFFF) - 0x030000 - 1;
|
||||
startLBA[i] = ((1913776 + 0x030000) * 2) - (startPSN ^ 0xFFFFFF) - 0x030000 - 1;
|
||||
endLBA[i] = ((1913776 + 0x030000) * 2) - (endPSN ^ 0xFFFFFF) - 0x030000 - 1;
|
||||
}
|
||||
else if (xgdType == 2 && startPSN >= (1913760 + 0x030000))
|
||||
{
|
||||
// Layer 1 of XGD2
|
||||
startLBA[i] = (1913760 + 0x030000) * 2 - (startPSN ^ 0xFFFFFF) - 0x030000 - 1;
|
||||
endLBA[i] = (1913760 + 0x030000) * 2 - (endPSN ^ 0xFFFFFF) - 0x030000 - 1;
|
||||
startLBA[i] = ((1913760 + 0x030000) * 2) - (startPSN ^ 0xFFFFFF) - 0x030000 - 1;
|
||||
endLBA[i] = ((1913760 + 0x030000) * 2) - (endPSN ^ 0xFFFFFF) - 0x030000 - 1;
|
||||
}
|
||||
else if (xgdType == 3 && startPSN >= (2133520 + 0x030000))
|
||||
{
|
||||
// Layer 1 of XGD3
|
||||
startLBA[i] = (2133520 + 0x030000) * 2 - (startPSN ^ 0xFFFFFF) - 0x030000 - 1;
|
||||
endLBA[i] = (2133520 + 0x030000) * 2 - (endPSN ^ 0xFFFFFF) - 0x030000 - 1;
|
||||
startLBA[i] = ((2133520 + 0x030000) * 2) - (startPSN ^ 0xFFFFFF) - 0x030000 - 1;
|
||||
endLBA[i] = ((2133520 + 0x030000) * 2) - (endPSN ^ 0xFFFFFF) - 0x030000 - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace MPF.Processors
|
||||
logEntry?.WriteToFile(logPath, new ExtractionOptions { ExtractFullPath = false, Overwrite = true });
|
||||
}
|
||||
catch { }
|
||||
|
||||
logArchive?.Dispose();
|
||||
}
|
||||
#endif
|
||||
@@ -152,6 +153,7 @@ namespace MPF.Processors
|
||||
}
|
||||
|
||||
// Extract info based generically on MediaType
|
||||
#pragma warning disable IDE0010
|
||||
switch (mediaType)
|
||||
{
|
||||
case MediaType.CDROM:
|
||||
@@ -161,8 +163,8 @@ namespace MPF.Processors
|
||||
// Attempt to get the error count
|
||||
if (GetErrorCount($"{basePath}.log", out long redumpErrors, out long c2Errors))
|
||||
{
|
||||
info.CommonDiscInfo.ErrorsCount = (redumpErrors == -1 ? "Error retrieving error count" : redumpErrors.ToString());
|
||||
info.DumpingInfo.C2ErrorsCount = (c2Errors == -1 ? "Error retrieving error count" : c2Errors.ToString());
|
||||
info.CommonDiscInfo.ErrorsCount = redumpErrors == -1 ? "Error retrieving error count" : redumpErrors.ToString();
|
||||
info.DumpingInfo.C2ErrorsCount = c2Errors == -1 ? "Error retrieving error count" : c2Errors.ToString();
|
||||
}
|
||||
|
||||
// Attempt to get extra metadata if it's an audio disc
|
||||
@@ -205,7 +207,7 @@ namespace MPF.Processors
|
||||
|
||||
// Attempt to get the error count
|
||||
long scsiErrors = GetSCSIErrorCount($"{basePath}.log");
|
||||
info.CommonDiscInfo.ErrorsCount = (scsiErrors == -1 ? "Error retrieving error count" : scsiErrors.ToString());
|
||||
info.CommonDiscInfo.ErrorsCount = scsiErrors == -1 ? "Error retrieving error count" : scsiErrors.ToString();
|
||||
|
||||
// Bluray-specific options
|
||||
if (mediaType == MediaType.BluRay || mediaType == MediaType.NintendoWiiUOpticalDisc)
|
||||
@@ -309,15 +311,15 @@ namespace MPF.Processors
|
||||
}
|
||||
|
||||
string? dmiCrc = HashTool.GetFileHash($"{basePath}.dmi", HashType.CRC32);
|
||||
if (dmiCrc != null)
|
||||
if (dmiCrc is not null)
|
||||
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.DMIHash] = dmiCrc.ToUpperInvariant();
|
||||
string? pfiCrc = HashTool.GetFileHash($"{basePath}.pfi", HashType.CRC32);
|
||||
if (pfiCrc != null)
|
||||
if (pfiCrc is not null)
|
||||
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.PFIHash] = pfiCrc.ToUpperInvariant();
|
||||
if (ProcessingTool.IsValidSS($"{basePath}.ss") && !ProcessingTool.IsValidPartialSS($"{basePath}.ss"))
|
||||
{
|
||||
string? ssCrc = HashTool.GetFileHash($"{basePath}.ss", HashType.CRC32);
|
||||
if (ssCrc != null)
|
||||
if (ssCrc is not null)
|
||||
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSHash] = ssCrc.ToUpperInvariant();
|
||||
}
|
||||
|
||||
@@ -340,6 +342,7 @@ namespace MPF.Processors
|
||||
// TODO: Support region setting from parsed value
|
||||
info.VersionAndEditions.Version = version ?? string.Empty;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RedumpSystem.SegaMegaCDSegaCD:
|
||||
@@ -362,6 +365,7 @@ namespace MPF.Processors
|
||||
// TODO: Support region setting from parsed value
|
||||
info.VersionAndEditions.Version = version ?? string.Empty;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RedumpSystem.SegaDreamcast:
|
||||
@@ -377,6 +381,7 @@ namespace MPF.Processors
|
||||
// TODO: Support region setting from parsed value
|
||||
info.VersionAndEditions.Version = version ?? string.Empty;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RedumpSystem.SegaNaomi:
|
||||
@@ -392,6 +397,7 @@ namespace MPF.Processors
|
||||
// TODO: Support region setting from parsed value
|
||||
info.VersionAndEditions.Version = version ?? string.Empty;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RedumpSystem.SegaNaomi2:
|
||||
@@ -407,6 +413,7 @@ namespace MPF.Processors
|
||||
// TODO: Support region setting from parsed value
|
||||
info.VersionAndEditions.Version = version ?? string.Empty;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RedumpSystem.SegaSaturn:
|
||||
@@ -443,7 +450,7 @@ namespace MPF.Processors
|
||||
}
|
||||
|
||||
string? ps2Protection = GetPlayStation2Protection($"{basePath}.log");
|
||||
if (ps2Protection != null)
|
||||
if (ps2Protection is not null)
|
||||
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.Protection] = ps2Protection;
|
||||
|
||||
break;
|
||||
@@ -475,6 +482,7 @@ namespace MPF.Processors
|
||||
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -488,6 +496,7 @@ namespace MPF.Processors
|
||||
if (!string.IsNullOrEmpty(outputDirectory))
|
||||
basePath = Path.Combine(outputDirectory, basePath);
|
||||
|
||||
#pragma warning disable IDE0010
|
||||
switch (mediaType)
|
||||
{
|
||||
case MediaType.CDROM:
|
||||
@@ -696,6 +705,7 @@ namespace MPF.Processors
|
||||
"state_zst"),
|
||||
];
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
|
||||
return [];
|
||||
}
|
||||
@@ -711,7 +721,7 @@ namespace MPF.Processors
|
||||
private static bool DatfileExists(string log)
|
||||
{
|
||||
// Uncompressed outputs
|
||||
if (GetDatfile(log) != null)
|
||||
if (GetDatfile(log) is not null)
|
||||
return true;
|
||||
|
||||
// Check for the log file
|
||||
@@ -745,11 +755,11 @@ namespace MPF.Processors
|
||||
}
|
||||
}
|
||||
|
||||
if (logEntry == null)
|
||||
if (logEntry is null)
|
||||
return false;
|
||||
|
||||
using var sr = new StreamReader(logEntry.OpenEntryStream());
|
||||
return GetDatfile(sr) != null;
|
||||
return GetDatfile(sr) is not null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -967,7 +977,7 @@ namespace MPF.Processors
|
||||
{
|
||||
using var sr = File.OpenText(log);
|
||||
var line = sr.ReadLine();
|
||||
while (line != null)
|
||||
while (line is not null)
|
||||
{
|
||||
// Trim the line for later use
|
||||
line = line.Trim();
|
||||
@@ -1016,7 +1026,7 @@ namespace MPF.Processors
|
||||
{
|
||||
using var sr = File.OpenText(log);
|
||||
var line = sr.ReadLine()?.TrimEnd();
|
||||
while (line != null)
|
||||
while (line is not null)
|
||||
{
|
||||
// If the line isn't the non-embedded disc type, skip
|
||||
if (!line.StartsWith("disc type:"))
|
||||
@@ -1042,7 +1052,7 @@ namespace MPF.Processors
|
||||
"HD-DVD" => MediaType.HDDVD,
|
||||
_ => null,
|
||||
};
|
||||
return discType != null;
|
||||
return discType is not null;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -1135,7 +1145,7 @@ namespace MPF.Processors
|
||||
|
||||
// Now read until we hit the manufacturing information
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
while (line != null && !sr.EndOfStream)
|
||||
while (line is not null && !sr.EndOfStream)
|
||||
{
|
||||
if (line.StartsWith("protection system type"))
|
||||
{
|
||||
@@ -1249,7 +1259,7 @@ namespace MPF.Processors
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
// C2: <error count>
|
||||
@@ -1357,7 +1367,7 @@ namespace MPF.Processors
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
line = sr.ReadLine()?.TrimStart();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
if (line.StartsWith("build date:"))
|
||||
@@ -1451,7 +1461,7 @@ namespace MPF.Processors
|
||||
var regex = new Regex(@"drive: (.+) - (.+) \(revision level: (.+), vendor specific: (.+)\)", RegexOptions.Compiled);
|
||||
|
||||
string? line;
|
||||
while ((line = sr.ReadLine()) != null)
|
||||
while ((line = sr.ReadLine()) is not null)
|
||||
{
|
||||
var match = regex.Match(line.Trim());
|
||||
if (match.Success)
|
||||
@@ -1499,7 +1509,7 @@ namespace MPF.Processors
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
|
||||
// If we have a null line, just break
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
// Single-layer discs have no layerbreak
|
||||
@@ -1595,7 +1605,7 @@ namespace MPF.Processors
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
|
||||
// If we have a null line, just break
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
// Store the first session range
|
||||
@@ -1651,7 +1661,7 @@ namespace MPF.Processors
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
|
||||
// If we have a null line, just break
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
if (line.StartsWith("anti-modchip: no"))
|
||||
@@ -1691,7 +1701,7 @@ namespace MPF.Processors
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
|
||||
// If we have a null line, just break
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
if (line.Contains("EDC: no"))
|
||||
@@ -1740,13 +1750,14 @@ namespace MPF.Processors
|
||||
line?.StartsWith("PS5 [") == true)
|
||||
break;
|
||||
}
|
||||
|
||||
if (sr.EndOfStream)
|
||||
return false;
|
||||
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
line = sr.ReadLine()?.TrimStart();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
if (line.StartsWith("anti-modchip:"))
|
||||
@@ -1862,7 +1873,7 @@ namespace MPF.Processors
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return false;
|
||||
|
||||
if (line.StartsWith("libcrypt: no"))
|
||||
@@ -1902,7 +1913,7 @@ namespace MPF.Processors
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
return null;
|
||||
|
||||
if (line.StartsWith("protection: PS2"))
|
||||
@@ -2151,7 +2162,7 @@ namespace MPF.Processors
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
line = sr.ReadLine()?.TrimStart();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
if (line.StartsWith("build date:"))
|
||||
@@ -2252,7 +2263,7 @@ namespace MPF.Processors
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
// SCSI: <error count>
|
||||
@@ -2392,7 +2403,7 @@ namespace MPF.Processors
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
line = sr.ReadLine()?.TrimStart();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
if (line.StartsWith("build date:"))
|
||||
@@ -2595,7 +2606,7 @@ namespace MPF.Processors
|
||||
using var sr = File.OpenText(log);
|
||||
var line = sr.ReadLine();
|
||||
|
||||
while (line != null)
|
||||
while (line is not null)
|
||||
{
|
||||
// Trim the line for later use
|
||||
line = line.Trim();
|
||||
@@ -2610,7 +2621,7 @@ namespace MPF.Processors
|
||||
#endif
|
||||
|
||||
// Skip if label is blank
|
||||
if (label == null || label.Length <= 0)
|
||||
if (label is null || label.Length <= 0)
|
||||
break;
|
||||
|
||||
if (volLabels.ContainsKey(label))
|
||||
|
||||
@@ -177,18 +177,18 @@ namespace MPF.Processors
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
string? line = sr.ReadLine()?.Trim();
|
||||
if (line == null)
|
||||
if (line is null)
|
||||
break;
|
||||
|
||||
if (line.StartsWith("TITLE") && title == null)
|
||||
if (line.StartsWith("TITLE") && title is null)
|
||||
#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
|
||||
title = line["TITLE: ".Length..];
|
||||
#else
|
||||
title = line.Substring("TITLE: ".Length);
|
||||
#endif
|
||||
else if (line.StartsWith("DISC_ID") && version == null)
|
||||
else if (line.StartsWith("DISC_ID") && version is null)
|
||||
serial = line.Split(' ')[1];
|
||||
else if (line.StartsWith("DISC_VERSION") && version == null)
|
||||
else if (line.StartsWith("DISC_VERSION") && version is null)
|
||||
version = line.Split(' ')[1];
|
||||
else if (line.StartsWith("pspUmdTypes"))
|
||||
category = ProcessingTool.GetUMDCategory(line.Split(' ')[2]);
|
||||
@@ -239,7 +239,7 @@ namespace MPF.Processors
|
||||
|
||||
string volType = "UNKNOWN";
|
||||
string label;
|
||||
while (line != null)
|
||||
while (line is not null)
|
||||
{
|
||||
// Trim the line for later use
|
||||
line = line.Trim();
|
||||
@@ -285,7 +285,7 @@ namespace MPF.Processors
|
||||
#endif
|
||||
|
||||
// Skip if label is blank
|
||||
if (label == null || label.Length <= 0)
|
||||
if (label is null || label.Length <= 0)
|
||||
{
|
||||
volType = "UNKNOWN";
|
||||
line = sr.ReadLine();
|
||||
|
||||
@@ -60,12 +60,13 @@ namespace MPF.Processors
|
||||
if (GetReadErrors(logPath, out long readErrors))
|
||||
info.CommonDiscInfo.ErrorsCount = readErrors == -1 ? "Error retrieving error count" : readErrors.ToString();
|
||||
|
||||
#pragma warning disable IDE0010
|
||||
switch (System)
|
||||
{
|
||||
case RedumpSystem.MicrosoftXbox:
|
||||
string xmidString = ProcessingTool.GetXMID(Path.Combine(outputDirectory, "DMI.bin"));
|
||||
var xmid = SabreTools.Serialization.Wrappers.XMID.Create(xmidString);
|
||||
if (xmid != null)
|
||||
if (xmid is not null)
|
||||
{
|
||||
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.XMID] = xmidString?.TrimEnd('\0') ?? string.Empty;
|
||||
info.CommonDiscInfo.Serial = xmid.Serial ?? string.Empty;
|
||||
@@ -90,7 +91,7 @@ namespace MPF.Processors
|
||||
// Parse DMI.bin
|
||||
string xemidString = ProcessingTool.GetXeMID(Path.Combine(outputDirectory, "DMI.bin"));
|
||||
var xemid = SabreTools.Serialization.Wrappers.XeMID.Create(xemidString);
|
||||
if (xemid != null)
|
||||
if (xemid is not null)
|
||||
{
|
||||
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.XeMID] = xemidString?.TrimEnd('\0') ?? string.Empty;
|
||||
info.CommonDiscInfo.Serial = xemid.Serial ?? string.Empty;
|
||||
@@ -102,6 +103,7 @@ namespace MPF.Processors
|
||||
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
|
||||
// Get the output file paths
|
||||
string dmiPath = Path.Combine(outputDirectory, "DMI.bin");
|
||||
@@ -600,7 +602,7 @@ namespace MPF.Processors
|
||||
if (i >= 4 && i <= 7)
|
||||
{
|
||||
byte[]? angles = line!.Substring(34, 10).FromHexString();
|
||||
if (angles == null || angles.Length != 5)
|
||||
if (angles is null || angles.Length != 5)
|
||||
return false;
|
||||
responses[i - 4] = angles!;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Markup;
|
||||
|
||||
#pragma warning disable IDE0051 // Remove unused private members
|
||||
namespace MPF.UI
|
||||
{
|
||||
/// <summary>
|
||||
@@ -10,7 +11,6 @@ namespace MPF.UI
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
|
||||
#if NET35_OR_GREATER || NETCOREAPP
|
||||
|
||||
#region ControlTemplates
|
||||
|
||||
@@ -99,6 +99,7 @@ namespace WPFCustomMessageBox
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, int? timeout = null, MessageBoxResult timeoutResult = MessageBoxResult.None)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return button switch
|
||||
{
|
||||
MessageBoxButton.YesNo
|
||||
@@ -106,6 +107,7 @@ namespace WPFCustomMessageBox
|
||||
|
||||
_ => ShowOKMessage(null, messageBoxText, caption, null, null, null, timeout, timeoutResult),
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -123,6 +125,7 @@ namespace WPFCustomMessageBox
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, int? timeout = null, MessageBoxResult timeoutResult = MessageBoxResult.None)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return button switch
|
||||
{
|
||||
MessageBoxButton.YesNo
|
||||
@@ -130,6 +133,7 @@ namespace WPFCustomMessageBox
|
||||
|
||||
_ => ShowOKMessage(owner, messageBoxText, caption, null, null, null, timeout, timeoutResult),
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -147,6 +151,7 @@ namespace WPFCustomMessageBox
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, int? timeout = null, MessageBoxResult timeoutResult = MessageBoxResult.None)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return button switch
|
||||
{
|
||||
MessageBoxButton.YesNo
|
||||
@@ -154,6 +159,7 @@ namespace WPFCustomMessageBox
|
||||
|
||||
_ => ShowOKMessage(null, messageBoxText, caption, null, null, icon, timeout, timeoutResult),
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -172,6 +178,7 @@ namespace WPFCustomMessageBox
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult Show(Window owner, string? messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, int? timeout = null, MessageBoxResult timeoutResult = MessageBoxResult.None)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return button switch
|
||||
{
|
||||
MessageBoxButton.YesNo
|
||||
@@ -179,6 +186,7 @@ namespace WPFCustomMessageBox
|
||||
|
||||
_ => ShowOKMessage(owner, messageBoxText, caption, null, null, icon, timeout, timeoutResult),
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -497,7 +505,6 @@ namespace WPFCustomMessageBox
|
||||
return ShowYesNoMessage(owner, messageBoxText, caption, yesButtonText, noButtonText, cancelButtonText, icon, timeout, timeoutResult);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box that has a message, caption, OK/Cancel buttons with custom System.String values for the buttons' text, and icon;
|
||||
/// and that returns a result.
|
||||
@@ -526,7 +533,6 @@ namespace WPFCustomMessageBox
|
||||
return msg.Result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box that has a message, caption, Yes/No/Cancel buttons with custom System.String values for the buttons' text, and icon;
|
||||
/// and that returns a result.
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace WPFCustomMessageBox
|
||||
ShowActivated = true;
|
||||
ShowInTaskbar = true;
|
||||
|
||||
if (owner != null && owner.IsLoaded)
|
||||
if (owner is not null && owner.IsLoaded)
|
||||
{
|
||||
Owner = owner;
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
@@ -154,6 +154,7 @@ namespace WPFCustomMessageBox
|
||||
|
||||
private void DisplayButtons(MessageBoxButton button)
|
||||
{
|
||||
#pragma warning disable IDE0010
|
||||
switch (button)
|
||||
{
|
||||
case MessageBoxButton.OKCancel:
|
||||
@@ -193,10 +194,12 @@ namespace WPFCustomMessageBox
|
||||
Button_Cancel!.Visibility = Visibility.Collapsed;
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
private void DisplayImage(MessageBoxImage image)
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
Icon icon = image switch
|
||||
{
|
||||
// Enumeration value 48 - also covers "Warning"
|
||||
@@ -211,6 +214,7 @@ namespace WPFCustomMessageBox
|
||||
MessageBoxImage.Question => SystemIcons.Question,
|
||||
_ => SystemIcons.Information,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
|
||||
Image_MessageBox!.Source = icon.ToImageSource();
|
||||
Image_MessageBox.Visibility = Visibility.Visible;
|
||||
|
||||
23
MPF.UI/External/WPFCustomMessageBox/Util.cs
vendored
23
MPF.UI/External/WPFCustomMessageBox/Util.cs
vendored
@@ -20,26 +20,25 @@ namespace WPFCustomMessageBox
|
||||
internal static class Util
|
||||
{
|
||||
[DllImport("user32.dll")]
|
||||
static extern int GetWindowLong(IntPtr hwnd, int index);
|
||||
public static extern int GetWindowLong(IntPtr hwnd, int index);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle);
|
||||
public static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, int x, int y, int width, int height, uint flags);
|
||||
public static extern bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, int x, int y, int width, int height, uint flags);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern IntPtr SendMessage(IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam);
|
||||
public static extern IntPtr SendMessage(IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
const int GWL_EXSTYLE = -20;
|
||||
const int WS_EX_DLGMODALFRAME = 0x0001;
|
||||
const int SWP_NOSIZE = 0x0001;
|
||||
const int SWP_NOMOVE = 0x0002;
|
||||
const int SWP_NOZORDER = 0x0004;
|
||||
const int SWP_FRAMECHANGED = 0x0020;
|
||||
private const int GWL_EXSTYLE = -20;
|
||||
private const int WS_EX_DLGMODALFRAME = 0x0001;
|
||||
private const int SWP_NOSIZE = 0x0001;
|
||||
private const int SWP_NOMOVE = 0x0002;
|
||||
private const int SWP_NOZORDER = 0x0004;
|
||||
private const int SWP_FRAMECHANGED = 0x0020;
|
||||
//const uint WM_SETICON = 0x0080;
|
||||
|
||||
|
||||
internal static ImageSource ToImageSource(this Icon icon)
|
||||
{
|
||||
ImageSource imageSource = Imaging.CreateBitmapSourceFromHIcon(
|
||||
@@ -62,7 +61,7 @@ namespace WPFCustomMessageBox
|
||||
/// <returns></returns>
|
||||
internal static string? TryAddKeyboardAccellerator(this string? input)
|
||||
{
|
||||
if (input == null)
|
||||
if (input is null)
|
||||
return input;
|
||||
|
||||
const string accellerator = "_"; // This is the default WPF accellerator symbol - used to be & in WinForms
|
||||
|
||||
@@ -18,11 +18,11 @@ namespace MPF.UI
|
||||
public static TDependencyObject? FindChild<TDependencyObject>(DependencyObject? parent, string childName) where TDependencyObject : DependencyObject
|
||||
{
|
||||
// Confirm parent and childName are valid.
|
||||
if (parent == null) return null;
|
||||
if (parent is null) return null;
|
||||
|
||||
TDependencyObject? foundChild = null;
|
||||
|
||||
if (parent is ItemsControl itemsControl && itemsControl.Items != null)
|
||||
if (parent is ItemsControl itemsControl && itemsControl.Items is not null)
|
||||
{
|
||||
int childrenCount = itemsControl.Items.Count;
|
||||
for (int i = 0; i < childrenCount; i++)
|
||||
@@ -36,7 +36,7 @@ namespace MPF.UI
|
||||
foundChild = FindChild<TDependencyObject>(child, childName);
|
||||
|
||||
// If the child is found, break so we do not overwrite the found child.
|
||||
if (foundChild != null)
|
||||
if (foundChild is not null)
|
||||
break;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(childName))
|
||||
@@ -57,7 +57,7 @@ namespace MPF.UI
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parent is ContentControl contentControl && contentControl.Content != null)
|
||||
else if (parent is ContentControl contentControl && contentControl.Content is not null)
|
||||
{
|
||||
var child = contentControl.Content as DependencyObject;
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace MPF.UI
|
||||
foundChild = FindChild<TDependencyObject>(child, childName);
|
||||
|
||||
// If the child is found, break so we do not overwrite the found child.
|
||||
if (foundChild != null)
|
||||
if (foundChild is not null)
|
||||
break;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(childName))
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace MPF.UI.UserControls
|
||||
public void EnqueueLog(LogLevel logLevel, string text)
|
||||
{
|
||||
// Null text gets ignored
|
||||
if (text == null)
|
||||
if (text is null)
|
||||
return;
|
||||
|
||||
// Create a new log line
|
||||
@@ -109,6 +109,7 @@ namespace MPF.UI.UserControls
|
||||
/// <returns>Brush representing the color</returns>
|
||||
public Brush GetForegroundColor()
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
return LogLevel switch
|
||||
{
|
||||
LogLevel.SECRET => Brushes.DarkGray,
|
||||
@@ -116,6 +117,7 @@ namespace MPF.UI.UserControls
|
||||
LogLevel.VERBOSE => Brushes.Yellow,
|
||||
_ => Brushes.White,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -279,10 +279,11 @@ namespace MPF.UI.Windows
|
||||
CreateIRDViewModel.CreateIRDStatus = "Creating IRD... Please Wait";
|
||||
string? outputPath = BrowseOutputFile();
|
||||
string? errorMessage = "Please provide an output path";
|
||||
if (outputPath != null)
|
||||
if (outputPath is not null)
|
||||
{
|
||||
errorMessage = CreateIRDViewModel.CreateIRD(outputPath);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(errorMessage))
|
||||
{
|
||||
bool? checkAgain = DisplayUserMessage("IRD Create", "An IRD has been created successfully! Would you like to create another IRD?", 2, false);
|
||||
|
||||
@@ -185,6 +185,7 @@ namespace MPF.UI.Windows
|
||||
|
||||
var dictionary = new ResourceDictionary
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
Source = lang switch
|
||||
{
|
||||
InterfaceLanguage.English => new Uri("../Resources/Strings.xaml", UriKind.Relative),
|
||||
@@ -201,6 +202,7 @@ namespace MPF.UI.Windows
|
||||
InterfaceLanguage.L337 => new Uri("../Resources/Strings.37.xaml", UriKind.Relative),
|
||||
_ => new Uri("../Resources/Strings.xaml", UriKind.Relative),
|
||||
}
|
||||
#pragma warning restore IDE0072
|
||||
};
|
||||
Application.Current.Resources.MergedDictionaries.Add(dictionary);
|
||||
|
||||
@@ -254,6 +256,7 @@ namespace MPF.UI.Windows
|
||||
{
|
||||
// TODO: Translate UI elements to Simplified Chinese
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -510,7 +513,7 @@ namespace MPF.UI.Windows
|
||||
}
|
||||
|
||||
// If there are no media types defined
|
||||
if (MainViewModel.MediaTypes == null)
|
||||
if (MainViewModel.MediaTypes is null)
|
||||
{
|
||||
SystemMediaTypeLabel!.Content = (string)Application.Current.FindResource("SystemLabelString");
|
||||
MediaTypeComboBox!.Visibility = Visibility.Hidden;
|
||||
@@ -627,8 +630,8 @@ namespace MPF.UI.Windows
|
||||
public void OnOptionsUpdated(object? sender, EventArgs e)
|
||||
{
|
||||
// Get the options window
|
||||
var optionsWindow = (sender as OptionsWindow);
|
||||
if (optionsWindow?.OptionsViewModel == null)
|
||||
var optionsWindow = sender as OptionsWindow;
|
||||
if (optionsWindow?.OptionsViewModel is null)
|
||||
return;
|
||||
|
||||
// Get if the settings were saved
|
||||
@@ -681,20 +684,20 @@ namespace MPF.UI.Windows
|
||||
/// <summary>
|
||||
/// Handler for AppExitMenuItem Click event
|
||||
/// </summary>
|
||||
public void AppExitClick(object sender, RoutedEventArgs e) =>
|
||||
Application.Current.Shutdown();
|
||||
public void AppExitClick(object sender, RoutedEventArgs e)
|
||||
=> Application.Current.Shutdown();
|
||||
|
||||
/// <summary>
|
||||
/// Handler for CheckDumpMenuItem Click event
|
||||
/// </summary>
|
||||
public void CheckDumpMenuItemClick(object sender, RoutedEventArgs e) =>
|
||||
ShowCheckDumpWindow();
|
||||
public void CheckDumpMenuItemClick(object sender, RoutedEventArgs e)
|
||||
=> ShowCheckDumpWindow();
|
||||
|
||||
/// <summary>
|
||||
/// Handler for CreateIRDMenuItem Click event
|
||||
/// </summary>
|
||||
public void CreateIRDMenuItemClick(object sender, RoutedEventArgs e) =>
|
||||
ShowCreateIRDWindow();
|
||||
public void CreateIRDMenuItemClick(object sender, RoutedEventArgs e)
|
||||
=> ShowCreateIRDWindow();
|
||||
|
||||
/// <summary>
|
||||
/// Handler for CheckForUpdatesMenuItem Click event
|
||||
@@ -705,14 +708,14 @@ namespace MPF.UI.Windows
|
||||
/// <summary>
|
||||
/// Handler for DebugViewMenuItem Click event
|
||||
/// </summary>
|
||||
public void DebugViewClick(object sender, RoutedEventArgs e) =>
|
||||
ShowDebugDiscInfoWindow();
|
||||
public void DebugViewClick(object sender, RoutedEventArgs e)
|
||||
=> ShowDebugDiscInfoWindow();
|
||||
|
||||
/// <summary>
|
||||
/// Handler for OptionsMenuItem Click event
|
||||
/// </summary>
|
||||
public void OptionsMenuItemClick(object sender, RoutedEventArgs e) =>
|
||||
ShowOptionsWindow();
|
||||
public void OptionsMenuItemClick(object sender, RoutedEventArgs e)
|
||||
=> ShowOptionsWindow();
|
||||
|
||||
/// <summary>
|
||||
/// Change UI language
|
||||
@@ -807,8 +810,8 @@ namespace MPF.UI.Windows
|
||||
/// <summary>
|
||||
/// Handler for MediaScanButton Click event
|
||||
/// </summary>
|
||||
public void MediaScanButtonClick(object sender, RoutedEventArgs e) =>
|
||||
MainViewModel.InitializeUIValues(removeEventHandlers: true, rebuildPrograms: false, rescanDrives: true);
|
||||
public void MediaScanButtonClick(object sender, RoutedEventArgs e)
|
||||
=> MainViewModel.InitializeUIValues(removeEventHandlers: true, rebuildPrograms: false, rescanDrives: true);
|
||||
|
||||
/// <summary>
|
||||
/// Handler for MediaTypeComboBox SelectionChanged event
|
||||
@@ -840,8 +843,8 @@ namespace MPF.UI.Windows
|
||||
/// <summary>
|
||||
/// Handler for StartStopButton Click event
|
||||
/// </summary>
|
||||
public void StartStopButtonClick(object sender, RoutedEventArgs e) =>
|
||||
MainViewModel.ToggleStartStop();
|
||||
public void StartStopButtonClick(object sender, RoutedEventArgs e)
|
||||
=> MainViewModel.ToggleStartStop();
|
||||
|
||||
/// <summary>
|
||||
/// Handler for SystemTypeComboBox SelectionChanged event
|
||||
|
||||
@@ -211,12 +211,12 @@ namespace MPF.UI.Windows
|
||||
private void HideReadOnlyFields(SubmissionInfo? submissionInfo)
|
||||
{
|
||||
// If there's no submission information
|
||||
if (submissionInfo == null)
|
||||
if (submissionInfo is null)
|
||||
return;
|
||||
|
||||
if (submissionInfo.FullyMatchedID == null)
|
||||
if (submissionInfo.FullyMatchedID is null)
|
||||
FullyMatchedID!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.PartiallyMatchedIDs == null || submissionInfo.PartiallyMatchedIDs.Count == 0)
|
||||
if (submissionInfo.PartiallyMatchedIDs is null || submissionInfo.PartiallyMatchedIDs.Count == 0)
|
||||
PartiallyMatchedIDs!.Visibility = Visibility.Collapsed;
|
||||
else
|
||||
PartiallyMatchedIDs!.Text = string.Join(", ", [.. submissionInfo.PartiallyMatchedIDs.ConvertAll(i => i.ToString())]);
|
||||
@@ -236,13 +236,13 @@ namespace MPF.UI.Windows
|
||||
HashDataLayerbreak2!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.SizeAndChecksums.Layerbreak3 == 0)
|
||||
HashDataLayerbreak3!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CopyProtection?.AntiModchip == null)
|
||||
if (submissionInfo.CopyProtection?.AntiModchip is null)
|
||||
AntiModchip!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.TracksAndWriteOffsets.OtherWriteOffsets == null)
|
||||
if (submissionInfo.TracksAndWriteOffsets.OtherWriteOffsets is null)
|
||||
DiscOffset!.Visibility = Visibility.Collapsed;
|
||||
if (ShouldCollapseComment(submissionInfo, SiteCode.DMIHash))
|
||||
DMIHash!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.EDC?.EDC == null)
|
||||
if (submissionInfo.EDC?.EDC is null)
|
||||
EDC!.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrEmpty(submissionInfo.CommonDiscInfo?.ErrorsCount))
|
||||
ErrorsCount!.Visibility = Visibility.Collapsed;
|
||||
@@ -258,7 +258,7 @@ namespace MPF.UI.Windows
|
||||
InternalSerialName!.Visibility = Visibility.Collapsed;
|
||||
if (ShouldCollapseComment(submissionInfo, SiteCode.Multisession))
|
||||
Multisession!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CopyProtection?.LibCrypt == null)
|
||||
if (submissionInfo.CopyProtection?.LibCrypt is null)
|
||||
LibCrypt!.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrEmpty(submissionInfo.CopyProtection?.LibCryptData))
|
||||
LibCryptData!.Visibility = Visibility.Collapsed;
|
||||
@@ -300,6 +300,7 @@ namespace MPF.UI.Windows
|
||||
var system = submissionInfo?.CommonDiscInfo?.System;
|
||||
bool reverseOrder = system.HasReversedRingcodes();
|
||||
|
||||
#pragma warning disable IDE0010
|
||||
switch (submissionInfo?.CommonDiscInfo?.Media)
|
||||
{
|
||||
case DiscType.CD:
|
||||
@@ -452,6 +453,7 @@ namespace MPF.UI.Windows
|
||||
L3Info!.Visibility = Visibility.Collapsed;
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -461,6 +463,7 @@ namespace MPF.UI.Windows
|
||||
private void UpdateFromSystemType(SubmissionInfo? submissionInfo)
|
||||
{
|
||||
var system = submissionInfo?.CommonDiscInfo?.System;
|
||||
#pragma warning disable IDE0010
|
||||
switch (system)
|
||||
{
|
||||
case RedumpSystem.AppleMacintosh:
|
||||
@@ -490,6 +493,7 @@ namespace MPF.UI.Windows
|
||||
DiscIDTextBox!.Visibility = Visibility.Visible;
|
||||
break;
|
||||
}
|
||||
#pragma warning restore IDE0010
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -498,7 +502,7 @@ namespace MPF.UI.Windows
|
||||
private static bool ShouldCollapseComment(SubmissionInfo? submissionInfo, SiteCode siteCode)
|
||||
{
|
||||
// If the special fields don't exist
|
||||
if (submissionInfo?.CommonDiscInfo?.CommentsSpecialFields == null)
|
||||
if (submissionInfo?.CommonDiscInfo?.CommentsSpecialFields is null)
|
||||
return true;
|
||||
|
||||
// If the key doesn't exist
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
#if NET40
|
||||
using System.Threading;
|
||||
#endif
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
@@ -97,7 +94,7 @@ namespace MPF.UI.Windows
|
||||
private void BrowseForPath(Window parent, System.Windows.Controls.Button? button)
|
||||
{
|
||||
// If the button is null, we can't do anything
|
||||
if (button == null)
|
||||
if (button is null)
|
||||
return;
|
||||
|
||||
// Strips button prefix to obtain the setting name
|
||||
@@ -116,7 +113,7 @@ namespace MPF.UI.Windows
|
||||
initialDirectory = Path.GetDirectoryName(Path.GetFullPath(currentPath));
|
||||
|
||||
CommonDialog dialog = shouldBrowseForPath
|
||||
? (CommonDialog)CreateFolderBrowserDialog()
|
||||
? CreateFolderBrowserDialog()
|
||||
: CreateOpenFileDialog(initialDirectory);
|
||||
using (dialog)
|
||||
{
|
||||
@@ -161,8 +158,8 @@ namespace MPF.UI.Windows
|
||||
/// </summary>
|
||||
/// <param name="name">Setting name to find</param>
|
||||
/// <returns>TextBox for that setting</returns>
|
||||
private static System.Windows.Controls.TextBox? TextBoxForPathSetting(Window parent, string name) =>
|
||||
parent.FindName(name + "TextBox") as System.Windows.Controls.TextBox;
|
||||
private static System.Windows.Controls.TextBox? TextBoxForPathSetting(Window parent, string name)
|
||||
=> parent.FindName(name + "TextBox") as System.Windows.Controls.TextBox;
|
||||
|
||||
/// <summary>
|
||||
/// Create an open folder dialog box
|
||||
@@ -208,8 +205,8 @@ namespace MPF.UI.Windows
|
||||
/// <summary>
|
||||
/// Handler for generic Click event
|
||||
/// </summary>
|
||||
private void BrowseForPathClick(object sender, EventArgs e) =>
|
||||
BrowseForPath(this, sender as System.Windows.Controls.Button);
|
||||
private void BrowseForPathClick(object sender, EventArgs e)
|
||||
=> BrowseForPath(this, sender as System.Windows.Controls.Button);
|
||||
|
||||
/// <summary>
|
||||
/// Alert user of non-redump mode implications
|
||||
|
||||
@@ -66,12 +66,15 @@ namespace MPF.UI.Windows
|
||||
|
||||
// Display and get the result
|
||||
MessageBoxResult result = CustomMessageBox.Show(this, message, title, button, image);
|
||||
|
||||
#pragma warning disable IDE0072
|
||||
return result switch
|
||||
{
|
||||
MessageBoxResult.OK or MessageBoxResult.Yes => true,
|
||||
MessageBoxResult.No => false,
|
||||
_ => null,
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user