mirror of
https://github.com/SabreTools/SabreTools.Skippers.git
synced 2026-07-08 18:06:10 +00:00
Add editorconfig, fix issues
This commit is contained in:
167
.editorconfig
Normal file
167
.editorconfig
Normal file
@@ -0,0 +1,167 @@
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# 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
|
||||
@@ -29,7 +29,7 @@ namespace Headerer
|
||||
Rule rule = SkipperMatch.GetMatchingRule(file, string.Empty);
|
||||
|
||||
// If we have an empty rule, return false
|
||||
if (rule.Tests == null || rule.Tests.Length == 0 || rule.Operation != HeaderSkipOperation.None)
|
||||
if (rule.Tests is null || rule.Tests.Length == 0 || rule.Operation != HeaderSkipOperation.None)
|
||||
return false;
|
||||
|
||||
Console.WriteLine("File has a valid copier header");
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Headerer
|
||||
public static Options? ParseOptions(string[] args)
|
||||
{
|
||||
// If we have invalid arguments
|
||||
if (args == null || args.Length == 0)
|
||||
if (args is null || args.Length == 0)
|
||||
return null;
|
||||
|
||||
// Create an Options object
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
var options = Options.ParseOptions(args);
|
||||
|
||||
// If we have an invalid state
|
||||
if (options == null)
|
||||
if (options is null)
|
||||
{
|
||||
Options.DisplayHelp();
|
||||
return;
|
||||
@@ -38,6 +38,10 @@
|
||||
case Feature.Restore:
|
||||
_ = Restore.RestoreHeader(inputPath, options.OutputDir);
|
||||
break;
|
||||
|
||||
case Feature.NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,14 +72,14 @@ namespace Headerer
|
||||
private static void AppendBytes(Stream input, Stream output, byte[]? bytesToAddToHead, byte[]? bytesToAddToTail)
|
||||
{
|
||||
// Write out prepended bytes
|
||||
if (bytesToAddToHead != null && bytesToAddToHead.Length > 0)
|
||||
if (bytesToAddToHead is not null && bytesToAddToHead.Length > 0)
|
||||
output.Write(bytesToAddToHead, 0, bytesToAddToHead.Length);
|
||||
|
||||
// Now copy the existing file over
|
||||
input.CopyTo(output);
|
||||
|
||||
// Write out appended bytes
|
||||
if (bytesToAddToTail != null && bytesToAddToTail.Length > 0)
|
||||
if (bytesToAddToTail is not null && bytesToAddToTail.Length > 0)
|
||||
output.Write(bytesToAddToTail, 0, bytesToAddToTail.Length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace SabreTools.Skippers
|
||||
private Rule? GetMatchingRule(Stream input)
|
||||
{
|
||||
// If we have no rules
|
||||
if (Rules == null)
|
||||
if (Rules is null)
|
||||
return null;
|
||||
|
||||
// Loop through the rules until one is found that works
|
||||
|
||||
@@ -17,10 +17,10 @@ namespace SabreTools.Skippers
|
||||
[XmlAttribute("start_offset")]
|
||||
public string? StartOffset
|
||||
{
|
||||
get => _startOffset == null ? "EOF" : _startOffset.Value.ToString();
|
||||
get => _startOffset is null ? "EOF" : _startOffset.Value.ToString();
|
||||
set
|
||||
{
|
||||
if (value == null || value.Equals("eof", StringComparison.OrdinalIgnoreCase))
|
||||
if (value is null || value.Equals("eof", StringComparison.OrdinalIgnoreCase))
|
||||
_startOffset = null;
|
||||
else
|
||||
_startOffset = Convert.ToInt64(value, fromBase: 16);
|
||||
@@ -34,10 +34,10 @@ namespace SabreTools.Skippers
|
||||
[XmlAttribute("end_offset")]
|
||||
public string? EndOffset
|
||||
{
|
||||
get => _endOffset == null ? "EOF" : _endOffset.Value.ToString();
|
||||
get => _endOffset is null ? "EOF" : _endOffset.Value.ToString();
|
||||
set
|
||||
{
|
||||
if (value == null || value.Equals("eof", StringComparison.OrdinalIgnoreCase))
|
||||
if (value is null || value.Equals("eof", StringComparison.OrdinalIgnoreCase))
|
||||
_endOffset = null;
|
||||
else
|
||||
_endOffset = Convert.ToInt64(value, fromBase: 16);
|
||||
@@ -106,7 +106,7 @@ namespace SabreTools.Skippers
|
||||
bool success = true;
|
||||
|
||||
// If there are no tests
|
||||
if (Tests == null || Tests.Length == 0)
|
||||
if (Tests is null || Tests.Length == 0)
|
||||
return success;
|
||||
|
||||
foreach (Test test in Tests)
|
||||
@@ -164,14 +164,14 @@ namespace SabreTools.Skippers
|
||||
bool success = true;
|
||||
|
||||
// If the input stream isn't valid
|
||||
if (input == null || !input.CanRead)
|
||||
if (input is null || !input.CanRead)
|
||||
return false;
|
||||
|
||||
// If the sizes are wrong for the values, fail
|
||||
long extsize = input.Length;
|
||||
if ((Operation > HeaderSkipOperation.Bitswap && (extsize % 2) != 0)
|
||||
|| (Operation > HeaderSkipOperation.Byteswap && (extsize % 4) != 0)
|
||||
|| (Operation > HeaderSkipOperation.Bitswap && (_startOffset == null || _startOffset % 2 != 0)))
|
||||
|| (Operation > HeaderSkipOperation.Bitswap && (_startOffset is null || _startOffset % 2 != 0)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -185,7 +185,7 @@ namespace SabreTools.Skippers
|
||||
br = new BinaryReader(input);
|
||||
|
||||
// Seek to the beginning offset
|
||||
if (_startOffset == null)
|
||||
if (_startOffset is null)
|
||||
success = false;
|
||||
|
||||
else if (Math.Abs((long)_startOffset) > input.Length)
|
||||
@@ -218,6 +218,7 @@ namespace SabreTools.Skippers
|
||||
r |= (byte)(b & 1);
|
||||
s--;
|
||||
}
|
||||
|
||||
r <<= s;
|
||||
buffer[pos] = (byte)r;
|
||||
break;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace SabreTools.Skippers
|
||||
public static void Init()
|
||||
{
|
||||
// If the list is populated, don't add to it
|
||||
if (Skippers != null)
|
||||
if (Skippers is not null)
|
||||
return;
|
||||
|
||||
// Generate header skippers internally
|
||||
@@ -90,22 +90,22 @@ namespace SabreTools.Skippers
|
||||
var skipperRule = new Rule(null, null, HeaderSkipOperation.None, null, null);
|
||||
|
||||
// If we have an invalid input
|
||||
if (input == null || !input.CanRead)
|
||||
if (input is null || !input.CanRead)
|
||||
return skipperRule;
|
||||
|
||||
// If we have an invalid set of skippers or skipper name
|
||||
if (Skippers == null || skipperName == null)
|
||||
if (Skippers is null || skipperName is null)
|
||||
return skipperRule;
|
||||
|
||||
// Loop through all known Detectors
|
||||
foreach (Detector? skipper in Skippers)
|
||||
{
|
||||
// This should not happen
|
||||
if (skipper == null)
|
||||
if (skipper is null)
|
||||
continue;
|
||||
|
||||
skipperRule = skipper.GetMatchingRule(input, skipperName);
|
||||
if (skipperRule != null)
|
||||
if (skipperRule is not null)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace SabreTools.Skippers
|
||||
try
|
||||
{
|
||||
// Null offset means EOF
|
||||
if (offset == null)
|
||||
if (offset is null)
|
||||
input.Seek(0, SeekOrigin.End);
|
||||
|
||||
// Positive offset means from beginning
|
||||
|
||||
@@ -20,10 +20,10 @@ namespace SabreTools.Skippers.TestTypes
|
||||
[XmlAttribute("offset")]
|
||||
public string? Offset
|
||||
{
|
||||
get => _offset == null ? "EOF" : _offset.Value.ToString();
|
||||
get => _offset is null ? "EOF" : _offset.Value.ToString();
|
||||
set
|
||||
{
|
||||
if (value == null || value.Equals("eof", StringComparison.OrdinalIgnoreCase))
|
||||
if (value is null || value.Equals("eof", StringComparison.OrdinalIgnoreCase))
|
||||
_offset = null;
|
||||
else
|
||||
_offset = Convert.ToInt64(value, fromBase: 16);
|
||||
@@ -37,7 +37,7 @@ namespace SabreTools.Skippers.TestTypes
|
||||
[XmlAttribute("value")]
|
||||
public string? Value
|
||||
{
|
||||
get => _value == null ? string.Empty : BitConverter.ToString(_value).Replace("-", string.Empty);
|
||||
get => _value is null ? string.Empty : BitConverter.ToString(_value).Replace("-", string.Empty);
|
||||
set => _value = ParseByteArrayFromHex(value);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace SabreTools.Skippers.TestTypes
|
||||
[XmlAttribute("mask")]
|
||||
public string? Mask
|
||||
{
|
||||
get => _mask == null ? string.Empty : BitConverter.ToString(_mask).Replace("-", string.Empty);
|
||||
get => _mask is null ? string.Empty : BitConverter.ToString(_mask).Replace("-", string.Empty);
|
||||
set => _mask = ParseByteArrayFromHex(value);
|
||||
}
|
||||
|
||||
@@ -95,11 +95,11 @@ namespace SabreTools.Skippers.TestTypes
|
||||
public override bool Passes(Stream input)
|
||||
{
|
||||
// If we have an invalid mask
|
||||
if (_mask == null || _mask.Length == 0)
|
||||
if (_mask is null || _mask.Length == 0)
|
||||
return false;
|
||||
|
||||
// If we have an invalid value
|
||||
if (_value == null || _value.Length == 0)
|
||||
if (_value is null || _value.Length == 0)
|
||||
return false;
|
||||
|
||||
// Seek to the correct position, if possible
|
||||
|
||||
@@ -20,10 +20,10 @@ namespace SabreTools.Skippers.TestTypes
|
||||
[XmlAttribute("offset")]
|
||||
public string? Offset
|
||||
{
|
||||
get => _offset == null ? "EOF" : _offset.Value.ToString();
|
||||
get => _offset is null ? "EOF" : _offset.Value.ToString();
|
||||
set
|
||||
{
|
||||
if (value == null || value.Equals("eof", StringComparison.OrdinalIgnoreCase))
|
||||
if (value is null || value.Equals("eof", StringComparison.OrdinalIgnoreCase))
|
||||
_offset = null;
|
||||
else
|
||||
_offset = Convert.ToInt64(value, fromBase: 16);
|
||||
@@ -37,7 +37,7 @@ namespace SabreTools.Skippers.TestTypes
|
||||
[XmlAttribute("value")]
|
||||
public string? Value
|
||||
{
|
||||
get => _value == null ? string.Empty : BitConverter.ToString(_value).Replace("-", string.Empty);
|
||||
get => _value is null ? string.Empty : BitConverter.ToString(_value).Replace("-", string.Empty);
|
||||
set => _value = ParseByteArrayFromHex(value);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace SabreTools.Skippers.TestTypes
|
||||
public override bool Passes(Stream input)
|
||||
{
|
||||
// If we have an invalid value
|
||||
if (_value == null || _value.Length == 0)
|
||||
if (_value is null || _value.Length == 0)
|
||||
return false;
|
||||
|
||||
// Seek to the correct position, if possible
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace SabreTools.Skippers.TestTypes
|
||||
[XmlAttribute("size")]
|
||||
public string? Size
|
||||
{
|
||||
get => _size == null ? "po2" : _size.Value.ToString();
|
||||
get => _size is null ? "po2" : _size.Value.ToString();
|
||||
set
|
||||
{
|
||||
if (value == null || value.Equals("po2", StringComparison.OrdinalIgnoreCase))
|
||||
if (value is null || value.Equals("po2", StringComparison.OrdinalIgnoreCase))
|
||||
_size = null;
|
||||
else
|
||||
_size = Convert.ToInt64(value, fromBase: 16);
|
||||
@@ -72,22 +72,22 @@ namespace SabreTools.Skippers.TestTypes
|
||||
|
||||
// If we have a null size, check that the size is a power of 2
|
||||
bool result = true;
|
||||
if (_size == null)
|
||||
if (_size is null)
|
||||
{
|
||||
// http://stackoverflow.com/questions/600293/how-to-check-if-a-number-is-a-power-of-2
|
||||
result = (((ulong)size & ((ulong)size - 1)) == 0);
|
||||
result = ((ulong)size & ((ulong)size - 1)) == 0;
|
||||
}
|
||||
else if (Operator == HeaderSkipTestFileOperator.Less)
|
||||
{
|
||||
result = (size < _size);
|
||||
result = size < _size;
|
||||
}
|
||||
else if (Operator == HeaderSkipTestFileOperator.Greater)
|
||||
{
|
||||
result = (size > _size);
|
||||
result = size > _size;
|
||||
}
|
||||
else if (Operator == HeaderSkipTestFileOperator.Equal)
|
||||
{
|
||||
result = (size == _size);
|
||||
result = size == _size;
|
||||
}
|
||||
|
||||
// Return if the expected and actual results match
|
||||
|
||||
@@ -20,10 +20,10 @@ namespace SabreTools.Skippers.TestTypes
|
||||
[XmlAttribute("offset")]
|
||||
public string? Offset
|
||||
{
|
||||
get => _offset == null ? "EOF" : _offset.Value.ToString();
|
||||
get => _offset is null ? "EOF" : _offset.Value.ToString();
|
||||
set
|
||||
{
|
||||
if (value == null || value.Equals("eof", StringComparison.OrdinalIgnoreCase))
|
||||
if (value is null || value.Equals("eof", StringComparison.OrdinalIgnoreCase))
|
||||
_offset = null;
|
||||
else
|
||||
_offset = Convert.ToInt64(value, fromBase: 16);
|
||||
@@ -37,7 +37,7 @@ namespace SabreTools.Skippers.TestTypes
|
||||
[XmlAttribute("value")]
|
||||
public string? Value
|
||||
{
|
||||
get => _value == null ? string.Empty : BitConverter.ToString(_value).Replace("-", string.Empty);
|
||||
get => _value is null ? string.Empty : BitConverter.ToString(_value).Replace("-", string.Empty);
|
||||
set => _value = ParseByteArrayFromHex(value);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace SabreTools.Skippers.TestTypes
|
||||
[XmlAttribute("mask")]
|
||||
public string? Mask
|
||||
{
|
||||
get => _mask == null ? string.Empty : BitConverter.ToString(_mask).Replace("-", string.Empty);
|
||||
get => _mask is null ? string.Empty : BitConverter.ToString(_mask).Replace("-", string.Empty);
|
||||
set => _mask = ParseByteArrayFromHex(value);
|
||||
}
|
||||
|
||||
@@ -95,11 +95,11 @@ namespace SabreTools.Skippers.TestTypes
|
||||
public override bool Passes(Stream input)
|
||||
{
|
||||
// If we have an invalid mask
|
||||
if (_mask == null || _mask.Length == 0)
|
||||
if (_mask is null || _mask.Length == 0)
|
||||
return false;
|
||||
|
||||
// If we have an invalid value
|
||||
if (_value == null || _value.Length == 0)
|
||||
if (_value is null || _value.Length == 0)
|
||||
return false;
|
||||
|
||||
// Seek to the correct position, if possible
|
||||
|
||||
@@ -20,10 +20,10 @@ namespace SabreTools.Skippers.TestTypes
|
||||
[XmlAttribute("offset")]
|
||||
public string? Offset
|
||||
{
|
||||
get => _offset == null ? "EOF" : _offset.Value.ToString();
|
||||
get => _offset is null ? "EOF" : _offset.Value.ToString();
|
||||
set
|
||||
{
|
||||
if (value == null || value.Equals("eof", StringComparison.OrdinalIgnoreCase))
|
||||
if (value is null || value.Equals("eof", StringComparison.OrdinalIgnoreCase))
|
||||
_offset = null;
|
||||
else
|
||||
_offset = Convert.ToInt64(value, fromBase: 16);
|
||||
@@ -37,7 +37,7 @@ namespace SabreTools.Skippers.TestTypes
|
||||
[XmlAttribute("value")]
|
||||
public string? Value
|
||||
{
|
||||
get => _value == null ? string.Empty : BitConverter.ToString(_value).Replace("-", string.Empty);
|
||||
get => _value is null ? string.Empty : BitConverter.ToString(_value).Replace("-", string.Empty);
|
||||
set => _value = ParseByteArrayFromHex(value);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace SabreTools.Skippers.TestTypes
|
||||
[XmlAttribute("mask")]
|
||||
public string? Mask
|
||||
{
|
||||
get => _mask == null ? string.Empty : BitConverter.ToString(_mask).Replace("-", string.Empty);
|
||||
get => _mask is null ? string.Empty : BitConverter.ToString(_mask).Replace("-", string.Empty);
|
||||
set => _mask = ParseByteArrayFromHex(value);
|
||||
}
|
||||
|
||||
@@ -95,11 +95,11 @@ namespace SabreTools.Skippers.TestTypes
|
||||
public override bool Passes(Stream input)
|
||||
{
|
||||
// If we have an invalid mask
|
||||
if (_mask == null || _mask.Length == 0)
|
||||
if (_mask is null || _mask.Length == 0)
|
||||
return false;
|
||||
|
||||
// If we have an invalid value
|
||||
if (_value == null || _value.Length == 0)
|
||||
if (_value is null || _value.Length == 0)
|
||||
return false;
|
||||
|
||||
// Seek to the correct position, if possible
|
||||
|
||||
Reference in New Issue
Block a user