From 344132b50a2cfd9b71d3ea8632cfb669641cf451 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 25 Jan 2026 16:15:05 -0500 Subject: [PATCH] Add editorconfig, fix issues --- .editorconfig | 167 +++++++++++++++ .../CrossModel/Listrom.Deserializer.cs | 8 +- .../CrossModel/OpenMSX.Serializer.cs | 4 + .../CrossModel/SeparatedValue.Serializer.cs | 4 + SabreTools.Serialization/Extensions/CDROM.cs | 14 +- .../Extensions/PortableExecutable.cs | 4 +- .../Extensions/StringBuilderExtensions.cs | 6 +- .../Extensions/TypeLengthValue.cs | 21 ++ .../Interfaces/IByteReader.cs | 2 +- .../Interfaces/IByteSerializer.cs | 2 +- .../Interfaces/ICrossModel.cs | 4 +- .../Interfaces/IFileDeserializer.cs | 2 +- .../Interfaces/IFileSerializer.cs | 2 +- .../Interfaces/IStreamDeserializer.cs | 2 +- .../Interfaces/IStreamSerializer.cs | 2 +- .../Interfaces/IStringDeserializer.cs | 2 +- .../Interfaces/IStringSerializer.cs | 2 +- .../ObjectIdentifier/Parser.OIDIRI.cs | 190 +++++++++--------- SabreTools.Serialization/Readers/AACS.cs | 8 + SabreTools.Serialization/Readers/BSP.cs | 10 +- SabreTools.Serialization/Readers/CFB.cs | 3 + SabreTools.Serialization/Readers/CHD.cs | 1 + SabreTools.Serialization/Readers/CIA.cs | 1 + .../Readers/ClrMamePro.cs | 65 +++++- SabreTools.Serialization/Readers/CueSheet.cs | 8 + SabreTools.Serialization/Readers/DosCenter.cs | 26 +++ SabreTools.Serialization/Readers/GZip.cs | 1 - SabreTools.Serialization/Readers/Hashfile.cs | 2 + SabreTools.Serialization/Readers/ISO9660.cs | 14 +- .../Readers/InstallShieldCabinet.cs | 3 + SabreTools.Serialization/Readers/LZKWAJ.cs | 1 + .../Readers/LinearExecutable.cs | 8 +- SabreTools.Serialization/Readers/MSDOS.cs | 2 + SabreTools.Serialization/Readers/MoPaQ.cs | 2 +- SabreTools.Serialization/Readers/N3DS.cs | 7 + SabreTools.Serialization/Readers/NCF.cs | 1 - .../Readers/NewExecutable.cs | 14 +- SabreTools.Serialization/Readers/Nitro.cs | 3 + SabreTools.Serialization/Readers/PIC.cs | 3 + SabreTools.Serialization/Readers/PKZIP.cs | 7 + .../Readers/PortableExecutable.cs | 8 +- SabreTools.Serialization/Readers/RomCenter.cs | 15 ++ SabreTools.Serialization/Readers/SGA.cs | 2 +- .../Readers/SeparatedValue.cs | 1 + SabreTools.Serialization/Readers/VBSP.cs | 5 + SabreTools.Serialization/Readers/WAD3.cs | 5 + .../Readers/WiseScript.cs | 18 +- .../Readers/WiseSectionHeader.cs | 1 + SabreTools.Serialization/Readers/XZ.cs | 2 +- SabreTools.Serialization/WrapperFactory.cs | 5 + .../Wrappers/AACSMediaKeyBlock.Printing.cs | 4 + .../Wrappers/BSP.Extraction.cs | 2 + .../Wrappers/BSP.Printing.cs | 4 + SabreTools.Serialization/Wrappers/CDROM.cs | 4 +- .../Wrappers/CHD.Printing.cs | 1 + .../Wrappers/CIA.Printing.cs | 13 ++ .../Wrappers/IExtractable.cs | 2 +- .../Wrappers/IPrintable.cs | 4 +- .../Wrappers/ISO9660.Printing.cs | 10 +- SabreTools.Serialization/Wrappers/IWrapper.cs | 2 +- .../Wrappers/IWrapperT.cs | 2 +- .../InstallShieldArchiveV3.Extraction.cs | 4 +- .../InstallShieldCabinet.Extraction.cs | 4 +- .../Wrappers/InstallShieldCabinet.Printing.cs | 1 + .../Wrappers/LZSZDD.Extraction.cs | 2 +- .../Wrappers/LinearExecutable.Printing.cs | 2 + .../Wrappers/MicrosoftCabinet.Extraction.cs | 6 +- .../Wrappers/MicrosoftCabinet.cs | 34 +--- .../Wrappers/N3DS.Printing.cs | 1 + .../Wrappers/NewExecutable.Printing.cs | 3 + .../Wrappers/Nitro.Encryption.cs | 3 +- .../Wrappers/PKZIP.Printing.cs | 1 + .../Wrappers/PortableExecutable.Printing.cs | 41 ++++ .../Wrappers/PortableExecutable.cs | 13 ++ .../Wrappers/RAR.Extraction.cs | 1 + .../Wrappers/SecuROMDFA.Printing.cs | 1 - .../Wrappers/SevenZip.Extraction.cs | 2 +- SabreTools.Serialization/Wrappers/Skeleton.cs | 4 +- .../Wrappers/TapeArchive.Extraction.cs | 9 +- .../Wrappers/VBSP.Extraction.cs | 2 + .../Wrappers/WiseScript.Printing.cs | 6 + .../Wrappers/WiseScript.cs | 3 + .../Wrappers/WiseSectionHeader.Printing.cs | 1 + .../Writers/ClrMamePro.cs | 4 + SabreTools.Serialization/Writers/Hashfile.cs | 2 + .../_EXTERNAL/StormLibSharp/MpqArchive.cs | 1 - .../StormLibSharp/Native/NativeMethods.cs | 5 +- 87 files changed, 689 insertions(+), 205 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..94343d5c --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/SabreTools.Serialization/CrossModel/Listrom.Deserializer.cs b/SabreTools.Serialization/CrossModel/Listrom.Deserializer.cs index c5b36cb1..0e0bb551 100644 --- a/SabreTools.Serialization/CrossModel/Listrom.Deserializer.cs +++ b/SabreTools.Serialization/CrossModel/Listrom.Deserializer.cs @@ -60,9 +60,9 @@ namespace SabreTools.Serialization.CrossModel SHA1 = item.ReadString(Data.Models.Metadata.Disk.SHA1Key), }; - if (item[Data.Models.Metadata.Disk.StatusKey] as string == "nodump") + if ((item[Data.Models.Metadata.Disk.StatusKey] as string) == "nodump") row.NoGoodDumpKnown = true; - else if (item[Data.Models.Metadata.Disk.StatusKey] as string == "baddump") + else if ((item[Data.Models.Metadata.Disk.StatusKey] as string) == "baddump") row.Bad = true; return row; @@ -81,9 +81,9 @@ namespace SabreTools.Serialization.CrossModel SHA1 = item.ReadString(Data.Models.Metadata.Rom.SHA1Key), }; - if (item[Data.Models.Metadata.Rom.StatusKey] as string == "nodump") + if ((item[Data.Models.Metadata.Rom.StatusKey] as string) == "nodump") row.NoGoodDumpKnown = true; - else if (item[Data.Models.Metadata.Rom.StatusKey] as string == "baddump") + else if ((item[Data.Models.Metadata.Rom.StatusKey] as string) == "baddump") row.Bad = true; return row; diff --git a/SabreTools.Serialization/CrossModel/OpenMSX.Serializer.cs b/SabreTools.Serialization/CrossModel/OpenMSX.Serializer.cs index 2fb72638..c86f5ee1 100644 --- a/SabreTools.Serialization/CrossModel/OpenMSX.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/OpenMSX.Serializer.cs @@ -86,6 +86,10 @@ namespace SabreTools.Serialization.CrossModel case SCCPlusCart sccPlusCart: dump[Data.Models.Metadata.Dump.SCCPlusCartKey] = ConvertToInternalModel(sccPlusCart); break; + + default: + // TODO: Log invalid values + break; } } diff --git a/SabreTools.Serialization/CrossModel/SeparatedValue.Serializer.cs b/SabreTools.Serialization/CrossModel/SeparatedValue.Serializer.cs index 95fab946..8a6492c1 100644 --- a/SabreTools.Serialization/CrossModel/SeparatedValue.Serializer.cs +++ b/SabreTools.Serialization/CrossModel/SeparatedValue.Serializer.cs @@ -71,6 +71,10 @@ namespace SabreTools.Serialization.CrossModel case Data.Models.Metadata.Rom rom: machine[Data.Models.Metadata.Machine.RomKey] = new Data.Models.Metadata.Rom[] { rom }; break; + + default: + // TODO: Log invalid values + break; } return machine; diff --git a/SabreTools.Serialization/Extensions/CDROM.cs b/SabreTools.Serialization/Extensions/CDROM.cs index b41dd6e5..1cbf3dad 100644 --- a/SabreTools.Serialization/Extensions/CDROM.cs +++ b/SabreTools.Serialization/Extensions/CDROM.cs @@ -44,7 +44,6 @@ namespace SabreTools.Data.Extensions // Ignore the actual error return SectorMode.UNKNOWN; } - } /// @@ -56,6 +55,7 @@ namespace SabreTools.Data.Extensions { return mode switch { + SectorMode.UNKNOWN => Constants.Mode0DataSize, SectorMode.MODE0 => Constants.Mode0DataSize, SectorMode.MODE1 => Constants.Mode1DataSize, SectorMode.MODE2 => Constants.Mode0DataSize, @@ -74,6 +74,7 @@ namespace SabreTools.Data.Extensions { return mode switch { + SectorMode.UNKNOWN => Constants.Mode0UserDataEnd, SectorMode.MODE0 => Constants.Mode0UserDataEnd, // TODO: Support flexible sector length (2352) SectorMode.MODE1 => Constants.Mode1UserDataEnd, SectorMode.MODE2 => Constants.Mode0UserDataEnd, // TODO: Support flexible sector length (2352) @@ -92,6 +93,7 @@ namespace SabreTools.Data.Extensions { return mode switch { + SectorMode.UNKNOWN => Constants.Mode0UserDataStart, SectorMode.MODE0 => Constants.Mode0UserDataStart, SectorMode.MODE1 => Constants.Mode1UserDataStart, SectorMode.MODE2 => Constants.Mode0UserDataStart, @@ -114,7 +116,9 @@ namespace SabreTools.Data.Extensions private SectorMode _currentMode = SectorMode.UNKNOWN; private long _userDataStart = Constants.Mode1UserDataStart; private long _userDataEnd = Constants.Mode1UserDataEnd; +#pragma warning disable IDE0044 private long _isoSectorSize = Constants.Mode1DataSize; +#pragma warning restore IDE0044 public ISO9660Stream(Stream inputStream) { @@ -138,7 +142,7 @@ namespace SabreTools.Data.Extensions /// public override long Length - => (_baseStream.Length / Constants.CDROMSectorSize) * _isoSectorSize; + => _baseStream.Length / Constants.CDROMSectorSize * _isoSectorSize; /// public override void SetLength(long value) @@ -167,7 +171,7 @@ namespace SabreTools.Data.Extensions SetState(_position); // Get the number of ISO sectors before current position - long isoPosition = (_position / Constants.CDROMSectorSize) * _isoSectorSize; + long isoPosition = _position / Constants.CDROMSectorSize * _isoSectorSize; // Add the within-sector position long remainder = _position % Constants.CDROMSectorSize; @@ -242,7 +246,7 @@ namespace SabreTools.Data.Extensions // Update state for base stream _position = _baseStream.Position; if (bytesToRead == (_isoSectorSize - sectorOffset)) - _position += (Constants.CDROMSectorSize - _userDataEnd) + _userDataStart; + _position += Constants.CDROMSectorSize - _userDataEnd + _userDataStart; // Update state for ISO stream totalRead += bytesRead; @@ -268,7 +272,7 @@ namespace SabreTools.Data.Extensions }; // Get the number of ISO sectors before current position - long newPosition = (targetPosition / _isoSectorSize) * Constants.CDROMSectorSize; + long newPosition = targetPosition / _isoSectorSize * Constants.CDROMSectorSize; // Set the current sector's mode and user data location SetState(newPosition); diff --git a/SabreTools.Serialization/Extensions/PortableExecutable.cs b/SabreTools.Serialization/Extensions/PortableExecutable.cs index 6d4493ee..5ff1e22e 100644 --- a/SabreTools.Serialization/Extensions/PortableExecutable.cs +++ b/SabreTools.Serialization/Extensions/PortableExecutable.cs @@ -929,7 +929,7 @@ namespace SabreTools.Data.Extensions stringFileInfo.Key = data.ReadNullTerminatedUnicodeString(ref offset) ?? string.Empty; if (stringFileInfo.Key != "StringFileInfo") { - offset -= 6 + ((stringFileInfo.Key?.Length ?? 0 + 1) * 2); + offset -= 6 + (((stringFileInfo.Key?.Length ?? 0) + 1) * 2); return null; } @@ -1053,7 +1053,7 @@ namespace SabreTools.Data.Extensions varData.Key = data.ReadNullTerminatedUnicodeString(ref offset) ?? string.Empty; if (varData.Key != "Translation") { - offset -= 6 + ((varData.Key?.Length ?? 0 + 1) * 2); + offset -= 6 + (((varData.Key?.Length ?? 0) + 1) * 2); return null; } diff --git a/SabreTools.Serialization/Extensions/StringBuilderExtensions.cs b/SabreTools.Serialization/Extensions/StringBuilderExtensions.cs index 95196f56..4d3d0cc3 100644 --- a/SabreTools.Serialization/Extensions/StringBuilderExtensions.cs +++ b/SabreTools.Serialization/Extensions/StringBuilderExtensions.cs @@ -21,7 +21,7 @@ namespace SabreTools.Data.Extensions /// public static StringBuilder AppendLine(this StringBuilder sb, char? value, string prefixString) { - string valueString = (value is null ? "[NULL]" : value.Value.ToString()); + string valueString = value is null ? "[NULL]" : value.Value.ToString(); return sb.AppendLine($"{prefixString}: {valueString}"); } @@ -256,7 +256,7 @@ namespace SabreTools.Data.Extensions /// public static StringBuilder AppendLine(this StringBuilder sb, byte[]? value, string prefixString) { - string valueString = (value is null ? "[NULL]" : BitConverter.ToString(value).Replace('-', ' ')); + string valueString = value is null ? "[NULL]" : BitConverter.ToString(value).Replace('-', ' '); if (valueString.Length == 0) return sb.AppendLine($"{prefixString}: [EMPTY]"); @@ -268,7 +268,7 @@ namespace SabreTools.Data.Extensions /// public static StringBuilder AppendLine(this StringBuilder sb, byte[]? value, string prefixString, Encoding encoding) { - string valueString = (value is null ? "[NULL]" : encoding.GetString(value).Replace("\0", string.Empty)); + string valueString = value is null ? "[NULL]" : encoding.GetString(value).Replace("\0", string.Empty); if (valueString.Length == 0) return sb.AppendLine($"{prefixString}: [EMPTY]"); diff --git a/SabreTools.Serialization/Extensions/TypeLengthValue.cs b/SabreTools.Serialization/Extensions/TypeLengthValue.cs index ffcb1b67..702f07a2 100644 --- a/SabreTools.Serialization/Extensions/TypeLengthValue.cs +++ b/SabreTools.Serialization/Extensions/TypeLengthValue.cs @@ -148,6 +148,27 @@ namespace SabreTools.Data.Extensions formatBuilder.Append($", Value: {Encoding.Unicode.GetString(valueAsByteArray)}"); break; + // Unimplemented + case ASN1Type.V_ASN1_EOC: + case ASN1Type.V_ASN1_NULL: + case ASN1Type.V_ASN1_OBJECT_DESCRIPTOR: + case ASN1Type.V_ASN1_EXTERNAL: + case ASN1Type.V_ASN1_REAL: + case ASN1Type.V_ASN1_ENUMERATED: + case ASN1Type.V_ASN1_SEQUENCE: + case ASN1Type.V_ASN1_SET: + case ASN1Type.V_ASN1_NUMERICSTRING: + case ASN1Type.V_ASN1_VIDEOTEXSTRING: + case ASN1Type.V_ASN1_GENERALIZEDTIME: + case ASN1Type.V_ASN1_GRAPHICSTRING: + case ASN1Type.V_ASN1_ISO64STRING: + case ASN1Type.V_ASN1_GENERALSTRING: + case ASN1Type.V_ASN1_UNIVERSALSTRING: + case ASN1Type.V_ASN1_PRIMITIVE_TAG: + case ASN1Type.V_ASN1_CONSTRUCTED: + case ASN1Type.V_ASN1_APPLICATION: + case ASN1Type.V_ASN1_CONTEXT_SPECIFIC: + case ASN1Type.V_ASN1_PRIVATE: default: formatBuilder.Append($", Value: {BitConverter.ToString(valueAsByteArray).Replace('-', ' ')}"); break; diff --git a/SabreTools.Serialization/Interfaces/IByteReader.cs b/SabreTools.Serialization/Interfaces/IByteReader.cs index 6f196c39..da267eaf 100644 --- a/SabreTools.Serialization/Interfaces/IByteReader.cs +++ b/SabreTools.Serialization/Interfaces/IByteReader.cs @@ -12,6 +12,6 @@ namespace SabreTools.Serialization.Interfaces /// Byte array to parse /// Offset into the byte array /// Filled object on success, null on error - TModel? Deserialize(byte[]? data, int offset); + public TModel? Deserialize(byte[]? data, int offset); } } diff --git a/SabreTools.Serialization/Interfaces/IByteSerializer.cs b/SabreTools.Serialization/Interfaces/IByteSerializer.cs index f71f9978..6b40cddf 100644 --- a/SabreTools.Serialization/Interfaces/IByteSerializer.cs +++ b/SabreTools.Serialization/Interfaces/IByteSerializer.cs @@ -11,6 +11,6 @@ namespace SabreTools.Serialization.Interfaces /// Type of object to serialize from /// Data to serialize /// Filled object on success, null on error - byte[]? SerializeArray(TModel? obj); + public byte[]? SerializeArray(TModel? obj); } } diff --git a/SabreTools.Serialization/Interfaces/ICrossModel.cs b/SabreTools.Serialization/Interfaces/ICrossModel.cs index 46913626..e875e186 100644 --- a/SabreTools.Serialization/Interfaces/ICrossModel.cs +++ b/SabreTools.Serialization/Interfaces/ICrossModel.cs @@ -12,7 +12,7 @@ namespace SabreTools.Serialization.Interfaces /// Type of object to deserialize from /// Object to deserialize from /// Filled object on success, null on error - TSource? Deserialize(TDest? obj); + public TSource? Deserialize(TDest? obj); /// /// Serialize a into @@ -21,6 +21,6 @@ namespace SabreTools.Serialization.Interfaces /// Type of object to serialize to /// Object to serialize from /// Filled object on success, null on error - TDest? Serialize(TSource? obj); + public TDest? Serialize(TSource? obj); } } diff --git a/SabreTools.Serialization/Interfaces/IFileDeserializer.cs b/SabreTools.Serialization/Interfaces/IFileDeserializer.cs index 386ea820..ed74b8c6 100644 --- a/SabreTools.Serialization/Interfaces/IFileDeserializer.cs +++ b/SabreTools.Serialization/Interfaces/IFileDeserializer.cs @@ -11,6 +11,6 @@ namespace SabreTools.Serialization.Interfaces /// Type of object to deserialize to /// Path to deserialize from /// Filled object on success, null on error - TModel? Deserialize(string? path); + public TModel? Deserialize(string? path); } } diff --git a/SabreTools.Serialization/Interfaces/IFileSerializer.cs b/SabreTools.Serialization/Interfaces/IFileSerializer.cs index 90c198cf..bc86a7b6 100644 --- a/SabreTools.Serialization/Interfaces/IFileSerializer.cs +++ b/SabreTools.Serialization/Interfaces/IFileSerializer.cs @@ -12,6 +12,6 @@ namespace SabreTools.Serialization.Interfaces /// Data to serialize /// Path to the file to serialize to /// True on successful serialization, false otherwise - bool SerializeFile(TModel? obj, string? path); + public bool SerializeFile(TModel? obj, string? path); } } diff --git a/SabreTools.Serialization/Interfaces/IStreamDeserializer.cs b/SabreTools.Serialization/Interfaces/IStreamDeserializer.cs index e3875a33..eaa9df50 100644 --- a/SabreTools.Serialization/Interfaces/IStreamDeserializer.cs +++ b/SabreTools.Serialization/Interfaces/IStreamDeserializer.cs @@ -11,6 +11,6 @@ namespace SabreTools.Serialization.Interfaces /// Type of object to deserialize to /// Stream to parse /// Filled object on success, null on error - TModel? Deserialize(System.IO.Stream? data); + public TModel? Deserialize(System.IO.Stream? data); } } diff --git a/SabreTools.Serialization/Interfaces/IStreamSerializer.cs b/SabreTools.Serialization/Interfaces/IStreamSerializer.cs index 7a3c420e..813e13eb 100644 --- a/SabreTools.Serialization/Interfaces/IStreamSerializer.cs +++ b/SabreTools.Serialization/Interfaces/IStreamSerializer.cs @@ -11,6 +11,6 @@ namespace SabreTools.Serialization.Interfaces /// Type of object to serialize from /// Data to serialize /// Filled object on success, null on error - System.IO.Stream? SerializeStream(TModel? obj); + public System.IO.Stream? SerializeStream(TModel? obj); } } diff --git a/SabreTools.Serialization/Interfaces/IStringDeserializer.cs b/SabreTools.Serialization/Interfaces/IStringDeserializer.cs index ba12fc7a..785c538f 100644 --- a/SabreTools.Serialization/Interfaces/IStringDeserializer.cs +++ b/SabreTools.Serialization/Interfaces/IStringDeserializer.cs @@ -11,6 +11,6 @@ namespace SabreTools.Serialization.Interfaces /// Type of object to deserialize to /// String to deserialize from /// Filled object on success, null on error - TModel? Deserialize(string? str); + public TModel? Deserialize(string? str); } } diff --git a/SabreTools.Serialization/Interfaces/IStringSerializer.cs b/SabreTools.Serialization/Interfaces/IStringSerializer.cs index 0699bc33..c5d5c130 100644 --- a/SabreTools.Serialization/Interfaces/IStringSerializer.cs +++ b/SabreTools.Serialization/Interfaces/IStringSerializer.cs @@ -11,6 +11,6 @@ namespace SabreTools.Serialization.Interfaces /// Type of object to serialize from /// Data to serialize /// Filled string on successful serialization, null otherwise - string? Serialize(TModel? obj); + public string? Serialize(TModel? obj); } } diff --git a/SabreTools.Serialization/ObjectIdentifier/Parser.OIDIRI.cs b/SabreTools.Serialization/ObjectIdentifier/Parser.OIDIRI.cs index 515323b5..51556619 100644 --- a/SabreTools.Serialization/ObjectIdentifier/Parser.OIDIRI.cs +++ b/SabreTools.Serialization/ObjectIdentifier/Parser.OIDIRI.cs @@ -86,10 +86,10 @@ namespace SabreTools.Data.ObjectIdentifier default: return oidPath; } - #endregion + #endregion - // itu-t, ccitt, itu-r - #region 0.* + // itu-t, ccitt, itu-r + #region 0.* oid_0: @@ -106,8 +106,8 @@ namespace SabreTools.Data.ObjectIdentifier default: return $"{oidPath}/{values[index - 1]}"; } - // recommendation - #region 0.0.* + // recommendation + #region 0.0.* oid_0_0: @@ -143,12 +143,12 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - #endregion + #endregion - // iso - #region 1.* + // iso + #region 1.* oid_1: @@ -163,8 +163,8 @@ namespace SabreTools.Data.ObjectIdentifier default: return $"{oidPath}/{values[index - 1]}"; } - // member-body - #region 1.2.* + // member-body + #region 1.2.* oid_1_2: @@ -202,12 +202,12 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - #endregion + #endregion - // joint-iso-itu-t, joint-iso-ccitt - #region 2.* + // joint-iso-itu-t, joint-iso-ccitt + #region 2.* oid_2: @@ -233,8 +233,8 @@ namespace SabreTools.Data.ObjectIdentifier default: return $"{oidPath}/{values[index - 1]}"; } - // country - #region 2.16.* + // country + #region 2.16.* oid_2_16: @@ -444,10 +444,10 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}{values[index - 1]}", }; - #endregion + #endregion - // uuid [TODO: Requires 128-bit values] - #region 2.25.* + // uuid [TODO: Requires 128-bit values] + #region 2.25.* oid_2_25: @@ -466,10 +466,10 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - // telebiometrics - #region 2.42.* + // telebiometrics + #region 2.42.* oid_2_42: @@ -484,8 +484,8 @@ namespace SabreTools.Data.ObjectIdentifier default: return $"{oidPath}/{values[index - 1]}"; } - // modules - #region 2.42.0.* + // modules + #region 2.42.0.* oid_2_42_0: @@ -497,8 +497,8 @@ namespace SabreTools.Data.ObjectIdentifier default: return $"{oidPath}/{values[index - 1]}"; } - // main - #region 2.42.0.0.* + // main + #region 2.42.0.0.* oid_2_42_0_0: @@ -510,12 +510,12 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - #endregion + #endregion - // tmm - #region 2.42.1.* + // tmm + #region 2.42.1.* oid_2_42_1: @@ -531,8 +531,8 @@ namespace SabreTools.Data.ObjectIdentifier default: return $"{oidPath}/{values[index - 1]}"; } - // modules - #region 2.42.1.0.* + // modules + #region 2.42.1.0.* oid_2_42_1_0: @@ -544,8 +544,8 @@ namespace SabreTools.Data.ObjectIdentifier default: return $"{oidPath}/{values[index - 1]}"; } - // main - #region 2.42.1.0.0.* + // main + #region 2.42.1.0.0.* oid_2_42_1_0_0: @@ -557,12 +557,12 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - #endregion + #endregion - // measures, metric - #region 2.42.1.1.* + // measures, metric + #region 2.42.1.1.* oid_2_42_1_1: @@ -578,8 +578,8 @@ namespace SabreTools.Data.ObjectIdentifier default: return $"{oidPath}/{values[index - 1]}"; } - // quantities - #region 2.42.1.1.1.* + // quantities + #region 2.42.1.1.1.* oid_2_42_1_1_1: @@ -595,10 +595,10 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - // methods - #region 2.42.1.1.5.* + // methods + #region 2.42.1.1.5.* oid_2_42_1_1_5: @@ -614,12 +614,12 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - #endregion + #endregion - // fields-of-study, scientific - #region 2.42.1.2.* + // fields-of-study, scientific + #region 2.42.1.2.* oid_2_42_1_2: @@ -635,10 +635,10 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - // modalities, sensory - #region 2.42.1.3.* + // modalities, sensory + #region 2.42.1.3.* oid_2_42_1_3: @@ -656,12 +656,12 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - #endregion + #endregion - // human-physiology - #region 2.42.2.* + // human-physiology + #region 2.42.2.* oid_2_42_2: @@ -675,8 +675,8 @@ namespace SabreTools.Data.ObjectIdentifier default: return $"{oidPath}/{values[index - 1]}"; } - // modules - #region 2.42.2.0.* + // modules + #region 2.42.2.0.* oid_2_42_2_0: @@ -688,8 +688,8 @@ namespace SabreTools.Data.ObjectIdentifier default: return $"{oidPath}/{values[index - 1]}"; } - // main - #region 2.42.2.0.0.* + // main + #region 2.42.2.0.0.* oid_2_42_2_0_0: @@ -701,12 +701,12 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - #endregion + #endregion - // symbols - #region 2.42.2.1.* + // symbols + #region 2.42.2.1.* oid_2_42_2_1: @@ -731,12 +731,12 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - #endregion + #endregion - // obj-cat, telehealth, e-health-protocol, th - #region 2.42.3.* + // obj-cat, telehealth, e-health-protocol, th + #region 2.42.3.* oid_2_42_3: @@ -758,8 +758,8 @@ namespace SabreTools.Data.ObjectIdentifier default: return $"{oidPath}/{values[index - 1]}"; } - // obj-cat, telehealth, e-health-protocol, th - #region 2.42.3.0.* + // obj-cat, telehealth, e-health-protocol, th + #region 2.42.3.0.* oid_2_42_3_0: @@ -776,8 +776,8 @@ namespace SabreTools.Data.ObjectIdentifier default: return $"{oidPath}/{values[index - 1]}"; } - // identification - #region 2.42.3.0.0.* + // identification + #region 2.42.3.0.0.* oid_2_42_3_0_0: @@ -789,10 +789,10 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - // set-up - #region 2.42.3.0.1.* + // set-up + #region 2.42.3.0.1.* oid_2_42_3_0_1: @@ -804,10 +804,10 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - // send-and-ack - #region 2.42.3.0.2.* + // send-and-ack + #region 2.42.3.0.2.* oid_2_42_3_0_2: @@ -819,10 +819,10 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - // command-response - #region 2.42.3.0.3.* + // command-response + #region 2.42.3.0.3.* oid_2_42_3_0_3: @@ -834,10 +834,10 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - // quantity-and-units - #region 2.42.3.0.4.* + // quantity-and-units + #region 2.42.3.0.4.* oid_2_42_3_0_4: @@ -849,10 +849,10 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - // examples - #region 2.42.3.0.5.* + // examples + #region 2.42.3.0.5.* oid_2_42_3_0_5: @@ -865,16 +865,16 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - #endregion + #endregion - #endregion + #endregion - #endregion + #endregion - // cybersecurity - #region 2.48.* + // cybersecurity + #region 2.48.* oid_2_48: @@ -887,10 +887,10 @@ namespace SabreTools.Data.ObjectIdentifier _ => $"{oidPath}/{values[index - 1]}", }; - #endregion + #endregion - // alerting - #region 2.49.* + // alerting + #region 2.49.* oid_2_49: diff --git a/SabreTools.Serialization/Readers/AACS.cs b/SabreTools.Serialization/Readers/AACS.cs index fe414bb3..8fa8dd82 100644 --- a/SabreTools.Serialization/Readers/AACS.cs +++ b/SabreTools.Serialization/Readers/AACS.cs @@ -81,6 +81,14 @@ namespace SabreTools.Serialization.Readers RecordType.VerifyMediaKey => ParseVerifyMediaKeyRecord(data), RecordType.Copyright => ParseCopyrightRecord(data), + // Unimplemented + RecordType.MediaKeyVariantData => ParseGenericRecord(data), + RecordType.Unknown0x28_AACS2 => ParseGenericRecord(data), + RecordType.DriveRevocationList_AACS2 => ParseGenericRecord(data), + RecordType.HostRevocationList_AACS2 => ParseGenericRecord(data), + RecordType.VerifyMediaKey_AACS2 => ParseGenericRecord(data), + RecordType.EmptyRecord0xF8_AACS2 => ParseGenericRecord(data), + // Unknown record type _ => ParseGenericRecord(data), }; diff --git a/SabreTools.Serialization/Readers/BSP.cs b/SabreTools.Serialization/Readers/BSP.cs index 44d8f702..2ec86cf9 100644 --- a/SabreTools.Serialization/Readers/BSP.cs +++ b/SabreTools.Serialization/Readers/BSP.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.IO; using System.Text; @@ -52,6 +51,7 @@ namespace SabreTools.Serialization.Readers data.SeekIfPossible(initialOffset + lumpEntry.Offset, SeekOrigin.Begin); // Read according to the lump type +#pragma warning disable IDE0010 switch ((LumpType)l) { case LumpType.LUMP_ENTITIES: @@ -102,10 +102,12 @@ namespace SabreTools.Serialization.Readers case LumpType.LUMP_MODELS: file.ModelsLump = ParseModelsLump(data, lumpEntry.Offset, lumpEntry.Length); break; + default: // Unsupported LumpType value, ignore break; } +#pragma warning restore IDE0010 } #endregion @@ -174,11 +176,13 @@ namespace SabreTools.Serialization.Readers { obj.Mins[i] = data.ReadInt16LittleEndian(); } + obj.Maxs = new short[3]; for (int i = 0; i < 3; i++) { obj.Maxs[i] = data.ReadInt16LittleEndian(); } + obj.FirstMarkSurfaceIndex = data.ReadUInt16LittleEndian(); obj.MarkSurfacesCount = data.ReadUInt16LittleEndian(); obj.AmbientLevels = data.ReadBytes(4); @@ -218,6 +222,7 @@ namespace SabreTools.Serialization.Readers { obj.HeadnodesIndex[i] = data.ReadInt32LittleEndian(); } + obj.VisLeafsCount = data.ReadInt32LittleEndian(); obj.FirstFaceIndex = data.ReadInt32LittleEndian(); obj.FacesCount = data.ReadInt32LittleEndian(); @@ -240,16 +245,19 @@ namespace SabreTools.Serialization.Readers { obj.Children[i] = data.ReadUInt16LittleEndian(); } + obj.Mins = new ushort[3]; for (int i = 0; i < 3; i++) { obj.Mins[i] = data.ReadUInt16LittleEndian(); } + obj.Maxs = new ushort[3]; for (int i = 0; i < 3; i++) { obj.Maxs[i] = data.ReadUInt16LittleEndian(); } + obj.FirstFace = data.ReadUInt16LittleEndian(); obj.FaceCount = data.ReadUInt16LittleEndian(); diff --git a/SabreTools.Serialization/Readers/CFB.cs b/SabreTools.Serialization/Readers/CFB.cs index fc6172a5..0ae3b12a 100644 --- a/SabreTools.Serialization/Readers/CFB.cs +++ b/SabreTools.Serialization/Readers/CFB.cs @@ -190,6 +190,9 @@ namespace SabreTools.Serialization.Readers case 4: directorySectorCount = fileHeader.NumberOfDirectorySectors; break; + default: + // TODO: Log invalid values + break; } // Loop through and add the directory sectors diff --git a/SabreTools.Serialization/Readers/CHD.cs b/SabreTools.Serialization/Readers/CHD.cs index 7489d583..880450f4 100644 --- a/SabreTools.Serialization/Readers/CHD.cs +++ b/SabreTools.Serialization/Readers/CHD.cs @@ -255,6 +255,7 @@ namespace SabreTools.Serialization.Readers { obj.Compressors[i] = (CodecType)data.ReadUInt32BigEndian(); } + obj.LogicalBytes = data.ReadUInt64BigEndian(); obj.MapOffset = data.ReadUInt64BigEndian(); obj.MetaOffset = data.ReadUInt64BigEndian(); diff --git a/SabreTools.Serialization/Readers/CIA.cs b/SabreTools.Serialization/Readers/CIA.cs index 2050edeb..3e5bb5e3 100644 --- a/SabreTools.Serialization/Readers/CIA.cs +++ b/SabreTools.Serialization/Readers/CIA.cs @@ -426,6 +426,7 @@ namespace SabreTools.Serialization.Readers var contentInfoRecord = ParseContentInfoRecord(data); obj.ContentInfoRecords[i] = contentInfoRecord; } + obj.ContentChunkRecords = new ContentChunkRecord[obj.ContentCount]; for (int i = 0; i < obj.ContentCount; i++) { diff --git a/SabreTools.Serialization/Readers/ClrMamePro.cs b/SabreTools.Serialization/Readers/ClrMamePro.cs index 7bd071fa..b5bc12ac 100644 --- a/SabreTools.Serialization/Readers/ClrMamePro.cs +++ b/SabreTools.Serialization/Readers/ClrMamePro.cs @@ -149,8 +149,22 @@ namespace SabreTools.Serialization.Readers dat.Info?.Source = [.. sources]; sources.Clear(); break; + + default: + // TODO: Log invalid values + break; } + continue; + + case CmpRowType.TopLevel: + case CmpRowType.Standalone: + case CmpRowType.Internal: + break; + + default: + // TODO: Log invalid values + break; } // If we're at the root @@ -177,6 +191,9 @@ namespace SabreTools.Serialization.Readers case "set": game = new Set(); break; + default: + // TODO: Log invalid values + break; } } @@ -234,6 +251,9 @@ namespace SabreTools.Serialization.Readers case "forcepacking": dat.ClrMamePro.ForcePacking = reader.Standalone?.Value; break; + default: + // TODO: Log invalid values + break; } } @@ -287,6 +307,9 @@ namespace SabreTools.Serialization.Readers }; samples.Add(sample); break; + default: + // TODO: Log invalid values + break; } } @@ -302,6 +325,9 @@ namespace SabreTools.Serialization.Readers sources.Add(source); break; + default: + // TODO: Log invalid values + break; } } @@ -382,7 +408,8 @@ namespace SabreTools.Serialization.Readers game.Driver = driver; break; default: - continue; + // TODO: Log invalid values + break; } } } @@ -467,6 +494,9 @@ namespace SabreTools.Serialization.Readers case "default": biosset.Default = kvp.Value; break; + default: + // TODO: Log invalid values + break; } } @@ -569,6 +599,9 @@ namespace SabreTools.Serialization.Readers case "mia": rom.MIA = kvp.Value; break; + default: + // TODO: Log invalid values + break; } } @@ -608,6 +641,9 @@ namespace SabreTools.Serialization.Readers case "flags": disk.Flags = kvp.Value; break; + default: + // TODO: Log invalid values + break; } } @@ -644,6 +680,9 @@ namespace SabreTools.Serialization.Readers case "spamsum": media.SpamSum = kvp.Value; break; + default: + // TODO: Log invalid values + break; } } @@ -668,6 +707,9 @@ namespace SabreTools.Serialization.Readers case "name": sample.Name = kvp.Value; break; + default: + // TODO: Log invalid values + break; } } @@ -692,6 +734,9 @@ namespace SabreTools.Serialization.Readers case "name": archive.Name = kvp.Value; break; + default: + // TODO: Log invalid values + break; } } @@ -725,6 +770,9 @@ namespace SabreTools.Serialization.Readers case "clock": chip.Clock = kvp.Value; break; + default: + // TODO: Log invalid values + break; } } @@ -767,6 +815,9 @@ namespace SabreTools.Serialization.Readers case "freq": video.Freq = kvp.Value; break; + default: + // TODO: Log invalid values + break; } } @@ -791,6 +842,9 @@ namespace SabreTools.Serialization.Readers case "channels": sound.Channels = kvp.Value; break; + default: + // TODO: Log invalid values + break; } } @@ -830,6 +884,9 @@ namespace SabreTools.Serialization.Readers case "service": input.Service = kvp.Value; break; + default: + // TODO: Log invalid values + break; } } @@ -861,6 +918,9 @@ namespace SabreTools.Serialization.Readers case "default": dipswitch.Default = kvp.Value; break; + default: + // TODO: Log invalid values + break; } } @@ -898,6 +958,9 @@ namespace SabreTools.Serialization.Readers case "blit": driver.Blit = kvp.Value; break; + default: + // TODO: Log invalid values + break; } } diff --git a/SabreTools.Serialization/Readers/CueSheet.cs b/SabreTools.Serialization/Readers/CueSheet.cs index bc755d6a..e7cbdb48 100644 --- a/SabreTools.Serialization/Readers/CueSheet.cs +++ b/SabreTools.Serialization/Readers/CueSheet.cs @@ -98,6 +98,10 @@ namespace SabreTools.Serialization.Readers cueFiles.Add(file); break; + + default: + // TODO: Log invalid values + break; } } @@ -621,6 +625,10 @@ namespace SabreTools.Serialization.Readers case "data": flag |= CueTrackFlag.DATA; break; + + default: + // TODO: Log invalid values + break; } } diff --git a/SabreTools.Serialization/Readers/DosCenter.cs b/SabreTools.Serialization/Readers/DosCenter.cs index 1dd2134d..f16b650f 100644 --- a/SabreTools.Serialization/Readers/DosCenter.cs +++ b/SabreTools.Serialization/Readers/DosCenter.cs @@ -53,8 +53,22 @@ namespace SabreTools.Serialization.Readers game = null; files.Clear(); break; + + default: + // TODO: Log invalid values + break; } + continue; + + case CmpRowType.TopLevel: + case CmpRowType.Standalone: + case CmpRowType.Internal: + break; + + default: + // TODO: Log invalid values + break; } // If we're at the root @@ -69,6 +83,9 @@ namespace SabreTools.Serialization.Readers case "game": game = new Game(); break; + default: + // TODO: Log invalid values + break; } } @@ -101,6 +118,9 @@ namespace SabreTools.Serialization.Readers case "comment:": dat.DosCenter.Comment = reader.Standalone?.Value; break; + default: + // TODO: Log invalid values + break; } } @@ -115,6 +135,9 @@ namespace SabreTools.Serialization.Readers case "name": game.Name = reader.Standalone?.Value; break; + default: + // TODO: Log invalid values + break; } } @@ -178,6 +201,9 @@ namespace SabreTools.Serialization.Readers case "date": file.Date = kvp.Value; break; + default: + // TODO: Log invalid values + break; } } diff --git a/SabreTools.Serialization/Readers/GZip.cs b/SabreTools.Serialization/Readers/GZip.cs index b5b0431f..d6834b48 100644 --- a/SabreTools.Serialization/Readers/GZip.cs +++ b/SabreTools.Serialization/Readers/GZip.cs @@ -116,7 +116,6 @@ namespace SabreTools.Serialization.Readers #endif obj.FileComment = data.ReadNullTerminatedAnsiString(); - #if NET20 || NET35 if ((obj.Flags & Flags.FHCRC) != 0) #else diff --git a/SabreTools.Serialization/Readers/Hashfile.cs b/SabreTools.Serialization/Readers/Hashfile.cs index a17acd3e..bd982d67 100644 --- a/SabreTools.Serialization/Readers/Hashfile.cs +++ b/SabreTools.Serialization/Readers/Hashfile.cs @@ -68,6 +68,7 @@ namespace SabreTools.Serialization.Readers /// public Data.Models.Hashfile.Hashfile? Deserialize(Stream? data, HashType hash) { +#pragma warning disable IDE0072 return hash switch { HashType.CRC32 => DeserializeSFV(data), @@ -84,6 +85,7 @@ namespace SabreTools.Serialization.Readers _ => null, }; +#pragma warning restore IDE0072 } /// diff --git a/SabreTools.Serialization/Readers/ISO9660.cs b/SabreTools.Serialization/Readers/ISO9660.cs index 7bf5cd09..3cc260f9 100644 --- a/SabreTools.Serialization/Readers/ISO9660.cs +++ b/SabreTools.Serialization/Readers/ISO9660.cs @@ -456,16 +456,19 @@ namespace SabreTools.Serialization.Readers data.SeekIfPossible(locationL * blockLength, SeekOrigin.Begin); groupL.PathTableL = ParsePathTable(data, sizeL, true); } + if (locationL2 != 0 && ((locationL2 * blockLength) + sizeL) < data.Length) { data.SeekIfPossible(locationL2 * blockLength, SeekOrigin.Begin); groupL.OptionalPathTableL = ParsePathTable(data, sizeL, true); } + if (locationM != 0 && ((locationM * blockLength) + sizeL) < data.Length) { data.SeekIfPossible(locationM * blockLength, SeekOrigin.Begin); groupL.PathTableM = ParsePathTable(data, sizeL, false); } + if (locationM2 != 0 && ((locationM2 * blockLength) + sizeL) < data.Length) { data.SeekIfPossible(locationM2 * blockLength, SeekOrigin.Begin); @@ -487,16 +490,19 @@ namespace SabreTools.Serialization.Readers data.SeekIfPossible(locationL * blockLength, SeekOrigin.Begin); groupB.PathTableL = ParsePathTable(data, sizeB, true); } + if (locationL2 != 0 && ((locationL2 * blockLength) + sizeB) < data.Length) { data.SeekIfPossible(locationL2 * blockLength, SeekOrigin.Begin); groupB.OptionalPathTableL = ParsePathTable(data, sizeB, true); } + if (locationM != 0 && ((locationM * blockLength) + sizeB) < data.Length) { data.SeekIfPossible(locationM * blockLength, SeekOrigin.Begin); groupB.PathTableM = ParsePathTable(data, sizeB, false); } + if (locationM2 != 0 && ((locationM2 * blockLength) + sizeB) < data.Length) { data.SeekIfPossible(locationM2 * blockLength, SeekOrigin.Begin); @@ -636,19 +642,19 @@ namespace SabreTools.Serialization.Readers // Use provided extent endinanness int extentLocation = bigEndian ? dr.ExtentLocation.BigEndian : dr.ExtentLocation.LittleEndian; uint extentLength = bigEndian ? dr.ExtentLength.BigEndian : dr.ExtentLength.LittleEndian; - long extentOffset = (long)extentLocation * (long)blockLength; - long extentFinal = extentOffset + (long)extentLength; + long extentOffset = extentLocation * (long)blockLength; + long extentFinal = extentOffset + extentLength; // Deal with extent length ambiguity if (!dr.ExtentLength.IsValid) { // If provided extent length is invalid, use the other value - if (extentLength <= 0 || extentFinal > (long)data.Length) + if (extentLength <= 0 || extentFinal > data.Length) extentLength = bigEndian ? dr.ExtentLength.LittleEndian : dr.ExtentLength.BigEndian; } // Validate extent length - if (extentLength <= 0 || extentFinal > (long)data.Length) + if (extentLength <= 0 || extentFinal > data.Length) return null; // Move stream to directory location diff --git a/SabreTools.Serialization/Readers/InstallShieldCabinet.cs b/SabreTools.Serialization/Readers/InstallShieldCabinet.cs index 3b06800e..a250c348 100644 --- a/SabreTools.Serialization/Readers/InstallShieldCabinet.cs +++ b/SabreTools.Serialization/Readers/InstallShieldCabinet.cs @@ -367,6 +367,7 @@ namespace SabreTools.Serialization.Readers { obj.Guid[i] = data.ReadGuid(); } + obj.CLSIDOffset = data.ReadUInt32LittleEndian(); obj.Reserved2 = data.ReadBytes(28); obj.Reserved3 = data.ReadBytes(majorVersion <= 5 ? 2 : 1); @@ -502,11 +503,13 @@ namespace SabreTools.Serialization.Readers { obj.FileGroupOffsets[i] = data.ReadUInt32LittleEndian(); } + obj.ComponentOffsets = new uint[71]; for (int i = 0; i < 71; i++) { obj.ComponentOffsets[i] = data.ReadUInt32LittleEndian(); } + obj.SetupTypesOffset = data.ReadUInt32LittleEndian(); obj.SetupTableOffset = data.ReadUInt32LittleEndian(); obj.Reserved7 = data.ReadUInt32LittleEndian(); diff --git a/SabreTools.Serialization/Readers/LZKWAJ.cs b/SabreTools.Serialization/Readers/LZKWAJ.cs index 9c3bdaae..8e4d2fe2 100644 --- a/SabreTools.Serialization/Readers/LZKWAJ.cs +++ b/SabreTools.Serialization/Readers/LZKWAJ.cs @@ -70,6 +70,7 @@ namespace SabreTools.Serialization.Readers extensions.UnknownDataLength = data.ReadUInt16LittleEndian(); extensions.UnknownData = data.ReadBytes((int)extensions.UnknownDataLength); } + if (header.HeaderFlags.HasFlag(KWAJHeaderFlags.HasFileName)) extensions.FileName = data.ReadNullTerminatedAnsiString(); if (header.HeaderFlags.HasFlag(KWAJHeaderFlags.HasFileExtension)) diff --git a/SabreTools.Serialization/Readers/LinearExecutable.cs b/SabreTools.Serialization/Readers/LinearExecutable.cs index f2377631..bb05b604 100644 --- a/SabreTools.Serialization/Readers/LinearExecutable.cs +++ b/SabreTools.Serialization/Readers/LinearExecutable.cs @@ -241,7 +241,7 @@ namespace SabreTools.Serialization.Readers data.SeekIfPossible(offset, SeekOrigin.Begin); // Create the fix-up page table - executable.FixupPageTable = new FixupPageTableEntry[executable.ObjectPageMap?.Length ?? 0 + 1]; + executable.FixupPageTable = new FixupPageTableEntry[(executable.ObjectPageMap?.Length ?? 0) + 1]; // Try to parse the fix-up page table for (int i = 0; i < executable.FixupPageTable.Length; i++) @@ -264,7 +264,7 @@ namespace SabreTools.Serialization.Readers data.SeekIfPossible(offset, SeekOrigin.Begin); // Create the fix-up record table - executable.FixupRecordTable = new FixupRecordTableEntry[executable.ObjectPageMap?.Length ?? 0 + 1]; + executable.FixupRecordTable = new FixupRecordTableEntry[(executable.ObjectPageMap?.Length ?? 0) + 1]; // Try to parse the fix-up record table for (int i = 0; i < executable.FixupRecordTable.Length; i++) @@ -489,6 +489,10 @@ namespace SabreTools.Serialization.Readers entry.ImportOrdinalNumber = data.ReadUInt32LittleEndian(); break; + // Bitflag that is ignored + case BundleType.ParameterTypingInformationPresent: + break; + default: return null; } diff --git a/SabreTools.Serialization/Readers/MSDOS.cs b/SabreTools.Serialization/Readers/MSDOS.cs index d95af8ff..7324581b 100644 --- a/SabreTools.Serialization/Readers/MSDOS.cs +++ b/SabreTools.Serialization/Readers/MSDOS.cs @@ -104,6 +104,7 @@ namespace SabreTools.Serialization.Readers { obj.Reserved1[i] = data.ReadUInt16LittleEndian(); } + obj.OEMIdentifier = data.ReadUInt16LittleEndian(); obj.OEMInformation = data.ReadUInt16LittleEndian(); obj.Reserved2 = new ushort[10]; @@ -111,6 +112,7 @@ namespace SabreTools.Serialization.Readers { obj.Reserved2[i] = data.ReadUInt16LittleEndian(); } + obj.NewExeHeaderAddr = data.ReadUInt32LittleEndian(); #endregion diff --git a/SabreTools.Serialization/Readers/MoPaQ.cs b/SabreTools.Serialization/Readers/MoPaQ.cs index 58df5092..9b9aa62c 100644 --- a/SabreTools.Serialization/Readers/MoPaQ.cs +++ b/SabreTools.Serialization/Readers/MoPaQ.cs @@ -217,7 +217,7 @@ namespace SabreTools.Serialization.Readers public static BlockEntry[]? ParseBlockTable(Stream data, long initialOffset, ArchiveHeader header, MoPaQDecrypter decrypter) { // Get the block table offset - long offset = initialOffset + ((uint)header.BlockTablePositionHi << 23) | header.BlockTablePosition; + long offset = initialOffset + (((uint)header.BlockTablePositionHi << 23) | header.BlockTablePosition); if (offset <= initialOffset || offset >= data.Length) return null; diff --git a/SabreTools.Serialization/Readers/N3DS.cs b/SabreTools.Serialization/Readers/N3DS.cs index e13d5e35..1544bc03 100644 --- a/SabreTools.Serialization/Readers/N3DS.cs +++ b/SabreTools.Serialization/Readers/N3DS.cs @@ -157,6 +157,7 @@ namespace SabreTools.Serialization.Readers { obj.Descriptors[i] = (ARM9AccessControlDescriptors)data.ReadByteValue(); } + obj.DescriptorVersion = data.ReadByteValue(); return obj; @@ -176,6 +177,7 @@ namespace SabreTools.Serialization.Readers { obj.Descriptors[i] = data.ReadUInt32LittleEndian(); } + obj.Reserved = data.ReadBytes(0x10); return obj; @@ -201,17 +203,20 @@ namespace SabreTools.Serialization.Readers { obj.ResourceLimitDescriptors[i] = data.ReadUInt16LittleEndian(); } + obj.StorageInfo = ParseStorageInfo(data); obj.ServiceAccessControl = new ulong[32]; for (int i = 0; i < 32; i++) { obj.ServiceAccessControl[i] = data.ReadUInt64LittleEndian(); } + obj.ExtendedServiceAccessControl = new ulong[2]; for (int i = 0; i < 2; i++) { obj.ExtendedServiceAccessControl[i] = data.ReadUInt64LittleEndian(); } + obj.Reserved = data.ReadBytes(0x0F); obj.ResourceLimitCategory = (ResourceLimitCategory)data.ReadByteValue(); @@ -307,6 +312,7 @@ namespace SabreTools.Serialization.Readers { obj.FileHeaders[i] = ParseExeFSFileHeader(data); } + obj.Reserved = data.ReadBytes(0x20); obj.FileHashes = new byte[10][]; for (int i = 0; i < 10; i++) @@ -561,6 +567,7 @@ namespace SabreTools.Serialization.Readers { obj.DependencyModuleList[i] = data.ReadUInt64LittleEndian(); } + obj.SystemInfo = ParseSystemInfo(data); return obj; diff --git a/SabreTools.Serialization/Readers/NCF.cs b/SabreTools.Serialization/Readers/NCF.cs index c31b8473..12e3ae9d 100644 --- a/SabreTools.Serialization/Readers/NCF.cs +++ b/SabreTools.Serialization/Readers/NCF.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using System.IO; using System.Text; using SabreTools.Data.Models.NCF; diff --git a/SabreTools.Serialization/Readers/NewExecutable.cs b/SabreTools.Serialization/Readers/NewExecutable.cs index 9b54ad0f..978a68a2 100644 --- a/SabreTools.Serialization/Readers/NewExecutable.cs +++ b/SabreTools.Serialization/Readers/NewExecutable.cs @@ -212,7 +212,12 @@ namespace SabreTools.Serialization.Readers entry.MoveableSegmentNumber = data.ReadByteValue(); entry.MoveableOffset = data.ReadUInt16LittleEndian(); break; + + default: + // TODO: Log invalid values + break; } + entryTable.Add(entry); } @@ -253,7 +258,7 @@ namespace SabreTools.Serialization.Readers obj.MovableEntriesCount = data.ReadUInt16LittleEndian(); obj.SegmentAlignmentShiftCount = data.ReadUInt16LittleEndian(); obj.ResourceEntriesCount = data.ReadUInt16LittleEndian(); - obj.TargetOperatingSystem = (Data.Models.NewExecutable.OperatingSystem)data.ReadByteValue(); + obj.TargetOperatingSystem = (OperatingSystem)data.ReadByteValue(); obj.AdditionalFlags = (OS2Flag)data.ReadByteValue(); obj.ReturnThunkOffset = data.ReadUInt16LittleEndian(); obj.SegmentReferenceThunkOffset = data.ReadUInt16LittleEndian(); @@ -469,6 +474,12 @@ namespace SabreTools.Serialization.Readers case RelocationRecordFlag.OSFIXUP: obj.OSFixupRelocationRecord = ParseOSFixupRelocationRecord(data); break; + case RelocationRecordFlag.ADDITIVE: + // TODO: Figure out the record for this, if possible + break; + default: + // TODO: Log invalid values + break; } return obj; @@ -666,7 +677,6 @@ namespace SabreTools.Serialization.Readers data.SeekIfPossible(obj.Offset + initialOffset, SeekOrigin.Begin); obj.Data = data.ReadBytes(obj.Length); - #if NET20 || NET35 if ((obj.FlagWord & SegmentTableEntryFlag.RELOCINFO) != 0) #else diff --git a/SabreTools.Serialization/Readers/Nitro.cs b/SabreTools.Serialization/Readers/Nitro.cs index 6afe1c05..ea76cfb1 100644 --- a/SabreTools.Serialization/Readers/Nitro.cs +++ b/SabreTools.Serialization/Readers/Nitro.cs @@ -175,16 +175,19 @@ namespace SabreTools.Serialization.Readers { obj.GlobalMBK15Settings[i] = data.ReadUInt32LittleEndian(); } + obj.LocalMBK68SettingsARM9 = new uint[3]; for (int i = 0; i < 3; i++) { obj.LocalMBK68SettingsARM9[i] = data.ReadUInt32LittleEndian(); } + obj.LocalMBK68SettingsARM7 = new uint[3]; for (int i = 0; i < 3; i++) { obj.LocalMBK68SettingsARM7[i] = data.ReadUInt32LittleEndian(); } + obj.GlobalMBK9Setting = data.ReadUInt32LittleEndian(); obj.RegionFlags = data.ReadUInt32LittleEndian(); obj.AccessControl = data.ReadUInt32LittleEndian(); diff --git a/SabreTools.Serialization/Readers/PIC.cs b/SabreTools.Serialization/Readers/PIC.cs index 99c24c4e..7e14325c 100644 --- a/SabreTools.Serialization/Readers/PIC.cs +++ b/SabreTools.Serialization/Readers/PIC.cs @@ -108,6 +108,9 @@ namespace SabreTools.Serialization.Readers case DiscTypeIdentifierRecordable: obj.FormatDependentContents = data.ReadBytes(100); break; + default: + // TODO: Log invalid values + break; } return obj; diff --git a/SabreTools.Serialization/Readers/PKZIP.cs b/SabreTools.Serialization/Readers/PKZIP.cs index 6f304d79..9b79b571 100644 --- a/SabreTools.Serialization/Readers/PKZIP.cs +++ b/SabreTools.Serialization/Readers/PKZIP.cs @@ -108,6 +108,10 @@ namespace SabreTools.Serialization.Readers validBlock = true; archive.ArchiveExtraDataRecord = aedr; break; + + default: + // TODO: Log invalid values + break; } // If there was an invalid block @@ -209,6 +213,7 @@ namespace SabreTools.Serialization.Readers else obj.FileName = Encoding.ASCII.GetString(filenameBytes); } + if (obj.ExtraFieldLength > 0 && data.Position + obj.ExtraFieldLength <= data.Length) { byte[] extraBytes = data.ReadBytes(obj.ExtraFieldLength); @@ -217,6 +222,7 @@ namespace SabreTools.Serialization.Readers obj.ExtraFields = ParseExtraFields(obj, extraBytes); } + if (obj.FileCommentLength > 0 && data.Position + obj.FileCommentLength <= data.Length) { byte[] commentBytes = data.ReadBytes(obj.FileCommentLength); @@ -562,6 +568,7 @@ namespace SabreTools.Serialization.Readers else obj.FileName = Encoding.ASCII.GetString(filenameBytes); } + if (obj.ExtraFieldLength > 0 && data.Position + obj.ExtraFieldLength <= data.Length) { byte[] extraBytes = data.ReadBytes(obj.ExtraFieldLength); diff --git a/SabreTools.Serialization/Readers/PortableExecutable.cs b/SabreTools.Serialization/Readers/PortableExecutable.cs index 479cbe54..bba8e8c0 100644 --- a/SabreTools.Serialization/Readers/PortableExecutable.cs +++ b/SabreTools.Serialization/Readers/PortableExecutable.cs @@ -1041,7 +1041,7 @@ namespace SabreTools.Serialization.Readers obj.Add(entry); // All zero values means the last entry - if (entry.OrdinalNameFlag == false + if (!entry.OrdinalNameFlag && entry.OrdinalNumber == 0 && entry.HintNameTableRVA == 0) break; @@ -1103,7 +1103,7 @@ namespace SabreTools.Serialization.Readers if (obj.OrdinalNameFlag) obj.OrdinalNumber = (ushort)(value & ~0x80000000); else - obj.HintNameTableRVA = (uint)(value & ~0x80000000); + obj.HintNameTableRVA = value & ~0x80000000; } else if (magic == OptionalHeaderMagicNumber.PE32Plus) { @@ -1182,7 +1182,7 @@ namespace SabreTools.Serialization.Readers obj.Add(entry); // All zero values means the last entry - if (entry.OrdinalNameFlag == false + if (!entry.OrdinalNameFlag && entry.OrdinalNumber == 0 && entry.HintNameTableRVA == 0) break; @@ -1246,7 +1246,7 @@ namespace SabreTools.Serialization.Readers if (obj.OrdinalNameFlag) obj.OrdinalNumber = (ushort)(value & ~0x80000000); else - obj.HintNameTableRVA = (uint)(value & ~0x80000000); + obj.HintNameTableRVA = value & ~0x80000000; } else if (magic == OptionalHeaderMagicNumber.PE32Plus) { diff --git a/SabreTools.Serialization/Readers/RomCenter.cs b/SabreTools.Serialization/Readers/RomCenter.cs index 773180f4..12a8e207 100644 --- a/SabreTools.Serialization/Readers/RomCenter.cs +++ b/SabreTools.Serialization/Readers/RomCenter.cs @@ -38,6 +38,7 @@ namespace SabreTools.Serialization.Readers case IniRowType.None: case IniRowType.Comment: continue; + case IniRowType.SectionHeader: switch (reader.Section?.ToLowerInvariant()) { @@ -53,8 +54,16 @@ namespace SabreTools.Serialization.Readers case "games": dat.Games ??= new Games(); break; + default: + break; } + continue; + + case IniRowType.KeyValue: + case IniRowType.Invalid: + default: + break; } // If we're in credits @@ -86,6 +95,8 @@ namespace SabreTools.Serialization.Readers case "comment": dat.Credits.Comment = reader.KeyValuePair?.Value; break; + default: + break; } } @@ -109,6 +120,8 @@ namespace SabreTools.Serialization.Readers case "merge": dat.Dat.Merge = reader.KeyValuePair?.Value; break; + default: + break; } } @@ -126,6 +139,8 @@ namespace SabreTools.Serialization.Readers case "version": dat.Emulator.Version = reader.KeyValuePair?.Value; break; + default: + break; } } diff --git a/SabreTools.Serialization/Readers/SGA.cs b/SabreTools.Serialization/Readers/SGA.cs index 9756d6fb..45e5fde9 100644 --- a/SabreTools.Serialization/Readers/SGA.cs +++ b/SabreTools.Serialization/Readers/SGA.cs @@ -246,7 +246,7 @@ namespace SabreTools.Serialization.Readers // TODO: If indexed by position, I think it needs to be adjusted by start of table // Create the strings dictionary - directory.StringTable = new Dictionary((int)directoryHeader.StringTableCount); + directory.StringTable = new Dictionary(directoryHeader.StringTableCount); // Get the current position to adjust the offsets long stringTableStart = data.Position; diff --git a/SabreTools.Serialization/Readers/SeparatedValue.cs b/SabreTools.Serialization/Readers/SeparatedValue.cs index b65e5334..5e5d7219 100644 --- a/SabreTools.Serialization/Readers/SeparatedValue.cs +++ b/SabreTools.Serialization/Readers/SeparatedValue.cs @@ -151,6 +151,7 @@ namespace SabreTools.Serialization.Readers Status = reader.Line[16], }; } + rows.Add(row); } diff --git a/SabreTools.Serialization/Readers/VBSP.cs b/SabreTools.Serialization/Readers/VBSP.cs index 9f0d2a99..8e8656ab 100644 --- a/SabreTools.Serialization/Readers/VBSP.cs +++ b/SabreTools.Serialization/Readers/VBSP.cs @@ -286,6 +286,7 @@ namespace SabreTools.Serialization.Readers { obj.Lumps[i] = ParseVbspLumpEntry(data); } + obj.MapRevision = data.ReadInt32LittleEndian(); return obj; @@ -572,6 +573,7 @@ namespace SabreTools.Serialization.Readers if (occluderData is not null) lump.Data[i] = occluderData; } + lump.PolyDataCount = data.ReadInt32LittleEndian(); lump.PolyData = new OccluderPolyData[lump.Count]; for (int i = 0; i < lump.Count; i++) @@ -580,6 +582,7 @@ namespace SabreTools.Serialization.Readers if (polyData is not null) lump.PolyData[i] = polyData; } + lump.VertexIndexCount = data.ReadInt32LittleEndian(); lump.VertexIndicies = new int[lump.VertexIndexCount]; for (int i = 0; i < lump.VertexIndexCount; i++) @@ -625,11 +628,13 @@ namespace SabreTools.Serialization.Readers { leaf.Mins[i] = data.ReadInt16LittleEndian(); } + leaf.Maxs = new short[3]; for (int i = 0; i < leaf.Maxs.Length; i++) { leaf.Maxs[i] = data.ReadInt16LittleEndian(); } + leaf.FirstLeafFace = data.ReadUInt16LittleEndian(); leaf.NumLeafFaces = data.ReadUInt16LittleEndian(); leaf.FirstLeafBrush = data.ReadUInt16LittleEndian(); diff --git a/SabreTools.Serialization/Readers/WAD3.cs b/SabreTools.Serialization/Readers/WAD3.cs index 6c763fc8..5621223b 100644 --- a/SabreTools.Serialization/Readers/WAD3.cs +++ b/SabreTools.Serialization/Readers/WAD3.cs @@ -165,11 +165,13 @@ namespace SabreTools.Serialization.Readers { obj.FontInfo[i] = ParseCharInfo(data); } + obj.Data = new byte[obj.Height][]; for (int i = 0; i < obj.Height; i++) { obj.Data[i] = data.ReadBytes((int)obj.Width); } + obj.ColorsUsed = data.ReadUInt16LittleEndian(); obj.Palette = new byte[obj.ColorsUsed][]; for (int i = 0; i < obj.ColorsUsed; i++) @@ -233,11 +235,13 @@ namespace SabreTools.Serialization.Readers { obj.MipOffsets[i] = data.ReadUInt32LittleEndian(); } + obj.MipImages = new MipMap[4]; for (int i = 0; i < obj.MipImages.Length; i++) { obj.MipImages[i] = ParseMipMap(data, obj.Width, obj.Height); } + obj.ColorsUsed = data.ReadUInt16LittleEndian(); obj.Palette = new byte[obj.ColorsUsed][]; for (int i = 0; i < obj.ColorsUsed; i++) @@ -264,6 +268,7 @@ namespace SabreTools.Serialization.Readers { obj.Data[i] = data.ReadBytes((int)obj.Width); } + obj.ColorsUsed = data.ReadUInt16LittleEndian(); obj.Palette = new byte[obj.ColorsUsed][]; for (int i = 0; i < obj.ColorsUsed; i++) diff --git a/SabreTools.Serialization/Readers/WiseScript.cs b/SabreTools.Serialization/Readers/WiseScript.cs index e2b96bb3..251921c1 100644 --- a/SabreTools.Serialization/Readers/WiseScript.cs +++ b/SabreTools.Serialization/Readers/WiseScript.cs @@ -69,9 +69,9 @@ namespace SabreTools.Serialization.Readers data.SeekIfPossible(current, SeekOrigin.Begin); // If the strings are valid - if ((ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2)) - && (logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%"))) - && (messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true))) + if (ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2) + && logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%")) + && messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true)) && !(ftpUrl.Length == 0 && logPath.Length == 0 && messageFont.Length == 0)) { // TODO: Figure out if this maps to existing fields @@ -92,9 +92,9 @@ namespace SabreTools.Serialization.Readers data.SeekIfPossible(current, SeekOrigin.Begin); // If the strings are valid - if ((ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2)) - && (logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%"))) - && (messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true))) + if (ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2) + && logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%")) + && messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true)) && !(ftpUrl.Length == 0 && logPath.Length == 0 && messageFont.Length == 0)) { header.Flags = data.ReadByteValue(); @@ -117,9 +117,9 @@ namespace SabreTools.Serialization.Readers data.SeekIfPossible(current, SeekOrigin.Begin); // If the strings are valid - if ((ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2)) - && (logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%"))) - && (messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true))) + if (ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2) + && logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%")) + && messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true)) && !(ftpUrl.Length == 0 && logPath.Length == 0 && messageFont.Length == 0)) { header.Flags = data.ReadByteValue(); diff --git a/SabreTools.Serialization/Readers/WiseSectionHeader.cs b/SabreTools.Serialization/Readers/WiseSectionHeader.cs index f971ff13..9457e323 100644 --- a/SabreTools.Serialization/Readers/WiseSectionHeader.cs +++ b/SabreTools.Serialization/Readers/WiseSectionHeader.cs @@ -309,6 +309,7 @@ namespace SabreTools.Serialization.Readers { oneCount++; } + counter++; } diff --git a/SabreTools.Serialization/Readers/XZ.cs b/SabreTools.Serialization/Readers/XZ.cs index 3098c027..760588fa 100644 --- a/SabreTools.Serialization/Readers/XZ.cs +++ b/SabreTools.Serialization/Readers/XZ.cs @@ -237,7 +237,7 @@ namespace SabreTools.Serialization.Readers } // Parse the padding as needed - int paddingLength = 4 - (int)(data.Position - currentOffset) % 4; + int paddingLength = 4 - ((int)(data.Position - currentOffset) % 4); if (paddingLength >= 0) obj.Padding = data.ReadBytes(paddingLength); diff --git a/SabreTools.Serialization/WrapperFactory.cs b/SabreTools.Serialization/WrapperFactory.cs index 7f5eb490..68f427a8 100644 --- a/SabreTools.Serialization/WrapperFactory.cs +++ b/SabreTools.Serialization/WrapperFactory.cs @@ -63,6 +63,11 @@ namespace SabreTools.Serialization WrapperType.XZ => XZ.Create(data), WrapperType.XZP => XZP.Create(data), WrapperType.ZSTD => ZSTD.Create(data), + + // Unimplemented + WrapperType.UNKNOWN => null, + WrapperType.WiseOverlayHeader => null, + WrapperType.WiseScript => null, _ => null, }; } diff --git a/SabreTools.Serialization/Wrappers/AACSMediaKeyBlock.Printing.cs b/SabreTools.Serialization/Wrappers/AACSMediaKeyBlock.Printing.cs index 387169df..3993a424 100644 --- a/SabreTools.Serialization/Wrappers/AACSMediaKeyBlock.Printing.cs +++ b/SabreTools.Serialization/Wrappers/AACSMediaKeyBlock.Printing.cs @@ -82,6 +82,10 @@ namespace SabreTools.Serialization.Wrappers case CopyrightRecord c: Print(builder, c); break; + + default: + // TODO: Log invalid values + break; } } diff --git a/SabreTools.Serialization/Wrappers/BSP.Extraction.cs b/SabreTools.Serialization/Wrappers/BSP.Extraction.cs index 79a4a107..b3bc4222 100644 --- a/SabreTools.Serialization/Wrappers/BSP.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/BSP.Extraction.cs @@ -48,6 +48,7 @@ namespace SabreTools.Serialization.Wrappers // Create the filename string filename = $"lump_{index}.bin"; +#pragma warning disable IDE0010 switch ((LumpType)index) { case LumpType.LUMP_ENTITIES: @@ -57,6 +58,7 @@ namespace SabreTools.Serialization.Wrappers filename = "texture_data.bin"; break; } +#pragma warning restore IDE0010 // If we have an invalid output directory if (string.IsNullOrEmpty(outputDirectory)) diff --git a/SabreTools.Serialization/Wrappers/BSP.Printing.cs b/SabreTools.Serialization/Wrappers/BSP.Printing.cs index a86cbb8b..ad9d8590 100644 --- a/SabreTools.Serialization/Wrappers/BSP.Printing.cs +++ b/SabreTools.Serialization/Wrappers/BSP.Printing.cs @@ -57,6 +57,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(lump.Offset, " Offset"); builder.AppendLine(lump.Length, " Length"); +#pragma warning disable IDE0010 switch ((LumpType)i) { case LumpType.LUMP_ENTITIES: @@ -108,6 +109,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine($" Unsupported lump type: {(LumpType)i} (0x{i:X4})"); break; } +#pragma warning restore IDE0010 } builder.AppendLine(); @@ -115,6 +117,7 @@ namespace SabreTools.Serialization.Wrappers private static string GetLumpName(int i) { +#pragma warning disable IDE0072 return (LumpType)i switch { LumpType.LUMP_ENTITIES => " - LUMP_ENTITIES", @@ -134,6 +137,7 @@ namespace SabreTools.Serialization.Wrappers LumpType.LUMP_MODELS => " - LUMP_MODELS", _ => string.Empty, }; +#pragma warning restore IDE0072 } private static void Print(StringBuilder builder, EntitiesLump lump) diff --git a/SabreTools.Serialization/Wrappers/CDROM.cs b/SabreTools.Serialization/Wrappers/CDROM.cs index 63e627c4..c27d1a1e 100644 --- a/SabreTools.Serialization/Wrappers/CDROM.cs +++ b/SabreTools.Serialization/Wrappers/CDROM.cs @@ -42,7 +42,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the CDROM data track /// Offset within the array to parse /// A CDROM data track wrapper on success, null on failure - public new static CDROM? Create(byte[]? data, int offset) + public static new CDROM? Create(byte[]? data, int offset) { // If the data is invalid if (data is null || data.Length == 0) @@ -62,7 +62,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Seekable Stream representing the CDROM data track /// A CDROM data track wrapper on success, null on failure - public new static CDROM? Create(Stream? data) + public static new CDROM? Create(Stream? data) { // If the data is invalid if (data is null || !data.CanRead || !data.CanSeek) diff --git a/SabreTools.Serialization/Wrappers/CHD.Printing.cs b/SabreTools.Serialization/Wrappers/CHD.Printing.cs index 6295eb4a..3a4334b3 100644 --- a/SabreTools.Serialization/Wrappers/CHD.Printing.cs +++ b/SabreTools.Serialization/Wrappers/CHD.Printing.cs @@ -138,6 +138,7 @@ namespace SabreTools.Serialization.Wrappers compressorsLine += string.Join(", ", [.. compressors]); } + builder.AppendLine(compressorsLine); builder.AppendLine(header.LogicalBytes, $"Logical bytes"); diff --git a/SabreTools.Serialization/Wrappers/CIA.Printing.cs b/SabreTools.Serialization/Wrappers/CIA.Printing.cs index 0e6ba402..a13f62ea 100644 --- a/SabreTools.Serialization/Wrappers/CIA.Printing.cs +++ b/SabreTools.Serialization/Wrappers/CIA.Printing.cs @@ -63,6 +63,7 @@ namespace SabreTools.Serialization.Wrappers case 0: certificateName = " (CA)"; break; case 1: certificateName = " (Ticket)"; break; case 2: certificateName = " (TMD)"; break; + default: break; } builder.AppendLine($" Certificate {i}{certificateName}"); @@ -87,6 +88,9 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(certificate.ECCPublicKey, " Public key"); builder.AppendLine(certificate.ECCPadding, " Padding"); break; + default: + builder.AppendLine($"Key type '{certificate.KeyType}' not recognized"); + break; } } @@ -134,6 +138,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(ticket.Limits[i], $" Limit {i}"); } } + builder.AppendLine(ticket.ContentIndexSize, " Content index size"); builder.AppendLine(ticket.ContentIndex, " Content index"); builder.AppendLine(); @@ -155,6 +160,7 @@ namespace SabreTools.Serialization.Wrappers { case 0: certificateName = " (Ticket)"; break; case 1: certificateName = " (CA)"; break; + default: break; } builder.AppendLine($" Certificate {i}{certificateName}"); @@ -179,6 +185,9 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(certificate.ECCPublicKey, " Public key"); builder.AppendLine(certificate.ECCPadding, " Padding"); break; + default: + builder.AppendLine($"Key type '{certificate.KeyType}' not recognized"); + break; } } } @@ -278,6 +287,7 @@ namespace SabreTools.Serialization.Wrappers { case 0: certificateName = " (TMD)"; break; case 1: certificateName = " (CA)"; break; + default: break; } builder.AppendLine($" Certificate {i}{certificateName}"); @@ -302,6 +312,9 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(certificate.ECCPublicKey, " Public key"); builder.AppendLine(certificate.ECCPadding, " Padding"); break; + default: + builder.AppendLine($"Key type '{certificate.KeyType}' not recognized"); + break; } } } diff --git a/SabreTools.Serialization/Wrappers/IExtractable.cs b/SabreTools.Serialization/Wrappers/IExtractable.cs index 70e55216..d6b062f6 100644 --- a/SabreTools.Serialization/Wrappers/IExtractable.cs +++ b/SabreTools.Serialization/Wrappers/IExtractable.cs @@ -12,6 +12,6 @@ namespace SabreTools.Serialization.Wrappers /// Output directory to write to /// True to include debug data, false otherwise /// True if extraction succeeded, false otherwise - bool Extract(string outputDirectory, bool includeDebug); + public bool Extract(string outputDirectory, bool includeDebug); } } diff --git a/SabreTools.Serialization/Wrappers/IPrintable.cs b/SabreTools.Serialization/Wrappers/IPrintable.cs index 97c4ec27..d78f924f 100644 --- a/SabreTools.Serialization/Wrappers/IPrintable.cs +++ b/SabreTools.Serialization/Wrappers/IPrintable.cs @@ -11,13 +11,13 @@ namespace SabreTools.Serialization.Wrappers /// /// Export the item information as JSON /// - string ExportJSON(); + public string ExportJSON(); #endif /// /// Print information associated with a model /// /// StringBuilder to append information to - void PrintInformation(StringBuilder builder); + public void PrintInformation(StringBuilder builder); } } diff --git a/SabreTools.Serialization/Wrappers/ISO9660.Printing.cs b/SabreTools.Serialization/Wrappers/ISO9660.Printing.cs index b84417ff..057063b0 100644 --- a/SabreTools.Serialization/Wrappers/ISO9660.Printing.cs +++ b/SabreTools.Serialization/Wrappers/ISO9660.Printing.cs @@ -134,7 +134,6 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(encoding.GetString(vd.SystemIdentifier), " System Identifier"); builder.AppendLine(encoding.GetString(vd.VolumeIdentifier), " Volume Identifier"); - if (vd.Unused8Bytes is not null && Array.TrueForAll(vd.Unused8Bytes, b => b == 0)) builder.AppendLine("Zeroed", " Unused 8 Bytes"); else @@ -149,6 +148,7 @@ namespace SabreTools.Serialization.Wrappers else builder.AppendLine(pvd2.Unused32Bytes, " Unused 32 Bytes"); } + if (vd is SupplementaryVolumeDescriptor svd2) { // TODO: Trim trailing 0x00 and split array into characters (multi-byte encoding detection) @@ -279,6 +279,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine($" No Type-L Path Table {tableNum}:"); builder.AppendLine(); } + if (ptgs[tableNum].OptionalPathTableL is not null) { builder.AppendLine($" Optional Type-L Path Table {tableNum}:"); @@ -290,6 +291,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine($" No Optional Type-L Path Table {tableNum}:"); builder.AppendLine(); } + if (ptgs[tableNum].PathTableM is not null) { builder.AppendLine($" Type-M Path Table {tableNum}:"); @@ -301,6 +303,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine($" No Type-M Path Table {tableNum}:"); builder.AppendLine(); } + if (ptgs[tableNum].OptionalPathTableM is not null) { builder.AppendLine($" Optional Type-M Path Table {tableNum}:"); @@ -439,7 +442,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(drdt.Hour, " Hour"); builder.AppendLine(drdt.Minute, " Minute"); builder.AppendLine(drdt.Second, " Second"); - string tz = $"{((drdt.TimezoneOffset - 48) * 15 / 60):+0;-0}:{((drdt.TimezoneOffset - 48) * 15 % 60 + 60) % 60:00} (0x{drdt.TimezoneOffset:X2})"; + string tz = $"{(drdt.TimezoneOffset - 48) * 15 / 60:+0;-0}:{(((drdt.TimezoneOffset - 48) * 15 % 60) + 60) % 60:00} (0x{drdt.TimezoneOffset:X2})"; builder.AppendLine(tz, " Timezone Offset"); } @@ -466,7 +469,6 @@ namespace SabreTools.Serialization.Wrappers else builder.AppendLine(" Fixed Bits: Not All Set"); - builder.AppendLine(Format(ear.FileCreationDateTime), " File Creation Date Time"); builder.AppendLine(Format(ear.FileModificationDateTime), " File Modification Date Time"); builder.AppendLine(Format(ear.FileExpirationDateTime), " File Expiration Date Time"); @@ -512,7 +514,7 @@ namespace SabreTools.Serialization.Wrappers ? Encoding.ASCII.GetString(dt.Centisecond) : BitConverter.ToString(dt.Centisecond).Replace('-', ' '); - string tz = $"{((dt.TimezoneOffset - 48) * 15 / 60):+0;-0}:{((dt.TimezoneOffset - 48) * 15 % 60 + 60) % 60:00} (0x{dt.TimezoneOffset:X2})"; + string tz = $"{(dt.TimezoneOffset - 48) * 15 / 60:+0;-0}:{(((dt.TimezoneOffset - 48) * 15 % 60) + 60) % 60:00} (0x{dt.TimezoneOffset:X2})"; return $"{year}-{month}-{day} {hour}:{minute}:{second}.{csecond} [{tz}]"; } diff --git a/SabreTools.Serialization/Wrappers/IWrapper.cs b/SabreTools.Serialization/Wrappers/IWrapper.cs index 719e01e0..6462b543 100644 --- a/SabreTools.Serialization/Wrappers/IWrapper.cs +++ b/SabreTools.Serialization/Wrappers/IWrapper.cs @@ -8,6 +8,6 @@ namespace SabreTools.Serialization.Wrappers /// /// Get a human-readable description of the wrapper /// - string Description(); + public string Description(); } } diff --git a/SabreTools.Serialization/Wrappers/IWrapperT.cs b/SabreTools.Serialization/Wrappers/IWrapperT.cs index 47fa5bfd..d0595fbe 100644 --- a/SabreTools.Serialization/Wrappers/IWrapperT.cs +++ b/SabreTools.Serialization/Wrappers/IWrapperT.cs @@ -9,6 +9,6 @@ namespace SabreTools.Serialization.Wrappers /// /// Get the backing model /// - TModel GetModel(); + public TModel GetModel(); } } diff --git a/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.Extraction.cs b/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.Extraction.cs index 5a5bde3d..103dfe79 100644 --- a/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.Extraction.cs @@ -102,8 +102,8 @@ namespace SabreTools.Serialization.Wrappers // Ensure the full output directory exists filename = Path.Combine(outputDirectory, filename); var directoryName = Path.GetDirectoryName(filename); - if (directoryName is not null && !System.IO.Directory.Exists(directoryName)) - System.IO.Directory.CreateDirectory(directoryName); + if (directoryName is not null && !Directory.Exists(directoryName)) + Directory.CreateDirectory(directoryName); // Try to write the data try diff --git a/SabreTools.Serialization/Wrappers/InstallShieldCabinet.Extraction.cs b/SabreTools.Serialization/Wrappers/InstallShieldCabinet.Extraction.cs index 17fcefc0..54acfd43 100644 --- a/SabreTools.Serialization/Wrappers/InstallShieldCabinet.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/InstallShieldCabinet.Extraction.cs @@ -452,7 +452,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Uncompress a source byte array to a destination /// - private unsafe static int Uncompress(byte[] dest, ref uint destLen, byte[] source, ref uint sourceLen) + private static unsafe int Uncompress(byte[] dest, ref uint destLen, byte[] source, ref uint sourceLen) { fixed (byte* sourcePtr = source, destPtr = dest) { @@ -485,7 +485,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Uncompress a source byte array to a destination (old version) /// - private unsafe static int UncompressOld(byte[] dest, ref uint destLen, byte[] source, ref uint sourceLen) + private static unsafe int UncompressOld(byte[] dest, ref uint destLen, byte[] source, ref uint sourceLen) { fixed (byte* sourcePtr = source, destPtr = dest) { diff --git a/SabreTools.Serialization/Wrappers/InstallShieldCabinet.Printing.cs b/SabreTools.Serialization/Wrappers/InstallShieldCabinet.Printing.cs index 8298070e..23a7e769 100644 --- a/SabreTools.Serialization/Wrappers/InstallShieldCabinet.Printing.cs +++ b/SabreTools.Serialization/Wrappers/InstallShieldCabinet.Printing.cs @@ -85,6 +85,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.LastFileSizeCompressed, " Last file size compressed"); builder.AppendLine(header.LastFileSizeCompressedHigh, " Last file size compressed high"); } + builder.AppendLine(); } diff --git a/SabreTools.Serialization/Wrappers/LZSZDD.Extraction.cs b/SabreTools.Serialization/Wrappers/LZSZDD.Extraction.cs index 2c3c737e..ae308c12 100644 --- a/SabreTools.Serialization/Wrappers/LZSZDD.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/LZSZDD.Extraction.cs @@ -93,7 +93,7 @@ namespace SabreTools.Serialization.Wrappers return Path.GetFileNameWithoutExtension(input); // Handle replacing characters - char c = (char.IsUpper(input[0]) ? char.ToLower(LastChar) : char.ToUpper(LastChar)); + char c = char.IsUpper(input[0]) ? char.ToLower(LastChar) : char.ToUpper(LastChar); #if NETCOREAPP || NETSTANDARD2_1_OR_GREATER string text2 = extension[..^1] + c; #else diff --git a/SabreTools.Serialization/Wrappers/LinearExecutable.Printing.cs b/SabreTools.Serialization/Wrappers/LinearExecutable.Printing.cs index 35cf8301..6c7c5ac1 100644 --- a/SabreTools.Serialization/Wrappers/LinearExecutable.Printing.cs +++ b/SabreTools.Serialization/Wrappers/LinearExecutable.Printing.cs @@ -301,6 +301,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(entry.ImportOrdinalNumber, " Import ordinal number"); break; + case BundleType.ParameterTypingInformationPresent: default: builder.AppendLine($" Unknown entry type {type}"); break; @@ -601,6 +602,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(entry.SourceOffsetList[j], $" Source Offset List Entry {j}"); } } + builder.AppendLine(); } } diff --git a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Extraction.cs b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Extraction.cs index 50cee365..b31c3b11 100644 --- a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.Extraction.cs @@ -439,7 +439,6 @@ namespace SabreTools.Serialization.Wrappers { _fileStream = GetFileStream(filename, outputDirectory); - // Loop through the data blocks // Has to be a while loop instead of a for loop due to cab spanning continue blocks for (int j = 0; j < _folder.DataCount; j++) @@ -494,6 +493,7 @@ namespace SabreTools.Serialization.Wrappers CompressionType.TYPE_LZX => [], // Should be impossible + CompressionType.MASK_TYPE => [], _ => [], }; @@ -549,7 +549,7 @@ namespace SabreTools.Serialization.Wrappers } _fileStream.Write(data, (int)tempBytesLeft, data.Length - (int)tempBytesLeft); - _bytesLeft -= (data.Length - tempBytesLeft); + _bytesLeft -= data.Length - tempBytesLeft; } // Top if block occurs on http://redump.org/disc/107833/ , middle on https://dbox.tools/titles/pc/57520FA0 , bottom still unobserved @@ -595,6 +595,7 @@ namespace SabreTools.Serialization.Wrappers /// not supplied by the cabinet file creating application, the checksum field is set to 0 (zero). Cabinet /// extracting applications do not compute or verify the checksum if the field is set to 0 (zero). /// +#pragma warning disable IDE0051 private static uint ChecksumData(byte[] data) { uint[] C = @@ -607,6 +608,7 @@ namespace SabreTools.Serialization.Wrappers return C[0] ^ C[1] ^ C[2] ^ C[3]; } +#pragma warning restore IDE0051 /// /// Individual algorithmic step diff --git a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs index 5aa4967b..3dd6119c 100644 --- a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs +++ b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs @@ -165,6 +165,8 @@ namespace SabreTools.Serialization.Wrappers FolderIndex.CONTINUED_FROM_PREV => 0, FolderIndex.CONTINUED_TO_NEXT => Header.FolderCount - 1, FolderIndex.CONTINUED_PREV_AND_NEXT => 0, + + FolderIndex.FIRST_FOLDER => (int)file.FolderIndex, _ => (int)file.FolderIndex, }; } @@ -305,38 +307,6 @@ namespace SabreTools.Serialization.Wrappers return [.. prevFiles, .. files, .. nextFiles]; } - /// - /// Get all files for the current folder index - /// - /// Index of the folder in the cabinet - /// True to ignore previous links, false otherwise - /// Array of all files for the folder - private CFFILE[] GetFiles(int folderIndex, bool ignorePrev = false) - { - // Ignore invalid archives - if (Files is null) - return []; - - // Get all files with a name and matching index - return Array.FindAll(Files, f => - { - if (string.IsNullOrEmpty(f.Name)) - return false; - - // Ignore links to previous cabinets, if required - if (ignorePrev) - { - if (f.FolderIndex == FolderIndex.CONTINUED_FROM_PREV) - return false; - else if (f.FolderIndex == FolderIndex.CONTINUED_PREV_AND_NEXT) - return false; - } - - int fileFolder = GetFolderIndex(f); - return fileFolder == folderIndex; - }); - } - #endregion } } diff --git a/SabreTools.Serialization/Wrappers/N3DS.Printing.cs b/SabreTools.Serialization/Wrappers/N3DS.Printing.cs index d00724ab..8256cae3 100644 --- a/SabreTools.Serialization/Wrappers/N3DS.Printing.cs +++ b/SabreTools.Serialization/Wrappers/N3DS.Printing.cs @@ -414,6 +414,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(descriptorsStr, " Descriptors"); builder.AppendLine(entry.ACIForLimitations.ARM9AccessControl.DescriptorVersion, " Descriptor version"); } + builder.AppendLine(); } diff --git a/SabreTools.Serialization/Wrappers/NewExecutable.Printing.cs b/SabreTools.Serialization/Wrappers/NewExecutable.Printing.cs index f722f214..c255620d 100644 --- a/SabreTools.Serialization/Wrappers/NewExecutable.Printing.cs +++ b/SabreTools.Serialization/Wrappers/NewExecutable.Printing.cs @@ -297,6 +297,9 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(entry.MoveableSegmentNumber, " Segment number"); builder.AppendLine(entry.MoveableOffset, " Offset"); break; + case SegmentEntryType.Unused: + default: + break; } } diff --git a/SabreTools.Serialization/Wrappers/Nitro.Encryption.cs b/SabreTools.Serialization/Wrappers/Nitro.Encryption.cs index dbc9681d..6cc7f867 100644 --- a/SabreTools.Serialization/Wrappers/Nitro.Encryption.cs +++ b/SabreTools.Serialization/Wrappers/Nitro.Encryption.cs @@ -395,7 +395,7 @@ namespace SabreTools.Serialization.Wrappers for (int i = 0; i < 4; i++) { r3 <<= 8; - r3 |= arg1[(j * 4 + i) & 7]; + r3 |= arg1[((j * 4) + i) & 7]; } _cardHash[j] ^= r3; @@ -409,6 +409,7 @@ namespace SabreTools.Serialization.Wrappers _cardHash[i + 0] = tmp1; _cardHash[i + 1] = tmp2; } + for (int i = 0; i < 0x400; i += 2) { Encrypt(ref tmp1, ref tmp2); diff --git a/SabreTools.Serialization/Wrappers/PKZIP.Printing.cs b/SabreTools.Serialization/Wrappers/PKZIP.Printing.cs index 491b38c6..8870a1c3 100644 --- a/SabreTools.Serialization/Wrappers/PKZIP.Printing.cs +++ b/SabreTools.Serialization/Wrappers/PKZIP.Printing.cs @@ -305,6 +305,7 @@ namespace SabreTools.Serialization.Wrappers case MicrosoftOpenPackagingGrowthHint field: Print(builder, field); break; case UnknownExtraField field: Print(builder, field); break; + default: break; } } diff --git a/SabreTools.Serialization/Wrappers/PortableExecutable.Printing.cs b/SabreTools.Serialization/Wrappers/PortableExecutable.Printing.cs index 3bbadbac..c9f1adf4 100644 --- a/SabreTools.Serialization/Wrappers/PortableExecutable.Printing.cs +++ b/SabreTools.Serialization/Wrappers/PortableExecutable.Printing.cs @@ -150,6 +150,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.ExportTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.ExportTable.Size, " Size"); } + if (header.ImportTable is not null) { builder.AppendLine(" Import Table (2)"); @@ -157,6 +158,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.ImportTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.ImportTable.Size, " Size"); } + if (header.ResourceTable is not null) { builder.AppendLine(" Resource Table (3)"); @@ -164,6 +166,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.ResourceTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.ResourceTable.Size, " Size"); } + if (header.ExceptionTable is not null) { builder.AppendLine(" Exception Table (4)"); @@ -171,6 +174,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.ExceptionTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.ExceptionTable.Size, " Size"); } + if (header.CertificateTable is not null) { builder.AppendLine(" Certificate Table (5)"); @@ -178,6 +182,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.CertificateTable.VirtualAddress, " Physical address"); builder.AppendLine(header.CertificateTable.Size, " Size"); } + if (header.BaseRelocationTable is not null) { builder.AppendLine(" Base Relocation Table (6)"); @@ -185,6 +190,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.BaseRelocationTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.BaseRelocationTable.Size, " Size"); } + if (header.Debug is not null) { builder.AppendLine(" Debug Table (7)"); @@ -192,6 +198,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.Debug.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.Debug.Size, " Size"); } + if (header.NumberOfRvaAndSizes >= 8) { builder.AppendLine(" Architecture Table (8)"); @@ -199,6 +206,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(" Physical address: 0 (0x00000000)"); builder.AppendLine(" Size: 0 (0x00000000)"); } + if (header.GlobalPtr is not null) { builder.AppendLine(" Global Pointer Register (9)"); @@ -206,6 +214,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.GlobalPtr.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.GlobalPtr.Size, " Size"); } + if (header.ThreadLocalStorageTable is not null) { builder.AppendLine(" Thread Local Storage (TLS) Table (10)"); @@ -213,6 +222,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.ThreadLocalStorageTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.ThreadLocalStorageTable.Size, " Size"); } + if (header.LoadConfigTable is not null) { builder.AppendLine(" Load Config Table (11)"); @@ -220,6 +230,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.LoadConfigTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.LoadConfigTable.Size, " Size"); } + if (header.BoundImport is not null) { builder.AppendLine(" Bound Import Table (12)"); @@ -227,6 +238,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.BoundImport.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.BoundImport.Size, " Size"); } + if (header.ImportAddressTable is not null) { builder.AppendLine(" Import Address Table (13)"); @@ -234,6 +246,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.ImportAddressTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.ImportAddressTable.Size, " Size"); } + if (header.DelayImportDescriptor is not null) { builder.AppendLine(" Delay Import Descriptor (14)"); @@ -241,6 +254,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.DelayImportDescriptor.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.DelayImportDescriptor.Size, " Size"); } + if (header.CLRRuntimeHeader is not null) { builder.AppendLine(" CLR Runtime Header (15)"); @@ -248,6 +262,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(header.CLRRuntimeHeader.VirtualAddress.ConvertVirtualAddress(table), " Physical address"); builder.AppendLine(header.CLRRuntimeHeader.Size, " Size"); } + if (header.NumberOfRvaAndSizes >= 16) { builder.AppendLine(" Reserved (16)"); @@ -317,6 +332,7 @@ namespace SabreTools.Serialization.Wrappers case FileRecord item: Print(builder, item, i); break; case SectionDefinition item: Print(builder, item, i); break; case CLRTokenDefinition item: Print(builder, item, i); break; + default: break; } } @@ -335,6 +351,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(entry.Zeroes, " Zeroes"); builder.AppendLine(entry.Offset, " Offset"); } + builder.AppendLine(entry.Value, " Value"); builder.AppendLine($" Section number: {entry.SectionNumber} (0x{entry.SectionNumber:X})"); builder.AppendLine($" Symbol type: {entry.SymbolType} (0x{entry.SymbolType:X})"); @@ -612,6 +629,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(table.OrdinalTableRVA, " Ordinal table RVA"); builder.AppendLine(table.OrdinalTableRVA.ConvertVirtualAddress(sections), " Ordinal table physical address"); } + builder.AppendLine(); } @@ -946,15 +964,18 @@ namespace SabreTools.Serialization.Wrappers PrintResourceRT_CURSOR(entry, level, builder); break; case ResourceType.RT_BITMAP: + case ResourceType.RT_NEWBITMAP: PrintResourceRT_BITMAP(entry, level, builder); break; case ResourceType.RT_ICON: PrintResourceRT_ICON(entry, level, builder); break; case ResourceType.RT_MENU: + case ResourceType.RT_NEWMENU: PrintResourceRT_MENU(entry, level, builder); break; case ResourceType.RT_DIALOG: + case ResourceType.RT_NEWDIALOG: PrintResourceRT_DIALOG(entry, level, builder); break; case ResourceType.RT_STRING: @@ -1005,6 +1026,16 @@ namespace SabreTools.Serialization.Wrappers case ResourceType.RT_MANIFEST: PrintResourceRT_MANIFEST(entry, level, builder); break; + + // Bitflag, ignore + case ResourceType.RT_NEWRESOURCE: + break; + + // Error state, ignore + case ResourceType.RT_ERROR: + PrintResourceUNKNOWN(entry, level, types[0], builder); + break; + default: PrintResourceUNKNOWN(entry, level, types[0], builder); break; @@ -1042,6 +1073,7 @@ namespace SabreTools.Serialization.Wrappers MenuResource? menu = null; try { menu = entry.AsMenu(); } catch { } + if (menu is null) { builder.AppendLine($"{padding}Menu resource found, but malformed"); @@ -1063,6 +1095,7 @@ namespace SabreTools.Serialization.Wrappers { builder.AppendLine($"{padding}Menu header found, but malformed"); } + builder.AppendLine(); builder.AppendLine($"{padding}Menu items"); @@ -1117,6 +1150,7 @@ namespace SabreTools.Serialization.Wrappers DialogBoxResource? dialogBox = null; try { dialogBox = entry.AsDialogBox(); } catch { } + if (dialogBox is null) { builder.AppendLine($"{padding}Dialog box resource found, but malformed"); @@ -1252,6 +1286,7 @@ namespace SabreTools.Serialization.Wrappers Dictionary? stringTable = null; try { stringTable = entry.AsStringTable(); } catch { } + if (stringTable is null) { builder.AppendLine($"{padding}String table resource found, but malformed"); @@ -1284,6 +1319,7 @@ namespace SabreTools.Serialization.Wrappers AcceleratorTableEntry[]? acceleratorTable = null; try { acceleratorTable = entry.AsAcceleratorTableResource(); } catch { } + if (acceleratorTable is null) { builder.AppendLine($"{padding}Accelerator table resource found, but malformed"); @@ -1366,6 +1402,7 @@ namespace SabreTools.Serialization.Wrappers MessageResourceData? messageTable = null; try { messageTable = entry.AsMessageResourceData(); } catch { } + if (messageTable is null) { builder.AppendLine($"{padding}Message resource data found, but malformed"); @@ -1397,6 +1434,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(messageResourceBlock.OffsetToEntries, $"{padding} Offset to entries"); } } + builder.AppendLine(); builder.AppendLine($"{padding}Message resource entries"); @@ -1443,6 +1481,7 @@ namespace SabreTools.Serialization.Wrappers VersionInfo? versionInfo = null; try { versionInfo = entry.AsVersionInfo(); } catch { } + if (versionInfo is null) { builder.AppendLine($"{padding}Version info resource found, but malformed"); @@ -1607,6 +1646,7 @@ namespace SabreTools.Serialization.Wrappers AssemblyManifest? assemblyManifest = null; try { assemblyManifest = entry.AsAssemblyManifest(); } catch { } + if (assemblyManifest is null) { builder.AppendLine($"{padding}Assembly manifest found, but malformed"); @@ -1663,6 +1703,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(dependency.DependentAssembly.AssemblyIdentity.PublicKeyToken, $"{padding}[Dependency {i} Assembly Identity] Public key token"); builder.AppendLine(dependency.DependentAssembly.AssemblyIdentity.Language, $"{padding}[Dependency {i} Assembly Identity] Language"); } + if (dependency.DependentAssembly.BindingRedirect is not null && dependency.DependentAssembly.BindingRedirect.Length > 0) { for (int j = 0; j < dependency.DependentAssembly.BindingRedirect.Length; j++) diff --git a/SabreTools.Serialization/Wrappers/PortableExecutable.cs b/SabreTools.Serialization/Wrappers/PortableExecutable.cs index 2b012f65..ca960f5f 100644 --- a/SabreTools.Serialization/Wrappers/PortableExecutable.cs +++ b/SabreTools.Serialization/Wrappers/PortableExecutable.cs @@ -1880,15 +1880,18 @@ namespace SabreTools.Serialization.Wrappers value = entry.Data; break; case ResourceType.RT_BITMAP: + case ResourceType.RT_NEWBITMAP: value = entry.Data; break; case ResourceType.RT_ICON: value = entry.Data; break; case ResourceType.RT_MENU: + case ResourceType.RT_NEWMENU: value = entry.AsMenu(); break; case ResourceType.RT_DIALOG: + case ResourceType.RT_NEWDIALOG: value = entry.AsDialogBox(); break; case ResourceType.RT_STRING: @@ -1941,6 +1944,16 @@ namespace SabreTools.Serialization.Wrappers _assemblyManifest = entry.AsAssemblyManifest(); value = _assemblyManifest; break; + + // Bitflag, ignore + case ResourceType.RT_NEWRESOURCE: + break; + + // Error state, ignore + case ResourceType.RT_ERROR: + value = entry.Data; + break; + default: value = entry.Data; break; diff --git a/SabreTools.Serialization/Wrappers/RAR.Extraction.cs b/SabreTools.Serialization/Wrappers/RAR.Extraction.cs index 0f5ef375..a362d18e 100644 --- a/SabreTools.Serialization/Wrappers/RAR.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/RAR.Extraction.cs @@ -257,6 +257,7 @@ namespace SabreTools.Serialization.Wrappers if (includeDebug) Console.Error.WriteLine(ex); } } + return true; } diff --git a/SabreTools.Serialization/Wrappers/SecuROMDFA.Printing.cs b/SabreTools.Serialization/Wrappers/SecuROMDFA.Printing.cs index 339ca567..5944a1d3 100644 --- a/SabreTools.Serialization/Wrappers/SecuROMDFA.Printing.cs +++ b/SabreTools.Serialization/Wrappers/SecuROMDFA.Printing.cs @@ -20,7 +20,6 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine(Model.BlockOrHeaderSize, "Block or header size"); builder.AppendLine(); - Print(builder, Model.Entries); } diff --git a/SabreTools.Serialization/Wrappers/SevenZip.Extraction.cs b/SabreTools.Serialization/Wrappers/SevenZip.Extraction.cs index 5980f946..c4716ece 100644 --- a/SabreTools.Serialization/Wrappers/SevenZip.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/SevenZip.Extraction.cs @@ -225,6 +225,7 @@ namespace SabreTools.Serialization.Wrappers if (includeDebug) Console.Error.WriteLine(ex); } } + return true; } @@ -268,7 +269,6 @@ namespace SabreTools.Serialization.Wrappers // Increment the index index++; } - } catch (Exception ex) { diff --git a/SabreTools.Serialization/Wrappers/Skeleton.cs b/SabreTools.Serialization/Wrappers/Skeleton.cs index e5af95a1..ef2b80cb 100644 --- a/SabreTools.Serialization/Wrappers/Skeleton.cs +++ b/SabreTools.Serialization/Wrappers/Skeleton.cs @@ -42,7 +42,7 @@ namespace SabreTools.Serialization.Wrappers /// Byte array representing the archive /// Offset within the array to parse /// An Skeleton Volume wrapper on success, null on failure - public new static Skeleton? Create(byte[]? data, int offset) + public static new Skeleton? Create(byte[]? data, int offset) { // If the data is invalid if (data is null || data.Length == 0) @@ -62,7 +62,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Stream representing the archive /// An Skeleton Volume wrapper on success, null on failure - public new static Skeleton? Create(Stream? data) + public static new Skeleton? Create(Stream? data) { // If the data is invalid if (data is null || !data.CanRead) diff --git a/SabreTools.Serialization/Wrappers/TapeArchive.Extraction.cs b/SabreTools.Serialization/Wrappers/TapeArchive.Extraction.cs index aaecf229..fca1605f 100644 --- a/SabreTools.Serialization/Wrappers/TapeArchive.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/TapeArchive.Extraction.cs @@ -81,9 +81,16 @@ namespace SabreTools.Serialization.Wrappers else if (Path.DirectorySeparatorChar == '/') entryDirectory = entryDirectory.Replace('\\', '/'); - // Create the director + // Create the directory Directory.CreateDirectory(entryDirectory); continue; + + // File types have no special handling + case TypeFlag.REGTYPE: + case TypeFlag.AREGTYPE: + case TypeFlag.CONTTYPE: + default: + break; } // Get the file size diff --git a/SabreTools.Serialization/Wrappers/VBSP.Extraction.cs b/SabreTools.Serialization/Wrappers/VBSP.Extraction.cs index 5001d79d..08304036 100644 --- a/SabreTools.Serialization/Wrappers/VBSP.Extraction.cs +++ b/SabreTools.Serialization/Wrappers/VBSP.Extraction.cs @@ -52,6 +52,7 @@ namespace SabreTools.Serialization.Wrappers // Create the filename string filename = $"lump_{index}.bin"; +#pragma warning disable IDE0010 switch ((LumpType)index) { case LumpType.LUMP_ENTITIES: @@ -61,6 +62,7 @@ namespace SabreTools.Serialization.Wrappers filename = "pakfile.zip"; break; } +#pragma warning restore IDE0010 // Ensure directory separators are consistent if (Path.DirectorySeparatorChar == '\\') diff --git a/SabreTools.Serialization/Wrappers/WiseScript.Printing.cs b/SabreTools.Serialization/Wrappers/WiseScript.Printing.cs index b9bcaf49..67bbfae6 100644 --- a/SabreTools.Serialization/Wrappers/WiseScript.Printing.cs +++ b/SabreTools.Serialization/Wrappers/WiseScript.Printing.cs @@ -56,6 +56,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine($" Header String {i}: {entry}"); } } + builder.AppendLine(); } @@ -144,6 +145,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine($" File Text {i}: {entry}"); } } + builder.AppendLine(data.Source, $" Source"); builder.AppendLine(); } @@ -172,6 +174,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine($" Title/Text String {i}: {entry}"); } } + builder.AppendLine(); } @@ -193,6 +196,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine($" Script Line {i}: {entry}"); } } + builder.AppendLine(); } @@ -304,6 +308,7 @@ namespace SabreTools.Serialization.Wrappers } } } + builder.AppendLine(); } @@ -381,6 +386,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine($" Description {i}: {entry}"); } } + builder.AppendLine(); builder.AppendLine(data.Source, $" Source"); builder.AppendLine(); diff --git a/SabreTools.Serialization/Wrappers/WiseScript.cs b/SabreTools.Serialization/Wrappers/WiseScript.cs index 9eccaee1..def4f1d5 100644 --- a/SabreTools.Serialization/Wrappers/WiseScript.cs +++ b/SabreTools.Serialization/Wrappers/WiseScript.cs @@ -162,6 +162,7 @@ namespace SabreTools.Serialization.Wrappers // Loop through the state machine and process foreach (var state in States) { +#pragma warning disable IDE0010 switch (state.Op) { case OperationCode.InstallFile: @@ -234,6 +235,7 @@ namespace SabreTools.Serialization.Wrappers { if (includeDebug) Console.WriteLine($"Directory {createDirectory.Pathname} could not be created!"); } + break; case OperationCode.CopyLocalFile: @@ -326,6 +328,7 @@ namespace SabreTools.Serialization.Wrappers default: break; } +#pragma warning restore IDE0010 } return true; diff --git a/SabreTools.Serialization/Wrappers/WiseSectionHeader.Printing.cs b/SabreTools.Serialization/Wrappers/WiseSectionHeader.Printing.cs index 8a165241..ce03fa51 100644 --- a/SabreTools.Serialization/Wrappers/WiseSectionHeader.Printing.cs +++ b/SabreTools.Serialization/Wrappers/WiseSectionHeader.Printing.cs @@ -55,6 +55,7 @@ namespace SabreTools.Serialization.Wrappers builder.AppendLine($" String {i}: {entry}"); } } + builder.AppendLine(); } } diff --git a/SabreTools.Serialization/Writers/ClrMamePro.cs b/SabreTools.Serialization/Writers/ClrMamePro.cs index 62b93881..17b05d46 100644 --- a/SabreTools.Serialization/Writers/ClrMamePro.cs +++ b/SabreTools.Serialization/Writers/ClrMamePro.cs @@ -164,6 +164,9 @@ namespace SabreTools.Serialization.Writers case Set: writer.WriteStartElement(name: "set"); break; + default: + // TODO: Log invalid values + break; } // Write the standalone values @@ -471,6 +474,7 @@ namespace SabreTools.Serialization.Writers { writer.WriteRequiredAttributeString("entry", entry); } + writer.WriteOptionalAttributeString("default", dipswitch.Default); writer.WriteEndElement(); // dipswitch } diff --git a/SabreTools.Serialization/Writers/Hashfile.cs b/SabreTools.Serialization/Writers/Hashfile.cs index 1863b59a..eba5b058 100644 --- a/SabreTools.Serialization/Writers/Hashfile.cs +++ b/SabreTools.Serialization/Writers/Hashfile.cs @@ -78,6 +78,7 @@ namespace SabreTools.Serialization.Writers }; // Write out the items, if they exist +#pragma warning disable IDE0010 switch (hash) { case HashType.CRC32: @@ -116,6 +117,7 @@ namespace SabreTools.Serialization.Writers default: throw new ArgumentOutOfRangeException(nameof(hash)); } +#pragma warning restore IDE0010 // Return the stream stream.SeekIfPossible(0, SeekOrigin.Begin); diff --git a/SabreTools.Serialization/_EXTERNAL/StormLibSharp/MpqArchive.cs b/SabreTools.Serialization/_EXTERNAL/StormLibSharp/MpqArchive.cs index 6a81001d..d0931d7c 100644 --- a/SabreTools.Serialization/_EXTERNAL/StormLibSharp/MpqArchive.cs +++ b/SabreTools.Serialization/_EXTERNAL/StormLibSharp/MpqArchive.cs @@ -258,7 +258,6 @@ namespace StormLibSharp return (MpqArchiveVerificationResult)NativeMethods.SFileVerifyArchive(_handle); } - #region IDisposable implementation public void Dispose() diff --git a/SabreTools.Serialization/_EXTERNAL/StormLibSharp/Native/NativeMethods.cs b/SabreTools.Serialization/_EXTERNAL/StormLibSharp/Native/NativeMethods.cs index b71a3d2a..32893883 100644 --- a/SabreTools.Serialization/_EXTERNAL/StormLibSharp/Native/NativeMethods.cs +++ b/SabreTools.Serialization/_EXTERNAL/StormLibSharp/Native/NativeMethods.cs @@ -52,7 +52,6 @@ namespace StormLibSharp.Native [DllImport(STORMLIB, CallingConvention = CallingConvention.Winapi, ExactSpelling = true, PreserveSig = true, SetLastError = true, ThrowOnUnmappableChar = false)] public static extern bool SFileFlushArchive(MpqArchiveSafeHandle? hMpq); - [DllImport(STORMLIB, CallingConvention = CallingConvention.Winapi, ExactSpelling = true, PreserveSig = true, SetLastError = true, ThrowOnUnmappableChar = false)] public static extern bool SFileCloseArchive(IntPtr hMpq); @@ -461,6 +460,8 @@ namespace StormLibSharp.Native } #pragma warning disable CS0169 +#pragma warning disable IDE0044 +#pragma warning disable IDE0051 internal struct SFILE_CREATE_MPQ { public uint cbSize; @@ -476,6 +477,8 @@ namespace StormLibSharp.Native public uint dwMaxFileCount; } #pragma warning restore CS0169 +#pragma warning restore IDE0044 +#pragma warning restore IDE0051 internal unsafe struct _SFILE_FIND_DATA {