From bd76adc35e1536654fead662288b0fd82b0d061f Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Mon, 7 Mar 2022 07:36:42 +0000 Subject: [PATCH] General cleanup and refactor. --- .editorconfig | 816 ++++++++---------------------- ATA/Identify.cs | 219 ++++---- ATA/Registers.cs | 4 +- Aaru.Decoders.csproj | 480 +++++++++--------- Bluray/BCA.cs | 4 +- Bluray/Cartridge.cs | 7 +- Bluray/DDS.cs | 7 +- Bluray/DI.cs | 21 +- Bluray/Spare.cs | 4 +- CD/ATIP.cs | 12 +- CD/CDTextOnLeadIn.cs | 28 +- CD/Enums.cs | 4 +- CD/FullTOC.cs | 86 ++-- CD/PMA.cs | 42 +- CD/Sector.cs | 38 +- CD/SectorBuilder.cs | 19 +- CD/Session.cs | 21 +- CD/Subchannel.cs | 160 +++--- CD/TOC.cs | 18 +- DVD/AACS.cs | 4 +- DVD/ADIP.cs | 4 +- DVD/BCA.cs | 4 +- DVD/CPRM.cs | 4 +- DVD/CSS&CPRM.cs | 15 +- DVD/Cartridge.cs | 4 +- DVD/DDS.cs | 16 +- DVD/DMI.cs | 4 +- DVD/Enums.cs | 27 +- DVD/Layers.cs | 4 +- DVD/PFI.cs | 29 +- DVD/PRI.cs | 15 +- DVD/RMD.cs | 4 +- DVD/Spare.cs | 16 +- DVD/UDI.cs | 4 +- Floppy/Amiga.cs | 4 +- Floppy/Apple2.cs | 68 +-- Floppy/AppleSony.cs | 41 +- Floppy/Commodore.cs | 4 +- Floppy/Enums.cs | 8 +- Floppy/ISO.cs | 3 +- Floppy/Perpendicular.cs | 3 +- Floppy/System34.cs | 3 +- Floppy/System3740.cs | 3 +- LisaTag.cs | 26 +- MMC/CID.cs | 10 +- MMC/CSD.cs | 11 +- MMC/ExtendedCSD.cs | 120 +++-- MMC/OCR.cs | 4 +- MMC/VendorString.cs | 12 +- PCMCIA/CIS.cs | 22 +- PCMCIA/Enums.cs | 22 +- PCMCIA/Types.cs | 4 +- PCMCIA/VendorCode.cs | 4 +- SCSI/DiscStructureCapabilities.cs | 8 +- SCSI/EVPD.cs | 112 ++-- SCSI/Inquiry.cs | 32 +- SCSI/MMC/AACS.cs | 17 +- SCSI/MMC/CPRM.cs | 4 +- SCSI/MMC/DiscInformation.cs | 17 +- SCSI/MMC/Enums.cs | 34 +- SCSI/MMC/Features.cs | 167 +++--- SCSI/MMC/Hybrid.cs | 13 +- SCSI/MMC/TrackInformation.cs | 8 +- SCSI/MMC/WriteProtect.cs | 4 +- SCSI/Modes/00_SFF.cs | 4 +- SCSI/Modes/01.cs | 6 +- SCSI/Modes/01_MMC.cs | 31 +- SCSI/Modes/02.cs | 9 +- SCSI/Modes/03.cs | 12 +- SCSI/Modes/04.cs | 10 +- SCSI/Modes/05.cs | 15 +- SCSI/Modes/06.cs | 4 +- SCSI/Modes/07.cs | 4 +- SCSI/Modes/07_MMC.cs | 29 +- SCSI/Modes/08.cs | 16 +- SCSI/Modes/0A.cs | 4 +- SCSI/Modes/0B.cs | 13 +- SCSI/Modes/0D.cs | 4 +- SCSI/Modes/0E.cs | 4 +- SCSI/Modes/0F.cs | 12 +- SCSI/Modes/10.cs | 16 +- SCSI/Modes/10_SSC.cs | 7 +- SCSI/Modes/11.cs | 12 +- SCSI/Modes/12_13_14.cs | 8 +- SCSI/Modes/1A.cs | 18 +- SCSI/Modes/1B.cs | 4 +- SCSI/Modes/1C.cs | 8 +- SCSI/Modes/1C_SFF.cs | 4 +- SCSI/Modes/1D.cs | 8 +- SCSI/Modes/21_Certance.cs | 4 +- SCSI/Modes/22_Certance.cs | 7 +- SCSI/Modes/24_IBM.cs | 4 +- SCSI/Modes/2A.cs | 21 +- SCSI/Modes/2F_IBM.cs | 4 +- SCSI/Modes/30_Apple.cs | 6 +- SCSI/Modes/3B_HP.cs | 4 +- SCSI/Modes/3C_HP.cs | 12 +- SCSI/Modes/3D_HP.cs | 4 +- SCSI/Modes/3D_IBM.cs | 4 +- SCSI/Modes/3E_Fujitsu.cs | 4 +- SCSI/Modes/3E_HP.cs | 7 +- SCSI/Modes/Headers.cs | 80 ++- SCSI/Modes/Mode10.cs | 121 +++-- SCSI/Modes/Mode6.cs | 51 +- SCSI/Modes/Structs.cs | 4 +- SCSI/SSC/BlockLimits.cs | 4 +- SCSI/SSC/DensitySupport.cs | 26 +- SCSI/Sense.cs | 26 +- SCSI/Types.cs | 4 +- SecureDigital/CID.cs | 8 +- SecureDigital/CSD.cs | 11 +- SecureDigital/OCR.cs | 4 +- SecureDigital/SCR.cs | 18 +- SecureDigital/VendorString.cs | 16 +- Sega/CD.cs | 22 +- Sega/Dreamcast.cs | 17 +- Sega/Saturn.cs | 12 +- Xbox/DMI.cs | 42 +- Xbox/SS.cs | 57 +-- 119 files changed, 1647 insertions(+), 2151 deletions(-) diff --git a/.editorconfig b/.editorconfig index 9181fe5..25aaa32 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,632 +1,216 @@ -root = true - [*] charset = utf-8 -next_line = crlf +end_of_line = lf +trim_trailing_whitespace = false insert_final_newline = false indent_style = space indent_size = 4 -# Generic non-language specific ones for Resharper and friends -brace_style = next_line -int_align = true -keep_existing_arrangement = false -place_simple_blocks_on_single_line = true -place_simple_declaration_blocks_on_single_line = true -place_attribute_on_same_line = false -space_after_unary_operator = false -space_after_comma = true -space_around_ternary_operator = true -space_around_binary_operator = true -space_around_member_access_operator = false -space_before_open_square_brackets = false -space_after_keywords_in_control_flow_statements = true -space_before_comma = false -space_between_method_call_name_and_opening_parenthesis = false -space_between_method_declaration_name_and_open_parenthesis = false -space_between_square_brackets = false -space_between_parentheses_of_control_flow_statements = false -accessor_owner_declaration_braces = next_line -accessor_declaration_braces = next_line -case_block_braces = next_line -initializer_braces = next_line -other_braces = next_line -allow_comment_after_lbrace = false -empty_block_style = together_same_line -braces_for_ifelse = not_required -braces_for_for = not_required -braces_for_foreach = not_required -braces_for_while = not_required -braces_for_dowhile = not_required -braces_for_using = not_required -braces_for_lock = not_required -braces_for_fixed = not_required -method_or_operator_body = expression_body -local_function_body = expression_body -constructor_or_destructor_body = expression_body -accessor_owner_body = expression_body -force_attribute_style = join -function_braces = next_line -force_control_statements_braces = always_remove -space_in_singleline_accessorholder = true -type_declaration_braces = next_line -invocable_declaration_braces = next_line -anonymous_method_declaration_braces = next_line -space_between_accessors_in_singleline_property = true -indent_nested_usings_stmt = true -space_within_empty_braces = false -indent_nested_fixed_stmt = true -indent_nested_lock_stmt = true -indent_nested_for_stmt = true -indent_nested_foreach_stmt = true -indent_nested_while_stmt = true -use_continuous_indent_inside_parens = true -indent_method_decl_pars = inside -indent_invocation_pars = inside -indent_statement_pars = inside -indent_typeparam_angles = inside -indent_typearg_angles = inside -indent_pars = inside -indent_preprocessor_if = outdent -indent_preprocessor_region = usual_indent -indent_preprocessor_other = usual_indent -indent_switch_labels = true -indent_type_constraints = true -stick_comment = false -alignment_tab_fill_style = use_spaces -align_multiline_parameter = true -align_multiline_extends_list = true -align_linq_query = true -align_multiline_binary_expressions_chain = true -outdent_binary_ops = true -align_multiline_calls_chain = true -outdent_dots = true -align_multiline_array_and_object_initializer = false -indent_anonymous_method_block = false -align_first_arg_by_paren = true -align_multiline_argument = true -align_tuple_components = true -align_multiline_expression = true -align_multiline_for_stmt = true -align_multiple_declaration = true -align_multline_type_parameter_list = true -align_multline_type_parameter_constrains = true -int_align_fields = true -int_align_properties = true -int_align_methods = true -int_align_parameters = false -int_align_variables = true -int_align_assignments = true -int_align_nested_ternary = true -int_align_invocations = false -int_align_binary_expressions = true -int_align_comments = true -int_align_switch_sections = true -keep_user_linebreaks = false -keep_existing_arrangement = false -keep_existing_linebreaks = false -max_line_length = 120 -wrap_before_comma = false -special_else_if_treatment = true -place_type_attribute_on_same_line = never -place_method_attribute_on_same_line = never -place_accessorholder_attribute_on_same_line = never -place_attribute_on_same_line = never -place_accessor_attribute_on_same_line = never -place_attribute_on_same_line = never -place_field_attribute_on_same_line = never -place_attribute_on_same_line = never -wrap_parameters_style = wrap_if_long -keep_existing_declaration_parens_arrangement = false -wrap_before_declaration_lpar = false -wrap_after_declaration_lpar = false -wrap_before_declaration_rpar = false -place_constructor_initializer_on_same_line = true -keep_existing_expr_member_arrangement = false -place_expr_method_on_single_line = true -place_expr_property_on_single_line = true -place_expr_accessor_on_single_line = true -wrap_before_arrow_with_expressions = false -place_type_constraints_on_same_line = true -wrap_before_first_type_parameter_constraint = true -wrap_multiple_type_parameter_constraints_style = wrap_if_long -wrap_before_type_parameter_langle = true -wrap_before_extends_colon = false -wrap_extends_list_style = wrap_if_long -keep_existing_declaration_block_arrangement = false -place_abstract_accessorholder_on_single_line = true -place_simple_accessorholder_on_single_line = false -place_accessor_with_attrs_holder_on_single_line = false -place_simple_accessor_on_single_line = true -place_simple_method_on_single_line = false -keep_existing_enum_arrangement = false -place_simple_enum_on_single_line = false -wrap_enum_declaration = wrap_if_long -new_line_before_else = true -new_line_before_while = false -wrap_for_stmt_header_style = wrap_if_long -wrap_multiple_declaration_style = wrap_if_long -keep_existing_embedded_arrangement = false -place_simple_embedded_statement_on_same_line = false -place_simple_case_statement_on_same_line = true -keep_existing_embedded_block_arrangement = false -place_simple_embedded_block_on_same_line = false -place_simple_anonymousmethod_on_single_line = false -keep_existing_initializer_arrangement = false -place_simple_initializer_on_single_line = false -wrap_object_and_collection_initializer_style = chop_always -wrap_array_initializer_style = wrap_if_long -wrap_arguments_style = wrap_if_long -keep_existing_invocation_parens_arrangement = false -wrap_after_invocation_lpar = false -wrap_before_invocation_rpar = false -wrap_after_dot_in_method_calls = true -wrap_chained_method_calls = wrap_if_long -wrap_before_binary_opsign = false -wrap_chained_binary_expressions = wrap_if_long -force_chop_compound_if_expression = true -force_chop_compound_while_expression = true -force_chop_compound_do_expression = true -wrap_before_ternary_opsigns = true -wrap_ternary_expr_style = wrap_if_long -nested_ternary_style = expanded -wrap_linq_expressions = wrap_if_long -wrap_before_linq_expression = false -place_linq_into_on_new_line = false -wrap_verbatim_interpolated_strings = wrap_if_long -extra_spaces = remove_all -space_after_keywords_in_control_flow_statements = false -space_between_method_call_name_and_opening_parenthesis = false -space_between_method_declaration_name_and_open_parenthesis = false -space_before_typeof_parentheses = false -space_before_checked_parentheses = false -space_before_sizeof_parentheses = false -space_before_nameof_parentheses = false -space_between_keyword_and_expression = true -space_between_keyword_and_type = true -space_around_assignment_op = true -space_around_logical_op = true -space_around_binary_operator = true -space_around_equality_op = true -space_around_relational_op = true -space_around_bitwise_op = true -space_around_additive_op = true -space_around_multiplicative_op = true -space_around_shift_op = true -space_around_nullcoalescing_op = true -space_around_arrow_op = false -space_after_logical_not_op = false -space_after_unary_operator = false -space_after_cast = false -space_around_dot = false -space_around_lambda_arrow = true -space_before_pointer_asterik_declaration = false -space_before_nullable_mark = false -blank_lines_around_class_definition = 1 -namespace_indentation = all -space_within_template_argument = false -align_union_type_usage = true -space_in_singleline_method = true -space_in_singleline_anonymous_method = true -space_within_single_line_array_initializer_braces = true -space_around_arrow_op = false - -# These are for markup languages (HTML, XML, etc) -spaces_around_eq_in_pi_attribute = false -space_after_last_pi_attribute = true -pi_attributes_indent = align_by_first_attribute -blank_line_after_pi = true -spaces_around_eq_in_attribute = false -space_after_last_attribute = false -space_before_self_closing = true -attribute_style = on_single_line -attribute_indent = align_by_first_attribute -sort_attributes = true -sort_class_selectors = true -max_blank_lines_between_tags = 0 -linebreak_before_all_elements = true -linebreak_before_multiline_elements = true -quote_style = doublequoted -delete_quotes_from_solid_values = false -normalize_tag_names = true - - -[{.babelrc,.stylelintrc,jest.config,.eslintrc,.prettierrc,*.json,*.jsb3,*.jsb2,*.bowerrc}] -indent_size = 2 - -[*.js.map] -indent_size = 2 - -[*.{css,scss}] -indent_size = 2 -declarations_style = separate_lines_for_nonsingle -media_query_style = separate_lines -selector_style = same_line -properties_style = separate_lines_for_nonsingle -brace_style = next_line - -[{.analysis_options,*.yml,*.yaml}] -indent_size = 2 - -# Xml project files -[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}] -indent_size = 2 - -# Xml files -[*.{xml,stylecop,resx,ruleset}] -indent_size = 2 - -# Xml config files -[*.{props,targets,config,nuspec}] -indent_size = 2 - -# .net files -[*.{cs,vb}] -# These set the this. / Me. -dotnet_style_qualification_for_field = false:warning -dotnet_style_qualification_for_property = false:warning -dotnet_style_qualification_for_method = false:warning -dotnet_style_qualification_for_event = false:warning - -# These make it suggest Int32 instead of int, etc. +# Microsoft .NET properties +csharp_new_line_between_query_expression_clauses = false +csharp_preferred_modifier_order = public, private, protected, internal, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async:suggestion +csharp_prefer_braces = false:warning +csharp_space_after_keywords_in_control_flow_statements = false +csharp_style_var_elsewhere = false:suggestion +csharp_style_var_for_built_in_types = false:suggestion +csharp_style_var_when_type_is_apparent = true:suggestion +csharp_using_directive_placement = inside_namespace:silent +dotnet_naming_rule.unity_serialized_field_rule.import_to_resharper = True +dotnet_naming_rule.unity_serialized_field_rule.resharper_description = Unity serialized field +dotnet_naming_rule.unity_serialized_field_rule.resharper_guid = 5f0fdb63-c892-4d2c-9324-15c80b22a7ef +dotnet_naming_rule.unity_serialized_field_rule.severity = warning +dotnet_naming_rule.unity_serialized_field_rule.style = lower_camel_case_style +dotnet_naming_rule.unity_serialized_field_rule.symbols = unity_serialized_field_symbols +dotnet_naming_rule.unity_serialized_field_rule_1.import_to_resharper = True +dotnet_naming_rule.unity_serialized_field_rule_1.resharper_description = Unity serialized field +dotnet_naming_rule.unity_serialized_field_rule_1.resharper_guid = 5f0fdb63-c892-4d2c-9324-15c80b22a7ef +dotnet_naming_rule.unity_serialized_field_rule_1.severity = warning +dotnet_naming_rule.unity_serialized_field_rule_1.style = lower_camel_case_style +dotnet_naming_rule.unity_serialized_field_rule_1.symbols = unity_serialized_field_symbols_1 +dotnet_naming_style.lower_camel_case_style.capitalization = camel_case +dotnet_naming_symbols.unity_serialized_field_symbols.applicable_accessibilities = * +dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds = +dotnet_naming_symbols.unity_serialized_field_symbols.resharper_applicable_kinds = unity_serialised_field +dotnet_naming_symbols.unity_serialized_field_symbols.resharper_required_modifiers = instance +dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_accessibilities = * +dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_kinds = +dotnet_naming_symbols.unity_serialized_field_symbols_1.resharper_applicable_kinds = unity_serialised_field +dotnet_naming_symbols.unity_serialized_field_symbols_1.resharper_required_modifiers = instance +dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:warning +dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:warning +dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:warning dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion dotnet_style_predefined_type_for_member_access = true:suggestion - -# This controls implicit access modifiers +dotnet_style_qualification_for_event = false:suggestion +dotnet_style_qualification_for_field = false:suggestion +dotnet_style_qualification_for_method = false:suggestion +dotnet_style_qualification_for_property = false:suggestion dotnet_style_require_accessibility_modifiers = never:suggestion -# Prefer non modified fields to be marked readonly -dotnet_style_readonly_field = true:warning +# ReSharper properties +resharper_align_first_arg_by_paren = true +resharper_align_linq_query = true +resharper_align_multiline_argument = true +resharper_align_multiline_binary_expressions_chain = true +resharper_align_multiline_binary_patterns = true +resharper_align_multiline_calls_chain = true +resharper_align_multiline_expression = true +resharper_align_multiline_extends_list = true +resharper_align_multiline_for_stmt = true +resharper_align_multiline_parameter = true +resharper_align_multiline_property_pattern = true +resharper_align_multiline_switch_expression = true +resharper_align_multiple_declaration = true +resharper_align_multline_type_parameter_constrains = true +resharper_align_multline_type_parameter_list = true +resharper_align_tuple_components = true +resharper_attribute_indent = align_by_first_attribute +resharper_attribute_style = on_single_line +resharper_autodetect_indent_settings = true +resharper_constructor_or_destructor_body = expression_body +resharper_cpp_brace_style = next_line +resharper_csharp_outdent_commas = true +resharper_default_value_when_type_not_evident = default_expression +resharper_empty_block_style = together_same_line +resharper_force_attribute_style = join +resharper_force_chop_compound_do_expression = true +resharper_force_chop_compound_if_expression = true +resharper_force_chop_compound_while_expression = true +resharper_for_built_in_types = use_var_when_evident +resharper_fsharp_type_declaration_braces = next_line +resharper_indent_nested_fixed_stmt = true +resharper_indent_nested_foreach_stmt = true +resharper_indent_nested_for_stmt = true +resharper_indent_nested_lock_stmt = true +resharper_indent_nested_usings_stmt = true +resharper_indent_nested_while_stmt = true +resharper_indent_preprocessor_if = outdent +resharper_indent_preprocessor_other = usual_indent +resharper_indent_switch_labels = true +resharper_int_align_assignments = true +resharper_int_align_binary_expressions = true +resharper_int_align_comments = true +resharper_int_align_fields = true +resharper_int_align_methods = true +resharper_int_align_nested_ternary = true +resharper_int_align_properties = true +resharper_int_align_property_patterns = true +resharper_int_align_switch_expressions = true +resharper_int_align_switch_sections = true +resharper_int_align_variables = true +resharper_keep_existing_arrangement = false +resharper_keep_user_linebreaks = false +resharper_linebreak_before_all_elements = true +resharper_local_function_body = expression_body +resharper_max_blank_lines_between_tags = 0 +resharper_max_enum_members_on_line = 1 +resharper_method_or_operator_body = expression_body +resharper_nested_ternary_style = expanded +resharper_new_line_before_while = false +resharper_normalize_tag_names = true +resharper_outdent_binary_ops = true +resharper_outdent_binary_pattern_ops = true +resharper_outdent_dots = true +resharper_outdent_statement_labels = true +resharper_place_attribute_on_same_line = false +resharper_place_expr_accessor_on_single_line = true +resharper_place_expr_method_on_single_line = true +resharper_place_expr_property_on_single_line = true +resharper_place_linq_into_on_new_line = false +resharper_place_simple_anonymousmethod_on_single_line = false +resharper_place_simple_case_statement_on_same_line = true +resharper_place_simple_embedded_statement_on_same_line = false +resharper_place_simple_initializer_on_single_line = false +resharper_place_simple_switch_expression_on_single_line = true +resharper_prefer_explicit_discard_declaration = true +resharper_qualified_using_at_nested_scope = true +resharper_show_autodetect_configure_formatting_tip = false +resharper_sort_attributes = true +resharper_sort_class_selectors = true +resharper_space_after_keywords_in_control_flow_statements = false +resharper_space_after_last_pi_attribute = true +resharper_space_after_unary_operator = false +resharper_space_around_binary_operator = true +resharper_space_before_self_closing = true +resharper_space_within_empty_braces = false +resharper_stick_comment = false +resharper_use_indent_from_vs = false +resharper_wrap_after_dot_in_method_calls = true +resharper_wrap_before_first_type_parameter_constraint = true +resharper_wrap_before_type_parameter_langle = true +resharper_wrap_enum_declaration = wrap_if_long +resharper_wrap_for_stmt_header_style = wrap_if_long +resharper_wrap_lines = true +resharper_wrap_multiple_declaration_style = wrap_if_long +resharper_wrap_multiple_type_parameter_constraints_style = wrap_if_long +resharper_wrap_object_and_collection_initializer_style = chop_always +resharper_wrap_ternary_expr_style = wrap_if_long +resharper_wrap_verbatim_interpolated_strings = wrap_if_long -# Parenthesis settings -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning -dotnet_style_parentheses_in_other_operators = always_for_clarity:warning +# ReSharper inspection severities +resharper_annotate_can_be_null_parameter_highlighting = warning +resharper_annotate_can_be_null_type_member_highlighting = warning +resharper_annotate_not_null_parameter_highlighting = warning +resharper_annotate_not_null_type_member_highlighting = warning +resharper_arrange_attributes_highlighting = hint +resharper_arrange_constructor_or_destructor_body_highlighting = warning +resharper_arrange_default_value_when_type_evident_highlighting = warning +resharper_arrange_default_value_when_type_not_evident_highlighting = warning +resharper_arrange_local_function_body_highlighting = warning +resharper_arrange_method_or_operator_body_highlighting = warning +resharper_arrange_object_creation_when_type_evident_highlighting = warning +resharper_arrange_object_creation_when_type_not_evident_highlighting = warning +resharper_arrange_redundant_parentheses_highlighting = hint +resharper_arrange_this_qualifier_highlighting = hint +resharper_arrange_type_member_modifiers_highlighting = hint +resharper_arrange_type_modifiers_highlighting = hint +resharper_async_void_method_highlighting = warning +resharper_built_in_type_reference_style_for_member_access_highlighting = hint +resharper_built_in_type_reference_style_highlighting = hint +resharper_compare_non_constrained_generic_with_null_highlighting = warning +resharper_heap_view_boxing_allocation_highlighting = none +resharper_heap_view_delegate_allocation_highlighting = none +resharper_heap_view_object_allocation_evident_highlighting = none +resharper_heap_view_object_allocation_highlighting = none +resharper_inheritdoc_consider_usage_highlighting = warning +resharper_local_function_can_be_made_static_highlighting = warning +resharper_loop_can_be_partly_converted_to_query_highlighting = warning +resharper_member_can_be_internal_highlighting = warning +resharper_nullable_warning_suppression_is_used_highlighting = warning +resharper_redundant_base_qualifier_highlighting = warning +resharper_remove_constructor_invocation_highlighting = warning +resharper_separate_control_transfer_statement_highlighting = warning +resharper_string_ends_with_is_culture_specific_highlighting = warning +resharper_string_starts_with_is_culture_specific_highlighting = warning +resharper_struct_member_can_be_made_read_only_highlighting = warning +resharper_suggest_var_or_type_built_in_types_highlighting = hint +resharper_suggest_var_or_type_elsewhere_highlighting = hint +resharper_suggest_var_or_type_simple_types_highlighting = hint +resharper_tabs_are_disallowed_highlighting = warning +resharper_unnecessary_whitespace_highlighting = warning +resharper_use_nameof_expression_for_part_of_the_string_highlighting = warning +resharper_use_positional_deconstruction_pattern_highlighting = warning +resharper_web_config_module_not_resolved_highlighting = warning +resharper_web_config_type_not_resolved_highlighting = warning +resharper_web_config_wrong_module_highlighting = warning -dotnet_style_object_initializer = true:suggestion -dotnet_style_collection_initializer = true:suggestion -dotnet_style_explicit_tuple_names = true:error -dotnet_style_prefer_inferred_tuple_names = true:warning -dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning -dotnet_style_prefer_conditional_expression_over_return = true:warning -dotnet_style_coalesce_expression = true:warning -dotnet_style_null_propagation = true:error +[{*.har,*.inputactions,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config}] +indent_style = space +indent_size = 2 -dotnet_sort_system_directives_first = true +[{*.yaml,*.yml,.analysis_options}] +indent_style = space +indent_size = 2 -# Constants in C style, all-caps -dotnet_naming_rule.constant_fields_caps.symbols = constant_fields -dotnet_naming_rule.constant_fields_caps.severity = warning -dotnet_naming_rule.constant_fields_caps.style = caps_style -dotnet_naming_symbols.constant_fields.applicable_kinds = field -dotnet_naming_symbols.constant_fields.required_modifiers = const -dotnet_naming_style.caps_style.capitalization = all_upper +[*.csv] +indent_style = tab +tab_width = 1 -# interfaces should be prefixed with I -dotnet_naming_rule.pascal_case_for_interface.severity = error -dotnet_naming_rule.pascal_case_for_interface.symbols = interfaces_fields -dotnet_naming_rule.pascal_case_for_interface.style = pascal_case_interface_style -dotnet_naming_symbols.interfaces_fields.applicable_kinds = interface -dotnet_naming_style.pascal_case_interface_style.required_prefix = I -dotnet_naming_style.pascal_case_interface_style.capitalization = pascal_case +[{*.bash,*.sh,*.tool,*.zsh}] +indent_style = space +indent_size = 2 -## internal and private fields should be _camelCase -dotnet_naming_rule.camel_case_for_private_internal_fields.severity = warning -dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields -dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style -dotnet_naming_symbols.private_internal_fields.applicable_kinds = field -dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal -dotnet_naming_style.camel_case_underscore_style.required_prefix = _ -dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case - -# 2018-12-07 NP: This is not yet working in VS2017 -# local variables should be camelCase -#dotnet_naming_rule.camel_case_for_locals.severity = suggestion -#dotnet_naming_rule.camel_case_for_locals.symbols = local_fields -#dotnet_naming_rule.camel_case_for_locals.style = camel_case_style -#dotnet_naming_symbols.local_fields.applicable_kinds = local -#dotnet_naming_style.camel_case_style.capitalization = camel_case - -[*.cs] -# var var var -csharp_style_var_for_built_in_types = false:warning -csharp_style_var_when_type_is_apparent = true:suggestion -csharp_style_var_elsewhere = false:warning - -csharp_style_expression_bodied_methods = when_on_single_line:suggestion -csharp_style_expression_bodied_constructors = when_on_single_line:suggestion -csharp_style_expression_bodied_operators = when_on_single_line:suggestion -csharp_style_expression_bodied_properties = when_on_single_line:suggestion -csharp_style_expression_bodied_indexers = when_on_single_line:suggestion -csharp_style_expression_bodied_accessors = when_on_single_line:suggestion - -csharp_style_pattern_matching_over_is_with_cast_check = true:warning -csharp_style_pattern_matching_over_as_with_null_check = when_on_single_line:warning - -csharp_style_inlined_variable_declaration = true:warning - -csharp_prefer_simple_default_expression = true:warning -csharp_style_deconstructed_variable_declaration = false:warning - -csharp_style_throw_expression = true:warning -csharp_style_conditional_delegate_call = true:warning - -csharp_prefer_braces = false - -csharp_new_line_before_open_brace = all -csharp_new_line_before_else = true -csharp_new_line_before_catch = true -csharp_new_line_before_finally = true -csharp_new_line_before_members_in_object_initializers = true -csharp_new_line_before_members_in_anonymous_types = true -csharp_new_line_between_query_expression_clauses = true - -csharp_indent_case_contents = true -csharp_indent_switch_labels = true -csharp_indent_labels = flush_left - -csharp_space_after_cast = false -csharp_space_after_keywords_in_control_flow_statements = false -csharp_space_between_method_declaration_parameter_list_parentheses = false -csharp_space_between_parentheses = none -csharp_space_before_colon_in_inheritance_clause = true -csharp_space_after_colon_in_inheritance_clause = true -csharp_space_around_binary_operators = before_and_after -csharp_space_between_method_declaration_empty_parameter_list_parentheses = false -csharp_space_between_method_call_name_and_opening_parenthesis = false -csharp_space_between_method_call_empty_parameter_list_parentheses = false - -csharp_preserve_single_line_statements = false -csharp_preserve_single_line_blocks = true - -csharp_blank_lines_around_region = 0 -csharp_blank_lines_inside_region = 0 -csharp_blank_lines_before_single_line_comment = 1 -csharp_keep_blank_lines_in_declarations = 1 -csharp_remove_blank_lines_near_braces_in_declarations = true -csharp_blank_lines_after_start_comment = false -csharp_blank_lines_between_using_groups = 0 -csharp_blank_lines_after_using_list = 1 -csharp_blank_lines_around_namespace = 1 -csharp_blank_lines_inside_namespace = 0 -csharp_blank_lines_around_type = 1 -csharp_blank_lines_inside_type = 0 -csharp_blank_lines_around_field = 0 -csharp_blank_lines_around_single_line_field = 0 -csharp_blank_lines_around_property = 1 -csharp_blank_lines_around_single_line_property = 0 -csharp_blank_lines_around_auto_property = 0 -csharp_blank_lines_around_single_line_auto_property = 0 -csharp_blank_lines_around_invocable = 1 -csharp_blank_lines_around_single_line_invocable = 1 -csharp_keep_blank_lines_in_code = 1 -csharp_remove_blank_lines_near_braces_in_code = true -csharp_blank_lines_around_local_method = 1 -csharp_blank_lines_around_single_line_local_method = 1 -csharp_blank_lines_before_control_transfer_statements = 1 -csharp_blank_lines_after_control_transfer_statements = 1 -csharp_blank_lines_before_block_statements = 1 -csharp_blank_lines_after_block_statements = 1 -csharp_blank_lines_before_multiline_statements = 1 -csharp_blank_lines_after_multiline_statements = 1 - -csharp_type_declaration_braces = next_line -csharp_brace_style = next_line -csharp_indent_inside_namespace = true -csharp_invocable_declaration_braces = next_line -csharp_anonymous_method_declaration_braces = next_line -csharp_accessor_owner_declaration_braces = next_line -csharp_accessor_declaration_braces = next_line -csharp_case_block_braces = next_line -csharp_initializer_braces = next_line -csharp_other_braces = next_line -csharp_allow_comment_after_lbrace = false -csharp_empty_block_style = together_same_line - -csharp_for_built_in_types = use_explicit_type -csharp_for_simple_types = use_var_when_evident -csharp_for_other_types = use_explicit_type -csharp_prefer_separate_deconstructed_variables_declaration = true -csharp_prefer_explicit_discard_declaration = false - -csharp_instance_members_qualify_members = none -csharp_builtin_type_reference_style = use_keyword -csharp_prefer_qualified_reference = false -csharp_add_imports_to_deepest_scope = false -csharp_allow_alias = true -csharp_default_private_modifier = implicit -csharp_default_internal_modifier = explicit -csharp_arguments_literal = positional -csharp_arguments_string_literal = positional -csharp_arguments_named = positional -csharp_arguments_anonymous_function = positional -csharp_arguments_other = positional -csharp_braces_for_ifelse = not_required -csharp_braces_for_for = not_required -csharp_braces_for_foreach = not_required -csharp_braces_for_while = not_required -csharp_braces_for_dowhile = not_required -csharp_braces_for_using = not_required -csharp_braces_for_lock = not_required -csharp_braces_for_fixed = not_required -csharp_method_or_operator_body = expression_body -csharp_local_function_body = expression_body -csharp_constructor_or_destructor_body = expression_body -csharp_accessor_owner_body = expression_body -csharp_force_attribute_style = join -csharp_indent_nested_usings_stmt = true - -csharp_builtin_type_reference_for_member_access_style = use_keyword -csharp_indent_nested_fixed_stmt = true -csharp_indent_nested_lock_stmt = true -csharp_indent_nested_for_stmt = true -csharp_indent_nested_foreach_stmt = true -csharp_indent_nested_while_stmt = true -csharp_use_continuous_indent_inside_parens = true -csharp_indent_method_decl_pars = inside -csharp_indent_invocation_pars = inside -csharp_indent_statement_pars = inside -csharp_indent_typeparam_angles = inside -csharp_indent_typearg_angles = inside -csharp_indent_pars = inside -csharp_indent_preprocessor_if = outdent -csharp_indent_preprocessor_region = usual_indent -csharp_indent_preprocessor_other = usual_indent -csharp_indent_switch_labels = true -csharp_indent_type_constraints = true -csharp_stick_comment = false -csharp_alignment_tab_fill_style = use_spaces -csharp_align_multiline_parameter = true -csharp_align_multiline_extends_list = true -csharp_align_linq_query = true -csharp_align_multiline_binary_expressions_chain = true -csharp_outdent_binary_ops = true -csharp_align_multiline_calls_chain = true -csharp_outdent_dots = true -csharp_align_multiline_array_and_object_initializer = false -csharp_indent_anonymous_method_block = false -csharp_align_first_arg_by_paren = true -csharp_align_multiline_argument = true -csharp_align_tuple_components = true -csharp_align_multiline_expression = true -csharp_align_multiline_for_stmt = true -csharp_align_multiple_declaration = true -csharp_align_multline_type_parameter_list = true -csharp_align_multline_type_parameter_constrains = true -csharp_int_align_fields = true -csharp_int_align_properties = true -csharp_int_align_methods = true -csharp_int_align_parameters = false -csharp_int_align_variables = true -csharp_int_align_assignments = true -csharp_int_align_nested_ternary = true -csharp_int_align_invocations = false -csharp_int_align_binary_expressions = true -csharp_int_align_comments = true -csharp_int_align_switch_sections = true -csharp_int_align = true -csharp_keep_user_linebreaks = false -csharp_keep_existing_arrangement = false -csharp_keep_existing_linebreaks = false -csharp_max_line_length = 120 -csharp_wrap_before_comma = false -csharp_special_else_if_treatment = true -csharp_insert_final_newline = false -csharp_place_type_attribute_on_same_line = never -csharp_place_method_attribute_on_same_line = never -csharp_place_accessorholder_attribute_on_same_line = never -csharp_place_attribute_on_same_line = never -csharp_place_accessor_attribute_on_same_line = never -csharp_place_attribute_on_same_line = never -csharp_place_field_attribute_on_same_line = never -csharp_place_attribute_on_same_line = never -csharp_wrap_parameters_style = wrap_if_long -csharp_keep_existing_declaration_parens_arrangement = false -csharp_wrap_before_declaration_lpar = false -csharp_wrap_after_declaration_lpar = false -csharp_wrap_before_declaration_rpar = false -csharp_place_constructor_initializer_on_same_line = true -csharp_keep_existing_expr_member_arrangement = false -csharp_place_expr_method_on_single_line = true -csharp_place_expr_property_on_single_line = true -csharp_place_expr_accessor_on_single_line = true -csharp_wrap_before_arrow_with_expressions = false -csharp_place_type_constraints_on_same_line = true -csharp_wrap_before_first_type_parameter_constraint = true -csharp_wrap_multiple_type_parameter_constraints_style = wrap_if_long -csharp_wrap_before_type_parameter_langle = true -csharp_wrap_before_extends_colon = false -csharp_wrap_extends_list_style = wrap_if_long -csharp_keep_existing_declaration_block_arrangement = false -csharp_place_abstract_accessorholder_on_single_line = true -csharp_place_simple_accessorholder_on_single_line = false -csharp_place_accessor_with_attrs_holder_on_single_line = false -csharp_place_simple_accessor_on_single_line = true -csharp_place_simple_method_on_single_line = false -csharp_keep_existing_enum_arrangement = false -csharp_place_simple_enum_on_single_line = false -csharp_wrap_enum_declaration = wrap_if_long -csharp_new_line_before_else = true -csharp_new_line_before_while = false -csharp_wrap_for_stmt_header_style = wrap_if_long -csharp_wrap_multiple_declaration_style = wrap_if_long -csharp_keep_existing_embedded_arrangement = false -csharp_place_simple_embedded_statement_on_same_line = false -csharp_place_simple_case_statement_on_same_line = true -csharp_keep_existing_embedded_block_arrangement = false -csharp_place_simple_embedded_block_on_same_line = false -csharp_place_simple_anonymousmethod_on_single_line = false -csharp_keep_existing_initializer_arrangement = false -csharp_place_simple_initializer_on_single_line = false -csharp_wrap_object_and_collection_initializer_style = chop_always -csharp_wrap_array_initializer_style = wrap_if_long -csharp_wrap_arguments_style = wrap_if_long -csharp_keep_existing_invocation_parens_arrangement = false -csharp_wrap_after_invocation_lpar = false -csharp_wrap_before_invocation_rpar = false -csharp_wrap_after_dot_in_method_calls = true -csharp_wrap_chained_method_calls = wrap_if_long -csharp_wrap_before_binary_opsign = false -csharp_wrap_chained_binary_expressions = wrap_if_long -csharp_force_chop_compound_if_expression = true -csharp_force_chop_compound_while_expression = true -csharp_force_chop_compound_do_expression = true -csharp_wrap_before_ternary_opsigns = true -csharp_wrap_ternary_expr_style = wrap_if_long -csharp_nested_ternary_style = expanded -csharp_wrap_linq_expressions = wrap_if_long -csharp_wrap_before_linq_expression = false -csharp_place_linq_into_on_new_line = false -csharp_wrap_verbatim_interpolated_strings = wrap_if_long -csharp_extra_spaces = remove_all -csharp_space_after_keywords_in_control_flow_statements = false -csharp_space_between_method_call_name_and_opening_parenthesis = false -csharp_space_between_method_declaration_name_and_open_parenthesis = false -csharp_space_before_typeof_parentheses = false -csharp_space_before_checked_parentheses = false -csharp_space_before_sizeof_parentheses = false -csharp_space_before_nameof_parentheses = false -csharp_space_between_keyword_and_expression = true -csharp_space_between_keyword_and_type = true -csharp_space_around_assignment_op = true -csharp_space_around_logical_op = true -csharp_space_around_binary_operator = true -csharp_space_around_equality_op = true -csharp_space_around_relational_op = true -csharp_space_around_bitwise_op = true -csharp_space_around_additive_op = true -csharp_space_around_multiplicative_op = true -csharp_space_around_shift_op = true -csharp_space_around_nullcoalescing_op = true -csharp_space_around_arrow_op = false -csharp_space_after_logical_not_op = false -csharp_space_after_unary_operator = false -csharp_space_after_cast = false -csharp_space_around_dot = false -csharp_space_around_lambda_arrow = true -csharp_space_before_pointer_asterik_declaration = false -csharp_space_before_nullable_mark = false - -[*.cshtml] -linebreaks_around_razor_statements = true -blank_lines_around_razor_functions = true -blank_lines_around_razor_helpers = true -blank_lines_around_razor_sections = true - -# C++ -[*.{cc,cpp,cxx,h,hpp,hxx}] -cpp_indent_access_specifiers_from_class = true -cpp_indent_wrapped_function_names = false -cpp_align_multiline_type_argument = true - -# C, C++ and ObjectiveC -[*.{c,h,cc,cpp,cxx,m,hpp,hxx}] -indent_preprocessor_directives = normal -indent_type_constraints = true - -# Javascript and Typescript -[*.{js,js.map,ts}] -quote_style = doublequoted -termination_style = ensure_semicolon \ No newline at end of file +[*.{appxmanifest,asax,ascx,aspx,axaml,build,cg,cginc,compute,cs,cshtml,dtd,fs,fsi,fsscript,fsx,hlsl,hlsli,hlslinc,master,ml,mli,nuspec,paml,razor,resw,resx,shader,skin,usf,ush,vb,xaml,xamlx,xoml,xsd}] +indent_style = space +indent_size = 4 +tab_width = 4 diff --git a/ATA/Identify.cs b/ATA/Identify.cs index 27079cf..f64bbd8 100644 --- a/ATA/Identify.cs +++ b/ATA/Identify.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.ATA; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.CommonTypes.Structs.Devices.SCSI; -namespace Aaru.Decoders.ATA; - // Information from following standards: // T10-791D rev. 4c (ATA) // T10-948D rev. 4c (ATA-2) @@ -71,8 +71,8 @@ public static class Identify var sb = new StringBuilder(); - bool atapi = false; - bool cfa = false; + var atapi = false; + var cfa = false; CommonTypes.Structs.Devices.ATA.Identify.IdentifyDevice ATAID = IdentifyDeviceResponse.Value; @@ -105,8 +105,7 @@ public static class Identify if(ATAID.CommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.MustBeSet) && !ATAID.CommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.MustBeClear)) { - if(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3. - MediaSerial)) + if(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.MediaSerial)) { if(ATAID.MediaManufacturer != "") sb.AppendFormat("Media manufacturer: {0}", ATAID.MediaManufacturer).AppendLine(); @@ -169,8 +168,8 @@ public static class Identify acs4 |= ATAID.MajorVersion.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.MajorVersionBit.ACS4); } - int maxatalevel = 0; - int minatalevel = 255; + var maxatalevel = 0; + var minatalevel = 255; sb.Append("Supported ATA versions: "); if(ata1) @@ -654,8 +653,8 @@ public static class Identify break; default: - sb.AppendFormat("Unknown ATAPI packet size code {0}", - (ushort)ATAID.GeneralConfiguration & 0x03).AppendLine(); + sb.AppendFormat("Unknown ATAPI packet size code {0}", (ushort)ATAID.GeneralConfiguration & 0x03). + AppendLine(); break; } @@ -663,8 +662,8 @@ public static class Identify else if(!cfa) { if(minatalevel >= 5) - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - GeneralConfigurationBit.IncompleteResponse)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. + IncompleteResponse)) sb.AppendLine("Incomplete identify response"); if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. @@ -676,58 +675,58 @@ public static class Identify sb.AppendLine("Device is removable"); if(minatalevel <= 5) - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - GeneralConfigurationBit.Fixed)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. + Fixed)) sb.AppendLine("Device is fixed"); if(ata1) { - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - GeneralConfigurationBit.SlowIDE)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. + SlowIDE)) sb.AppendLine("Device transfer rate is <= 5 Mb/s"); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - GeneralConfigurationBit.FastIDE)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. + FastIDE)) sb.AppendLine("Device transfer rate is > 5 Mb/s but <= 10 Mb/s"); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - GeneralConfigurationBit.UltraFastIDE)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. + UltraFastIDE)) sb.AppendLine("Device transfer rate is > 10 Mb/s"); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - GeneralConfigurationBit.SoftSector)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. + SoftSector)) sb.AppendLine("Device is soft sectored"); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - GeneralConfigurationBit.HardSector)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. + HardSector)) sb.AppendLine("Device is hard sectored"); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - GeneralConfigurationBit.NotMFM)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. + NotMFM)) sb.AppendLine("Device is not MFM encoded"); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - GeneralConfigurationBit.FormatGapReq)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. + FormatGapReq)) sb.AppendLine("Format speed tolerance gap is required"); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - GeneralConfigurationBit.TrackOffset)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. + TrackOffset)) sb.AppendLine("Track offset option is available"); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - GeneralConfigurationBit.DataStrobeOffset)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. + DataStrobeOffset)) sb.AppendLine("Data strobe offset option is available"); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - GeneralConfigurationBit.RotationalSpeedTolerance)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. + RotationalSpeedTolerance)) sb.AppendLine("Rotational speed tolerance is higher than 0,5%"); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - GeneralConfigurationBit.SpindleControl)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. + SpindleControl)) sb.AppendLine("Spindle motor control is implemented"); - if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - GeneralConfigurationBit.HighHeadSwitch)) + if(ATAID.GeneralConfiguration.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit. + HighHeadSwitch)) sb.AppendLine("Head switch time is bigger than 15 µs."); } } @@ -818,7 +817,7 @@ public static class Identify (ulong)ATAID.CurrentSectors * 512 / 1024 / 1024).AppendLine(); else { - ulong currentSectors = (ulong)(ATAID.Cylinders * ATAID.Heads * ATAID.SectorsPerTrack); + var currentSectors = (ulong)(ATAID.Cylinders * ATAID.Heads * ATAID.SectorsPerTrack); sb.AppendFormat("Device size in CHS mode: {0} bytes, {1} Mb, {2} MiB", currentSectors * logicalSectorSize, @@ -899,8 +898,7 @@ public static class Identify (ushort)ATAID.SpecificConfiguration != 0xFFFF) switch(ATAID.SpecificConfiguration) { - case CommonTypes.Structs.Devices.ATA.Identify.SpecificConfigurationEnum. - RequiresSetIncompleteResponse: + case CommonTypes.Structs.Devices.ATA.Identify.SpecificConfigurationEnum.RequiresSetIncompleteResponse: sb.AppendLine("Device requires SET FEATURES to spin up and IDENTIFY DEVICE response is incomplete."); break; @@ -913,8 +911,7 @@ public static class Identify sb.AppendLine("Device does not require SET FEATURES to spin up and IDENTIFY DEVICE response is incomplete."); break; - case CommonTypes.Structs.Devices.ATA.Identify.SpecificConfigurationEnum. - NotRequiresSetCompleteResponse: + case CommonTypes.Structs.Devices.ATA.Identify.SpecificConfigurationEnum.NotRequiresSetCompleteResponse: sb.AppendLine("Device does not require SET FEATURES to spin up and IDENTIFY DEVICE response is complete."); break; @@ -962,8 +959,7 @@ public static class Identify sb.Append("Device capabilities:"); - if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit. - StandardStandbyTimer)) + if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.StandardStandbyTimer)) sb.AppendLine().Append("Standby time values are standard"); if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.IORDY)) @@ -989,15 +985,12 @@ public static class Identify AppendFormat("A maximum of {0} sectors can be transferred per interrupt on READ/WRITE MULTIPLE", ATAID.MultipleSectorNumber); - sb.AppendLine().AppendFormat("Device supports setting a maximum of {0} sectors", - ATAID.MultipleMaxSectors); + sb.AppendLine().AppendFormat("Device supports setting a maximum of {0} sectors", ATAID.MultipleMaxSectors); } - if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit. - PhysicalAlignment1) || + if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.PhysicalAlignment1) || ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.PhysicalAlignment0)) - sb.AppendLine().AppendFormat("Long Physical Alignment setting is {0}", - (ushort)ATAID.Capabilities & 0x03); + sb.AppendLine().AppendFormat("Long Physical Alignment setting is {0}", (ushort)ATAID.Capabilities & 0x03); if(ata1) if(ATAID.TrustedComputing.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TrustedComputingBit. @@ -1012,8 +1005,7 @@ public static class Identify if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.CommandQueue)) sb.AppendLine().Append("ATAPI device supports command queueing"); - if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit. - OverlapOperation)) + if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.OverlapOperation)) sb.AppendLine().Append("ATAPI device supports overlapped operations"); if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit. @@ -1332,30 +1324,29 @@ public static class Identify } } - if(!ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2. - Clear)) + if(!ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2.Clear)) { if(!ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit. Clear) && ATAID.SATACapabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit.NCQ)) { - if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SATACapabilitiesBit2.NCQMgmt)) + if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2. + NCQMgmt)) sb.AppendLine().Append("NCQ queue management is supported"); - if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SATACapabilitiesBit2.NCQStream)) + if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2. + NCQStream)) sb.AppendLine().Append("NCQ streaming is supported"); } if(atapi) { - if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SATACapabilitiesBit2.HostEnvDetect)) + if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2. + HostEnvDetect)) sb.AppendLine().Append("ATAPI device supports host environment detection"); - if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SATACapabilitiesBit2.DevAttSlimline)) + if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2. + DevAttSlimline)) sb.AppendLine().Append("ATAPI device supports attention on slimline connected devices"); } @@ -1506,8 +1497,7 @@ public static class Identify { sb.AppendLine().Append("Power management is supported"); - if(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit. - PowerManagement)) + if(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.PowerManagement)) sb.Append(" and enabled"); } @@ -1515,8 +1505,7 @@ public static class Identify { sb.AppendLine().Append("Removable media feature set is supported"); - if(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit. - RemovableMedia)) + if(ATAID.EnabledCommandSet.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit.RemovableMedia)) sb.Append(" and enabled"); } @@ -1546,8 +1535,7 @@ public static class Identify { sb.AppendLine().Append("FLUSH CACHE is supported"); - if(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2. - FlushCache)) + if(ATAID.EnabledCommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.FlushCache)) sb.Append(" and enabled"); } @@ -1595,8 +1583,7 @@ public static class Identify sb.Append(" and enabled"); } - if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2. - SetFeaturesRequired)) + if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.SetFeaturesRequired)) sb.AppendLine().Append("SET FEATURES is required before spin-up"); if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.PowerUpInStandby)) @@ -1608,8 +1595,7 @@ public static class Identify sb.Append(" and enabled"); } - if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2. - RemovableNotification)) + if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.RemovableNotification)) { sb.AppendLine().Append("Removable Media Status Notification is supported"); @@ -1662,8 +1648,7 @@ public static class Identify sb.Append(" and enabled"); } - if(ATAID.SCTCommandTransport.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SCTCommandTransportBit. - Supported)) + if(ATAID.SCTCommandTransport.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SCTCommandTransportBit.Supported)) sb.AppendLine().Append("S.M.A.R.T. Command Transport is supported"); if(ATAID.CommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.MustBeSet) && @@ -1682,8 +1667,7 @@ public static class Identify { sb.AppendLine().Append("S.M.A.R.T. error logging is supported"); - if(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3. - SMARTLog)) + if(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.SMARTLog)) sb.Append(" and enabled"); } @@ -1709,8 +1693,7 @@ public static class Identify { sb.AppendLine().Append("WRITE DMA QUEUED FUA EXT is supported"); - if(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3. - FUAWriteQ)) + if(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.FUAWriteQ)) sb.Append(" and enabled"); } @@ -1718,8 +1701,7 @@ public static class Identify { sb.AppendLine().Append("WRITE DMA FUA EXT and WRITE MULTIPLE FUA EXT are supported"); - if(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3. - FUAWrite)) + if(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.FUAWrite)) sb.Append(" and enabled"); } @@ -1735,8 +1717,7 @@ public static class Identify { sb.AppendLine().Append("Streaming feature set is supported"); - if(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3. - Streaming)) + if(ATAID.EnabledCommandSet3.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit3.Streaming)) sb.Append(" and enabled"); } @@ -1827,8 +1808,7 @@ public static class Identify { sb.AppendLine().Append("WRITE UNCORRECTABLE is supported"); - if(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4. - WriteUnc)) + if(ATAID.EnabledCommandSet4.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit4.WriteUnc)) sb.Append(" and enabled"); } @@ -1865,8 +1845,7 @@ public static class Identify sb.AppendLine().Append("CRYPTO SCRAMBLE EXT is supported"); if(ATAID.CommandSet5.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit5.DeviceConfDMA)) - sb.AppendLine(). - Append("DEVICE CONFIGURATION IDENTIFY DMA and DEVICE CONFIGURATION SET DMA are supported"); + sb.AppendLine().Append("DEVICE CONFIGURATION IDENTIFY DMA and DEVICE CONFIGURATION SET DMA are supported"); if(ATAID.CommandSet5.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit5.ReadBufferDMA)) sb.AppendLine().Append("READ BUFFER DMA is supported"); @@ -1897,8 +1876,7 @@ public static class Identify sb.AppendLine().Append("Read after TRIM returns empty data"); } - if(ATAID.CommandSet5.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit5. - LongPhysSectorAligError)) + if(ATAID.CommandSet5.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit5.LongPhysSectorAligError)) sb.AppendLine().Append("Device supports Long Physical Sector Alignment Error Reporting Control"); if(ATAID.CommandSet5.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit5.Encrypted)) @@ -1928,9 +1906,8 @@ public static class Identify if(!ata1 && maxatalevel >= 8) - if(ATAID.TrustedComputing.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TrustedComputingBit.Set) && - !ATAID.TrustedComputing.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TrustedComputingBit. - Clear) && + if(ATAID.TrustedComputing.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TrustedComputingBit.Set) && + !ATAID.TrustedComputing.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TrustedComputingBit.Clear) && ATAID.TrustedComputing.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.TrustedComputingBit. TrustedComputing)) sb.AppendLine().Append("Trusted Computing feature set is supported"); @@ -1943,8 +1920,7 @@ public static class Identify ReadLogDMAExt)) sb.AppendLine().Append("READ LOG DMA EXT is supported"); - if(!ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2. - Clear)) + if(!ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2.Clear)) if(ATAID.SATACapabilities2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATACapabilitiesBit2. FPDMAQ)) sb.AppendLine().Append("RECEIVE FPDMA QUEUED and SEND FPDMA QUEUED are supported"); @@ -1970,8 +1946,7 @@ public static class Identify sb.Append(" and enabled"); } - if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit. - InitPowerMgmt)) + if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit.InitPowerMgmt)) { sb.AppendLine().Append("Device-initiated power management is supported"); @@ -1995,8 +1970,8 @@ public static class Identify { sb.AppendLine().Append("Hardware Feature Control is supported"); - if(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SATAFeaturesBit.HardwareFeatureControl)) + if(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit. + HardwareFeatureControl)) sb.Append(" and enabled"); } @@ -2006,8 +1981,8 @@ public static class Identify { sb.AppendLine().Append("Asynchronous notification is supported"); - if(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SATAFeaturesBit.AsyncNotification)) + if(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit. + AsyncNotification)) sb.Append(" and enabled"); } @@ -2021,8 +1996,7 @@ public static class Identify sb.Append(" and enabled"); } - if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit. - NCQAutoSense)) + if(ATAID.SATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit.NCQAutoSense)) sb.AppendLine().Append("NCQ Autosense is supported"); if(ATAID.EnabledSATAFeatures.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SATAFeaturesBit. @@ -2055,21 +2029,21 @@ public static class Identify { sb.AppendLine("Security is enabled"); - sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SecurityStatusBit.Locked) - ? "Security is locked" : "Security is not locked"); + sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SecurityStatusBit. + Locked) ? "Security is locked" + : "Security is not locked"); - sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SecurityStatusBit.Frozen) - ? "Security is frozen" : "Security is not frozen"); + sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SecurityStatusBit. + Frozen) ? "Security is frozen" + : "Security is not frozen"); - sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SecurityStatusBit.Expired) - ? "Security count has expired" : "Security count has not expired"); + sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SecurityStatusBit. + Expired) ? "Security count has expired" + : "Security count has not expired"); - sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify. - SecurityStatusBit.Maximum) - ? "Security level is maximum" : "Security level is high"); + sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SecurityStatusBit. + Maximum) ? "Security level is maximum" + : "Security level is high"); } else sb.AppendLine("Security is not enabled"); @@ -2080,8 +2054,8 @@ public static class Identify sb.AppendFormat("{0} minutes to complete secure erase", ATAID.SecurityEraseTime * 2).AppendLine(); if(ATAID.SecurityStatus.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SecurityStatusBit.Enhanced)) - sb.AppendFormat("{0} minutes to complete enhanced secure erase", - ATAID.EnhancedSecurityEraseTime * 2).AppendLine(); + sb.AppendFormat("{0} minutes to complete enhanced secure erase", ATAID.EnhancedSecurityEraseTime * 2). + AppendLine(); sb.AppendFormat("Master password revision code: {0}", ATAID.MasterPasswordRevisionCode).AppendLine(); } @@ -2098,8 +2072,7 @@ public static class Identify sb.AppendFormat("Streaming performance granularity is {0}", ATAID.StreamPerformanceGranularity); } - if(ATAID.SCTCommandTransport.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SCTCommandTransportBit. - Supported)) + if(ATAID.SCTCommandTransport.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.SCTCommandTransportBit.Supported)) { sb.AppendLine().AppendLine("S.M.A.R.T. Command Transport (SCT):"); @@ -2184,17 +2157,17 @@ public static class Identify ATAID.ReservedWord116 != 0xFFFF) sb.AppendFormat("Word 116: 0x{0:X4}", ATAID.ReservedWord116).AppendLine(); - for(int i = 0; i < ATAID.ReservedWords121.Length; i++) + for(var i = 0; i < ATAID.ReservedWords121.Length; i++) if(ATAID.ReservedWords121[i] != 0x0000 && ATAID.ReservedWords121[i] != 0xFFFF) sb.AppendFormat("Word {1}: 0x{0:X4}", ATAID.ReservedWords121[i], 121 + i).AppendLine(); - for(int i = 0; i < ATAID.ReservedWords129.Length; i++) + for(var i = 0; i < ATAID.ReservedWords129.Length; i++) if(ATAID.ReservedWords129[i] != 0x0000 && ATAID.ReservedWords129[i] != 0xFFFF) sb.AppendFormat("Word {1}: 0x{0:X4}", ATAID.ReservedWords129[i], 129 + i).AppendLine(); - for(int i = 0; i < ATAID.ReservedCFA.Length; i++) + for(var i = 0; i < ATAID.ReservedCFA.Length; i++) if(ATAID.ReservedCFA[i] != 0x0000 && ATAID.ReservedCFA[i] != 0xFFFF) sb.AppendFormat("Word {1} (CFA): 0x{0:X4}", ATAID.ReservedCFA[i], 161 + i).AppendLine(); @@ -2227,12 +2200,12 @@ public static class Identify ATAID.ReservedWord221 != 0xFFFF) sb.AppendFormat("Word 221: 0x{0:X4}", ATAID.ReservedWord221).AppendLine(); - for(int i = 0; i < ATAID.ReservedCEATA224.Length; i++) + for(var i = 0; i < ATAID.ReservedCEATA224.Length; i++) if(ATAID.ReservedCEATA224[i] != 0x0000 && ATAID.ReservedCEATA224[i] != 0xFFFF) sb.AppendFormat("Word {1} (CE-ATA): 0x{0:X4}", ATAID.ReservedCEATA224[i], 224 + i).AppendLine(); - for(int i = 0; i < ATAID.ReservedWords.Length; i++) + for(var i = 0; i < ATAID.ReservedWords.Length; i++) if(ATAID.ReservedWords[i] != 0x0000 && ATAID.ReservedWords[i] != 0xFFFF) sb.AppendFormat("Word {1}: 0x{0:X4}", ATAID.ReservedWords[i], 236 + i).AppendLine(); diff --git a/ATA/Registers.cs b/ATA/Registers.cs index d35f9fc..1f4321b 100644 --- a/ATA/Registers.cs +++ b/ATA/Registers.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Runtime.InteropServices; - namespace Aaru.Decoders.ATA; +using System.Runtime.InteropServices; + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] public struct AtaRegistersChs { diff --git a/Aaru.Decoders.csproj b/Aaru.Decoders.csproj index d599fba..8ee3b21 100644 --- a/Aaru.Decoders.csproj +++ b/Aaru.Decoders.csproj @@ -1,244 +1,242 @@  - - Debug - AnyCPU - 2.0 - {0BEB3088-B634-4289-AE17-CDF2D25D00D5} - Library - Aaru.Decoders - Aaru.Decoders - $(Version) - false - true - 6.0.0-alpha8 - Claunia.com - Copyright © 2011-2022 Natalia Portillo - Aaru Data Preservation Suite - Aaru.Decoders - $(Version) - net6 - 10 - Binary structure decoders used by the Aaru Data Preservation Suite. - https://github.com/aaru-dps/ - LGPL-2.1-only - https://github.com/aaru-dps/Aaru - true - en-US - true - true - snupkg - Natalia Portillo <claunia@claunia.com> - true - - - $(Version)+{chash:8} - true - true - - - true - full - false - bin\Debug\net6 - DEBUG; - prompt - 4 - false - - - full - true - bin\Release\net6 - prompt - 4 - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LICENSE.LGPL - - - - - - - - - - - - - - - - - - - - - - - - /Library/Frameworks/Mono.framework/Versions/Current/lib/mono - /usr/lib/mono - /usr/local/lib/mono - - $(BaseFrameworkPathOverrideForMono)/4.0-api - $(BaseFrameworkPathOverrideForMono)/4.5-api - $(BaseFrameworkPathOverrideForMono)/4.5.1-api - $(BaseFrameworkPathOverrideForMono)/4.5.2-api - $(BaseFrameworkPathOverrideForMono)/4.6-api - $(BaseFrameworkPathOverrideForMono)/4.6.1-api - $(BaseFrameworkPathOverrideForMono)/4.6.2-api - $(BaseFrameworkPathOverrideForMono)/4.7-api - $(BaseFrameworkPathOverrideForMono)/4.7.1-api - true - - $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) - + + Debug + AnyCPU + 2.0 + {0BEB3088-B634-4289-AE17-CDF2D25D00D5} + Library + Aaru.Decoders + Aaru.Decoders + $(Version) + false + true + 6.0.0-alpha8 + Claunia.com + Copyright © 2011-2022 Natalia Portillo + Aaru Data Preservation Suite + Aaru.Decoders + $(Version) + net6 + 10 + Binary structure decoders used by the Aaru Data Preservation Suite. + https://github.com/aaru-dps/ + LGPL-2.1-only + https://github.com/aaru-dps/Aaru + true + en-US + true + true + snupkg + Natalia Portillo <claunia@claunia.com> + true + + + $(Version)+{chash:8} + true + true + + + true + full + false + bin\Debug\net6 + DEBUG; + prompt + 4 + false + + + full + true + bin\Release\net6 + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LICENSE.LGPL + + + + + + + + + + + + + + + + + + + + + + + + /Library/Frameworks/Mono.framework/Versions/Current/lib/mono + /usr/lib/mono + /usr/local/lib/mono + + $(BaseFrameworkPathOverrideForMono)/4.0-api + $(BaseFrameworkPathOverrideForMono)/4.5-api + $(BaseFrameworkPathOverrideForMono)/4.5.1-api + $(BaseFrameworkPathOverrideForMono)/4.5.2-api + $(BaseFrameworkPathOverrideForMono)/4.6-api + $(BaseFrameworkPathOverrideForMono)/4.6.1-api + $(BaseFrameworkPathOverrideForMono)/4.6.2-api + $(BaseFrameworkPathOverrideForMono)/4.7-api + $(BaseFrameworkPathOverrideForMono)/4.7.1-api + true + + $(FrameworkPathOverride)/Facades;$(AssemblySearchPaths) + \ No newline at end of file diff --git a/Bluray/BCA.cs b/Bluray/BCA.cs index 2b37d6e..07f5c30 100644 --- a/Bluray/BCA.cs +++ b/Bluray/BCA.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Bluray; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Decoders.Bluray; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 diff --git a/Bluray/Cartridge.cs b/Bluray/Cartridge.cs index bd65083..4292d7f 100644 --- a/Bluray/Cartridge.cs +++ b/Bluray/Cartridge.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Bluray; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Decoders.Bluray; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -92,8 +92,7 @@ public static class Cartridge if(CSResponse.Length != 8) { AaruConsole.DebugWriteLine("BD Cartridge Status decoder", - "Found incorrect Blu-ray Cartridge Status size ({0} bytes)", - CSResponse.Length); + "Found incorrect Blu-ray Cartridge Status size ({0} bytes)", CSResponse.Length); return null; } diff --git a/Bluray/DDS.cs b/Bluray/DDS.cs index e2c0cf4..14faa0e 100644 --- a/Bluray/DDS.cs +++ b/Bluray/DDS.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Bluray; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Decoders.Bluray; - /// Information from the following standards: /// ANSI X3.304-1997 /// T10/1048-D revision 9.0 @@ -132,8 +132,7 @@ public static class DDS if(decoded.Signature != DDSIdentifier) { - AaruConsole.DebugWriteLine("BD DDS decoder", "Found incorrect DDS signature (0x{0:X4})", - decoded.Signature); + AaruConsole.DebugWriteLine("BD DDS decoder", "Found incorrect DDS signature (0x{0:X4})", decoded.Signature); return null; } diff --git a/Bluray/DI.cs b/Bluray/DI.cs index 7e7c909..9536459 100644 --- a/Bluray/DI.cs +++ b/Bluray/DI.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Bluray; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -37,8 +39,6 @@ using System.Text; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Decoders.Bluray; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -102,8 +102,7 @@ public static class DI if(DIResponse.Length != 4100) { AaruConsole.DebugWriteLine("BD Disc Information decoder", - "Found incorrect Blu-ray Disc Information size ({0} bytes)", - DIResponse.Length); + "Found incorrect Blu-ray Disc Information size ({0} bytes)", DIResponse.Length); return null; } @@ -115,8 +114,8 @@ public static class DI Reserved2 = DIResponse[3] }; - int offset = 4; - List units = new List(); + var offset = 4; + var units = new List(); while(true) { @@ -210,7 +209,7 @@ public static class DI decoded.Units = new DiscInformationUnits[units.Count]; - for(int i = 0; i < units.Count; i++) + for(var i = 0; i < units.Count; i++) decoded.Units[i] = units[i]; return decoded; @@ -375,8 +374,7 @@ public static class DI sb.AppendFormat("Last user data PSN for disc: {0}", unit.LastPsn).AppendLine(); - sb.AppendFormat("First address unit number of data zone in this layer: {0}", unit.FirstAun). - AppendLine(); + sb.AppendFormat("First address unit number of data zone in this layer: {0}", unit.FirstAun).AppendLine(); sb.AppendFormat("Last address unit number of data zone in this layer: {0}", unit.LastAun).AppendLine(); @@ -386,8 +384,7 @@ public static class DI sb.AppendFormat("Disc manufacturer ID: \"{0}\"", Encoding.ASCII.GetString(unit.ManufacturerID)). AppendLine(); - sb.AppendFormat("Disc media type ID: \"{0}\"", Encoding.ASCII.GetString(unit.MediaTypeID)). - AppendLine(); + sb.AppendFormat("Disc media type ID: \"{0}\"", Encoding.ASCII.GetString(unit.MediaTypeID)).AppendLine(); sb.AppendFormat("Disc timestamp: 0x{0:X2}", unit.TimeStamp).AppendLine(); sb.AppendFormat("Disc product revison number: {0}", unit.ProductRevisionNumber).AppendLine(); @@ -404,7 +401,7 @@ public static class DI public static string ManufacturerFromDI(string manufacturerId) { - string manufacturer = ""; + var manufacturer = ""; switch(manufacturerId) { diff --git a/Bluray/Spare.cs b/Bluray/Spare.cs index 39cc685..a193263 100644 --- a/Bluray/Spare.cs +++ b/Bluray/Spare.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Bluray; + using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Decoders.Bluray; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 diff --git a/CD/ATIP.cs b/CD/ATIP.cs index 23e65d8..9beb260 100644 --- a/CD/ATIP.cs +++ b/CD/ATIP.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.CD; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Decoders.CD; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -215,8 +215,7 @@ public static class ATIP break; default: - sb.AppendFormat("Reference speed set is unknown: {0}", response.ReferenceSpeed). - AppendLine(); + sb.AppendFormat("Reference speed set is unknown: {0}", response.ReferenceSpeed).AppendLine(); break; } @@ -271,9 +270,8 @@ public static class ATIP sb.AppendFormat("ATIP Start time of Lead-in: {0}:{1:D2}:{2:D2}", response.LeadInStartMin, response.LeadInStartSec, response.LeadInStartFrame).AppendLine(); - sb.AppendFormat("ATIP Last possible start time of Lead-out: {0}:{1:D2}:{2:D2}", - response.LeadOutStartMin, response.LeadOutStartSec, response.LeadOutStartFrame). - AppendLine(); + sb.AppendFormat("ATIP Last possible start time of Lead-out: {0}:{1:D2}:{2:D2}", response.LeadOutStartMin, + response.LeadOutStartSec, response.LeadOutStartFrame).AppendLine(); if(response.A1Valid) sb.AppendFormat("A1 value: 0x{0:X6}", diff --git a/CD/CDTextOnLeadIn.cs b/CD/CDTextOnLeadIn.cs index 1448d0e..e8a7592 100644 --- a/CD/CDTextOnLeadIn.cs +++ b/CD/CDTextOnLeadIn.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.CD; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Decoders.CD; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -118,17 +118,17 @@ public static class CDTextOnLeadIn return null; } - for(int i = 0; i < (decoded.DataLength - 2) / 18; i++) + for(var i = 0; i < (decoded.DataLength - 2) / 18; i++) { - decoded.DataPacks[i].HeaderID1 = CDTextResponse[0 + (i * 18) + 4]; - decoded.DataPacks[i].HeaderID2 = CDTextResponse[1 + (i * 18) + 4]; - decoded.DataPacks[i].HeaderID3 = CDTextResponse[2 + (i * 18) + 4]; - decoded.DataPacks[i].DBCC = Convert.ToBoolean(CDTextResponse[3 + (i * 18) + 4] & 0x80); - decoded.DataPacks[i].BlockNumber = (byte)((CDTextResponse[3 + (i * 18) + 4] & 0x70) >> 4); - decoded.DataPacks[i].CharacterPosition = (byte)(CDTextResponse[3 + (i * 18) + 4] & 0x0F); + decoded.DataPacks[i].HeaderID1 = CDTextResponse[0 + i * 18 + 4]; + decoded.DataPacks[i].HeaderID2 = CDTextResponse[1 + i * 18 + 4]; + decoded.DataPacks[i].HeaderID3 = CDTextResponse[2 + i * 18 + 4]; + decoded.DataPacks[i].DBCC = Convert.ToBoolean(CDTextResponse[3 + i * 18 + 4] & 0x80); + decoded.DataPacks[i].BlockNumber = (byte)((CDTextResponse[3 + i * 18 + 4] & 0x70) >> 4); + decoded.DataPacks[i].CharacterPosition = (byte)(CDTextResponse[3 + i * 18 + 4] & 0x0F); decoded.DataPacks[i].TextDataField = new byte[12]; - Array.Copy(CDTextResponse, 4 + (i * 18) + 4, decoded.DataPacks[i].TextDataField, 0, 12); - decoded.DataPacks[i].CRC = BigEndianBitConverter.ToUInt16(CDTextResponse, 16 + (i * 18) + 4); + Array.Copy(CDTextResponse, 4 + i * 18 + 4, decoded.DataPacks[i].TextDataField, 0, 12); + decoded.DataPacks[i].CRC = BigEndianBitConverter.ToUInt16(CDTextResponse, 16 + i * 18 + 4); } return decoded; @@ -155,8 +155,7 @@ public static class CDTextOnLeadIn { // Ignore NOPs if((descriptor.HeaderID1 & 0x80) != 0) - sb.AppendFormat("Incorrect CD-Text pack type {0}, not decoding", descriptor.HeaderID1). - AppendLine(); + sb.AppendFormat("Incorrect CD-Text pack type {0}, not decoding", descriptor.HeaderID1).AppendLine(); } else { @@ -322,8 +321,7 @@ public static class CDTextOnLeadIn default: { sb.AppendFormat("Binary contents: {0}", - PrintHex.ByteArrayToHexArrayString(descriptor.TextDataField, 28)). - AppendLine(); + PrintHex.ByteArrayToHexArrayString(descriptor.TextDataField, 28)).AppendLine(); break; } diff --git a/CD/Enums.cs b/CD/Enums.cs index ea42e6c..4062b24 100644 --- a/CD/Enums.cs +++ b/CD/Enums.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.CD; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "MemberCanBeInternal")] public enum TocAdr : byte { diff --git a/CD/FullTOC.cs b/CD/FullTOC.cs index 6a6ba63..c607092 100644 --- a/CD/FullTOC.cs +++ b/CD/FullTOC.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.CD; + using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -39,8 +41,6 @@ using Aaru.CommonTypes.Structs; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Decoders.CD; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -91,22 +91,22 @@ public static class FullTOC return null; } - for(int i = 0; i < (decoded.DataLength - 2) / 11; i++) + for(var i = 0; i < (decoded.DataLength - 2) / 11; i++) { - decoded.TrackDescriptors[i].SessionNumber = CDFullTOCResponse[0 + (i * 11) + 4]; - decoded.TrackDescriptors[i].ADR = (byte)((CDFullTOCResponse[1 + (i * 11) + 4] & 0xF0) >> 4); - decoded.TrackDescriptors[i].CONTROL = (byte)(CDFullTOCResponse[1 + (i * 11) + 4] & 0x0F); - decoded.TrackDescriptors[i].TNO = CDFullTOCResponse[2 + (i * 11) + 4]; - decoded.TrackDescriptors[i].POINT = CDFullTOCResponse[3 + (i * 11) + 4]; - decoded.TrackDescriptors[i].Min = CDFullTOCResponse[4 + (i * 11) + 4]; - decoded.TrackDescriptors[i].Sec = CDFullTOCResponse[5 + (i * 11) + 4]; - decoded.TrackDescriptors[i].Frame = CDFullTOCResponse[6 + (i * 11) + 4]; - decoded.TrackDescriptors[i].Zero = CDFullTOCResponse[7 + (i * 11) + 4]; - decoded.TrackDescriptors[i].HOUR = (byte)((CDFullTOCResponse[7 + (i * 11) + 4] & 0xF0) >> 4); - decoded.TrackDescriptors[i].PHOUR = (byte)(CDFullTOCResponse[7 + (i * 11) + 4] & 0x0F); - decoded.TrackDescriptors[i].PMIN = CDFullTOCResponse[8 + (i * 11) + 4]; - decoded.TrackDescriptors[i].PSEC = CDFullTOCResponse[9 + (i * 11) + 4]; - decoded.TrackDescriptors[i].PFRAME = CDFullTOCResponse[10 + (i * 11) + 4]; + decoded.TrackDescriptors[i].SessionNumber = CDFullTOCResponse[0 + i * 11 + 4]; + decoded.TrackDescriptors[i].ADR = (byte)((CDFullTOCResponse[1 + i * 11 + 4] & 0xF0) >> 4); + decoded.TrackDescriptors[i].CONTROL = (byte)(CDFullTOCResponse[1 + i * 11 + 4] & 0x0F); + decoded.TrackDescriptors[i].TNO = CDFullTOCResponse[2 + i * 11 + 4]; + decoded.TrackDescriptors[i].POINT = CDFullTOCResponse[3 + i * 11 + 4]; + decoded.TrackDescriptors[i].Min = CDFullTOCResponse[4 + i * 11 + 4]; + decoded.TrackDescriptors[i].Sec = CDFullTOCResponse[5 + i * 11 + 4]; + decoded.TrackDescriptors[i].Frame = CDFullTOCResponse[6 + i * 11 + 4]; + decoded.TrackDescriptors[i].Zero = CDFullTOCResponse[7 + i * 11 + 4]; + decoded.TrackDescriptors[i].HOUR = (byte)((CDFullTOCResponse[7 + i * 11 + 4] & 0xF0) >> 4); + decoded.TrackDescriptors[i].PHOUR = (byte)(CDFullTOCResponse[7 + i * 11 + 4] & 0x0F); + decoded.TrackDescriptors[i].PMIN = CDFullTOCResponse[8 + i * 11 + 4]; + decoded.TrackDescriptors[i].PSEC = CDFullTOCResponse[9 + i * 11 + 4]; + decoded.TrackDescriptors[i].PFRAME = CDFullTOCResponse[10 + i * 11 + 4]; } return decoded; @@ -121,14 +121,14 @@ public static class FullTOC var sb = new StringBuilder(); - int lastSession = 0; + var lastSession = 0; sb.AppendFormat("First complete session number: {0}", response.FirstCompleteSession).AppendLine(); sb.AppendFormat("Last complete session number: {0}", response.LastCompleteSession).AppendLine(); foreach(TrackDataDescriptor descriptor in response.TrackDescriptors) - if((descriptor.CONTROL & 0x08) == 0x08 || - (descriptor.ADR != 1 && descriptor.ADR != 5 && descriptor.ADR != 4 && descriptor.ADR != 6) || + if((descriptor.CONTROL & 0x08) == 0x08 || + descriptor.ADR != 1 && descriptor.ADR != 5 && descriptor.ADR != 4 && descriptor.ADR != 6 || descriptor.TNO != 0) { sb.AppendLine("Unknown TOC entry format, printing values as-is"); @@ -292,9 +292,8 @@ public static class FullTOC descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME, descriptor.PHOUR).AppendLine(); else - sb.AppendFormat("Lead-out start position: {0:D2}:{1:D2}:{2:D2}", - descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME). - AppendLine(); + sb.AppendFormat("Lead-out start position: {0:D2}:{1:D2}:{2:D2}", descriptor.PMIN, + descriptor.PSEC, descriptor.PFRAME).AppendLine(); //sb.AppendFormat("Absolute time: {3:D2}:{0:D2}:{1:D2}:{2:D2}", descriptor.Min, descriptor.Sec, descriptor.Frame, descriptor.HOUR).AppendLine(); @@ -343,11 +342,10 @@ public static class FullTOC descriptor.POINT).AppendLine(); else { - string type = "Audio"; + var type = "Audio"; if((TocControl)(descriptor.CONTROL & 0x0D) == TocControl.DataTrack || - (TocControl)(descriptor.CONTROL & 0x0D) == - TocControl.DataTrackIncremental) + (TocControl)(descriptor.CONTROL & 0x0D) == TocControl.DataTrackIncremental) type = "Data"; if(descriptor.PHOUR > 0) @@ -422,8 +420,8 @@ public static class FullTOC { sb. AppendFormat("Start of next possible program in the recordable area of the disc: {3:D2}:{0:D2}:{1:D2}:{2:D2}", - descriptor.Min, descriptor.Sec, descriptor.Frame, - descriptor.HOUR).AppendLine(); + descriptor.Min, descriptor.Sec, descriptor.Frame, descriptor.HOUR). + AppendLine(); sb. AppendFormat("Maximum start of outermost Lead-out in the recordable area of the disc: {3:D2}:{0:D2}:{1:D2}:{2:D2}", @@ -438,8 +436,7 @@ public static class FullTOC sb. AppendFormat("Maximum start of outermost Lead-out in the recordable area of the disc: {0:D2}:{1:D2}:{2:D2}", - descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME). - AppendLine(); + descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME).AppendLine(); } break; @@ -447,8 +444,7 @@ public static class FullTOC case 0xB1: { - sb.AppendFormat("Number of skip interval pointers: {0}", descriptor.PMIN). - AppendLine(); + sb.AppendFormat("Number of skip interval pointers: {0}", descriptor.PMIN).AppendLine(); sb.AppendFormat("Number of skip track pointers: {0}", descriptor.PSEC).AppendLine(); @@ -482,8 +478,7 @@ public static class FullTOC else sb. AppendFormat("Start time of the first Lead-in area in the disc: {0:D2}:{1:D2}:{2:D2}", - descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME). - AppendLine(); + descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME).AppendLine(); break; } @@ -513,19 +508,16 @@ public static class FullTOC sb. AppendFormat("Stop position of inner part lead-out area: {3:D2}:{0:D2}:{1:D2}:{2:D2}", - descriptor.Min, descriptor.Sec, descriptor.Frame, - descriptor.HOUR).AppendLine(); + descriptor.Min, descriptor.Sec, descriptor.Frame, descriptor.HOUR). + AppendLine(); } else { - sb. - AppendFormat("Start position of outer part lead-in area: {0:D2}:{1:D2}:{2:D2}", - descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME). - AppendLine(); + sb.AppendFormat("Start position of outer part lead-in area: {0:D2}:{1:D2}:{2:D2}", + descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME).AppendLine(); - sb. - AppendFormat("Stop position of inner part lead-out area: {0:D2}:{1:D2}:{2:D2}", - descriptor.Min, descriptor.Sec, descriptor.Frame).AppendLine(); + sb.AppendFormat("Stop position of inner part lead-out area: {0:D2}:{1:D2}:{2:D2}", + descriptor.Min, descriptor.Sec, descriptor.Frame).AppendLine(); } break; @@ -538,8 +530,7 @@ public static class FullTOC { sb. AppendFormat("Start time for interval that should be skipped: {0:D2}:{1:D2}:{2:D2}", - descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME). - AppendLine(); + descriptor.PMIN, descriptor.PSEC, descriptor.PFRAME).AppendLine(); sb. AppendFormat("Ending time for interval that should be skipped: {0:D2}:{1:D2}:{2:D2}", @@ -570,7 +561,7 @@ public static class FullTOC case 6: { - uint id = (uint)((descriptor.Min << 16) + (descriptor.Sec << 8) + descriptor.Frame); + var id = (uint)((descriptor.Min << 16) + (descriptor.Sec << 8) + descriptor.Frame); sb.AppendFormat("Disc ID: {0:X6}", id & 0x00FFFFFF).AppendLine(); break; @@ -632,8 +623,7 @@ public static class FullTOC public byte PFRAME; } - public static CDFullTOC Create(List tracks, Dictionary trackFlags, - bool createC0Entry = false) + public static CDFullTOC Create(List tracks, Dictionary trackFlags, bool createC0Entry = false) { var toc = new CDFullTOC(); Dictionary sessionEndingTrack = new(); diff --git a/CD/PMA.cs b/CD/PMA.cs index 6fde8f3..751848d 100644 --- a/CD/PMA.cs +++ b/CD/PMA.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.CD; + using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Decoders.CD; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -81,21 +81,21 @@ public static class PMA return null; } - for(int i = 0; i < (decoded.DataLength - 2) / 11; i++) + for(var i = 0; i < (decoded.DataLength - 2) / 11; i++) { - decoded.PMADescriptors[i].Reserved = CDPMAResponse[0 + (i * 11) + 4]; - decoded.PMADescriptors[i].ADR = (byte)((CDPMAResponse[1 + (i * 11) + 4] & 0xF0) >> 4); - decoded.PMADescriptors[i].CONTROL = (byte)(CDPMAResponse[1 + (i * 11) + 4] & 0x0F); - decoded.PMADescriptors[i].TNO = CDPMAResponse[2 + (i * 11) + 4]; - decoded.PMADescriptors[i].POINT = CDPMAResponse[3 + (i * 11) + 4]; - decoded.PMADescriptors[i].Min = CDPMAResponse[4 + (i * 11) + 4]; - decoded.PMADescriptors[i].Sec = CDPMAResponse[5 + (i * 11) + 4]; - decoded.PMADescriptors[i].Frame = CDPMAResponse[6 + (i * 11) + 4]; - decoded.PMADescriptors[i].HOUR = (byte)((CDPMAResponse[7 + (i * 11) + 4] & 0xF0) >> 4); - decoded.PMADescriptors[i].PHOUR = (byte)(CDPMAResponse[7 + (i * 11) + 4] & 0x0F); - decoded.PMADescriptors[i].PMIN = CDPMAResponse[8 + (i * 11) + 4]; - decoded.PMADescriptors[i].PSEC = CDPMAResponse[9 + (i * 11) + 4]; - decoded.PMADescriptors[i].PFRAME = CDPMAResponse[10 + (i * 11) + 4]; + decoded.PMADescriptors[i].Reserved = CDPMAResponse[0 + i * 11 + 4]; + decoded.PMADescriptors[i].ADR = (byte)((CDPMAResponse[1 + i * 11 + 4] & 0xF0) >> 4); + decoded.PMADescriptors[i].CONTROL = (byte)(CDPMAResponse[1 + i * 11 + 4] & 0x0F); + decoded.PMADescriptors[i].TNO = CDPMAResponse[2 + i * 11 + 4]; + decoded.PMADescriptors[i].POINT = CDPMAResponse[3 + i * 11 + 4]; + decoded.PMADescriptors[i].Min = CDPMAResponse[4 + i * 11 + 4]; + decoded.PMADescriptors[i].Sec = CDPMAResponse[5 + i * 11 + 4]; + decoded.PMADescriptors[i].Frame = CDPMAResponse[6 + i * 11 + 4]; + decoded.PMADescriptors[i].HOUR = (byte)((CDPMAResponse[7 + i * 11 + 4] & 0xF0) >> 4); + decoded.PMADescriptors[i].PHOUR = (byte)(CDPMAResponse[7 + i * 11 + 4] & 0x0F); + decoded.PMADescriptors[i].PMIN = CDPMAResponse[8 + i * 11 + 4]; + decoded.PMADescriptors[i].PSEC = CDPMAResponse[9 + i * 11 + 4]; + decoded.PMADescriptors[i].PFRAME = CDPMAResponse[10 + i * 11 + 4]; } return decoded; @@ -181,7 +181,7 @@ public static class PMA break; case 2: - uint id = (uint)((descriptor.Min << 16) + (descriptor.Sec << 8) + descriptor.Frame); + var id = (uint)((descriptor.Min << 16) + (descriptor.Sec << 8) + descriptor.Frame); sb.AppendFormat("Disc ID: {0:X6}", id & 0x00FFFFFF).AppendLine(); break; @@ -244,8 +244,8 @@ public static class PMA descriptor.PFRAME); if(descriptor.PHOUR > 0) - sb.AppendFormat("{3}:{0:D2}:{1:D2}:{2:D2} ", descriptor.Min, descriptor.Sec, - descriptor.Frame, descriptor.HOUR); + sb.AppendFormat("{3}:{0:D2}:{1:D2}:{2:D2} ", descriptor.Min, descriptor.Sec, descriptor.Frame, + descriptor.HOUR); else sb.AppendFormat("{0:D2}:{1:D2}:{2:D2} ", descriptor.Min, descriptor.Sec, descriptor.Frame); @@ -263,8 +263,8 @@ public static class PMA descriptor.PFRAME); if(descriptor.PHOUR > 0) - sb.AppendFormat("{3}:{0:D2}:{1:D2}:{2:D2} ", descriptor.Min, descriptor.Sec, - descriptor.Frame, descriptor.HOUR); + sb.AppendFormat("{3}:{0:D2}:{1:D2}:{2:D2} ", descriptor.Min, descriptor.Sec, descriptor.Frame, + descriptor.HOUR); else sb.AppendFormat("{0:D2}:{1:D2}:{2:D2} ", descriptor.Min, descriptor.Sec, descriptor.Frame); diff --git a/CD/Sector.cs b/CD/Sector.cs index f0fc69b..f3fd2cd 100644 --- a/CD/Sector.cs +++ b/CD/Sector.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.CD; + using System; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -37,8 +39,6 @@ using System.Runtime.CompilerServices; using System.Text; using Aaru.Checksums; -namespace Aaru.Decoders.CD; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static class Sector @@ -189,21 +189,21 @@ public static class Sector sector.Length < 2352) return sector; - byte[] sync = new byte[12]; + var sync = new byte[12]; Array.Copy(sector, 0, sync, 0, 12); if(!SyncMark.SequenceEqual(sync)) return sector; - byte[] scrambled = new byte[sector.Length]; + var scrambled = new byte[sector.Length]; - for(int i = 0; i < 2352; i++) + for(var i = 0; i < 2352; i++) scrambled[i] = (byte)(sector[i] ^ ScrambleTable[i]); if(sector.Length <= 2352) return scrambled; - for(int i = 2352; i < sector.Length; i++) + for(var i = 2352; i < sector.Length; i++) scrambled[i] = sector[i]; return scrambled; @@ -222,7 +222,7 @@ public static class Sector { case 0: return new byte[2048]; case 1: - byte[] sector = new byte[2048]; + var sector = new byte[2048]; Array.Copy(data, 16, sector, 0, 2048); return sector; @@ -241,7 +241,7 @@ public static class Sector data.Length != 2336) return data; - int pos = 0; + var pos = 0; if(data.Length == 2352) { @@ -270,7 +270,7 @@ public static class Sector int len = (data[pos + 2] & 0x20) == 0x20 ? 2324 : 2048; pos += 8; - byte[] sector = new byte[len]; + var sector = new byte[len]; Array.Copy(data, pos, sector, 0, len); return sector; @@ -303,8 +303,8 @@ public static class Sector byte min = buffer[12]; byte sec = buffer[13]; byte frame = buffer[14]; - int lba = 0; - bool moreThan90 = false; + var lba = 0; + var moreThan90 = false; if(min > 0x90) { @@ -313,9 +313,9 @@ public static class Sector moreThan90 = true; } - lba += (((min >> 4) * 10) + (min & 0x0F)) * 75 * 60; - lba += (((sec >> 4) * 10) + (sec & 0x0F)) * 75; - lba += ((frame >> 4) * 10) + (frame & 0x0F); + lba += ((min >> 4) * 10 + (min & 0x0F)) * 75 * 60; + lba += ((sec >> 4) * 10 + (sec & 0x0F)) * 75; + lba += (frame >> 4) * 10 + (frame & 0x0F); lba -= 150; if(moreThan90) @@ -381,21 +381,19 @@ public static class Sector CdChecksums.CheckCdSector(buffer, out bool? correctEccP, out bool? correctEccQ, out bool? correctEdc); - bool empty = true; + var empty = true; switch(buffer[15] & 0x03) { case 0: - for(int i = 16; i < 2352; i++) - { + for(var i = 16; i < 2352; i++) if(buffer[i] != 0x00) { empty = false; break; } - } sb.AppendLine(empty ? "Correct sector contents." : "Incorrect sector contents."); @@ -405,15 +403,13 @@ public static class Sector sb.AppendLine(correctEccP == true ? "Correct ECC P." : "Incorrect ECC P."); sb.AppendLine(correctEccQ == true ? "Correct ECC Q." : "Incorrect ECC Q."); - for(int i = 2068; i < 2076; i++) - { + for(var i = 2068; i < 2076; i++) if(buffer[i] != 0x00) { empty = false; break; } - } sb.AppendLine(empty ? "Correct zero fill." : "Incorrect zero fill."); diff --git a/CD/SectorBuilder.cs b/CD/SectorBuilder.cs index cbdc397..1cc96cf 100644 --- a/CD/SectorBuilder.cs +++ b/CD/SectorBuilder.cs @@ -26,11 +26,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.CD; + using System; using Aaru.CommonTypes.Enums; -namespace Aaru.Decoders.CD; - public class SectorBuilder { readonly byte[] _eccBTable; @@ -46,7 +46,7 @@ public class SectorBuilder for(uint i = 0; i < 256; i++) { uint edc = i; - uint j = (uint)((i << 1) ^ ((i & 0x80) == 0x80 ? 0x11D : 0)); + var j = (uint)((i << 1) ^ ((i & 0x80) == 0x80 ? 0x11D : 0)); _eccFTable[i] = (byte)j; _eccBTable[i ^ j] = (byte)i; @@ -81,9 +81,9 @@ public class SectorBuilder (byte minute, byte second, byte frame) msf = LbaToMsf(lba); - sector[0x00C] = (byte)(((msf.minute / 10) << 4) + (msf.minute % 10)); - sector[0x00D] = (byte)(((msf.second / 10) << 4) + (msf.second % 10)); - sector[0x00E] = (byte)(((msf.frame / 10) << 4) + (msf.frame % 10)); + sector[0x00C] = (byte)(((msf.minute / 10) << 4) + msf.minute % 10); + sector[0x00D] = (byte)(((msf.second / 10) << 4) + msf.second % 10); + sector[0x00E] = (byte)(((msf.frame / 10) << 4) + msf.frame % 10); switch(type) { @@ -162,7 +162,7 @@ public class SectorBuilder default: return; } - byte[] zeroaddress = new byte[4]; + var zeroaddress = new byte[4]; switch(type) { @@ -196,8 +196,7 @@ public class SectorBuilder // } - void EccWriteSector(byte[] address, byte[] data, ref byte[] ecc, int addressOffset, int dataOffset, - int eccOffset) + void EccWriteSector(byte[] address, byte[] data, ref byte[] ecc, int addressOffset, int dataOffset, int eccOffset) { WriteEcc(address, data, 86, 24, 2, 86, ref ecc, addressOffset, dataOffset, eccOffset); // P WriteEcc(address, data, 52, 43, 86, 88, ref ecc, addressOffset, dataOffset, eccOffset + 0xAC); // Q @@ -211,7 +210,7 @@ public class SectorBuilder for(major = 0; major < majorCount; major++) { - uint idx = ((major >> 1) * majorMult) + (major & 1); + uint idx = (major >> 1) * majorMult + (major & 1); byte eccA = 0; byte eccB = 0; uint minor; diff --git a/CD/Session.cs b/CD/Session.cs index 88c7607..e4e07de 100644 --- a/CD/Session.cs +++ b/CD/Session.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.CD; + using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Decoders.CD; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -77,16 +77,16 @@ public static class Session return null; } - for(int i = 0; i < (decoded.DataLength - 2) / 8; i++) + for(var i = 0; i < (decoded.DataLength - 2) / 8; i++) { - decoded.TrackDescriptors[i].Reserved1 = CDSessionInfoResponse[0 + (i * 8) + 4]; - decoded.TrackDescriptors[i].ADR = (byte)((CDSessionInfoResponse[1 + (i * 8) + 4] & 0xF0) >> 4); - decoded.TrackDescriptors[i].CONTROL = (byte)(CDSessionInfoResponse[1 + (i * 8) + 4] & 0x0F); - decoded.TrackDescriptors[i].TrackNumber = CDSessionInfoResponse[2 + (i * 8) + 4]; - decoded.TrackDescriptors[i].Reserved2 = CDSessionInfoResponse[3 + (i * 8) + 4]; + decoded.TrackDescriptors[i].Reserved1 = CDSessionInfoResponse[0 + i * 8 + 4]; + decoded.TrackDescriptors[i].ADR = (byte)((CDSessionInfoResponse[1 + i * 8 + 4] & 0xF0) >> 4); + decoded.TrackDescriptors[i].CONTROL = (byte)(CDSessionInfoResponse[1 + i * 8 + 4] & 0x0F); + decoded.TrackDescriptors[i].TrackNumber = CDSessionInfoResponse[2 + i * 8 + 4]; + decoded.TrackDescriptors[i].Reserved2 = CDSessionInfoResponse[3 + i * 8 + 4]; decoded.TrackDescriptors[i].TrackStartAddress = - BigEndianBitConverter.ToUInt32(CDSessionInfoResponse, 4 + (i * 8) + 4); + BigEndianBitConverter.ToUInt32(CDSessionInfoResponse, 4 + i * 8 + 4); } return decoded; @@ -106,8 +106,7 @@ public static class Session foreach(TrackDataDescriptor descriptor in response.TrackDescriptors) { - sb.AppendFormat("First track number in last complete session: {0}", descriptor.TrackNumber). - AppendLine(); + sb.AppendFormat("First track number in last complete session: {0}", descriptor.TrackNumber).AppendLine(); sb.AppendFormat("Track starts at LBA {0}, or MSF {1:X2}:{2:X2}:{3:X2}", descriptor.TrackStartAddress, (descriptor.TrackStartAddress & 0x0000FF00) >> 8, diff --git a/CD/Subchannel.cs b/CD/Subchannel.cs index 10ab868..7f9e0e3 100644 --- a/CD/Subchannel.cs +++ b/CD/Subchannel.cs @@ -26,11 +26,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.CD; + using System; using Aaru.Checksums; -namespace Aaru.Decoders.CD; - public static class Subchannel { static readonly string[] _isrcTable = @@ -53,17 +53,17 @@ public static class Subchannel if((q[0] & 0xF) == 1 || (q[0] & 0xF) == 5) { - q[1] = (byte)(((q[1] / 10) << 4) + (q[1] % 10)); - q[2] = (byte)(((q[2] / 10) << 4) + (q[2] % 10)); - q[3] = (byte)(((q[3] / 10) << 4) + (q[3] % 10)); - q[4] = (byte)(((q[4] / 10) << 4) + (q[4] % 10)); - q[5] = (byte)(((q[5] / 10) << 4) + (q[5] % 10)); - q[6] = (byte)(((q[6] / 10) << 4) + (q[6] % 10)); - q[7] = (byte)(((q[7] / 10) << 4) + (q[7] % 10)); - q[8] = (byte)(((q[8] / 10) << 4) + (q[8] % 10)); + q[1] = (byte)(((q[1] / 10) << 4) + q[1] % 10); + q[2] = (byte)(((q[2] / 10) << 4) + q[2] % 10); + q[3] = (byte)(((q[3] / 10) << 4) + q[3] % 10); + q[4] = (byte)(((q[4] / 10) << 4) + q[4] % 10); + q[5] = (byte)(((q[5] / 10) << 4) + q[5] % 10); + q[6] = (byte)(((q[6] / 10) << 4) + q[6] % 10); + q[7] = (byte)(((q[7] / 10) << 4) + q[7] % 10); + q[8] = (byte)(((q[8] / 10) << 4) + q[8] % 10); } - q[9] = (byte)(((q[9] / 10) << 4) + (q[9] % 10)); + q[9] = (byte)(((q[9] / 10) << 4) + q[9] % 10); } public static void BcdToBinaryQ(byte[] q) @@ -71,31 +71,29 @@ public static class Subchannel if((q[0] & 0xF) == 1 || (q[0] & 0xF) == 5) { - q[1] = (byte)((q[1] / 16 * 10) + (q[1] & 0x0F)); - q[2] = (byte)((q[2] / 16 * 10) + (q[2] & 0x0F)); - q[3] = (byte)((q[3] / 16 * 10) + (q[3] & 0x0F)); - q[4] = (byte)((q[4] / 16 * 10) + (q[4] & 0x0F)); - q[5] = (byte)((q[5] / 16 * 10) + (q[5] & 0x0F)); - q[6] = (byte)((q[6] / 16 * 10) + (q[6] & 0x0F)); - q[7] = (byte)((q[7] / 16 * 10) + (q[7] & 0x0F)); - q[8] = (byte)((q[8] / 16 * 10) + (q[8] & 0x0F)); + q[1] = (byte)(q[1] / 16 * 10 + (q[1] & 0x0F)); + q[2] = (byte)(q[2] / 16 * 10 + (q[2] & 0x0F)); + q[3] = (byte)(q[3] / 16 * 10 + (q[3] & 0x0F)); + q[4] = (byte)(q[4] / 16 * 10 + (q[4] & 0x0F)); + q[5] = (byte)(q[5] / 16 * 10 + (q[5] & 0x0F)); + q[6] = (byte)(q[6] / 16 * 10 + (q[6] & 0x0F)); + q[7] = (byte)(q[7] / 16 * 10 + (q[7] & 0x0F)); + q[8] = (byte)(q[8] / 16 * 10 + (q[8] & 0x0F)); } - q[9] = (byte)((q[9] / 16 * 10) + (q[9] & 0x0F)); + q[9] = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F)); } public static byte[] ConvertQToRaw(byte[] subchannel) { - int pos = 0; - byte[] subBuf = new byte[subchannel.Length * 6]; + var pos = 0; + var subBuf = new byte[subchannel.Length * 6]; - for(int i = 0; i < subchannel.Length; i += 16) + for(var i = 0; i < subchannel.Length; i += 16) { // P if((subchannel[i + 15] & 0x80) <= 0) - { pos += 12; - } else { subBuf[pos++] = 0xFF; @@ -135,13 +133,13 @@ public static class Subchannel public static byte[] Interleave(byte[] subchannel) { - byte[] subBuf = new byte[subchannel.Length]; + var subBuf = new byte[subchannel.Length]; - int outPos = 0; + var outPos = 0; - for(int inPos = 0; inPos < subchannel.Length; inPos += 96) + for(var inPos = 0; inPos < subchannel.Length; inPos += 96) { - for(int i = 0; i < 12; i++) + for(var i = 0; i < 12; i++) { // P subBuf[outPos + 0] += (byte)(subchannel[inPos + i + 0] & 0x80); @@ -231,12 +229,12 @@ public static class Subchannel public static byte[] Deinterleave(byte[] subchannel) { - byte[] subBuf = new byte[subchannel.Length]; - int inPos = 0; + var subBuf = new byte[subchannel.Length]; + var inPos = 0; - for(int outPos = 0; outPos < subchannel.Length; outPos += 96) + for(var outPos = 0; outPos < subchannel.Length; outPos += 96) { - for(int i = 0; i < 12; i++) + for(var i = 0; i < 12; i++) { // P subBuf[outPos + i + 0] += (byte)((subchannel[inPos + 0] & 0x80) >> 0); @@ -338,26 +336,26 @@ public static class Subchannel int adr = subBuf[0] & 0x0F; string controlInfo = ((control & 0xC) / 4) switch - { - 0 => $"stereo audio {((control & 0x01) == 1 ? "with" : "without")} pre-emphasis", - 1 => $"{((control & 0x01) == 1 ? "incremental" : "uninterrupted")} data", - 2 => $"quadraphonic audio {((control & 0x01) == 1 ? "with" : "without")} pre-emphasis", - _ => $"reserved control value {control & 0x01}" - }; + { + 0 => $"stereo audio {((control & 0x01) == 1 ? "with" : "without")} pre-emphasis", + 1 => $"{((control & 0x01) == 1 ? "incremental" : "uninterrupted")} data", + 2 => $"quadraphonic audio {((control & 0x01) == 1 ? "with" : "without")} pre-emphasis", + _ => $"reserved control value {control & 0x01}" + }; string copy = (control & 0x02) > 0 ? "copy permitted" : "copy prohibited"; if(bcd) BcdToBinaryQ(subBuf); - int qPos = (subBuf[3] * 60 * 75) + (subBuf[4] * 75) + subBuf[5] - 150; + int qPos = subBuf[3] * 60 * 75 + subBuf[4] * 75 + subBuf[5] - 150; byte pmin = subBuf[7]; byte psec = subBuf[8]; - int qStart = (subBuf[7] * 60 * 75) + (subBuf[8] * 75) + subBuf[9] - 150; - int nextPos = (subBuf[3] * 60 * 75) + (subBuf[4] * 75) + subBuf[5] - 150; + int qStart = subBuf[7] * 60 * 75 + subBuf[8] * 75 + subBuf[9] - 150; + int nextPos = subBuf[3] * 60 * 75 + subBuf[4] * 75 + subBuf[5] - 150; byte zero = subBuf[6]; - int maxOut = (subBuf[7] * 60 * 75) + (subBuf[8] * 75) + subBuf[9] - 150; + int maxOut = subBuf[7] * 60 * 75 + subBuf[8] * 75 + subBuf[9] - 150; bool final = subBuf[3] == 0xFF && subBuf[4] == 0xFF && subBuf[5] == 0xFF; BinaryToBcdQ(subBuf); @@ -374,12 +372,12 @@ public static class Subchannel case 1 when subBuf[2] == 0xA0: { string format = subBuf[8] switch - { - 0x00 => "CD-DA / CD-ROM", - 0x10 => "CD-i", - 0x20 => "CD-ROM XA", - _ => $"unknown {subBuf[0]:X2}" - }; + { + 0x00 => "CD-DA / CD-ROM", + 0x10 => "CD-i", + 0x20 => "CD-ROM XA", + _ => $"unknown {subBuf[0]:X2}" + }; return $"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {(corruptedPause ? "corrupted pause" : pause ? "pause" : "not pause")}, {controlInfo}, {copy}, Q mode {adr} position: {subBuf[3]:X2}:{subBuf[4]:X2}:{subBuf[5]:X2} (LBA {qPos}), track {subBuf[2]:X} is first program area track in {format} format, Q CRC 0x{subBuf[10]:X2}{subBuf[11]:X2} ({(crcOk ? "OK" : "BAD")}), R-W {(rwEmpty ? "empty" : "not empty")}"; @@ -401,23 +399,17 @@ public static class Subchannel $"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {(corruptedPause ? "corrupted pause" : pause ? "pause" : "not pause")}, {controlInfo}, {copy}, Q: {subBuf[0]:X2} {subBuf[1]:X2} {subBuf[2]:X2} {subBuf[3]:X2} {subBuf[4]:X2} {subBuf[5]:X2} {subBuf[6]:X2} {subBuf[7]:X2} {subBuf[8]:X2} {subBuf[9]:X2} CRC 0x{subBuf[10]:X2}{subBuf[11]:X2} ({(crcOk ? "OK" : "BAD")}), R-W {(rwEmpty ? "empty" : "not empty")}"; if(subBuf[2] <= 0x40) - { return $"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {(corruptedPause ? "corrupted pause" : pause ? "pause" : "not pause")}, {controlInfo}, {copy}, Q mode {adr} skip interval start time {subBuf[7]:X2}{subBuf[8]:X2}{subBuf[9]:X2}, skip interval stop time {subBuf[3]:X2}{subBuf[4]:X2}{subBuf[5]:X2}, CRC 0x{subBuf[10]:X2}{subBuf[11]:X2} ({(crcOk ? "OK" : "BAD")}), R-W {(rwEmpty ? "empty" : "not empty")}"; - } if(subBuf[2] == 0xB0) - { return final ? $"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {(corruptedPause ? "corrupted pause" : pause ? "pause" : "not pause")}, {controlInfo}, {copy}, Q mode {adr} next program area can start at {subBuf[3]:X2}:{subBuf[4]:X2}:{subBuf[5]:X2} (LBA {nextPos}), last-session, {zero} mode 5 pointers, CRC 0x{subBuf[10]:X2}{subBuf[11]:X2} ({(crcOk ? "OK" : "BAD")}), R-W {(rwEmpty ? "empty" : "not empty")}" : $"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {(corruptedPause ? "corrupted pause" : pause ? "pause" : "not pause")}, {controlInfo}, {copy}, Q mode {adr} next program area can start at {subBuf[3]:X2}:{subBuf[4]:X2}:{subBuf[5]:X2} (LBA {nextPos}), maximum Lead-out at {subBuf[7]:X2}:{subBuf[8]:X2}:{subBuf[9]:X2} (LBA {maxOut}), {zero} mode 5 pointers, CRC 0x{subBuf[10]:X2}{subBuf[11]:X2} ({(crcOk ? "OK" : "BAD")}), R-W {(rwEmpty ? "empty" : "not empty")}"; - } if(subBuf[2] == 0xB1) - { return $"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {(corruptedPause ? "corrupted pause" : pause ? "pause" : "not pause")}, {controlInfo}, {copy}, Q mode {adr}, {pmin} skip interval pointers, {psec} skip track assignments, CRC 0x{subBuf[10]:X2}{subBuf[11]:X2} ({(crcOk ? "OK" : "BAD")}), R-W {(rwEmpty ? "empty" : "not empty")}"; - } if(subBuf[2] != 0xB2 && subBuf[2] != 0xB3 && @@ -450,23 +442,22 @@ public static class Subchannel area = subBuf[1] == 0xAA ? "Lead-out" : "Program"; return adr switch - { - 1 => - $"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {(corruptedPause ? "corrupted pause" : pause ? "pause" : "not pause")}, {controlInfo}, {copy}, Q mode {adr} position: track {subBuf[1]:X} index {subBuf[2]:X} relative position {subBuf[3]:X2}:{subBuf[4]:X2}:{subBuf[5]:X2} (LBA {qPos + 150}), absolute position {subBuf[7]:X2}:{subBuf[8]:X2}:{subBuf[9]:X2} (LBA {qStart}), Q CRC 0x{subBuf[10]:X2}{subBuf[11]:X2} ({(crcOk ? "OK" : "BAD")}), R-W {(rwEmpty ? "empty" : "not empty")}", - 2 => - $"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {(corruptedPause ? "corrupted pause" : pause ? "pause" : "not pause")}, {controlInfo}, {copy}, Q mode {adr} MCN: {DecodeMcn(subBuf)} frame {subBuf[9]:X2} CRC 0x{subBuf[10]:X2}{subBuf[11]:X2} ({(crcOk ? "OK" : "BAD")}), R-W {(rwEmpty ? "empty" : "not empty")}", - 3 => - $"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {(corruptedPause ? "corrupted pause" : pause ? "pause" : "not pause")}, {controlInfo}, {copy}, Q mode {adr} ISRC: {DecodeIsrc(subBuf)} frame {subBuf[9]:X2} CRC 0x{subBuf[10]:X2}{subBuf[11]:X2} ({(crcOk ? "OK" : "BAD")}), R-W {(rwEmpty ? "empty" : "not empty")}", - _ => - $"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {(corruptedPause ? "corrupted pause" : pause ? "pause" : "not pause")}, {controlInfo}, {copy}, Q: {subBuf[0]:X2} {subBuf[1]:X2} {subBuf[2]:X2} {subBuf[3]:X2} {subBuf[4]:X2} {subBuf[5]:X2} {subBuf[6]:X2} {subBuf[7]:X2} {subBuf[8]:X2} {subBuf[9]:X2} CRC 0x{subBuf[10]:X2}{subBuf[11]:X2} ({(crcOk ? "OK" : "BAD")}), R-W {(rwEmpty ? "empty" : "not empty")}" - }; + { + 1 => + $"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {(corruptedPause ? "corrupted pause" : pause ? "pause" : "not pause")}, {controlInfo}, {copy}, Q mode {adr} position: track {subBuf[1]:X} index {subBuf[2]:X} relative position {subBuf[3]:X2}:{subBuf[4]:X2}:{subBuf[5]:X2} (LBA {qPos + 150}), absolute position {subBuf[7]:X2}:{subBuf[8]:X2}:{subBuf[9]:X2} (LBA {qStart}), Q CRC 0x{subBuf[10]:X2}{subBuf[11]:X2} ({(crcOk ? "OK" : "BAD")}), R-W {(rwEmpty ? "empty" : "not empty")}", + 2 => + $"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {(corruptedPause ? "corrupted pause" : pause ? "pause" : "not pause")}, {controlInfo}, {copy}, Q mode {adr} MCN: {DecodeMcn(subBuf)} frame {subBuf[9]:X2} CRC 0x{subBuf[10]:X2}{subBuf[11]:X2} ({(crcOk ? "OK" : "BAD")}), R-W {(rwEmpty ? "empty" : "not empty")}", + 3 => + $"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {(corruptedPause ? "corrupted pause" : pause ? "pause" : "not pause")}, {controlInfo}, {copy}, Q mode {adr} ISRC: {DecodeIsrc(subBuf)} frame {subBuf[9]:X2} CRC 0x{subBuf[10]:X2}{subBuf[11]:X2} ({(crcOk ? "OK" : "BAD")}), R-W {(rwEmpty ? "empty" : "not empty")}", + _ => + $"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {(corruptedPause ? "corrupted pause" : pause ? "pause" : "not pause")}, {controlInfo}, {copy}, Q: {subBuf[0]:X2} {subBuf[1]:X2} {subBuf[2]:X2} {subBuf[3]:X2} {subBuf[4]:X2} {subBuf[5]:X2} {subBuf[6]:X2} {subBuf[7]:X2} {subBuf[8]:X2} {subBuf[9]:X2} CRC 0x{subBuf[10]:X2}{subBuf[11]:X2} ({(crcOk ? "OK" : "BAD")}), R-W {(rwEmpty ? "empty" : "not empty")}" + }; } public static string DecodeIsrc(byte[] q) => - $"{_isrcTable[q[1] / 4]}{_isrcTable[((q[1] & 3) * 16) + (q[2] / 16)]}{_isrcTable[((q[2] & 0xF) * 4) + (q[3] / 64)]}{_isrcTable[q[3] & 0x3F]}{_isrcTable[q[4] / 4]}{q[5]:X2}{q[6]:X2}{q[7]:X2}{q[8] / 16:X1}"; + $"{_isrcTable[q[1] / 4]}{_isrcTable[(q[1] & 3) * 16 + q[2] / 16]}{_isrcTable[(q[2] & 0xF) * 4 + q[3] / 64]}{_isrcTable[q[3] & 0x3F]}{_isrcTable[q[4] / 4]}{q[5]:X2}{q[6]:X2}{q[7]:X2}{q[8] / 16:X1}"; - public static string DecodeMcn(byte[] q) => - $"{q[1]:X2}{q[2]:X2}{q[3]:X2}{q[4]:X2}{q[5]:X2}{q[6]:X2}{q[7] >> 4:X}"; + public static string DecodeMcn(byte[] q) => $"{q[1]:X2}{q[2]:X2}{q[3]:X2}{q[4]:X2}{q[5]:X2}{q[6]:X2}{q[7] >> 4:X}"; public static byte GetIsrcCode(char c) { @@ -512,15 +503,14 @@ public static class Subchannel } } - public static byte[] Generate(int sector, uint trackSequence, int pregap, int trackStart, byte flags, - byte index) + public static byte[] Generate(int sector, uint trackSequence, int pregap, int trackStart, byte flags, byte index) { bool isPregap = sector < 0 || sector <= trackStart + pregap; if(index == 0) index = (byte)(isPregap ? 0 : 1); - byte[] sub = new byte[96]; + var sub = new byte[96]; // P if(isPregap) @@ -540,7 +530,7 @@ public static class Subchannel } // Q - byte[] q = new byte[12]; + var q = new byte[12]; q[0] = (byte)((flags << 4) + 1); q[1] = (byte)trackSequence; @@ -556,12 +546,12 @@ public static class Subchannel sector += 150; int min = relative / 60 / 75; - int sec = (relative / 75) - (min * 60); - int frame = relative - (min * 60 * 75) - (sec * 75); + int sec = relative / 75 - min * 60; + int frame = relative - min * 60 * 75 - sec * 75; int amin = sector / 60 / 75; - int asec = (sector / 75) - (amin * 60); - int aframe = sector - (amin * 60 * 75) - (asec * 75); + int asec = sector / 75 - amin * 60; + int aframe = sector - amin * 60 * 75 - asec * 75; q[3] = (byte)min; q[4] = (byte)sec; @@ -571,16 +561,16 @@ public static class Subchannel q[8] = (byte)asec; q[9] = (byte)aframe; - q[1] = (byte)(((q[1] / 10) << 4) + (q[1] % 10)); - q[2] = (byte)(((q[2] / 10) << 4) + (q[2] % 10)); - q[3] = (byte)(((q[3] / 10) << 4) + (q[3] % 10)); - q[4] = (byte)(((q[4] / 10) << 4) + (q[4] % 10)); - q[5] = (byte)(((q[5] / 10) << 4) + (q[5] % 10)); - q[6] = (byte)(((q[6] / 10) << 4) + (q[6] % 10)); - q[7] = (byte)(((q[7] / 10) << 4) + (q[7] % 10)); - q[8] = (byte)(((q[8] / 10) << 4) + (q[8] % 10)); + q[1] = (byte)(((q[1] / 10) << 4) + q[1] % 10); + q[2] = (byte)(((q[2] / 10) << 4) + q[2] % 10); + q[3] = (byte)(((q[3] / 10) << 4) + q[3] % 10); + q[4] = (byte)(((q[4] / 10) << 4) + q[4] % 10); + q[5] = (byte)(((q[5] / 10) << 4) + q[5] % 10); + q[6] = (byte)(((q[6] / 10) << 4) + q[6] % 10); + q[7] = (byte)(((q[7] / 10) << 4) + q[7] % 10); + q[8] = (byte)(((q[8] / 10) << 4) + q[8] % 10); - q[9] = (byte)(((q[9] / 10) << 4) + (q[9] % 10)); + q[9] = (byte)(((q[9] / 10) << 4) + q[9] % 10); CRC16CCITTContext.Data(q, 10, out byte[] qCrc); q[10] = qCrc[0]; diff --git a/CD/TOC.cs b/CD/TOC.cs index 41619da..f49365a 100644 --- a/CD/TOC.cs +++ b/CD/TOC.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.CD; + using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Console; using Aaru.Helpers; -namespace Aaru.Decoders.CD; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -80,16 +80,16 @@ public static class TOC return null; } - for(int i = 0; i < (decoded.DataLength - 2) / 8; i++) + for(var i = 0; i < (decoded.DataLength - 2) / 8; i++) { - decoded.TrackDescriptors[i].Reserved1 = CDTOCResponse[0 + (i * 8) + 4]; - decoded.TrackDescriptors[i].ADR = (byte)((CDTOCResponse[1 + (i * 8) + 4] & 0xF0) >> 4); - decoded.TrackDescriptors[i].CONTROL = (byte)(CDTOCResponse[1 + (i * 8) + 4] & 0x0F); - decoded.TrackDescriptors[i].TrackNumber = CDTOCResponse[2 + (i * 8) + 4]; - decoded.TrackDescriptors[i].Reserved2 = CDTOCResponse[3 + (i * 8) + 4]; + decoded.TrackDescriptors[i].Reserved1 = CDTOCResponse[0 + i * 8 + 4]; + decoded.TrackDescriptors[i].ADR = (byte)((CDTOCResponse[1 + i * 8 + 4] & 0xF0) >> 4); + decoded.TrackDescriptors[i].CONTROL = (byte)(CDTOCResponse[1 + i * 8 + 4] & 0x0F); + decoded.TrackDescriptors[i].TrackNumber = CDTOCResponse[2 + i * 8 + 4]; + decoded.TrackDescriptors[i].Reserved2 = CDTOCResponse[3 + i * 8 + 4]; decoded.TrackDescriptors[i].TrackStartAddress = - BigEndianBitConverter.ToUInt32(CDTOCResponse, 4 + (i * 8) + 4); + BigEndianBitConverter.ToUInt32(CDTOCResponse, 4 + i * 8 + 4); } return decoded; diff --git a/DVD/AACS.cs b/DVD/AACS.cs index d6c30ab..d24e150 100644 --- a/DVD/AACS.cs +++ b/DVD/AACS.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.DVD; +using System.Diagnostics.CodeAnalysis; + // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 diff --git a/DVD/ADIP.cs b/DVD/ADIP.cs index 6659867..2cc16a4 100644 --- a/DVD/ADIP.cs +++ b/DVD/ADIP.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.DVD; +using System.Diagnostics.CodeAnalysis; + // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 diff --git a/DVD/BCA.cs b/DVD/BCA.cs index 66f1c70..bb184ec 100644 --- a/DVD/BCA.cs +++ b/DVD/BCA.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.DVD; +using System.Diagnostics.CodeAnalysis; + // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 diff --git a/DVD/CPRM.cs b/DVD/CPRM.cs index 5adaf48..6bd6c02 100644 --- a/DVD/CPRM.cs +++ b/DVD/CPRM.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.DVD; +using System.Diagnostics.CodeAnalysis; + // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 diff --git a/DVD/CSS&CPRM.cs b/DVD/CSS&CPRM.cs index 9eac0c2..188c31d 100644 --- a/DVD/CSS&CPRM.cs +++ b/DVD/CSS&CPRM.cs @@ -31,11 +31,11 @@ // Copyright © 2020-2022 Rebecca Wallander // ****************************************************************************/ +namespace Aaru.Decoders.DVD; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.DVD; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -91,15 +91,12 @@ public static class CSS_CPRM public static string PrettifyRegionalPlaybackControlState(RegionalPlaybackControlState? rpc) { if(rpc == null) - { return null; - } RegionalPlaybackControlState decoded = rpc.Value; var sb = new StringBuilder(); - var typeCode = - (TypeCode)((decoded.TypeCode_VendorResetsAvailable_UserControlledChangesAvailable & 0xc0) >> 6); + var typeCode = (TypeCode)((decoded.TypeCode_VendorResetsAvailable_UserControlledChangesAvailable & 0xc0) >> 6); int vendorResets = (decoded.TypeCode_VendorResetsAvailable_UserControlledChangesAvailable & 0x38) >> 3; @@ -345,7 +342,9 @@ public static class CSS_CPRM enum TypeCode { - None = 0, Set = 1, LastChance = 2, - Perm = 3 + None = 0, + Set = 1, + LastChance = 2, + Perm = 3 } } \ No newline at end of file diff --git a/DVD/Cartridge.cs b/DVD/Cartridge.cs index 84c6db9..b6d5063 100644 --- a/DVD/Cartridge.cs +++ b/DVD/Cartridge.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.DVD; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.DVD; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 diff --git a/DVD/DDS.cs b/DVD/DDS.cs index fba7db3..bcff599 100644 --- a/DVD/DDS.cs +++ b/DVD/DDS.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.DVD; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.DVD; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -91,7 +91,7 @@ public static class DDS Array.Copy(response, 14, dds.Reserved, 0, 6); dds.GroupCertificationFlags = new GroupCertificationFlag[24]; - for(int i = 0; i < 24; i++) + for(var i = 0; i < 24; i++) { dds.GroupCertificationFlags[i].InProcess |= (response[20 + i] & 0x80) == 0x80; dds.GroupCertificationFlags[i].PartialCertification |= (response[20 + i] & 0x40) == 0x40; @@ -115,9 +115,9 @@ public static class DDS dds.LSN0Location = (uint)((response[93] << 16) + (response[94] << 8) + response[95]); dds.StartLSNForZone = new uint[dds.Zones]; - for(int i = 0; i < dds.Zones; i++) - dds.StartLSNForZone[i] = (uint)((response[260 + (i * 4) + 1] << 16) + - (response[260 + (i * 4) + 2] << 8) + response[260 + (i * 4) + 3]); + for(var i = 0; i < dds.Zones; i++) + dds.StartLSNForZone[i] = (uint)((response[260 + i * 4 + 1] << 16) + (response[260 + i * 4 + 2] << 8) + + response[260 + i * 4 + 3]); } return dds; @@ -154,7 +154,7 @@ public static class DDS sb.AppendFormat("DDS has been updated {0} times", decoded.UpdateCount).AppendLine(); if(decoded.Groups == 24) - for(int i = 0; i < decoded.GroupCertificationFlags.Length; i++) + for(var i = 0; i < decoded.GroupCertificationFlags.Length; i++) { if(decoded.GroupCertificationFlags[i].InProcess) { @@ -179,7 +179,7 @@ public static class DDS sb.AppendFormat("LSN 0 is at PSN {0:X}h", decoded.LSN0Location).AppendLine(); - for(int i = 0; i < decoded.StartLSNForZone.Length; i++) + for(var i = 0; i < decoded.StartLSNForZone.Length; i++) sb.AppendFormat("Zone {0} starts at LSN {1}", i, decoded.StartLSNForZone[i]).AppendLine(); } diff --git a/DVD/DMI.cs b/DVD/DMI.cs index 1e5a3d6..46e72b2 100644 --- a/DVD/DMI.cs +++ b/DVD/DMI.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.DVD; +using System.Diagnostics.CodeAnalysis; + // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 diff --git a/DVD/Enums.cs b/DVD/Enums.cs index 7133669..ce52d8d 100644 --- a/DVD/Enums.cs +++ b/DVD/Enums.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.DVD; +using System.Diagnostics.CodeAnalysis; + #region Public enumerations [SuppressMessage("ReSharper", "InconsistentNaming")] public enum DiskCategory : byte @@ -86,8 +86,10 @@ public enum MaximumRateField : byte [SuppressMessage("ReSharper", "InconsistentNaming")] public enum LayerTypeFieldMask : byte { - Embossed = 0x01, Recordable = 0x02, Rewritable = 0x04, - Reserved = 0x08 + Embossed = 0x01, + Recordable = 0x02, + Rewritable = 0x04, + Reserved = 0x08 } [SuppressMessage("ReSharper", "InconsistentNaming")] @@ -143,7 +145,8 @@ public enum WPDiscTypes : byte /// Should not write without a cartridge DoNotWrite = 0x00, /// Can write without a cartridge - CanWrite = 0x01, Reserved1 = 0x02, Reserved2 = 0x03 + CanWrite = 0x01, Reserved1 = 0x02, + Reserved2 = 0x03 } [SuppressMessage("ReSharper", "InconsistentNaming")] @@ -167,15 +170,21 @@ public enum DVDRAMDiscType [SuppressMessage("ReSharper", "InconsistentNaming")] public enum DVDLayerStructure { - Unspecified = 0, InvertedStack = 1, TwoP = 2, - Reserved = 3 + Unspecified = 0, + InvertedStack = 1, + TwoP = 2, + Reserved = 3 } [SuppressMessage("ReSharper", "InconsistentNaming")] public enum DVDRecordingSpeed { - None = 0, Two = 0, Four = 0x10, - Six = 0x20, Eight = 0x30, Ten = 0x40, + None = 0, + Two = 0, + Four = 0x10, + Six = 0x20, + Eight = 0x30, + Ten = 0x40, Twelve = 0x50 } #endregion \ No newline at end of file diff --git a/DVD/Layers.cs b/DVD/Layers.cs index 82d0691..4b2259c 100644 --- a/DVD/Layers.cs +++ b/DVD/Layers.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.DVD; +using System.Diagnostics.CodeAnalysis; + // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 diff --git a/DVD/PFI.cs b/DVD/PFI.cs index 0021164..9837137 100644 --- a/DVD/PFI.cs +++ b/DVD/PFI.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.DVD; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.CommonTypes; using Aaru.Helpers; -namespace Aaru.Decoders.DVD; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -78,7 +78,7 @@ public static class PFI if(response.Length == 2048) { - byte[] tmp2 = new byte[2052]; + var tmp2 = new byte[2052]; Array.Copy(response, 0, tmp2, 4, 2048); response = tmp2; } @@ -105,11 +105,9 @@ public static class PFI pfi.LinearDensity = (LinearDensityField)((response[7] & 0xF0) >> 4); pfi.TrackDensity = (TrackDensityField)(response[7] & 0x0F); - pfi.DataAreaStartPSN = - (uint)((response[8] << 24) + (response[9] << 16) + (response[10] << 8) + response[11]); + pfi.DataAreaStartPSN = (uint)((response[8] << 24) + (response[9] << 16) + (response[10] << 8) + response[11]); - pfi.DataAreaEndPSN = - (uint)((response[12] << 24) + (response[13] << 16) + (response[14] << 8) + response[15]); + pfi.DataAreaEndPSN = (uint)((response[12] << 24) + (response[13] << 16) + (response[14] << 8) + response[15]); pfi.Layer0EndPSN = (uint)((response[16] << 24) + (response[17] << 16) + (response[18] << 8) + response[19]); @@ -118,7 +116,6 @@ public static class PFI pfi.RecordedBookType = pfi.DiskCategory; if(mediaType != MediaType.DVDROM) - { switch(mediaType) { case MediaType.DVDPR: @@ -201,7 +198,6 @@ public static class PFI break; } - } switch(pfi.DiskCategory) { @@ -360,8 +356,7 @@ public static class PFI Array.Copy(response, 31, tmp, 0, 3); pfi.MediaTypeID = StringHandlers.CToString(tmp); - pfi.ProductRevision = pfi.DiskCategory == DiskCategory.DVDPRDL ? (byte)(response[34] & 0x3F) - : response[34]; + pfi.ProductRevision = pfi.DiskCategory == DiskCategory.DVDPRDL ? (byte)(response[34] & 0x3F) : response[34]; pfi.PFIUsedInADIP = response[35]; } @@ -499,7 +494,7 @@ public static class PFI break; } - string categorySentence = "Disc is a {0} {1} version {2}"; + var categorySentence = "Disc is a {0} {1} version {2}"; switch(decoded.DiskCategory) { @@ -677,15 +672,14 @@ public static class PFI break; default: - sb.AppendFormat(categorySentence, sizeString, "unknown disc type", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(categorySentence, sizeString, "unknown disc type", decoded.PartVersion).AppendLine(); break; } if(decoded.RecordedBookType != decoded.DiskCategory) { - string bookTypeSentence = "Disc book type is {0}"; + var bookTypeSentence = "Disc book type is {0}"; switch(decoded.RecordedBookType) { @@ -916,8 +910,7 @@ public static class PFI sb.AppendFormat("Current Border-Out first sector is PSN {0:X}h", decoded.CurrentBorderOutSector). AppendLine(); - sb.AppendFormat("Next Border-In first sector is PSN {0:X}h", decoded.NextBorderInSector). - AppendLine(); + sb.AppendFormat("Next Border-In first sector is PSN {0:X}h", decoded.NextBorderInSector).AppendLine(); break; case DiskCategory.DVDPR: @@ -971,7 +964,7 @@ public static class PFI public static string ManufacturerFromDVDPlusID(string manufacturerId) { - string manufacturer = ""; + var manufacturer = ""; switch(manufacturerId) { diff --git a/DVD/PRI.cs b/DVD/PRI.cs index 3aabd62..f3575e4 100644 --- a/DVD/PRI.cs +++ b/DVD/PRI.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.DVD; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Helpers; -namespace Aaru.Decoders.DVD; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -157,8 +157,7 @@ public static class PRI sb.AppendLine("General purpose disc for use in general purpose drives"); } - sb.AppendLine((decoded.DiscPhysicalCode & 0x80) > 0 ? "Disc track pitch is 0,74 μm" - : "Unknown track pitch"); + sb.AppendLine((decoded.DiscPhysicalCode & 0x80) > 0 ? "Disc track pitch is 0,74 μm" : "Unknown track pitch"); sb.AppendLine((decoded.DiscPhysicalCode & 0x40) > 0 ? "Reference velocity is 3,49 m/s" : "Unknown reference velocity"); @@ -255,9 +254,7 @@ public static class PRI sb.AppendFormat("Recommended recording power is {0} mW", recordingPower).AppendLine(); } else - { sb.AppendLine("Recording power is not specified"); - } if((decoded.WaveLengthCode & 0xF) > 0) { @@ -330,9 +327,7 @@ public static class PRI sb.AppendFormat("Recommended erasing power ratio is {0} ε", erasingPower).AppendLine(); } else - { sb.AppendLine("Erasing power ratio is not specified"); - } } else { @@ -401,7 +396,7 @@ public static class PRI if(decoded.WaveLengthCode > 0) { - int wavelength = 0; + var wavelength = 0; switch(decoded.WaveLengthCode) { @@ -484,7 +479,7 @@ public static class PRI public static string ManufacturerFromPrePit(string manufacturerId) { - string manufacturer = ""; + var manufacturer = ""; // Bad thing is that it also includes a media code... if(manufacturerId.StartsWith("RITEK", StringComparison.Ordinal)) diff --git a/DVD/RMD.cs b/DVD/RMD.cs index 0b6279f..6ca065a 100644 --- a/DVD/RMD.cs +++ b/DVD/RMD.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.DVD; +using System.Diagnostics.CodeAnalysis; + // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 diff --git a/DVD/Spare.cs b/DVD/Spare.cs index 0eab4b9..d775af7 100644 --- a/DVD/Spare.cs +++ b/DVD/Spare.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.DVD; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.DVD; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -59,11 +59,10 @@ public static class Spare return new SpareAreaInformation { - DataLength = (ushort)((response[0] << 8) + response[1]), - Reserved1 = response[2], - Reserved2 = response[3], - UnusedPrimaryBlocks = - (uint)((response[4] << 24) + (response[5] << 16) + (response[6] << 8) + response[7]), + DataLength = (ushort)((response[0] << 8) + response[1]), + Reserved1 = response[2], + Reserved2 = response[3], + UnusedPrimaryBlocks = (uint)((response[4] << 24) + (response[5] << 16) + (response[6] << 8) + response[7]), UnusedSupplementaryBlocks = (uint)((response[8] << 24) + (response[9] << 16) + (response[10] << 8) + response[11]), AllocatedSupplementaryBlocks = @@ -82,8 +81,7 @@ public static class Spare sb.AppendFormat("{0} unused primary spare blocks", decoded.UnusedPrimaryBlocks).AppendLine(); sb.AppendFormat("{0} unused supplementary spare blocks", decoded.UnusedSupplementaryBlocks).AppendLine(); - sb.AppendFormat("{0} allocated supplementary spare blocks", decoded.AllocatedSupplementaryBlocks). - AppendLine(); + sb.AppendFormat("{0} allocated supplementary spare blocks", decoded.AllocatedSupplementaryBlocks).AppendLine(); return sb.ToString(); } diff --git a/DVD/UDI.cs b/DVD/UDI.cs index 15559cb..0ae91f2 100644 --- a/DVD/UDI.cs +++ b/DVD/UDI.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.DVD; +using System.Diagnostics.CodeAnalysis; + // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 diff --git a/Floppy/Amiga.cs b/Floppy/Amiga.cs index a4d4bb6..b9ce0ff 100644 --- a/Floppy/Amiga.cs +++ b/Floppy/Amiga.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Floppy; + using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.Decoders.Floppy; - /// Methods and structures for Commodore Amiga decoding [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] diff --git a/Floppy/Apple2.cs b/Floppy/Apple2.cs index 77d648c..99e440c 100644 --- a/Floppy/Apple2.cs +++ b/Floppy/Apple2.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Floppy; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -38,8 +40,6 @@ using System.Linq; using System.Runtime.InteropServices; using Aaru.Console; -namespace Aaru.Decoders.Floppy; - /// Methods and structures for Apple ][ floppy decoding [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] @@ -155,29 +155,29 @@ public static class Apple2 data.Length != 410) return null; - byte[] buffer = new byte[data.Length]; - byte carry = 0; + var buffer = new byte[data.Length]; + byte carry = 0; - for(int i = 0; i < data.Length; i++) + for(var i = 0; i < data.Length; i++) { carry ^= ReadTable5and3[data[i]]; buffer[i] = carry; } - byte[] output = new byte[256]; + var output = new byte[256]; - for(int i = 0; i < 51; i++) + for(var i = 0; i < 51; i++) { - byte b1 = buffer[(51 * 3) - i]; - byte b2 = buffer[(51 * 2) - i]; + byte b1 = buffer[51 * 3 - i]; + byte b2 = buffer[51 * 2 - i]; byte b3 = buffer[51 - i]; - byte b4 = (byte)((((b1 & 2) << 1) | (b2 & 2) | ((b3 & 2) >> 1)) & 0xFF); - byte b5 = (byte)((((b1 & 1) << 2) | ((b2 & 1) << 1) | (b3 & 1)) & 0xFF); - output[250 - (5 * i)] = (byte)(((buffer[i + (51 * 3) + 1] << 3) | ((b1 >> 2) & 0x7)) & 0xFF); - output[251 - (5 * i)] = (byte)(((buffer[i + (51 * 4) + 1] << 3) | ((b2 >> 2) & 0x7)) & 0xFF); - output[252 - (5 * i)] = (byte)(((buffer[i + (51 * 5) + 1] << 3) | ((b3 >> 2) & 0x7)) & 0xFF); - output[253 - (5 * i)] = (byte)(((buffer[i + (51 * 6) + 1] << 3) | b4) & 0xFF); - output[254 - (5 * i)] = (byte)(((buffer[i + (51 * 7) + 1] << 3) | b5) & 0xFF); + var b4 = (byte)((((b1 & 2) << 1) | (b2 & 2) | ((b3 & 2) >> 1)) & 0xFF); + var b5 = (byte)((((b1 & 1) << 2) | ((b2 & 1) << 1) | (b3 & 1)) & 0xFF); + output[250 - 5 * i] = (byte)(((buffer[i + 51 * 3 + 1] << 3) | ((b1 >> 2) & 0x7)) & 0xFF); + output[251 - 5 * i] = (byte)(((buffer[i + 51 * 4 + 1] << 3) | ((b2 >> 2) & 0x7)) & 0xFF); + output[252 - 5 * i] = (byte)(((buffer[i + 51 * 5 + 1] << 3) | ((b3 >> 2) & 0x7)) & 0xFF); + output[253 - 5 * i] = (byte)(((buffer[i + 51 * 6 + 1] << 3) | b4) & 0xFF); + output[254 - 5 * i] = (byte)(((buffer[i + 51 * 7 + 1] << 3) | b5) & 0xFF); } output[255] = (byte)(((buffer[409] << 3) | (buffer[0] & 0x7)) & 0xFF); @@ -193,16 +193,16 @@ public static class Apple2 data.Length != 342) return null; - byte[] buffer = new byte[data.Length]; - byte carry = 0; + var buffer = new byte[data.Length]; + byte carry = 0; - for(int i = 0; i < data.Length; i++) + for(var i = 0; i < data.Length; i++) { carry ^= ReadTable6and2[data[i]]; buffer[i] = carry; } - byte[] output = new byte[256]; + var output = new byte[256]; for(uint i = 0; i < 256; i++) { @@ -220,8 +220,8 @@ public static class Apple2 } else { - output[i] |= (byte)(((buffer[i - (86 * 2)] & 0x10) >> 3) & 0xFF); - output[i] |= (byte)(((buffer[i - (86 * 2)] & 0x20) >> 5) & 0xFF); + output[i] |= (byte)(((buffer[i - 86 * 2] & 0x10) >> 3) & 0xFF); + output[i] |= (byte)(((buffer[i - 86 * 2] & 0x20) >> 5) & 0xFF); } } @@ -326,9 +326,9 @@ public static class Apple2 sector.addressField.epilogue[2]); position += 14; - int syncCount = 0; - bool onSync = false; - var gaps = new MemoryStream(); + var syncCount = 0; + var onSync = false; + var gaps = new MemoryStream(); while(data[position] == 0xFF) { @@ -471,13 +471,13 @@ public static class Apple2 public static RawTrack MarshalTrack(byte[] data, out int endOffset, int offset = 0) { - int position = offset; - bool firstSector = true; - bool onSync = false; - var gaps = new MemoryStream(); - int count = 0; - List sectors = new List(); - byte[] trackNumber = new byte[2]; + int position = offset; + var firstSector = true; + var onSync = false; + var gaps = new MemoryStream(); + var count = 0; + var sectors = new List(); + var trackNumber = new byte[2]; endOffset = offset; while(position < data.Length && @@ -560,8 +560,8 @@ public static class Apple2 public static List MarshalDisk(byte[] data, out int endOffset, int offset = 0) { endOffset = offset; - List tracks = new List(); - int position = offset; + var tracks = new List(); + int position = offset; RawTrack track = MarshalTrack(data, out position, position); diff --git a/Floppy/AppleSony.cs b/Floppy/AppleSony.cs index 676e9dd..a10d78a 100644 --- a/Floppy/AppleSony.cs +++ b/Floppy/AppleSony.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Floppy; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -37,7 +39,6 @@ using System.IO; using System.Linq; using System.Runtime.InteropServices; -namespace Aaru.Decoders.Floppy; // Information from: // Inside Macintosh, Volume II, ISBN 0-201-17732-3 @@ -53,16 +54,16 @@ public static class AppleSony sector.addressField.prologue[2] != 0x96) return null; - byte[] bf1 = new byte[175]; - byte[] bf2 = new byte[175]; - byte[] bf3 = new byte[175]; + var bf1 = new byte[175]; + var bf2 = new byte[175]; + var bf3 = new byte[175]; byte[] nib_data = sector.dataField.data; var ms = new MemoryStream(); - int j = 0; + var j = 0; byte w3 = 0; - for(int i = 0; i <= 174; i++) + for(var i = 0; i <= 174; i++) { byte w4 = nib_data[j++]; byte w1 = nib_data[j++]; @@ -88,7 +89,7 @@ public static class AppleSony if((ck1 & 0x0100) > 0) ck1++; - byte carry = (byte)((bf1[j] ^ ck1) & 0xFF); + var carry = (byte)((bf1[j] ^ ck1) & 0xFF); ck3 += carry; if((ck1 & 0x0100) > 0) @@ -179,9 +180,9 @@ public static class AppleSony }; position += 10; - int syncCount = 0; - bool onSync = false; - var gaps = new MemoryStream(); + var syncCount = 0; + var onSync = false; + var gaps = new MemoryStream(); while(data[position] == 0xFF) { @@ -323,14 +324,14 @@ public static class AppleSony public static RawTrack MarshalTrack(byte[] data, out int endOffset, int offset = 0) { - int position = offset; - bool firstSector = true; - bool onSync = false; - var gaps = new MemoryStream(); - int count = 0; - List sectors = new List(); - byte trackNumber = 0; - byte sideNumber = 0; + int position = offset; + var firstSector = true; + var onSync = false; + var gaps = new MemoryStream(); + var count = 0; + var sectors = new List(); + byte trackNumber = 0; + byte sideNumber = 0; endOffset = offset; while(position < data.Length && @@ -407,8 +408,8 @@ public static class AppleSony public static List MarshalDisk(byte[] data, out int endOffset, int offset = 0) { endOffset = offset; - List tracks = new List(); - int position = offset; + var tracks = new List(); + int position = offset; RawTrack track = MarshalTrack(data, out position, position); diff --git a/Floppy/Commodore.cs b/Floppy/Commodore.cs index aa4f5d3..56f5b24 100644 --- a/Floppy/Commodore.cs +++ b/Floppy/Commodore.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Floppy; + using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.Decoders.Floppy; - /// Methods and structures for Commodore GCR floppy decoding [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] diff --git a/Floppy/Enums.cs b/Floppy/Enums.cs index 83a64af..1175203 100644 --- a/Floppy/Enums.cs +++ b/Floppy/Enums.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.Floppy; +using System.Diagnostics.CodeAnalysis; + /// In-sector code for sector size [SuppressMessage("ReSharper", "InconsistentNaming")] public enum IBMSectorSizeCode : byte @@ -59,7 +59,9 @@ public enum IBMSectorSizeCode : byte [SuppressMessage("ReSharper", "InconsistentNaming")] public enum IBMIdType : byte { - IndexMark = 0xFC, AddressMark = 0xFE, DataMark = 0xFB, + IndexMark = 0xFC, + AddressMark = 0xFE, + DataMark = 0xFB, DeletedDataMark = 0xF8 } diff --git a/Floppy/ISO.cs b/Floppy/ISO.cs index d6da8e5..64096b3 100644 --- a/Floppy/ISO.cs +++ b/Floppy/ISO.cs @@ -30,10 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Floppy; + using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.Decoders.Floppy; // Information from: // National Semiconductor PC87332VLJ datasheet // SMsC FDC37C78 datasheet diff --git a/Floppy/Perpendicular.cs b/Floppy/Perpendicular.cs index f791315..7681303 100644 --- a/Floppy/Perpendicular.cs +++ b/Floppy/Perpendicular.cs @@ -30,10 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Floppy; + using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.Decoders.Floppy; // Information from: // National Semiconductor PC87332VLJ datasheet // SMsC FDC37C78 datasheet diff --git a/Floppy/System34.cs b/Floppy/System34.cs index 5809d22..8a88018 100644 --- a/Floppy/System34.cs +++ b/Floppy/System34.cs @@ -30,10 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Floppy; + using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.Decoders.Floppy; // Information from: // National Semiconductor PC87332VLJ datasheet // SMsC FDC37C78 datasheet diff --git a/Floppy/System3740.cs b/Floppy/System3740.cs index 287e0aa..4787c3d 100644 --- a/Floppy/System3740.cs +++ b/Floppy/System3740.cs @@ -30,10 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Floppy; + using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -namespace Aaru.Decoders.Floppy; // Information from: // National Semiconductor PC87332VLJ datasheet // SMsC FDC37C78 datasheet diff --git a/LisaTag.cs b/LisaTag.cs index 1f6f4d7..6cf0a1c 100644 --- a/LisaTag.cs +++ b/LisaTag.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders; + using System; using System.Diagnostics.CodeAnalysis; using Aaru.Helpers; -namespace Aaru.Decoders; - /// Represents a Lisa Office 7/7 sector tag [SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "NotAccessedField.Global"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), @@ -80,7 +80,7 @@ public static class LisaTag var phTag = new ProfileTag(); - byte[] tmp = new byte[4]; + var tmp = new byte[4]; phTag.Version = BigEndianBitConverter.ToUInt16(tag, 0); phTag.Kind = (byte)((tag[2] & 0xC0) >> 6); @@ -128,7 +128,7 @@ public static class LisaTag var pmTag = new PriamTag(); - byte[] tmp = new byte[4]; + var tmp = new byte[4]; pmTag.Version = BigEndianBitConverter.ToUInt16(tag, 0); pmTag.Kind = (byte)((tag[2] & 0xC0) >> 6); @@ -266,7 +266,7 @@ public static class LisaTag public bool IsLast; /// Converts this tag to Priam DataTower format - public PriamTag ToPriam() => new PriamTag + public PriamTag ToPriam() => new() { AbsPage = AbsPage, Checksum = Checksum, @@ -284,7 +284,7 @@ public static class LisaTag }; /// Converts this tag to Sony format - public SonyTag ToSony() => new SonyTag + public SonyTag ToSony() => new() { FileId = FileId, IsFirst = IsFirst, @@ -300,7 +300,7 @@ public static class LisaTag /// Gets a byte array representation of this tag public byte[] GetBytes() { - byte[] tagBytes = new byte[20]; + var tagBytes = new byte[20]; byte[] tmp = BigEndianBitConverter.GetBytes(Version); Array.Copy(tmp, 0, tagBytes, 0, 2); @@ -364,7 +364,7 @@ public static class LisaTag public bool IsLast; /// Converts this tag to Apple Profile format - public ProfileTag ToProfile() => new ProfileTag + public ProfileTag ToProfile() => new() { AbsPage = AbsPage, Checksum = Checksum, @@ -382,7 +382,7 @@ public static class LisaTag }; /// Converts this tag to Sony format - public SonyTag ToSony() => new SonyTag + public SonyTag ToSony() => new() { FileId = FileId, IsFirst = IsFirst, @@ -398,7 +398,7 @@ public static class LisaTag /// Gets a byte array representation of this tag public byte[] GetBytes() { - byte[] tagBytes = new byte[24]; + var tagBytes = new byte[24]; byte[] tmp = BigEndianBitConverter.GetBytes(Version); Array.Copy(tmp, 0, tagBytes, 0, 2); @@ -454,7 +454,7 @@ public static class LisaTag public bool IsLast; /// Converts this tag to Apple Profile format - public ProfileTag ToProfile() => new ProfileTag + public ProfileTag ToProfile() => new() { FileId = FileId, IsFirst = IsFirst, @@ -468,7 +468,7 @@ public static class LisaTag }; /// Converts this tag to Priam DataTower format - public PriamTag ToPriam() => new PriamTag + public PriamTag ToPriam() => new() { FileId = FileId, IsFirst = IsFirst, @@ -484,7 +484,7 @@ public static class LisaTag /// Gets a byte array representation of this tag public byte[] GetBytes() { - byte[] tagBytes = new byte[12]; + var tagBytes = new byte[12]; byte[] tmp = BigEndianBitConverter.GetBytes(Version); Array.Copy(tmp, 0, tagBytes, 0, 2); diff --git a/MMC/CID.cs b/MMC/CID.cs index bed69b5..f16957c 100644 --- a/MMC/CID.cs +++ b/MMC/CID.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.MMC; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Helpers; -namespace Aaru.Decoders.MMC; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "UnassignedField.Global")] public class CID @@ -60,7 +60,7 @@ public static partial class Decoders if(response?.Length != 4) return null; - byte[] data = new byte[16]; + var data = new byte[16]; byte[] tmp = BitConverter.GetBytes(response[0]); Array.Copy(tmp, 0, data, 0, 4); @@ -89,7 +89,7 @@ public static partial class Decoders CRC = (byte)((response[15] & 0xFE) >> 1) }; - byte[] tmp = new byte[6]; + var tmp = new byte[6]; Array.Copy(response, 3, tmp, 0, 6); cid.ProductName = StringHandlers.CToString(tmp); @@ -129,7 +129,7 @@ public static partial class Decoders cid.ProductRevision & 0x0F).AppendLine(); sb.AppendFormat("\tProduct serial number: {0}", cid.ProductSerialNumber).AppendLine(); - string year = ""; + var year = ""; switch(cid.ManufacturingDate & 0x0F) { diff --git a/MMC/CSD.cs b/MMC/CSD.cs index 9ed834e..2b7b208 100644 --- a/MMC/CSD.cs +++ b/MMC/CSD.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.MMC; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.MMC; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")] public class CSD @@ -84,7 +84,7 @@ public static partial class Decoders if(response?.Length != 4) return null; - byte[] data = new byte[16]; + var data = new byte[16]; byte[] tmp = BitConverter.GetBytes(response[0]); Array.Copy(tmp, 0, data, 0, 4); @@ -148,7 +148,7 @@ public static partial class Decoders double unitFactor = 0; double multiplier = 0; - string unit = ""; + var unit = ""; var sb = new StringBuilder(); sb.AppendLine("MultiMediaCard Device Specific Data Register:"); @@ -609,8 +609,7 @@ public static partial class Decoders break; } - sb.AppendFormat("\tWriting is {0} times slower than reading", Math.Pow(2, csd.WriteSpeedFactor)). - AppendLine(); + sb.AppendFormat("\tWriting is {0} times slower than reading", Math.Pow(2, csd.WriteSpeedFactor)).AppendLine(); if(csd.WriteBlockLength == 15) sb.AppendLine("\tWrite block length size is defined in extended CSD"); diff --git a/MMC/ExtendedCSD.cs b/MMC/ExtendedCSD.cs index facf333..73daf48 100644 --- a/MMC/ExtendedCSD.cs +++ b/MMC/ExtendedCSD.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.MMC; + using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using System.Text; -namespace Aaru.Decoders.MMC; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "UnassignedField.Global"), StructLayout(LayoutKind.Sequential, Pack = 1)] @@ -219,7 +219,8 @@ public enum DeviceSupportedCommandSets : byte [Flags] public enum HPIFeatures : byte { - Supported = 1 << 0, CMD12 = 1 << 1 + Supported = 1 << 0, + CMD12 = 1 << 1 } [Flags] @@ -237,13 +238,15 @@ public enum DataTagSupport : byte [Flags] public enum ExtendedPartitionsSupport : byte { - SystemCode = 1 << 0, NonPersistent = 1 << 1 + SystemCode = 1 << 0, + NonPersistent = 1 << 1 } [Flags] public enum SupportedModes : byte { - FFU = 1 << 0, VendorSpecific = 1 << 1 + FFU = 1 << 0, + VendorSpecific = 1 << 1 } [Flags] @@ -267,41 +270,55 @@ public enum CacheFlushingPolicy : byte [Flags] public enum SecureFeatureSupport : byte { - Purge = 1 << 0, Defective = 1 << 2, Trim = 1 << 4, - Sanitize = 1 << 6 + Purge = 1 << 0, + Defective = 1 << 2, + Trim = 1 << 4, + Sanitize = 1 << 6 } [Flags] public enum BootInformation : byte { - Alternative = 1 << 0, DDR = 1 << 1, HighSpeed = 1 << 2 + Alternative = 1 << 0, + DDR = 1 << 1, + HighSpeed = 1 << 2 } [Flags] public enum SecureWriteProtectInformation : byte { - Supported = 1 << 0, Enabled = 1 << 1 + Supported = 1 << 0, + Enabled = 1 << 1 } [Flags] public enum DriverStrength : byte { - Type0 = 1 << 0, Type1 = 1 << 1, Type2 = 1 << 2, - Type3 = 1 << 3, Type4 = 1 << 4 + Type0 = 1 << 0, + Type1 = 1 << 1, + Type2 = 1 << 2, + Type3 = 1 << 3, + Type4 = 1 << 4 } [Flags] public enum DeviceType : byte { - HS_26 = 1 << 0, HS_52 = 1 << 1, HS_DDR_52 = 1 << 2, - HS_DDR_52_LV = 1 << 3, HS200_18 = 1 << 4, HS200_12 = 1 << 5, - HS400_18 = 1 << 6, HS400_12 = 1 << 7 + HS_26 = 1 << 0, + HS_52 = 1 << 1, + HS_DDR_52 = 1 << 2, + HS_DDR_52_LV = 1 << 3, + HS200_18 = 1 << 4, + HS200_12 = 1 << 5, + HS400_18 = 1 << 6, + HS400_12 = 1 << 7 } [Flags] public enum BootConfigProtection : byte { - PowerCycle = 1 << 0, Permanent = 1 << 4 + PowerCycle = 1 << 0, + Permanent = 1 << 4 } [Flags] @@ -313,22 +330,32 @@ public enum HighCapacityEraseGroupDefinition : byte [Flags] public enum BootAreaWriteProtectionRegister : byte { - PowerOn = 1 << 0, PowerOnArea2 = 1 << 1, Permanent = 1 << 2, - PermanentArea2 = 1 << 3, PermanentDisable = 1 << 4, PowerOnDisable = 1 << 6, - Selected = 1 << 7 + PowerOn = 1 << 0, + PowerOnArea2 = 1 << 1, + Permanent = 1 << 2, + PermanentArea2 = 1 << 3, + PermanentDisable = 1 << 4, + PowerOnDisable = 1 << 6, + Selected = 1 << 7 } [Flags] public enum UserAreaWriteProtectionRegister : byte { - ApplyPowerOn = 1 << 0, ApplyPermanent = 1 << 2, DisablePowerOn = 1 << 3, - DisablePermanent = 1 << 4, DisableWriteProtect = 1 << 6, DisablePassword = 1 << 7 + ApplyPowerOn = 1 << 0, + ApplyPermanent = 1 << 2, + DisablePowerOn = 1 << 3, + DisablePermanent = 1 << 4, + DisableWriteProtect = 1 << 6, + DisablePassword = 1 << 7 } [Flags] public enum PartitioningSupport : byte { - Supported = 1 << 0, Enhanced = 1 << 1, Extended = 1 << 2 + Supported = 1 << 0, + Enhanced = 1 << 1, + Extended = 1 << 2 } [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), @@ -358,8 +385,7 @@ public static partial class Decoders double unit; if(csd.ExtendedSecurityCommandsError != 0) - sb.AppendFormat("\tLast extended security error was {0}", csd.ExtendedSecurityCommandsError). - AppendLine(); + sb.AppendFormat("\tLast extended security error was {0}", csd.ExtendedSecurityCommandsError).AppendLine(); if(csd.SupportedCommandSets.HasFlag(DeviceSupportedCommandSets.Standard)) sb.AppendLine("\tDevice supports standard MMC command set"); @@ -388,8 +414,8 @@ public static partial class Decoders { sb.AppendFormat("\tMax context ID is {0}.", csd.ContextManagementCaps & 0xF).AppendLine(); - sb.AppendFormat("\tLarge unit maximum multiplier is {0}.", - ((csd.ContextManagementCaps & 0x70) >> 4) + 1).AppendLine(); + sb.AppendFormat("\tLarge unit maximum multiplier is {0}.", ((csd.ContextManagementCaps & 0x70) >> 4) + 1). + AppendLine(); } sb.AppendFormat("\tLarge unit size is {0} MiB", csd.LargeUnitSize + 1).AppendLine(); @@ -405,7 +431,7 @@ public static partial class Decoders sb.AppendLine("\tDevice supports FFU"); if(csd.FFUFeatures.HasFlag(FFUFeatures.SupportedModeOperationCodes)) - { + // todo public byte ModeOperationCodes if(csd.OperationCodesTimeout > 0) @@ -425,16 +451,13 @@ public static partial class Decoders AppendFormat("\tMaximum timeout for switch command when setting a value to the mode operation codes field is {0:D2}µs", unit).AppendLine(); } - } } if(csd.SupportedModes.HasFlag(SupportedModes.VendorSpecific)) sb.AppendLine("\tDevice supports Vendor Specific Mode"); if(csd.BarrierSupport == 0x01) - { sb.AppendLine("\tDevice supports the barrier command"); - } if(csd.CMDQueuingSupport.HasFlag(CMDQueuingSupport.Supported)) sb.AppendFormat("\tDevice supports command queuing with a depth of {0}", csd.CMDQueuingDepth + 1). @@ -697,8 +720,8 @@ public static partial class Decoders sb.AppendFormat("\tDevice takes a maximum of {0} s to switch production state awareness", unit / 1000000).AppendLine(); else if(unit > 1000) - sb.AppendFormat("\tDevice takes a maximum of {0} ms to switch production state awareness", - unit / 1000).AppendLine(); + sb.AppendFormat("\tDevice takes a maximum of {0} ms to switch production state awareness", unit / 1000). + AppendLine(); else sb.AppendFormat("\tDevice takes a maximum of {0} μs to switch production state awareness", unit). AppendLine(); @@ -727,8 +750,7 @@ public static partial class Decoders sb.AppendFormat("\tDevice takes a maximum of {0} s to move to sleep state", unit / 1000000). AppendLine(); else if(unit > 1000) - sb.AppendFormat("\tDevice takes a maximum of {0} ms to move to sleep state", unit / 1000). - AppendLine(); + sb.AppendFormat("\tDevice takes a maximum of {0} ms to move to sleep state", unit / 1000).AppendLine(); else sb.AppendFormat("\tDevice takes a maximum of {0} μs to move to sleep state", unit).AppendLine(); } @@ -756,8 +778,8 @@ public static partial class Decoders if(csd.MinimumReadPerformance26_4 == 0) sb.AppendLine("\tDevice cannot achieve 2.4MB/s reading in SDR 26Mhz 4-bit mode"); else - sb.AppendFormat("\tDevice can achieve a minimum of {0}MB/s reading in SDR 26Mhz 4-bit mode", - unit / 1000).AppendLine(); + sb.AppendFormat("\tDevice can achieve a minimum of {0}MB/s reading in SDR 26Mhz 4-bit mode", unit / 1000). + AppendLine(); unit = csd.MinimumReadPerformance52 * 300; @@ -788,8 +810,8 @@ public static partial class Decoders if(csd.MinimumWritePerformance26_4 == 0) sb.AppendLine("\tDevice cannot achieve 2.4MB/s writing in SDR 26Mhz 4-bit mode"); else - sb.AppendFormat("\tDevice can achieve a minimum of {0}MB/s writing in SDR 26Mhz 4-bit mode", - unit / 1000).AppendLine(); + sb.AppendFormat("\tDevice can achieve a minimum of {0}MB/s writing in SDR 26Mhz 4-bit mode", unit / 1000). + AppendLine(); unit = csd.MinimumWritePerformance52 * 300; @@ -913,8 +935,7 @@ public static partial class Decoders { sb.AppendLine("\tDevice supports enhanced strobe mode"); - sb.AppendLine((csd.BusWidth & 0x80) == 0x80 - ? "\tDevice uses strobe during Data Out, CRC and CMD responses" + sb.AppendLine((csd.BusWidth & 0x80) == 0x80 ? "\tDevice uses strobe during Data Out, CRC and CMD responses" : "\tDevice uses strobe during Data Out and CRC responses"); } @@ -981,8 +1002,8 @@ public static partial class Decoders break; default: - sb.AppendFormat("\tUnknown enabled boot partition code {0}", - (csd.PartitionConfiguration & 0x38) >> 3).AppendLine(); + sb.AppendFormat("\tUnknown enabled boot partition code {0}", (csd.PartitionConfiguration & 0x38) >> 3). + AppendLine(); break; } @@ -1037,8 +1058,7 @@ public static partial class Decoders break; } - sb.AppendLine((csd.BootBusConditions & 4) == 4 - ? "\tDevice will retain boot conditions after boot operation." + sb.AppendLine((csd.BootBusConditions & 4) == 4 ? "\tDevice will retain boot conditions after boot operation." : "\tDevice will reset boot conditions to compatibility mode after boot operation."); switch((csd.BootBusConditions & 0x24) >> 3) @@ -1099,24 +1119,19 @@ public static partial class Decoders if(csd.BootAreaWriteProtectionRegister.HasFlag(BootAreaWriteProtectionRegister.Permanent)) { if(csd.BootAreaWriteProtectionRegister.HasFlag(BootAreaWriteProtectionRegister.Selected)) - { sb.AppendLine(csd.BootAreaWriteProtectionRegister.HasFlag(BootAreaWriteProtectionRegister. PermanentArea2) ? "\tBoot area 2 is permanently write protected." : "\tBoot area 1 is permanently write protected."); - } else sb.AppendLine("\tBoth boot areas are permanently write protected."); } else if(csd.BootAreaWriteProtectionRegister.HasFlag(BootAreaWriteProtectionRegister.PowerOn)) { if(csd.BootAreaWriteProtectionRegister.HasFlag(BootAreaWriteProtectionRegister.Selected)) - { - sb.AppendLine(csd.BootAreaWriteProtectionRegister.HasFlag(BootAreaWriteProtectionRegister. - PowerOnArea2) + sb.AppendLine(csd.BootAreaWriteProtectionRegister.HasFlag(BootAreaWriteProtectionRegister.PowerOnArea2) ? "\tBoot area 2 is write protected until next power cycle." : "\tBoot area 1 is write protected until next power cycle."); - } else sb.AppendLine("\tBoth boot areas are write protected until next power cycle."); } @@ -1149,8 +1164,7 @@ public static partial class Decoders sb.AppendLine("\tFirmware updates are permanently disabled"); if(csd.RPMBSize > 0) - sb.AppendFormat("\tDevice has a {0} KiB replay protected memory block", csd.RPMBSize * 128). - AppendLine(); + sb.AppendFormat("\tDevice has a {0} KiB replay protected memory block", csd.RPMBSize * 128).AppendLine(); if(csd.PartitioningSupport.HasFlag(PartitioningSupport.Supported)) { @@ -1191,8 +1205,8 @@ public static partial class Decoders break; default: - sb.AppendFormat("\tDevice emulates unknown sector size indicated by code {0}", - csd.NativeSectorSize).AppendLine(); + sb.AppendFormat("\tDevice emulates unknown sector size indicated by code {0}", csd.NativeSectorSize). + AppendLine(); break; } diff --git a/MMC/OCR.cs b/MMC/OCR.cs index 3bcb773..f3018da 100644 --- a/MMC/OCR.cs +++ b/MMC/OCR.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.MMC; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Helpers; -namespace Aaru.Decoders.MMC; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")] public class OCR diff --git a/MMC/VendorString.cs b/MMC/VendorString.cs index 049a825..5bc9974 100644 --- a/MMC/VendorString.cs +++ b/MMC/VendorString.cs @@ -39,10 +39,10 @@ public static class VendorString /// MMC vendor ID /// Manufacturer public static string Prettify(byte mmcVendorId) => mmcVendorId switch - { - 0x07 => "Nokia", - 0x15 => "Samsung", - 0x2C => "extreMEmory", - _ => $"Unknown manufacturer ID 0x{mmcVendorId:X2}" - }; + { + 0x07 => "Nokia", + 0x15 => "Samsung", + 0x2C => "extreMEmory", + _ => $"Unknown manufacturer ID 0x{mmcVendorId:X2}" + }; } \ No newline at end of file diff --git a/PCMCIA/CIS.cs b/PCMCIA/CIS.cs index adb58e3..3bc9740 100644 --- a/PCMCIA/CIS.cs +++ b/PCMCIA/CIS.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.PCMCIA; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -37,8 +39,6 @@ using System.Linq; using System.Text; using Aaru.Helpers; -namespace Aaru.Decoders.PCMCIA; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static class CIS @@ -46,8 +46,8 @@ public static class CIS // TODO: Handle links? Or are they removed in lower layers of the operating system drivers? public static Tuple[] GetTuples(byte[] data) { - List tuples = new List(); - int position = 0; + var tuples = new List(); + var position = 0; while(position < data.Length) { @@ -94,10 +94,10 @@ public static class CIS if((data?.Length - 2) % 6 != 0) return null; - var tuple = new DeviceGeometryTuple(); - List geometries = new List(); + var tuple = new DeviceGeometryTuple(); + var geometries = new List(); - for(int position = 2; position < data.Length; position += 6) + for(var position = 2; position < data.Length; position += 6) { var geometry = new DeviceGeometry { @@ -219,10 +219,10 @@ public static class CIS if(data.Length < 4) return null; - List buffer = new List(); + var buffer = new List(); List strings = null; - bool firstString = false; - bool secondString = false; + var firstString = false; + var secondString = false; var tuple = new Level1VersionTuple { @@ -232,7 +232,7 @@ public static class CIS MinorVersion = data[3] }; - for(int position = 4; position < data.Length; position++) + for(var position = 4; position < data.Length; position++) { if(data[position] == 0xFF) break; diff --git a/PCMCIA/Enums.cs b/PCMCIA/Enums.cs index c0975d9..0426bf3 100644 --- a/PCMCIA/Enums.cs +++ b/PCMCIA/Enums.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.PCMCIA; +using System.Diagnostics.CodeAnalysis; + /// Tuple codes. [SuppressMessage("ReSharper", "InconsistentNaming")] public enum TupleCodes : byte @@ -165,9 +165,17 @@ public enum DeviceSpeedCodes : byte [SuppressMessage("ReSharper", "InconsistentNaming")] public enum FunctionCodes : byte { - MultiFunction = 0x00, Memory = 0x01, Serial = 0x02, - Parallel = 0x03, FixedDisk = 0x04, Video = 0x05, - Network = 0x06, AIMS = 0x07, SCSI = 0x08, - Security = 0x09, Instrument = 0x0A, HighSpeedSerial = 0x0B, - VendorSpecific = 0xFE + MultiFunction = 0x00, + Memory = 0x01, + Serial = 0x02, + Parallel = 0x03, + FixedDisk = 0x04, + Video = 0x05, + Network = 0x06, + AIMS = 0x07, + SCSI = 0x08, + Security = 0x09, + Instrument = 0x0A, + HighSpeedSerial = 0x0B, + VendorSpecific = 0xFE } \ No newline at end of file diff --git a/PCMCIA/Types.cs b/PCMCIA/Types.cs index 5b46919..1dc4aa3 100644 --- a/PCMCIA/Types.cs +++ b/PCMCIA/Types.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.PCMCIA; +using System.Diagnostics.CodeAnalysis; + /// Basic classure of a PCMCIA tuple [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] diff --git a/PCMCIA/VendorCode.cs b/PCMCIA/VendorCode.cs index 01992b4..97c4dff 100644 --- a/PCMCIA/VendorCode.cs +++ b/PCMCIA/VendorCode.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.PCMCIA; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "MemberCanBeInternal")] public static class VendorCode { diff --git a/SCSI/DiscStructureCapabilities.cs b/SCSI/DiscStructureCapabilities.cs index 87c8d39..7d8d9cf 100644 --- a/SCSI/DiscStructureCapabilities.cs +++ b/SCSI/DiscStructureCapabilities.cs @@ -30,23 +30,23 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")] public static class DiscStructureCapabilities { public static Capability[] Decode(byte[] response) { - ushort len = (ushort)((response[0] << 8) + response[1]); + var len = (ushort)((response[0] << 8) + response[1]); if(len + 2 != response.Length) return null; - List caps = new List(); + var caps = new List(); uint offset = 4; diff --git a/SCSI/EVPD.cs b/SCSI/EVPD.cs index 13d92b7..59b1562 100644 --- a/SCSI/EVPD.cs +++ b/SCSI/EVPD.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -40,8 +42,6 @@ using Aaru.CommonTypes.Structs.Devices.ATA; using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Helpers; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global"), SuppressMessage("ReSharper", "UnassignedField.Global")] @@ -58,7 +58,7 @@ public static class EVPD if(page.Length != page[3] + 4) return null; - byte[] decoded = new byte[page.Length - 4]; + var decoded = new byte[page.Length - 4]; Array.Copy(page, 4, decoded, 0, page.Length - 4); @@ -80,7 +80,7 @@ public static class EVPD if(page.Length != page[3] + 4) return null; - byte[] ascii = new byte[page[4]]; + var ascii = new byte[page[4]]; Array.Copy(page, 5, ascii, 0, page[4]); @@ -98,11 +98,11 @@ public static class EVPD if(page.Length != page[3] + 4) return null; - byte[] ascii = new byte[page.Length - 4]; + var ascii = new byte[page.Length - 4]; Array.Copy(page, 4, ascii, 0, page.Length - 4); - for(int i = 0; i < ascii.Length - 1; i++) + for(var i = 0; i < ascii.Length - 1; i++) if(ascii[i] < 0x20) return null; @@ -120,7 +120,7 @@ public static class EVPD if(page.Length != page[3] + 4) return null; - byte[] ascii = new byte[page.Length - 4]; + var ascii = new byte[page.Length - 4]; Array.Copy(page, 4, ascii, 0, page.Length - 4); @@ -136,7 +136,7 @@ public static class EVPD if(page.Length != page[3] + 4) return null; - byte[] ascii = new byte[page.Length - 4]; + var ascii = new byte[page.Length - 4]; Array.Copy(page, 4, ascii, 0, page.Length - 4); @@ -153,7 +153,7 @@ public static class EVPD if(page.Length != 12) return 0; - byte[] bitmap = new byte[8]; + var bitmap = new byte[8]; Array.Copy(page, 4, bitmap, 0, 8); @@ -170,7 +170,7 @@ public static class EVPD if(page.Length != page[3] + 4) return null; - byte[] ascii = new byte[page.Length - 4]; + var ascii = new byte[page.Length - 4]; Array.Copy(page, 4, ascii, 0, page.Length - 4); @@ -187,8 +187,8 @@ public static class EVPD if(page.Length != page[3] + 4) return null; - byte[] element = new byte[page.Length - 4]; - var sb = new StringBuilder(); + var element = new byte[page.Length - 4]; + var sb = new StringBuilder(); foreach(byte b in element) sb.AppendFormat("{0:X2}", b); @@ -237,8 +237,8 @@ public static class EVPD Default = (ScsiDefinitions)(pageResponse[5] & 0x7F) }; - int position = 6; - List definitions = new List(); + var position = 6; + var definitions = new List(); while(position < pageResponse.Length) { @@ -394,8 +394,8 @@ public static class EVPD PageLength = (byte)(pageResponse[3] + 4) }; - int position = 4; - List descriptors = new List(); + var position = 4; + var descriptors = new List(); while(position < pageResponse.Length) { @@ -604,7 +604,7 @@ public static class EVPD { sb.AppendFormat("\tIEEE EUI-64: {0:X2}", descriptor.Binary[0]); - for(int i = 1; i < descriptor.Binary.Length; i++) + for(var i = 1; i < descriptor.Binary.Length; i++) sb.AppendFormat(":{0:X2}", descriptor.Binary[i]); sb.AppendLine(); @@ -619,7 +619,7 @@ public static class EVPD { sb.AppendFormat("\tNAA: {0:X2}", descriptor.Binary[0]); - for(int i = 1; i < descriptor.Binary.Length; i++) + for(var i = 1; i < descriptor.Binary.Length; i++) sb.AppendFormat(":{0:X2}", descriptor.Binary[i]); sb.AppendLine(); @@ -661,7 +661,7 @@ public static class EVPD { sb.AppendFormat("\tMD5 logical unit identifier: {0:x2}", descriptor.Binary[0]); - for(int i = 1; i < descriptor.Binary.Length; i++) + for(var i = 1; i < descriptor.Binary.Length; i++) sb.AppendFormat("{0:x2}", descriptor.Binary[i]); sb.AppendLine(); @@ -753,10 +753,8 @@ public static class EVPD break; case ProtocolIdentifiers.SSA: - sb. - AppendFormat("\tProtocol (SSA) specific descriptor with unknown format (hex): {0}", - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)). - AppendLine(); + sb.AppendFormat("\tProtocol (SSA) specific descriptor with unknown format (hex): {0}", + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40)).AppendLine(); break; case ProtocolIdentifiers.SCSIe: @@ -765,9 +763,8 @@ public static class EVPD break; case ProtocolIdentifiers.UAS: - sb. - AppendFormat("\tProtocol (UAS) specific descriptor: USB address {0} interface {1}", - descriptor.Binary[0] & 0x7F, descriptor.Binary[2]).AppendLine(); + sb.AppendFormat("\tProtocol (UAS) specific descriptor: USB address {0} interface {1}", + descriptor.Binary[0] & 0x7F, descriptor.Binary[2]).AppendLine(); break; default: @@ -798,10 +795,9 @@ public static class EVPD break; default: - sb. - AppendFormat("Inquiry descriptor type {2} contains unknown kind {1} of data (hex): {0}", - PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40), - (byte)descriptor.CodeSet, (byte)descriptor.Type).AppendLine(); + sb.AppendFormat("Inquiry descriptor type {2} contains unknown kind {1} of data (hex): {0}", + PrintHex.ByteArrayToHexArrayString(descriptor.Binary, 40), + (byte)descriptor.CodeSet, (byte)descriptor.Type).AppendLine(); break; } @@ -854,8 +850,8 @@ public static class EVPD PageLength = (byte)(pageResponse[3] + 4) }; - int position = 4; - List identifiers = new List(); + var position = 4; + var identifiers = new List(); while(position < pageResponse.Length) { @@ -897,7 +893,7 @@ public static class EVPD { sb.AppendFormat("\t{0:X2}", identifier.Identifier[0]); - for(int i = 1; i < identifier.Identifier.Length; i++) + for(var i = 1; i < identifier.Identifier.Length; i++) sb.AppendFormat(":{0:X2}", identifier.Identifier[i]); sb.AppendLine(); @@ -910,9 +906,14 @@ public static class EVPD #region EVPD Page 0x85: Management Network Addresses page public enum NetworkServiceTypes : byte { - Unspecified = 0, StorageConf = 1, Diagnostics = 2, - Status = 3, Logging = 4, CodeDownload = 5, - CopyService = 6, Administrative = 7 + Unspecified = 0, + StorageConf = 1, + Diagnostics = 2, + Status = 3, + Logging = 4, + CodeDownload = 5, + CopyService = 6, + Administrative = 7 } public struct NetworkDescriptor @@ -960,8 +961,8 @@ public static class EVPD PageLength = (ushort)((pageResponse[2] << 8) + pageResponse[3] + 4) }; - int position = 4; - List descriptors = new List(); + var position = 4; + var descriptors = new List(); while(position < pageResponse.Length) { @@ -1069,9 +1070,8 @@ public static class EVPD break; default: - sb.AppendFormat("Address of unknown type {1}: {0}", - StringHandlers.CToString(descriptor.Address), (byte)descriptor.Type). - AppendLine(); + sb.AppendFormat("Address of unknown type {1}: {0}", StringHandlers.CToString(descriptor.Address), + (byte)descriptor.Type).AppendLine(); break; } @@ -1322,8 +1322,8 @@ public static class EVPD sb.AppendLine("Device supports vendor specific activation for new microcode"); if(page.ExtendedTestMinutes > 0) - sb.AppendFormat("Extended self-test takes {0} to complete", - TimeSpan.FromMinutes(page.ExtendedTestMinutes)).AppendLine(); + sb.AppendFormat("Extended self-test takes {0} to complete", TimeSpan.FromMinutes(page.ExtendedTestMinutes)). + AppendLine(); if(page.MaximumSenseLength > 0) sb.AppendFormat("Device supports a maximum of {0} bytes for sense data", page.MaximumSenseLength). @@ -1406,11 +1406,10 @@ public static class EVPD sb.AppendLine("SCSI to ATA Translation Layer Data:"); sb.AppendFormat("\tTranslation layer vendor: {0}", - VendorString.Prettify(StringHandlers.CToString(page.VendorIdentification).Trim())). - AppendLine(); + VendorString.Prettify(StringHandlers.CToString(page.VendorIdentification).Trim())).AppendLine(); - sb.AppendFormat("\tTranslation layer name: {0}", - StringHandlers.CToString(page.ProductIdentification).Trim()).AppendLine(); + sb.AppendFormat("\tTranslation layer name: {0}", StringHandlers.CToString(page.ProductIdentification).Trim()). + AppendLine(); sb.AppendFormat("\tTranslation layer release level: {0}", StringHandlers.CToString(page.ProductRevisionLevel).Trim()).AppendLine(); @@ -1686,13 +1685,12 @@ public static class EVPD break; case 0xC5: - sb.AppendFormat("\tBoard Serial Number: {0}", StringHandlers.CToString(page.SerialNumber)). - AppendLine(); + sb.AppendFormat("\tBoard Serial Number: {0}", StringHandlers.CToString(page.SerialNumber)).AppendLine(); break; case 0xC6: - sb.AppendFormat("\tBase Mechanical Serial Number: {0}", - StringHandlers.CToString(page.SerialNumber)).AppendLine(); + sb.AppendFormat("\tBase Mechanical Serial Number: {0}", StringHandlers.CToString(page.SerialNumber)). + AppendLine(); break; } @@ -1781,7 +1779,7 @@ public static class EVPD CartridgeSerialNumber = new byte[32] }; - byte[] buf = new byte[8]; + var buf = new byte[8]; Array.Copy(pageResponse, 24, buf, 0, 8); decoded.InitiatorID = BitConverter.ToUInt64(buf.Reverse().ToArray(), 0); Array.Copy(pageResponse, 32, decoded.CartridgeSerialNumber, 0, 32); @@ -2068,8 +2066,7 @@ public static class EVPD sb.AppendFormat("\tManufacturing serial number: {0}", StringHandlers.CToString(page.ManufacturingSerial)). AppendLine(); - sb.AppendFormat("\tReported serial number: {0}", StringHandlers.CToString(page.ReportedSerial)). - AppendLine(); + sb.AppendFormat("\tReported serial number: {0}", StringHandlers.CToString(page.ReportedSerial)).AppendLine(); return sb.ToString(); } @@ -2198,10 +2195,9 @@ public static class EVPD if(pageResponse[4] != pageResponse[3] - 1) return null; - List array = new List(); + var array = new List(); - const string fwRegExStr = - @"Firmware Rev\s+=\s+(?\d+\.\d+)\s+Build date\s+=\s+(?(\w|\d|\s*.)*)\s*$"; + const string fwRegExStr = @"Firmware Rev\s+=\s+(?\d+\.\d+)\s+Build date\s+=\s+(?(\w|\d|\s*.)*)\s*$"; const string fwcRegExStr = @"FW_CONF\s+=\s+(?0x[0-9A-Fa-f]{8})\s*$"; const string servoRegExStr = @"Servo\s+Rev\s+=\s+(?\d+\.\d+)\s*$"; @@ -2209,7 +2205,7 @@ public static class EVPD var fwcRegEx = new Regex(fwcRegExStr); var servoRegEx = new Regex(servoRegExStr); - for(int pos = 5; pos < pageResponse.Length; pos++) + for(var pos = 5; pos < pageResponse.Length; pos++) if(pageResponse[pos] == 0x00) { string str = StringHandlers.CToString(array.ToArray()); diff --git a/SCSI/Inquiry.cs b/SCSI/Inquiry.cs index d641a24..7b93db8 100644 --- a/SCSI/Inquiry.cs +++ b/SCSI/Inquiry.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -37,8 +39,6 @@ using System.Text; using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Helpers; -namespace Aaru.Decoders.SCSI; - // Information from the following standards: // T9/375-D revision 10l // T10/995-D revision 10 @@ -68,8 +68,8 @@ public static class Inquiry sb.AppendFormat("Device name: {0}", StringHandlers.CToString(response.ProductIdentification).Trim()). AppendLine(); - sb.AppendFormat("Device release level: {0}", - StringHandlers.CToString(response.ProductRevisionLevel).Trim()).AppendLine(); + sb.AppendFormat("Device release level: {0}", StringHandlers.CToString(response.ProductRevisionLevel).Trim()). + AppendLine(); switch((PeripheralQualifiers)response.PeripheralQualifier) { @@ -90,8 +90,8 @@ public static class Inquiry break; default: - sb.AppendFormat("Vendor value {0} set in Peripheral Qualifier field.", - response.PeripheralQualifier).AppendLine(); + sb.AppendFormat("Vendor value {0} set in Peripheral Qualifier field.", response.PeripheralQualifier). + AppendLine(); break; } @@ -191,8 +191,7 @@ public static class Inquiry break; default: - sb.AppendFormat("Unknown device type field value 0x{0:X2}", response.PeripheralDeviceType). - AppendLine(); + sb.AppendFormat("Unknown device type field value 0x{0:X2}", response.PeripheralDeviceType).AppendLine(); break; } @@ -2323,18 +2322,15 @@ public static class Inquiry sb.AppendFormat("Firmware personality: {0}", response.Qt_FirmwarePersonality).AppendLine(); sb.AppendFormat("Firmware subpersonality: {0}", response.Qt_FirmwareSubPersonality).AppendLine(); - sb.AppendFormat("Tape directory format version: {0}", response.Qt_TapeDirectoryFormatVersion). - AppendLine(); + sb.AppendFormat("Tape directory format version: {0}", response.Qt_TapeDirectoryFormatVersion).AppendLine(); sb.AppendFormat("Controller hardware version: {0}", response.Qt_ControllerHardwareVersion).AppendLine(); sb.AppendFormat("Drive EEPROM version: {0}", response.Qt_DriveEEPROMVersion).AppendLine(); sb.AppendFormat("Drive hardware version: {0}", response.Qt_DriveHardwareVersion).AppendLine(); - sb.AppendFormat("Media loader firmware version: {0}", response.Qt_MediaLoaderFirmwareVersion). - AppendLine(); + sb.AppendFormat("Media loader firmware version: {0}", response.Qt_MediaLoaderFirmwareVersion).AppendLine(); - sb.AppendFormat("Media loader hardware version: {0}", response.Qt_MediaLoaderHardwareVersion). - AppendLine(); + sb.AppendFormat("Media loader hardware version: {0}", response.Qt_MediaLoaderHardwareVersion).AppendLine(); sb.AppendFormat("Media loader mechanical version: {0}", response.Qt_MediaLoaderMechanicalVersion). AppendLine(); @@ -2345,8 +2341,7 @@ public static class Inquiry if(response.Qt_MediaLoaderPresent) sb.AppendLine("Media loader is present"); - sb.AppendFormat("Module revision: {0}", StringHandlers.CToString(response.Qt_ModuleRevision)). - AppendLine(); + sb.AppendFormat("Module revision: {0}", StringHandlers.CToString(response.Qt_ModuleRevision)).AppendLine(); } #endregion Quantum vendor prettifying @@ -2403,8 +2398,7 @@ public static class Inquiry if(response.Seagate3Present) sb.AppendFormat("Drive servo part number: {0}", - PrintHex.ByteArrayToHexArrayString(response.Seagate_ServoPROMPartNo, 40)). - AppendLine(); + PrintHex.ByteArrayToHexArrayString(response.Seagate_ServoPROMPartNo, 40)).AppendLine(); } #endregion Seagate vendor prettifying @@ -2439,7 +2433,7 @@ public static class Inquiry response.IsHiMD) if(response.KreonPresent) { - byte[] vendor = new byte[7]; + var vendor = new byte[7]; Array.Copy(response.VendorSpecific, 11, vendor, 0, 7); sb.AppendLine("Vendor-specific bytes 47 to 55"); sb.AppendLine("============================================================"); diff --git a/SCSI/MMC/AACS.cs b/SCSI/MMC/AACS.cs index d5683d5..0bd13da 100644 --- a/SCSI/MMC/AACS.cs +++ b/SCSI/MMC/AACS.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI.MMC; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Helpers; -namespace Aaru.Decoders.SCSI.MMC; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -222,8 +222,7 @@ public static class AACS if(response.Reserved != 0) sb.AppendFormat("Reserved = 0x{0:X2}", response.Reserved).AppendLine(); #endif - sb.AppendFormat("Total number of media key blocks available to transfer {0}", response.TotalPacks). - AppendLine(); + sb.AppendFormat("Total number of media key blocks available to transfer {0}", response.TotalPacks).AppendLine(); sb.AppendFormat("AACS Media Key Blocks in hex follows:"); sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.MediaKeyBlockPacks, 80)); @@ -301,12 +300,12 @@ public static class AACS decoded.Extents = new AACSLBAExtent[(AACSLBAExtsResponse.Length - 4) / 16]; - for(int i = 0; i < (AACSLBAExtsResponse.Length - 4) / 16; i++) + for(var i = 0; i < (AACSLBAExtsResponse.Length - 4) / 16; i++) { decoded.Extents[i].Reserved = new byte[8]; - Array.Copy(AACSLBAExtsResponse, 0 + (i * 16) + 4, decoded.Extents[i].Reserved, 0, 8); - decoded.Extents[i].StartLBA = BigEndianBitConverter.ToUInt32(AACSLBAExtsResponse, 8 + (i * 16) + 4); - decoded.Extents[i].LBACount = BigEndianBitConverter.ToUInt32(AACSLBAExtsResponse, 12 + (i * 16) + 4); + Array.Copy(AACSLBAExtsResponse, 0 + i * 16 + 4, decoded.Extents[i].Reserved, 0, 8); + decoded.Extents[i].StartLBA = BigEndianBitConverter.ToUInt32(AACSLBAExtsResponse, 8 + i * 16 + 4); + decoded.Extents[i].LBACount = BigEndianBitConverter.ToUInt32(AACSLBAExtsResponse, 12 + i * 16 + 4); } return decoded; @@ -327,7 +326,7 @@ public static class AACS else sb.AppendFormat("Drive can store {0} LBA Extents", response.MaxLBAExtents).AppendLine(); - for(int i = 0; i < response.Extents.Length; i++) + for(var i = 0; i < response.Extents.Length; i++) sb.AppendFormat("LBA Extent {0} starts at LBA {1} and goes for {2} sectors", i, response.Extents[i].StartLBA, response.Extents[i].LBACount); diff --git a/SCSI/MMC/CPRM.cs b/SCSI/MMC/CPRM.cs index 88fd500..be421c4 100644 --- a/SCSI/MMC/CPRM.cs +++ b/SCSI/MMC/CPRM.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI.MMC; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Helpers; -namespace Aaru.Decoders.SCSI.MMC; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 diff --git a/SCSI/MMC/DiscInformation.cs b/SCSI/MMC/DiscInformation.cs index eae7eee..6f75cbc 100644 --- a/SCSI/MMC/DiscInformation.cs +++ b/SCSI/MMC/DiscInformation.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI.MMC; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI.MMC; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -95,7 +95,7 @@ public static class DiscInformation decoded.LastPossibleLeadOutStartLBA = (uint)((response[20] << 24) + (response[21] << 16) + (response[22] << 8) + response[23]); - byte[] temp = new byte[8]; + var temp = new byte[8]; Array.Copy(response, 24, temp, 0, 8); Array.Reverse(temp); decoded.DiscBarcode = BitConverter.ToUInt64(temp, 0); @@ -107,17 +107,17 @@ public static class DiscInformation decoded.OPCTablesNumber = response[33]; if(decoded.OPCTablesNumber <= 0 || - response.Length != (decoded.OPCTablesNumber * 8) + 34) + response.Length != decoded.OPCTablesNumber * 8 + 34) return decoded; decoded.OPCTables = new OPCTable[decoded.OPCTablesNumber]; - for(int i = 0; i < decoded.OPCTablesNumber; i++) + for(var i = 0; i < decoded.OPCTablesNumber; i++) { - decoded.OPCTables[i].Speed = (ushort)((response[34 + (i * 8) + 0] << 16) + response[34 + (i * 8) + 1]); + decoded.OPCTables[i].Speed = (ushort)((response[34 + i * 8 + 0] << 16) + response[34 + i * 8 + 1]); decoded.OPCTables[i].OPCValues = new byte[6]; - Array.Copy(response, 34 + (i * 8) + 2, decoded.OPCTables[i].OPCValues, 0, 6); + Array.Copy(response, 34 + i * 8 + 2, decoded.OPCTables[i].OPCValues, 0, 6); } return decoded; @@ -218,8 +218,7 @@ public static class DiscInformation sb.AppendFormat("First track in last session is track {0}", information.Value.FirstTrackLastSession). AppendLine(); - sb.AppendFormat("Last track in last session is track {0}", information.Value.LastTrackLastSession). - AppendLine(); + sb.AppendFormat("Last track in last session is track {0}", information.Value.LastTrackLastSession).AppendLine(); sb.AppendFormat("Last session Lead-In address is {0} (as LBA) or {1:X2}:{2:X2}:{3:X2}", information.Value.LastSessionLeadInStartLBA, diff --git a/SCSI/MMC/Enums.cs b/SCSI/MMC/Enums.cs index 0ffa0a6..f399e3e 100644 --- a/SCSI/MMC/Enums.cs +++ b/SCSI/MMC/Enums.cs @@ -30,47 +30,59 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.SCSI.MMC; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal")] public enum FormatLayerTypeCodes : ushort { - CDLayer = 0x0008, DVDLayer = 0x0010, BDLayer = 0x0040, + CDLayer = 0x0008, + DVDLayer = 0x0010, + BDLayer = 0x0040, HDDVDLayer = 0x0050 } [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal")] public enum SessionStatusCodes : byte { - Empty = 0x00, Incomplete = 0x01, ReservedOrDamaged = 0x02, - Complete = 0x03 + Empty = 0x00, + Incomplete = 0x01, + ReservedOrDamaged = 0x02, + Complete = 0x03 } [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal")] public enum DiscStatusCodes : byte { - Empty = 0x00, Incomplete = 0x01, Finalized = 0x02, - Others = 0x03 + Empty = 0x00, + Incomplete = 0x01, + Finalized = 0x02, + Others = 0x03 } [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal")] public enum BGFormatStatusCodes : byte { - NoFormattable = 0x00, IncompleteBackgroundFormat = 0x01, BackgroundFormatInProgress = 0x02, - FormatComplete = 0x03 + NoFormattable = 0x00, + IncompleteBackgroundFormat = 0x01, + BackgroundFormatInProgress = 0x02, + FormatComplete = 0x03 } [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal")] public enum DiscTypeCodes : byte { /// Also valid for CD-DA, DVD and BD - CDROM = 0x00, CDi = 0x10, CDROMXA = 0x20, Undefined = 0xFF + CDROM = 0x00, CDi = 0x10, + CDROMXA = 0x20, + Undefined = 0xFF } public enum LayerJumpRecordingStatus : byte { - Incremental = 0, Unspecified = 1, Manual = 2, + Incremental = 0, + Unspecified = 1, + Manual = 2, RegularInterval = 3 } \ No newline at end of file diff --git a/SCSI/MMC/Features.cs b/SCSI/MMC/Features.cs index 5be965e..517d62a 100644 --- a/SCSI/MMC/Features.cs +++ b/SCSI/MMC/Features.cs @@ -30,6 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ + + +// ReSharper disable MemberCanBePrivate.Global + +namespace Aaru.Decoders.SCSI.MMC; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -37,10 +43,6 @@ using System.Text; using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Helpers; -// ReSharper disable MemberCanBePrivate.Global - -namespace Aaru.Decoders.SCSI.MMC; - /// MMC Feature enumeration [SuppressMessage("ReSharper", "InconsistentNaming")] public enum FeatureNumber : ushort @@ -1307,7 +1309,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0000) return null; @@ -1321,8 +1323,8 @@ public static class Features decoded.Persistent |= (feature[2] & 0x02) == 0x02; decoded.Version = (byte)((feature[2] & 0x3C) >> 2); - int offset = 4; - List listProfiles = new List(); + var offset = 4; + var listProfiles = new List(); while(offset < feature.Length) { @@ -1349,7 +1351,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0001) return null; @@ -1385,7 +1387,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0002) return null; @@ -1415,7 +1417,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0003) return null; @@ -1451,7 +1453,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0004) return null; @@ -1485,7 +1487,7 @@ public static class Features if(feature.Length < 12) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0010) return null; @@ -1516,7 +1518,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x001D) return null; @@ -1541,7 +1543,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x001E) return null; @@ -1575,7 +1577,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x001F) return null; @@ -1612,7 +1614,7 @@ public static class Features if(feature.Length < 16) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0020) return null; @@ -1631,8 +1633,7 @@ public static class Features decoded.LastLBA = (uint)((feature[4] << 24) + (feature[5] << 16) + (feature[6] << 8) + feature[7]); - decoded.LogicalBlockSize = - (uint)((feature[8] << 24) + (feature[9] << 16) + (feature[10] << 8) + feature[11]); + decoded.LogicalBlockSize = (uint)((feature[8] << 24) + (feature[9] << 16) + (feature[10] << 8) + feature[11]); decoded.Blocking = (ushort)((feature[12] << 8) + feature[13]); decoded.PP |= (feature[14] & 0x01) == 0x01; @@ -1648,7 +1649,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0021) return null; @@ -1689,7 +1690,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0022) return null; @@ -1714,7 +1715,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0023) return null; @@ -1753,7 +1754,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0024) return null; @@ -1782,7 +1783,7 @@ public static class Features if(feature.Length < 12) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0025) return null; @@ -1813,7 +1814,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0026) return null; @@ -1838,7 +1839,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0027) return null; @@ -1863,7 +1864,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0028) return null; @@ -1896,7 +1897,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0029) return null; @@ -1925,7 +1926,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x002A) return null; @@ -1956,7 +1957,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x002B) return null; @@ -1983,7 +1984,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x002C) return null; @@ -2013,7 +2014,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x002D) return null; @@ -2050,7 +2051,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x002E) return null; @@ -2086,7 +2087,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x002F) return null; @@ -2120,7 +2121,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0030) return null; @@ -2145,7 +2146,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0031) return null; @@ -2172,7 +2173,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0032) return null; @@ -2200,7 +2201,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0033) return null; @@ -2232,7 +2233,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0035) return null; @@ -2257,7 +2258,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0037) return null; @@ -2284,7 +2285,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0038) return null; @@ -2309,7 +2310,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x003A) return null; @@ -2338,7 +2339,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x003B) return null; @@ -2365,7 +2366,7 @@ public static class Features if(feature.Length < 32) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0040) return null; @@ -2403,7 +2404,7 @@ public static class Features if(feature.Length < 24) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0041) return null; @@ -2439,7 +2440,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0042) return null; @@ -2464,7 +2465,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0050) return null; @@ -2492,7 +2493,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0051) return null; @@ -2520,7 +2521,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0080) return null; @@ -2547,7 +2548,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0100) return null; @@ -2572,7 +2573,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0101) return null; @@ -2599,7 +2600,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0102) return null; @@ -2628,7 +2629,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0103) return null; @@ -2658,7 +2659,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0104) return null; @@ -2687,7 +2688,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0105) return null; @@ -2719,7 +2720,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0106) return null; @@ -2746,7 +2747,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0107) return null; @@ -2788,7 +2789,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0108) return null; @@ -2802,7 +2803,7 @@ public static class Features decoded.Persistent |= (feature[2] & 0x02) == 0x02; decoded.Version = (byte)((feature[2] & 0x3C) >> 2); - byte[] serial = new byte[feature.Length]; + var serial = new byte[feature.Length]; Array.Copy(feature, 4, serial, 0, feature.Length - 4); decoded.Serial = StringHandlers.CToString(serial).Trim(); @@ -2817,7 +2818,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0109) return null; @@ -2842,7 +2843,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x010A) return null; @@ -2858,9 +2859,9 @@ public static class Features decoded.DCBs = new uint[feature[3] / 4]; - for(int i = 0; i < decoded.DCBs.Length; i++) - decoded.DCBs[i] = (uint)((feature[0 + 4 + (i * 4)] << 24) + (feature[1 + 4 + (i * 4)] << 16) + - (feature[2 + 4 + (i * 4)] << 8) + feature[3 + 4 + (i * 4)]); + for(var i = 0; i < decoded.DCBs.Length; i++) + decoded.DCBs[i] = (uint)((feature[0 + 4 + i * 4] << 24) + (feature[1 + 4 + i * 4] << 16) + + (feature[2 + 4 + i * 4] << 8) + feature[3 + 4 + i * 4]); return decoded; } @@ -2873,7 +2874,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x010B) return null; @@ -2900,7 +2901,7 @@ public static class Features if(feature.Length < 20) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x010C) return null; @@ -2933,7 +2934,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x010D) return null; @@ -2971,7 +2972,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x010E) return null; @@ -2998,7 +2999,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0110) return null; @@ -3023,7 +3024,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0113) return null; @@ -3048,7 +3049,7 @@ public static class Features if(feature.Length < 6) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0142) return null; @@ -3067,11 +3068,11 @@ public static class Features decoded.ME |= (feature[4] & 0x01) == 0x01; decoded.Profiles = new ushort[feature[5]]; - if((feature[5] * 2) + 6 != feature.Length) + if(feature[5] * 2 + 6 != feature.Length) return decoded; - for(int i = 0; i < feature[5]; i++) - decoded.Profiles[i] = (ushort)((feature[0 + 6 + (2 * i)] << 8) + feature[1 + 6 + (2 * i)]); + for(var i = 0; i < feature[5]; i++) + decoded.Profiles[i] = (ushort)((feature[0 + 6 + 2 * i] << 8) + feature[1 + 6 + 2 * i]); return decoded; } @@ -3318,8 +3319,7 @@ public static class Features break; default: - sb.AppendFormat("an unknown interface with code {0}", (uint)ftr.PhysicalInterfaceStandard). - AppendLine(); + sb.AppendFormat("an unknown interface with code {0}", (uint)ftr.PhysicalInterfaceStandard).AppendLine(); break; } @@ -4029,8 +4029,7 @@ public static class Features return sb.ToString(); } - public static string Prettify_0030(Feature_0030? feature) => - !feature.HasValue ? null : "Drive can read DDCDs\n"; + public static string Prettify_0030(Feature_0030? feature) => !feature.HasValue ? null : "Drive can read DDCDs\n"; public static string Prettify_0031(Feature_0031? feature) { @@ -4273,8 +4272,7 @@ public static class Features } public static string Prettify_0042(Feature_0042? feature) => - !feature.HasValue ? null - : "Drive is able to detect and report defective writable unit and behave accordinly\n"; + !feature.HasValue ? null : "Drive is able to detect and report defective writable unit and behave accordinly\n"; public static string Prettify_0050(Feature_0050? feature) { @@ -4558,7 +4556,7 @@ public static class Features Feature_010C ftr = feature.Value; var sb = new StringBuilder(); - byte[] temp = new byte[4]; + var temp = new byte[4]; temp[0] = (byte)((ftr.Century & 0xFF00) >> 8); temp[1] = (byte)(ftr.Century & 0xFF); temp[2] = (byte)((ftr.Year & 0xFF00) >> 8); @@ -4660,8 +4658,7 @@ public static class Features sb.AppendLine(); if(ftr.MaxScrambleExtent > 0) - sb.AppendFormat("\tMaximum {0} scranble extent information entries", ftr.MaxScrambleExtent). - AppendLine(); + sb.AppendFormat("\tMaximum {0} scranble extent information entries", ftr.MaxScrambleExtent).AppendLine(); return sb.ToString(); } @@ -4718,7 +4715,7 @@ public static class Features if(ftr.Profiles == null) return sb.ToString(); - for(int i = 0; i < ftr.Profiles.Length; i++) + for(var i = 0; i < ftr.Profiles.Length; i++) sb.AppendFormat("\tProfile {0}: {1}", i, ftr.Profiles[i]).AppendLine(); return sb.ToString(); @@ -4848,8 +4845,8 @@ public static class Features CurrentProfile = (ushort)((response[6] << 8) + response[7]) }; - uint offset = 8; - List descLst = new List(); + uint offset = 8; + var descLst = new List(); while(offset + 4 < response.Length) { diff --git a/SCSI/MMC/Hybrid.cs b/SCSI/MMC/Hybrid.cs index 6db9d60..afe1123 100644 --- a/SCSI/MMC/Hybrid.cs +++ b/SCSI/MMC/Hybrid.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI.MMC; + using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Helpers; -namespace Aaru.Decoders.SCSI.MMC; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 @@ -74,8 +74,8 @@ public static class Hybrid FormatLayers = new ushort[(FormatLayersResponse.Length - 6) / 2] }; - for(int i = 0; i < (FormatLayersResponse.Length - 6) / 2; i++) - decoded.FormatLayers[i] = BigEndianBitConverter.ToUInt16(FormatLayersResponse, (i * 2) + 6); + for(var i = 0; i < (FormatLayersResponse.Length - 6) / 2; i++) + decoded.FormatLayers[i] = BigEndianBitConverter.ToUInt16(FormatLayersResponse, i * 2 + 6); return decoded; } @@ -91,7 +91,7 @@ public static class Hybrid sb.AppendFormat("{0} format layers recognized", response.NumberOfLayers); - for(int i = 0; i < response.FormatLayers.Length; i++) + for(var i = 0; i < response.FormatLayers.Length; i++) switch(response.FormatLayers[i]) { case (ushort)FormatLayerTypeCodes.BDLayer: @@ -148,8 +148,7 @@ public static class Hybrid default: { - sb.AppendFormat("Layer {0} is of unknown type 0x{1:X4}", i, response.FormatLayers[i]). - AppendLine(); + sb.AppendFormat("Layer {0} is of unknown type 0x{1:X4}", i, response.FormatLayers[i]).AppendLine(); if(response.DefaultFormatLayer == i) sb.AppendLine("This is the default layer."); diff --git a/SCSI/MMC/TrackInformation.cs b/SCSI/MMC/TrackInformation.cs index 8a98bf7..c8478c5 100644 --- a/SCSI/MMC/TrackInformation.cs +++ b/SCSI/MMC/TrackInformation.cs @@ -79,11 +79,9 @@ public class TrackInformation (uint)((response[8] << 24) + (response[9] << 16) + (response[10] << 8) + response[11]), NextWritableAddress = (uint)((response[12] << 24) + (response[13] << 16) + (response[14] << 8) + response[15]), - FreeBlocks = (uint)((response[16] << 24) + (response[17] << 16) + (response[18] << 8) + response[19]), - FixedPacketSize = - (uint)((response[20] << 24) + (response[21] << 16) + (response[22] << 8) + response[23]), - LogicalTrackSize = - (uint)((response[24] << 24) + (response[25] << 16) + (response[26] << 8) + response[27]), + FreeBlocks = (uint)((response[16] << 24) + (response[17] << 16) + (response[18] << 8) + response[19]), + FixedPacketSize = (uint)((response[20] << 24) + (response[21] << 16) + (response[22] << 8) + response[23]), + LogicalTrackSize = (uint)((response[24] << 24) + (response[25] << 16) + (response[26] << 8) + response[27]), LastRecordedAddress = (uint)((response[28] << 24) + (response[29] << 16) + (response[30] << 8) + response[31]) }; diff --git a/SCSI/MMC/WriteProtect.cs b/SCSI/MMC/WriteProtect.cs index 5e17318..e95cbdf 100644 --- a/SCSI/MMC/WriteProtect.cs +++ b/SCSI/MMC/WriteProtect.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI.MMC; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Helpers; -namespace Aaru.Decoders.SCSI.MMC; - // Information from the following standards: // ANSI X3.304-1997 // T10/1048-D revision 9.0 diff --git a/SCSI/Modes/00_SFF.cs b/SCSI/Modes/00_SFF.cs index 06d0032..6817ccc 100644 --- a/SCSI/Modes/00_SFF.cs +++ b/SCSI/Modes/00_SFF.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes diff --git a/SCSI/Modes/01.cs b/SCSI/Modes/01.cs index 2ca280b..16a4382 100644 --- a/SCSI/Modes/01.cs +++ b/SCSI/Modes/01.cs @@ -30,18 +30,18 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes { public static byte[] EncodeModePage_01(ModePage_01 page) { - byte[] pg = new byte[8]; + var pg = new byte[8]; pg[0] = 0x01; pg[1] = 6; diff --git a/SCSI/Modes/01_MMC.cs b/SCSI/Modes/01_MMC.cs index a988cf3..81a1adb 100644 --- a/SCSI/Modes/01_MMC.cs +++ b/SCSI/Modes/01_MMC.cs @@ -30,18 +30,18 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes { public static byte[] EncodeModePage_01_MMC(ModePage_01_MMC page) { - byte[] pg = new byte[12]; + var pg = new byte[12]; pg[0] = 0x01; pg[1] = 10; @@ -128,21 +128,20 @@ public static partial class Modes if(page.ReadRetryCount > 0) sb.AppendFormat("\tDrive will repeat read operations {0} times", page.ReadRetryCount).AppendLine(); - string AllUsed = "\tAll available recovery procedures will be used.\n"; - string CIRCRetriesUsed = "\tOnly retries and CIRC are used.\n"; - string RetriesUsed = "\tOnly retries are used.\n"; - string RecoveredNotReported = "\tRecovered errors will not be reported.\n"; - string RecoveredReported = "\tRecovered errors will be reported.\n"; - string RecoveredAbort = "\tRecovered errors will be reported and aborted with CHECK CONDITION.\n"; - string UnrecECCAbort = "\tUnrecovered ECC errors will return CHECK CONDITION."; - string UnrecCIRCAbort = "\tUnrecovered CIRC errors will return CHECK CONDITION."; - string UnrecECCNotAbort = "\tUnrecovered ECC errors will not abort the transfer."; - string UnrecCIRCNotAbort = "\tUnrecovered CIRC errors will not abort the transfer."; + var AllUsed = "\tAll available recovery procedures will be used.\n"; + var CIRCRetriesUsed = "\tOnly retries and CIRC are used.\n"; + var RetriesUsed = "\tOnly retries are used.\n"; + var RecoveredNotReported = "\tRecovered errors will not be reported.\n"; + var RecoveredReported = "\tRecovered errors will be reported.\n"; + var RecoveredAbort = "\tRecovered errors will be reported and aborted with CHECK CONDITION.\n"; + var UnrecECCAbort = "\tUnrecovered ECC errors will return CHECK CONDITION."; + var UnrecCIRCAbort = "\tUnrecovered CIRC errors will return CHECK CONDITION."; + var UnrecECCNotAbort = "\tUnrecovered ECC errors will not abort the transfer."; + var UnrecCIRCNotAbort = "\tUnrecovered CIRC errors will not abort the transfer."; - string UnrecECCAbortData = "\tUnrecovered ECC errors will return CHECK CONDITION and the uncorrected data."; + var UnrecECCAbortData = "\tUnrecovered ECC errors will return CHECK CONDITION and the uncorrected data."; - string UnrecCIRCAbortData = - "\tUnrecovered CIRC errors will return CHECK CONDITION and the uncorrected data."; + var UnrecCIRCAbortData = "\tUnrecovered CIRC errors will return CHECK CONDITION and the uncorrected data."; switch(page.Parameter) { diff --git a/SCSI/Modes/02.cs b/SCSI/Modes/02.cs index b9d9f6d..783f644 100644 --- a/SCSI/Modes/02.cs +++ b/SCSI/Modes/02.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -153,9 +153,8 @@ public static partial class Modes AppendLine(); if(page.FirstBurstSize > 0) - sb. - AppendFormat("\t{0} bytes maximum can be transferred for a command along with the disconnect command", - page.FirstBurstSize * 512).AppendLine(); + sb.AppendFormat("\t{0} bytes maximum can be transferred for a command along with the disconnect command", + page.FirstBurstSize * 512).AppendLine(); if(page.DIMM) sb.AppendLine("\tTarget shall not transfer data for a command during the same interconnect tenancy"); diff --git a/SCSI/Modes/03.cs b/SCSI/Modes/03.cs index 0c5472d..6b99620 100644 --- a/SCSI/Modes/03.cs +++ b/SCSI/Modes/03.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -130,8 +130,8 @@ public static partial class Modes AppendFormat("\t{0} tracks per zone to use in dividing the capacity for the purpose of allocating alternate sectors", page.TracksPerZone).AppendLine(); - sb.AppendFormat("\t{0} sectors per zone that shall be reserved for defect handling", - page.AltSectorsPerZone).AppendLine(); + sb.AppendFormat("\t{0} sectors per zone that shall be reserved for defect handling", page.AltSectorsPerZone). + AppendLine(); sb.AppendFormat("\t{0} tracks per zone that shall be reserved for defect handling", page.AltTracksPerZone). AppendLine(); @@ -143,8 +143,8 @@ public static partial class Modes sb.AppendFormat("\t{0} Bytes per physical sector", page.BytesPerSector).AppendLine(); sb.AppendFormat("\tTarget-dependent interleave value is {0}", page.Interleave).AppendLine(); - sb.AppendFormat("\t{0} sectors between last block of one track and first block of the next", - page.TrackSkew).AppendLine(); + sb.AppendFormat("\t{0} sectors between last block of one track and first block of the next", page.TrackSkew). + AppendLine(); sb.AppendFormat("\t{0} sectors between last block of a cylinder and first block of the next one", page.CylinderSkew).AppendLine(); diff --git a/SCSI/Modes/04.cs b/SCSI/Modes/04.cs index d08c110..1617411 100644 --- a/SCSI/Modes/04.cs +++ b/SCSI/Modes/04.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -120,12 +120,10 @@ public static partial class Modes sb.AppendFormat("\t{0} cylinders", page.Cylinders).AppendLine(); if(page.WritePrecompCylinder < page.Cylinders) - sb.AppendFormat("\tWrite pre-compensation starts at cylinder {0}", page.WritePrecompCylinder). - AppendLine(); + sb.AppendFormat("\tWrite pre-compensation starts at cylinder {0}", page.WritePrecompCylinder).AppendLine(); if(page.WriteReduceCylinder < page.Cylinders) - sb.AppendFormat("\tWrite current reduction starts at cylinder {0}", page.WriteReduceCylinder). - AppendLine(); + sb.AppendFormat("\tWrite current reduction starts at cylinder {0}", page.WriteReduceCylinder).AppendLine(); if(page.DriveStepRate > 0) sb.AppendFormat("\tDrive steps in {0} ns", (uint)page.DriveStepRate * 100).AppendLine(); diff --git a/SCSI/Modes/05.cs b/SCSI/Modes/05.cs index f419c3e..144a426 100644 --- a/SCSI/Modes/05.cs +++ b/SCSI/Modes/05.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -169,12 +169,10 @@ public static partial class Modes sb.AppendFormat("\t{0} bytes per sector", page.BytesPerSector).AppendLine(); if(page.WritePrecompCylinder < page.Cylinders) - sb.AppendFormat("\tWrite pre-compensation starts at cylinder {0}", page.WritePrecompCylinder). - AppendLine(); + sb.AppendFormat("\tWrite pre-compensation starts at cylinder {0}", page.WritePrecompCylinder).AppendLine(); if(page.WriteReduceCylinder < page.Cylinders) - sb.AppendFormat("\tWrite current reduction starts at cylinder {0}", page.WriteReduceCylinder). - AppendLine(); + sb.AppendFormat("\tWrite current reduction starts at cylinder {0}", page.WriteReduceCylinder).AppendLine(); if(page.DriveStepRate > 0) sb.AppendFormat("\tDrive steps in {0} μs", (uint)page.DriveStepRate * 100).AppendLine(); @@ -195,9 +193,8 @@ public static partial class Modes (double)page.MotorOnDelay * 10).AppendLine(); if(page.MotorOffDelay != 0xFF) - sb. - AppendFormat("\tTarget shall wait {0} seconds before releasing the motor on signal after becoming idle", - (double)page.MotorOffDelay * 10).AppendLine(); + sb.AppendFormat("\tTarget shall wait {0} seconds before releasing the motor on signal after becoming idle", + (double)page.MotorOffDelay * 10).AppendLine(); else sb.AppendLine("\tTarget shall never release the motor on signal"); diff --git a/SCSI/Modes/06.cs b/SCSI/Modes/06.cs index bf233ae..c0aa065 100644 --- a/SCSI/Modes/06.cs +++ b/SCSI/Modes/06.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes diff --git a/SCSI/Modes/07.cs b/SCSI/Modes/07.cs index b82f9e9..31dff82 100644 --- a/SCSI/Modes/07.cs +++ b/SCSI/Modes/07.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")] public static partial class Modes diff --git a/SCSI/Modes/07_MMC.cs b/SCSI/Modes/07_MMC.cs index 6b00178..198ba83 100644 --- a/SCSI/Modes/07_MMC.cs +++ b/SCSI/Modes/07_MMC.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -93,21 +93,20 @@ public static partial class Modes if(page.VerifyRetryCount > 0) sb.AppendFormat("\tDrive will repeat verify operations {0} times", page.VerifyRetryCount).AppendLine(); - string AllUsed = "\tAll available recovery procedures will be used.\n"; - string CIRCRetriesUsed = "\tOnly retries and CIRC are used.\n"; - string RetriesUsed = "\tOnly retries are used.\n"; - string RecoveredNotReported = "\tRecovered errors will not be reported.\n"; - string RecoveredReported = "\tRecovered errors will be reported.\n"; - string RecoveredAbort = "\tRecovered errors will be reported and aborted with CHECK CONDITION.\n"; - string UnrecECCAbort = "\tUnrecovered ECC errors will return CHECK CONDITION."; - string UnrecCIRCAbort = "\tUnrecovered CIRC errors will return CHECK CONDITION."; - string UnrecECCNotAbort = "\tUnrecovered ECC errors will not abort the transfer."; - string UnrecCIRCNotAbort = "\tUnrecovered CIRC errors will not abort the transfer."; + var AllUsed = "\tAll available recovery procedures will be used.\n"; + var CIRCRetriesUsed = "\tOnly retries and CIRC are used.\n"; + var RetriesUsed = "\tOnly retries are used.\n"; + var RecoveredNotReported = "\tRecovered errors will not be reported.\n"; + var RecoveredReported = "\tRecovered errors will be reported.\n"; + var RecoveredAbort = "\tRecovered errors will be reported and aborted with CHECK CONDITION.\n"; + var UnrecECCAbort = "\tUnrecovered ECC errors will return CHECK CONDITION."; + var UnrecCIRCAbort = "\tUnrecovered CIRC errors will return CHECK CONDITION."; + var UnrecECCNotAbort = "\tUnrecovered ECC errors will not abort the transfer."; + var UnrecCIRCNotAbort = "\tUnrecovered CIRC errors will not abort the transfer."; - string UnrecECCAbortData = "\tUnrecovered ECC errors will return CHECK CONDITION and the uncorrected data."; + var UnrecECCAbortData = "\tUnrecovered ECC errors will return CHECK CONDITION and the uncorrected data."; - string UnrecCIRCAbortData = - "\tUnrecovered CIRC errors will return CHECK CONDITION and the uncorrected data."; + var UnrecCIRCAbortData = "\tUnrecovered CIRC errors will return CHECK CONDITION and the uncorrected data."; switch(page.Parameter) { diff --git a/SCSI/Modes/08.cs b/SCSI/Modes/08.cs index 1015426..fb88665 100644 --- a/SCSI/Modes/08.cs +++ b/SCSI/Modes/08.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -198,8 +198,8 @@ public static partial class Modes break; default: - sb.AppendFormat("\tUnknown demand write retention priority value {0}", - page.DemandReadRetentionPrio).AppendLine(); + sb.AppendFormat("\tUnknown demand write retention priority value {0}", page.DemandReadRetentionPrio). + AppendLine(); break; } @@ -223,8 +223,7 @@ public static partial class Modes AppendLine(); if(page.MaximumPreFetch > 0) - sb.AppendFormat("\tA maximum of {0} blocks will be pre-fetched", page.MaximumPreFetch). - AppendLine(); + sb.AppendFormat("\tA maximum of {0} blocks will be pre-fetched", page.MaximumPreFetch).AppendLine(); if(page.MaximumPreFetchCeiling > 0) sb. @@ -265,9 +264,8 @@ public static partial class Modes } if(page.NonCacheSegmentSize > 0) - sb. - AppendFormat("\tDrive shall allocate {0} bytes to buffer even when all cached data cannot be evicted", - page.NonCacheSegmentSize).AppendLine(); + sb.AppendFormat("\tDrive shall allocate {0} bytes to buffer even when all cached data cannot be evicted", + page.NonCacheSegmentSize).AppendLine(); if(page.NV_DIS) sb.AppendLine("\tNon-Volatile cache is disabled"); diff --git a/SCSI/Modes/0A.cs b/SCSI/Modes/0A.cs index 34d4490..e79a8fe 100644 --- a/SCSI/Modes/0A.cs +++ b/SCSI/Modes/0A.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes diff --git a/SCSI/Modes/0B.cs b/SCSI/Modes/0B.cs index e96345b..d67cf2a 100644 --- a/SCSI/Modes/0B.cs +++ b/SCSI/Modes/0B.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -93,20 +93,17 @@ public static partial class Modes sb.AppendLine("\tParameters can be saved"); if(page.MediumType1 != MediumTypes.Default) - sb.AppendFormat("Supported medium type one: {0}", GetMediumTypeDescription(page.MediumType1)). - AppendLine(); + sb.AppendFormat("Supported medium type one: {0}", GetMediumTypeDescription(page.MediumType1)).AppendLine(); if(page.MediumType2 != MediumTypes.Default) - sb.AppendFormat("Supported medium type two: {0}", GetMediumTypeDescription(page.MediumType2)). - AppendLine(); + sb.AppendFormat("Supported medium type two: {0}", GetMediumTypeDescription(page.MediumType2)).AppendLine(); if(page.MediumType3 != MediumTypes.Default) sb.AppendFormat("Supported medium type three: {0}", GetMediumTypeDescription(page.MediumType3)). AppendLine(); if(page.MediumType4 != MediumTypes.Default) - sb.AppendFormat("Supported medium type four: {0}", GetMediumTypeDescription(page.MediumType4)). - AppendLine(); + sb.AppendFormat("Supported medium type four: {0}", GetMediumTypeDescription(page.MediumType4)).AppendLine(); return sb.ToString(); } diff --git a/SCSI/Modes/0D.cs b/SCSI/Modes/0D.cs index c6d408c..4a91860 100644 --- a/SCSI/Modes/0D.cs +++ b/SCSI/Modes/0D.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes diff --git a/SCSI/Modes/0E.cs b/SCSI/Modes/0E.cs index 74faa3c..ab5f7b1 100644 --- a/SCSI/Modes/0E.cs +++ b/SCSI/Modes/0E.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes diff --git a/SCSI/Modes/0F.cs b/SCSI/Modes/0F.cs index 26464da..b1eb6df 100644 --- a/SCSI/Modes/0F.cs +++ b/SCSI/Modes/0F.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -82,11 +82,11 @@ public static partial class Modes decoded.DDE |= (pageResponse[3] & 0x80) == 0x80; decoded.RED = (byte)((pageResponse[3] & 0x60) >> 5); - decoded.CompressionAlgo = (uint)((pageResponse[4] << 24) + (pageResponse[5] << 16) + - (pageResponse[6] << 8) + pageResponse[7]); + decoded.CompressionAlgo = (uint)((pageResponse[4] << 24) + (pageResponse[5] << 16) + (pageResponse[6] << 8) + + pageResponse[7]); - decoded.DecompressionAlgo = (uint)((pageResponse[8] << 24) + (pageResponse[9] << 16) + - (pageResponse[10] << 8) + pageResponse[11]); + decoded.DecompressionAlgo = (uint)((pageResponse[8] << 24) + (pageResponse[9] << 16) + (pageResponse[10] << 8) + + pageResponse[11]); return decoded; } diff --git a/SCSI/Modes/10.cs b/SCSI/Modes/10.cs index ebf41c8..b3356d2 100644 --- a/SCSI/Modes/10.cs +++ b/SCSI/Modes/10.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -80,11 +80,11 @@ public static partial class Modes decoded.MaxXorWrite = (uint)((pageResponse[4] << 24) + (pageResponse[5] << 16) + (pageResponse[6] << 8) + pageResponse[7]); - decoded.MaxRegenSize = (uint)((pageResponse[12] << 24) + (pageResponse[13] << 16) + - (pageResponse[14] << 8) + pageResponse[15]); + decoded.MaxRegenSize = (uint)((pageResponse[12] << 24) + (pageResponse[13] << 16) + (pageResponse[14] << 8) + + pageResponse[15]); - decoded.MaxRebuildRead = (uint)((pageResponse[16] << 24) + (pageResponse[17] << 16) + - (pageResponse[18] << 8) + pageResponse[19]); + decoded.MaxRebuildRead = (uint)((pageResponse[16] << 24) + (pageResponse[17] << 16) + (pageResponse[18] << 8) + + pageResponse[19]); decoded.RebuildDelay = (ushort)((pageResponse[22] << 8) + pageResponse[23]); @@ -116,8 +116,8 @@ public static partial class Modes page.MaxXorWrite).AppendLine(); if(page.MaxRegenSize > 0) - sb.AppendFormat("\tDrive accepts a maximum of {0} blocks in a REGENERATE command", - page.MaxRegenSize).AppendLine(); + sb.AppendFormat("\tDrive accepts a maximum of {0} blocks in a REGENERATE command", page.MaxRegenSize). + AppendLine(); if(page.MaxRebuildRead > 0) sb.AppendFormat("\tDrive accepts a maximum of {0} blocks in a READ command during rebuild", diff --git a/SCSI/Modes/10_SSC.cs b/SCSI/Modes/10_SSC.cs index 1338571..b20348f 100644 --- a/SCSI/Modes/10_SSC.cs +++ b/SCSI/Modes/10_SSC.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -139,8 +139,7 @@ public static partial class Modes decoded.SEW |= (pageResponse[10] & 0x08) == 0x08; decoded.SOCF = (byte)((pageResponse[8] & 0x0C) >> 2); - decoded.BufferSizeEarlyWarning = - (uint)((pageResponse[11] << 16) + (pageResponse[12] << 8) + pageResponse[13]); + decoded.BufferSizeEarlyWarning = (uint)((pageResponse[11] << 16) + (pageResponse[12] << 8) + pageResponse[13]); decoded.SelectedCompression = pageResponse[14]; diff --git a/SCSI/Modes/11.cs b/SCSI/Modes/11.cs index e2ef39c..deff75d 100644 --- a/SCSI/Modes/11.cs +++ b/SCSI/Modes/11.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -123,7 +123,7 @@ public static partial class Modes decoded.MediumFormatRecognition = (MediumFormatRecognitionValues)pageResponse[5]; decoded.PartitionSizes = new ushort[(pageResponse.Length - 8) / 2]; - for(int i = 8; i < pageResponse.Length; i += 2) + for(var i = 8; i < pageResponse.Length; i += 2) { decoded.PartitionSizes[(i - 8) / 2] = (ushort)(pageResponse[i] << 8); decoded.PartitionSizes[(i - 8) / 2] += pageResponse[i + 1]; @@ -194,8 +194,8 @@ public static partial class Modes break; case PartitionSizeUnitOfMeasures.Exponential: - sb.AppendFormat("\tPartitions are defined in units of {0} bytes", - Math.Pow(10, page.PartitionUnits)).AppendLine(); + sb.AppendFormat("\tPartitions are defined in units of {0} bytes", Math.Pow(10, page.PartitionUnits)). + AppendLine(); measure = $"units of {Math.Pow(10, page.PartitionUnits)} bytes"; @@ -234,7 +234,7 @@ public static partial class Modes sb.AppendFormat("\tMedium has defined {0} partitions", page.PartitionSizes.Length).AppendLine(); - for(int i = 0; i < page.PartitionSizes.Length; i++) + for(var i = 0; i < page.PartitionSizes.Length; i++) if(page.PartitionSizes[i] == 0) if(page.PartitionSizes.Length == 1) sb.AppendLine("\tDevice recognizes one single partition spanning whole medium"); diff --git a/SCSI/Modes/12_13_14.cs b/SCSI/Modes/12_13_14.cs index 9565bbc..2b91658 100644 --- a/SCSI/Modes/12_13_14.cs +++ b/SCSI/Modes/12_13_14.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -74,7 +74,7 @@ public static partial class Modes decoded.PartitionSizes = new ushort[(pageResponse.Length - 2) / 2]; - for(int i = 2; i < pageResponse.Length; i += 2) + for(var i = 2; i < pageResponse.Length; i += 2) { decoded.PartitionSizes[(i - 2) / 2] = (ushort)(pageResponse[i] << 8); decoded.PartitionSizes[(i - 2) / 2] += pageResponse[i + 1]; @@ -101,7 +101,7 @@ public static partial class Modes sb.AppendFormat("\tMedium has defined {0} partitions", page.PartitionSizes.Length).AppendLine(); - for(int i = 0; i < page.PartitionSizes.Length; i++) + for(var i = 0; i < page.PartitionSizes.Length; i++) sb.AppendFormat("\tPartition {0} is {1} units long", i, page.PartitionSizes[i]).AppendLine(); return sb.ToString(); diff --git a/SCSI/Modes/1A.cs b/SCSI/Modes/1A.cs index a514fa5..d4679ab 100644 --- a/SCSI/Modes/1A.cs +++ b/SCSI/Modes/1A.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -114,8 +114,8 @@ public static partial class Modes decoded.IdleTimer_C = (uint)((pageResponse[16] << 24) + (pageResponse[17] << 16) + (pageResponse[18] << 8) + pageResponse[19]); - decoded.StandbyTimer_Y = (uint)((pageResponse[20] << 24) + (pageResponse[21] << 16) + - (pageResponse[22] << 8) + pageResponse[23]); + decoded.StandbyTimer_Y = (uint)((pageResponse[20] << 24) + (pageResponse[21] << 16) + (pageResponse[22] << 8) + + pageResponse[23]); decoded.CCF_Idle = (byte)((pageResponse[39] & 0xC0) >> 6); decoded.CCF_Standby = (byte)((pageResponse[39] & 0x30) >> 4); @@ -140,8 +140,8 @@ public static partial class Modes if(page.PS) sb.AppendLine("\tParameters can be saved"); - if((page.Standby && page.StandbyTimer > 0) || - (page.Standby_Y && page.StandbyTimer_Y > 0)) + if(page.Standby && page.StandbyTimer > 0 || + page.Standby_Y && page.StandbyTimer_Y > 0) { if(page.Standby && page.StandbyTimer > 0) @@ -154,9 +154,9 @@ public static partial class Modes else sb.AppendLine("\tDrive will not enter standy mode"); - if((page.Idle && page.IdleTimer > 0) || - (page.Idle_B && page.IdleTimer_B > 0) || - (page.Idle_C && page.IdleTimer_C > 0)) + if(page.Idle && page.IdleTimer > 0 || + page.Idle_B && page.IdleTimer_B > 0 || + page.Idle_C && page.IdleTimer_C > 0) { if(page.Idle && page.IdleTimer > 0) diff --git a/SCSI/Modes/1B.cs b/SCSI/Modes/1B.cs index 29cd752..2222a49 100644 --- a/SCSI/Modes/1B.cs +++ b/SCSI/Modes/1B.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes diff --git a/SCSI/Modes/1C.cs b/SCSI/Modes/1C.cs index dac1a6a..5746d8d 100644 --- a/SCSI/Modes/1C.cs +++ b/SCSI/Modes/1C.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -103,8 +103,8 @@ public static partial class Modes decoded.EBACKERR |= (pageResponse[2] & 0x02) == 0x02; if(pageResponse.Length >= 12) - decoded.ReportCount = (uint)((pageResponse[8] << 24) + (pageResponse[9] << 16) + - (pageResponse[10] << 8) + pageResponse[11]); + decoded.ReportCount = (uint)((pageResponse[8] << 24) + (pageResponse[9] << 16) + (pageResponse[10] << 8) + + pageResponse[11]); return decoded; } diff --git a/SCSI/Modes/1C_SFF.cs b/SCSI/Modes/1C_SFF.cs index bb410a5..a49ce34 100644 --- a/SCSI/Modes/1C_SFF.cs +++ b/SCSI/Modes/1C_SFF.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes diff --git a/SCSI/Modes/1D.cs b/SCSI/Modes/1D.cs index de450be..665ed90 100644 --- a/SCSI/Modes/1D.cs +++ b/SCSI/Modes/1D.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -124,8 +124,8 @@ public static partial class Modes break; default: - sb.AppendFormat("\tUnknown WORM mode filemark restrictions code {0}", - page.WormModeLabelRestrictions).AppendLine(); + sb.AppendFormat("\tUnknown WORM mode filemark restrictions code {0}", page.WormModeLabelRestrictions). + AppendLine(); break; } diff --git a/SCSI/Modes/21_Certance.cs b/SCSI/Modes/21_Certance.cs index c88b88d..4d0a172 100644 --- a/SCSI/Modes/21_Certance.cs +++ b/SCSI/Modes/21_Certance.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes diff --git a/SCSI/Modes/22_Certance.cs b/SCSI/Modes/22_Certance.cs index 62e2972..021bc06 100644 --- a/SCSI/Modes/22_Certance.cs +++ b/SCSI/Modes/22_Certance.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")] public static partial class Modes @@ -173,8 +173,7 @@ public static partial class Modes if(page.PortATransportType > 0) sb.AppendFormat("\tDrive responds to SCSI ID {0}", page.PortAPresentSelectionID).AppendLine(); - sb.AppendFormat("\tDrive will respond to SCSI ID {0} on Port A enabling", page.NextSelectionID). - AppendLine(); + sb.AppendFormat("\tDrive will respond to SCSI ID {0} on Port A enabling", page.NextSelectionID).AppendLine(); sb.AppendFormat("\tDrive jumpers choose SCSI ID {0}", page.JumperedSelectionID).AppendLine(); diff --git a/SCSI/Modes/24_IBM.cs b/SCSI/Modes/24_IBM.cs index 6564c0e..de64673 100644 --- a/SCSI/Modes/24_IBM.cs +++ b/SCSI/Modes/24_IBM.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes diff --git a/SCSI/Modes/2A.cs b/SCSI/Modes/2A.cs index de28225..8cbf543 100644 --- a/SCSI/Modes/2A.cs +++ b/SCSI/Modes/2A.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text; using Aaru.CommonTypes.Structs.Devices.SCSI.Modes; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")] public static partial class Modes @@ -114,8 +114,7 @@ public static partial class Modes break; default: - sb.AppendFormat("\tDrive uses unknown loading mechanism type {0}", page.LoadingMechanism). - AppendLine(); + sb.AppendFormat("\tDrive uses unknown loading mechanism type {0}", page.LoadingMechanism).AppendLine(); break; } @@ -131,8 +130,7 @@ public static partial class Modes : "\tDrive is not locked, media can be ejected and inserted"); } else - sb.AppendLine(page.LockState - ? "\tDrive is locked, media cannot be ejected, but if empty, can be inserted" + sb.AppendLine(page.LockState ? "\tDrive is locked, media cannot be ejected, but if empty, can be inserted" : "\tDrive is not locked, media can be ejected and inserted"); if(page.Eject) @@ -200,8 +198,7 @@ public static partial class Modes else { if(page.MaxWriteSpeed > 0) - sb.AppendFormat("\tDrive's maximum writing speed is {0} Kbyte/sec.", page.MaxWriteSpeed). - AppendLine(); + sb.AppendFormat("\tDrive's maximum writing speed is {0} Kbyte/sec.", page.MaxWriteSpeed).AppendLine(); if(page.CurrentWriteSpeed > 0) sb.AppendFormat("\tDrive's current writing speed is {0} Kbyte/sec.", page.CurrentWriteSpeed). @@ -209,11 +206,11 @@ public static partial class Modes } if(page.WriteSpeedPerformanceDescriptors != null) - foreach(ModePage_2A_WriteDescriptor descriptor in - page.WriteSpeedPerformanceDescriptors.Where(descriptor => descriptor.WriteSpeed > 0)) + foreach(ModePage_2A_WriteDescriptor descriptor in page.WriteSpeedPerformanceDescriptors.Where(descriptor => + descriptor.WriteSpeed > 0)) if(descriptor.RotationControl == 0) - sb.AppendFormat("\tDrive supports writing at {0} Kbyte/sec. in CLV mode", - descriptor.WriteSpeed).AppendLine(); + sb.AppendFormat("\tDrive supports writing at {0} Kbyte/sec. in CLV mode", descriptor.WriteSpeed). + AppendLine(); else if(descriptor.RotationControl == 1) sb.AppendFormat("\tDrive supports writing at is {0} Kbyte/sec. in pure CAV mode", descriptor.WriteSpeed).AppendLine(); diff --git a/SCSI/Modes/2F_IBM.cs b/SCSI/Modes/2F_IBM.cs index 9fa77f1..f1bc8ae 100644 --- a/SCSI/Modes/2F_IBM.cs +++ b/SCSI/Modes/2F_IBM.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "UnassignedField.Global")] public static partial class Modes diff --git a/SCSI/Modes/30_Apple.cs b/SCSI/Modes/30_Apple.cs index 4528970..d73bedb 100644 --- a/SCSI/Modes/30_Apple.cs +++ b/SCSI/Modes/30_Apple.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System; using System.Diagnostics.CodeAnalysis; using System.Linq; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -61,7 +61,7 @@ public static partial class Modes if(pageResponse.Length != 30) return false; - byte[] str = new byte[20]; + var str = new byte[20]; Array.Copy(pageResponse, 10, str, 0, 20); return AppleOEMString.SequenceEqual(str); diff --git a/SCSI/Modes/3B_HP.cs b/SCSI/Modes/3B_HP.cs index a4820d6..140ca77 100644 --- a/SCSI/Modes/3B_HP.cs +++ b/SCSI/Modes/3B_HP.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Helpers; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes diff --git a/SCSI/Modes/3C_HP.cs b/SCSI/Modes/3C_HP.cs index fb61fa2..2be1079 100644 --- a/SCSI/Modes/3C_HP.cs +++ b/SCSI/Modes/3C_HP.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Helpers; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -121,11 +121,11 @@ public static partial class Modes { sb.AppendFormat("\tDrive has been powered up {0} times", page.CurrentPowerOn); - sb.AppendFormat("\tDrive has been powered up since {0} this time", - TimeSpan.FromSeconds(page.PowerOnTime)).AppendLine(); + sb.AppendFormat("\tDrive has been powered up since {0} this time", TimeSpan.FromSeconds(page.PowerOnTime)). + AppendLine(); - sb.AppendFormat("\tDrive has been powered up a total of {0}", - TimeSpan.FromSeconds(page.CumulativePowerOn)).AppendLine(); + sb.AppendFormat("\tDrive has been powered up a total of {0}", TimeSpan.FromSeconds(page.CumulativePowerOn)). + AppendLine(); } if(page.WT) diff --git a/SCSI/Modes/3D_HP.cs b/SCSI/Modes/3D_HP.cs index 898b318..9a8ef82 100644 --- a/SCSI/Modes/3D_HP.cs +++ b/SCSI/Modes/3D_HP.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes diff --git a/SCSI/Modes/3D_IBM.cs b/SCSI/Modes/3D_IBM.cs index eec079c..1699910 100644 --- a/SCSI/Modes/3D_IBM.cs +++ b/SCSI/Modes/3D_IBM.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes diff --git a/SCSI/Modes/3E_Fujitsu.cs b/SCSI/Modes/3E_Fujitsu.cs index 0104faa..b4c71b6 100644 --- a/SCSI/Modes/3E_Fujitsu.cs +++ b/SCSI/Modes/3E_Fujitsu.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.CommonTypes.Structs.Devices.SCSI; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")] public static partial class Modes diff --git a/SCSI/Modes/3E_HP.cs b/SCSI/Modes/3E_HP.cs index 6b17c92..d9965f6 100644 --- a/SCSI/Modes/3E_HP.cs +++ b/SCSI/Modes/3E_HP.cs @@ -30,11 +30,11 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -87,8 +87,7 @@ public static partial class Modes if(page.PS) sb.AppendLine("\tParameters can be saved"); - sb.AppendLine(page.CDmode ? "\tDrive is emulating a CD-ROM drive" - : "\tDrive is not emulating a CD-ROM drive"); + sb.AppendLine(page.CDmode ? "\tDrive is emulating a CD-ROM drive" : "\tDrive is not emulating a CD-ROM drive"); if(page.NonAuto) sb.AppendLine("\tDrive will not exit emulation automatically"); diff --git a/SCSI/Modes/Headers.cs b/SCSI/Modes/Headers.cs index f3f4b1a..215d8da 100644 --- a/SCSI/Modes/Headers.cs +++ b/SCSI/Modes/Headers.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.CommonTypes.Structs.Devices.SCSI; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -75,16 +75,15 @@ public static partial class Modes case MediumTypes.Unspecified_DS: return "Unspecified double sided flexible disk"; */ - case MediumTypes.X3_73: return "ANSI X3.73-1980: 200 mm, 6631 ftprad, 1,9 Tracks per mm, 1 side"; - case MediumTypes.X3_73_DS: return "ANSI X3.73-1980: 200 mm, 6631 ftprad, 1,9 Tracks per mm, 2 sides"; - case MediumTypes.X3_82: return "ANSI X3.80-1980: 130 mm, 3979 ftprad, 1,9 Tracks per mm, 1 side"; - case MediumTypes.Type3Floppy: - return "3.5-inch, 135 tpi, 12362 bits/radian, double-sided MFM (aka 1.25Mb)"; - case MediumTypes.HDFloppy: return "3.5-inch, 135 tpi, 15916 bits/radian, double-sided MFM (aka 1.44Mb)"; - case MediumTypes.ReadOnly: return "a Read-only optical"; - case MediumTypes.WORM: return "a Write-once Read-many optical"; - case MediumTypes.Erasable: return "a Erasable optical"; - case MediumTypes.RO_WORM: return "a combination of read-only and write-once optical"; + case MediumTypes.X3_73: return "ANSI X3.73-1980: 200 mm, 6631 ftprad, 1,9 Tracks per mm, 1 side"; + case MediumTypes.X3_73_DS: return "ANSI X3.73-1980: 200 mm, 6631 ftprad, 1,9 Tracks per mm, 2 sides"; + case MediumTypes.X3_82: return "ANSI X3.80-1980: 130 mm, 3979 ftprad, 1,9 Tracks per mm, 1 side"; + case MediumTypes.Type3Floppy: return "3.5-inch, 135 tpi, 12362 bits/radian, double-sided MFM (aka 1.25Mb)"; + case MediumTypes.HDFloppy: return "3.5-inch, 135 tpi, 15916 bits/radian, double-sided MFM (aka 1.44Mb)"; + case MediumTypes.ReadOnly: return "a Read-only optical"; + case MediumTypes.WORM: return "a Write-once Read-many optical"; + case MediumTypes.Erasable: return "a Erasable optical"; + case MediumTypes.RO_WORM: return "a combination of read-only and write-once optical"; // These magneto-opticals were never manufactured /* @@ -115,8 +114,7 @@ public static partial class Modes case PeripheralDeviceTypes.DirectAccess: { if(header.Value.MediumType != MediumTypes.Default) - sb.AppendFormat("\tMedium is {0}", GetMediumTypeDescription(header.Value.MediumType)). - AppendLine(); + sb.AppendFormat("\tMedium is {0}", GetMediumTypeDescription(header.Value.MediumType)).AppendLine(); if(header.Value.WriteProtected) sb.AppendLine("\tMedium is write protected"); @@ -127,7 +125,7 @@ public static partial class Modes if(header.Value.BlockDescriptors != null) foreach(BlockDescriptor descriptor in header.Value.BlockDescriptors) { - string density = ""; + var density = ""; switch(descriptor.Density) { @@ -448,7 +446,7 @@ public static partial class Modes if(header.Value.BlockDescriptors != null) foreach(BlockDescriptor descriptor in header.Value.BlockDescriptors) { - string density = ""; + var density = ""; switch(header.Value.MediumType) { @@ -532,13 +530,11 @@ public static partial class Modes break; case DensityType.QIC1350: - density = - "QIC-1350: 6,3 mm 30-Track Magnetic Tape Cartridge, 2034 bpmm, RLL"; + density = "QIC-1350: 6,3 mm 30-Track Magnetic Tape Cartridge, 2034 bpmm, RLL"; break; case DensityType.X3B5_88: - density = - "ANXI X3B5/88-185A: 3,81 mm Magnetic Tape Cassette, 2400 bpmm, DDS"; + density = "ANXI X3B5/88-185A: 3,81 mm Magnetic Tape Cassette, 2400 bpmm, DDS"; break; case DensityType.X3_202: @@ -1701,9 +1697,8 @@ public static partial class Modes if(density != "") if(descriptor.Blocks == 0) if(descriptor.BlockLength == 0) - sb. - AppendFormat("\tAll remaining blocks conform to {0} and have a variable length", - density).AppendLine(); + sb.AppendFormat("\tAll remaining blocks conform to {0} and have a variable length", + density).AppendLine(); else sb.AppendFormat("\tAll remaining blocks conform to {0} and are {1} bytes each", density, descriptor.BlockLength).AppendLine(); @@ -1711,14 +1706,14 @@ public static partial class Modes sb.AppendFormat("\t{0} blocks conform to {1} and have a variable length", descriptor.Blocks, density).AppendLine(); else - sb.AppendFormat("\t{0} blocks conform to {1} and are {2} bytes each", - descriptor.Blocks, density, descriptor.BlockLength).AppendLine(); + sb.AppendFormat("\t{0} blocks conform to {1} and are {2} bytes each", descriptor.Blocks, + density, descriptor.BlockLength).AppendLine(); else if(descriptor.Blocks == 0) if(descriptor.BlockLength == 0) sb.AppendFormat("\tAll remaining blocks have a variable length").AppendLine(); else - sb.AppendFormat("\tAll remaining blocks are {0} bytes each", - descriptor.BlockLength).AppendLine(); + sb.AppendFormat("\tAll remaining blocks are {0} bytes each", descriptor.BlockLength). + AppendLine(); else if(descriptor.BlockLength == 0) sb.AppendFormat("\t{0} blocks have a variable length", descriptor.Blocks).AppendLine(); else @@ -1811,14 +1806,13 @@ public static partial class Modes if(header.Value.BlockDescriptors != null) foreach(BlockDescriptor descriptor in header.Value.BlockDescriptors) { - string density = ""; + var density = ""; switch(descriptor.Density) { case DensityType.Default: break; case DensityType.ISO10090: - density = - "ISO/IEC 10090: 86 mm Read/Write single-sided optical disc with 12500 tracks"; + density = "ISO/IEC 10090: 86 mm Read/Write single-sided optical disc with 12500 tracks"; break; case DensityType.D581: @@ -1826,23 +1820,19 @@ public static partial class Modes break; case DensityType.X3_212: - density = - "ANSI X3.212: 130 mm Read/Write double-sided optical disc with 18750 tracks"; + density = "ANSI X3.212: 130 mm Read/Write double-sided optical disc with 18750 tracks"; break; case DensityType.X3_191: - density = - "ANSI X3.191: 130 mm Write-Once double-sided optical disc with 30000 tracks"; + density = "ANSI X3.191: 130 mm Write-Once double-sided optical disc with 30000 tracks"; break; case DensityType.X3_214: - density = - "ANSI X3.214: 130 mm Write-Once double-sided optical disc with 20000 tracks"; + density = "ANSI X3.214: 130 mm Write-Once double-sided optical disc with 20000 tracks"; break; case DensityType.X3_211: - density = - "ANSI X3.211: 130 mm Write-Once double-sided optical disc with 18750 tracks"; + density = "ANSI X3.211: 130 mm Write-Once double-sided optical disc with 18750 tracks"; break; case DensityType.D407: @@ -1869,11 +1859,11 @@ public static partial class Modes sb.AppendFormat("\tAll remaining blocks are {0} and have a variable length", density).AppendLine(); else - sb.AppendFormat("\tAll remaining blocks are {0} and are {1} bytes each", - density, descriptor.BlockLength).AppendLine(); + sb.AppendFormat("\tAll remaining blocks are {0} and are {1} bytes each", density, + descriptor.BlockLength).AppendLine(); else if(descriptor.BlockLength == 0) - sb.AppendFormat("\t{0} blocks are {1} and have a variable length", - descriptor.Blocks, density).AppendLine(); + sb.AppendFormat("\t{0} blocks are {1} and have a variable length", descriptor.Blocks, + density).AppendLine(); else sb.AppendFormat("\t{0} blocks are {1} and are {2} bytes each", descriptor.Blocks, density, descriptor.BlockLength).AppendLine(); @@ -1881,8 +1871,8 @@ public static partial class Modes if(descriptor.BlockLength == 0) sb.AppendFormat("\tAll remaining blocks have a variable length").AppendLine(); else - sb.AppendFormat("\tAll remaining blocks are {0} bytes each", - descriptor.BlockLength).AppendLine(); + sb.AppendFormat("\tAll remaining blocks are {0} bytes each", descriptor.BlockLength). + AppendLine(); else if(descriptor.BlockLength == 0) sb.AppendFormat("\t{0} blocks have a variable length", descriptor.Blocks).AppendLine(); else @@ -2060,7 +2050,7 @@ public static partial class Modes if(header.Value.BlockDescriptors != null) foreach(BlockDescriptor descriptor in header.Value.BlockDescriptors) { - string density = ""; + var density = ""; switch(descriptor.Density) { diff --git a/SCSI/Modes/Mode10.cs b/SCSI/Modes/Mode10.cs index 68025f0..4478bf3 100644 --- a/SCSI/Modes/Mode10.cs +++ b/SCSI/Modes/Mode10.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using Aaru.CommonTypes.Structs.Devices.SCSI; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -48,8 +48,8 @@ public static partial class Modes modeResponse.Length < 8) return null; - ushort modeLength = (ushort)((modeResponse[0] << 8) + modeResponse[1]); - ushort blockDescLength = (ushort)((modeResponse[6] << 8) + modeResponse[7]); + var modeLength = (ushort)((modeResponse[0] << 8) + modeResponse[1]); + var blockDescLength = (ushort)((modeResponse[6] << 8) + modeResponse[7]); if(modeResponse.Length < modeLength) return null; @@ -66,9 +66,9 @@ public static partial class Modes { header.BlockDescriptors = new BlockDescriptor[blockDescLength / 16]; - for(int i = 0; i < header.BlockDescriptors.Length; i++) + for(var i = 0; i < header.BlockDescriptors.Length; i++) { - if(12 + (i * 16) + 8 >= modeResponse.Length) + if(12 + i * 16 + 8 >= modeResponse.Length) break; header.BlockDescriptors[i] = new BlockDescriptor @@ -76,47 +76,47 @@ public static partial class Modes Density = DensityType.Default }; - byte[] temp = new byte[8]; - temp[0] = modeResponse[7 + (i * 16) + 8]; - temp[1] = modeResponse[6 + (i * 16) + 8]; - temp[2] = modeResponse[5 + (i * 16) + 8]; - temp[3] = modeResponse[4 + (i * 16) + 8]; - temp[4] = modeResponse[3 + (i * 16) + 8]; - temp[5] = modeResponse[2 + (i * 16) + 8]; - temp[6] = modeResponse[1 + (i * 16) + 8]; - temp[7] = modeResponse[0 + (i * 16) + 8]; + var temp = new byte[8]; + temp[0] = modeResponse[7 + i * 16 + 8]; + temp[1] = modeResponse[6 + i * 16 + 8]; + temp[2] = modeResponse[5 + i * 16 + 8]; + temp[3] = modeResponse[4 + i * 16 + 8]; + temp[4] = modeResponse[3 + i * 16 + 8]; + temp[5] = modeResponse[2 + i * 16 + 8]; + temp[6] = modeResponse[1 + i * 16 + 8]; + temp[7] = modeResponse[0 + i * 16 + 8]; header.BlockDescriptors[i].Blocks = BitConverter.ToUInt64(temp, 0); - header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[15 + (i * 16) + 8] << 24); - header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[14 + (i * 16) + 8] << 16); - header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[13 + (i * 16) + 8] << 8); - header.BlockDescriptors[i].BlockLength += modeResponse[12 + (i * 16) + 8]; + header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[15 + i * 16 + 8] << 24); + header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[14 + i * 16 + 8] << 16); + header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[13 + i * 16 + 8] << 8); + header.BlockDescriptors[i].BlockLength += modeResponse[12 + i * 16 + 8]; } } else { header.BlockDescriptors = new BlockDescriptor[blockDescLength / 8]; - for(int i = 0; i < header.BlockDescriptors.Length; i++) + for(var i = 0; i < header.BlockDescriptors.Length; i++) { - if(7 + (i * 8) + 8 >= modeResponse.Length) + if(7 + i * 8 + 8 >= modeResponse.Length) break; header.BlockDescriptors[i] = new BlockDescriptor(); if(deviceType != PeripheralDeviceTypes.DirectAccess) - header.BlockDescriptors[i].Density = (DensityType)modeResponse[0 + (i * 8) + 8]; + header.BlockDescriptors[i].Density = (DensityType)modeResponse[0 + i * 8 + 8]; else { header.BlockDescriptors[i].Density = DensityType.Default; - header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[0 + (i * 8) + 8] << 24); + header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[0 + i * 8 + 8] << 24); } - header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[1 + (i * 8) + 8] << 16); - header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[2 + (i * 8) + 8] << 8); - header.BlockDescriptors[i].Blocks += modeResponse[3 + (i * 8) + 8]; - header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[5 + (i * 8) + 8] << 16); - header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[6 + (i * 8) + 8] << 8); - header.BlockDescriptors[i].BlockLength += modeResponse[7 + (i * 8) + 8]; + header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[1 + i * 8 + 8] << 16); + header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[2 + i * 8 + 8] << 8); + header.BlockDescriptors[i].Blocks += modeResponse[3 + i * 8 + 8]; + header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[5 + i * 8 + 8] << 16); + header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[6 + i * 8 + 8] << 8); + header.BlockDescriptors[i].BlockLength += modeResponse[7 + i * 8 + 8]; } } @@ -166,15 +166,15 @@ public static partial class Modes bool longlba = (modeResponse[4] & 0x01) == 0x01; int offset; - int blkDrLength = 0; + var blkDrLength = 0; if(decoded.Header.BlockDescriptors != null) blkDrLength = decoded.Header.BlockDescriptors.Length; if(longlba) - offset = 8 + (blkDrLength * 16); + offset = 8 + blkDrLength * 16; else - offset = 8 + (blkDrLength * 8); + offset = 8 + blkDrLength * 8; int length = modeResponse[0] << 8; length += modeResponse[1]; @@ -189,7 +189,7 @@ public static partial class Modes { bool isSubpage = (modeResponse[offset] & 0x40) == 0x40; var pg = new ModePage(); - byte pageNo = (byte)(modeResponse[offset] & 0x3F); + var pageNo = (byte)(modeResponse[offset] & 0x3F); if(pageNo == 0) { @@ -239,14 +239,13 @@ public static partial class Modes return decoded; } - public static byte[] EncodeModeHeader10(ModeHeader header, PeripheralDeviceTypes deviceType, - bool longLBA = false) + public static byte[] EncodeModeHeader10(ModeHeader header, PeripheralDeviceTypes deviceType, bool longLBA = false) { byte[] hdr; if(header.BlockDescriptors != null) - hdr = longLBA ? new byte[8 + (header.BlockDescriptors.Length * 16)] - : new byte[8 + (header.BlockDescriptors.Length * 8)]; + hdr = longLBA ? new byte[8 + header.BlockDescriptors.Length * 16] + : new byte[8 + header.BlockDescriptors.Length * 8]; else hdr = new byte[8]; @@ -295,36 +294,36 @@ public static partial class Modes return hdr; if(longLBA) - for(int i = 0; i < header.BlockDescriptors.Length; i++) + for(var i = 0; i < header.BlockDescriptors.Length; i++) { byte[] temp = BitConverter.GetBytes(header.BlockDescriptors[i].Blocks); - hdr[7 + (i * 16) + 8] = temp[0]; - hdr[6 + (i * 16) + 8] = temp[1]; - hdr[5 + (i * 16) + 8] = temp[2]; - hdr[4 + (i * 16) + 8] = temp[3]; - hdr[3 + (i * 16) + 8] = temp[4]; - hdr[2 + (i * 16) + 8] = temp[5]; - hdr[1 + (i * 16) + 8] = temp[6]; - hdr[0 + (i * 16) + 8] = temp[7]; - hdr[12 + (i * 16) + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF000000) >> 24); - hdr[13 + (i * 16) + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16); - hdr[14 + (i * 16) + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8); - hdr[15 + (i * 16) + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF); + hdr[7 + i * 16 + 8] = temp[0]; + hdr[6 + i * 16 + 8] = temp[1]; + hdr[5 + i * 16 + 8] = temp[2]; + hdr[4 + i * 16 + 8] = temp[3]; + hdr[3 + i * 16 + 8] = temp[4]; + hdr[2 + i * 16 + 8] = temp[5]; + hdr[1 + i * 16 + 8] = temp[6]; + hdr[0 + i * 16 + 8] = temp[7]; + hdr[12 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF000000) >> 24); + hdr[13 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16); + hdr[14 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8); + hdr[15 + i * 16 + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF); } else - for(int i = 0; i < header.BlockDescriptors.Length; i++) + for(var i = 0; i < header.BlockDescriptors.Length; i++) { if(deviceType != PeripheralDeviceTypes.DirectAccess) - hdr[0 + (i * 8) + 8] = (byte)header.BlockDescriptors[i].Density; + hdr[0 + i * 8 + 8] = (byte)header.BlockDescriptors[i].Density; else - hdr[0 + (i * 8) + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF000000) >> 24); + hdr[0 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF000000) >> 24); - hdr[1 + (i * 8) + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16); - hdr[2 + (i * 8) + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8); - hdr[3 + (i * 8) + 8] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF); - hdr[5 + (i * 8) + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16); - hdr[6 + (i * 8) + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8); - hdr[7 + (i * 8) + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF); + hdr[1 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16); + hdr[2 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8); + hdr[3 + i * 8 + 8] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF); + hdr[5 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16); + hdr[6 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8); + hdr[7 + i * 8 + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF); } return hdr; @@ -332,14 +331,14 @@ public static partial class Modes public static byte[] EncodeMode10(DecodedMode mode, PeripheralDeviceTypes deviceType) { - int modeSize = 0; + var modeSize = 0; if(mode.Pages != null) modeSize += mode.Pages.Sum(page => page.PageResponse.Length); byte[] hdr = EncodeModeHeader10(mode.Header, deviceType); modeSize += hdr.Length; - byte[] md = new byte[modeSize]; + var md = new byte[modeSize]; Array.Copy(hdr, 0, md, 0, hdr.Length); diff --git a/SCSI/Modes/Mode6.cs b/SCSI/Modes/Mode6.cs index db349f5..77f14c2 100644 --- a/SCSI/Modes/Mode6.cs +++ b/SCSI/Modes/Mode6.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using Aaru.CommonTypes.Structs.Devices.SCSI; -namespace Aaru.Decoders.SCSI; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes @@ -58,15 +58,15 @@ public static partial class Modes { header.BlockDescriptors = new BlockDescriptor[modeResponse[3] / 8]; - for(int i = 0; i < header.BlockDescriptors.Length; i++) + for(var i = 0; i < header.BlockDescriptors.Length; i++) { - header.BlockDescriptors[i].Density = (DensityType)modeResponse[0 + (i * 8) + 4]; - header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[1 + (i * 8) + 4] << 16); - header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[2 + (i * 8) + 4] << 8); - header.BlockDescriptors[i].Blocks += modeResponse[3 + (i * 8) + 4]; - header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[5 + (i * 8) + 4] << 16); - header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[6 + (i * 8) + 4] << 8); - header.BlockDescriptors[i].BlockLength += modeResponse[7 + (i * 8) + 4]; + header.BlockDescriptors[i].Density = (DensityType)modeResponse[0 + i * 8 + 4]; + header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[1 + i * 8 + 4] << 16); + header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[2 + i * 8 + 4] << 8); + header.BlockDescriptors[i].Blocks += modeResponse[3 + i * 8 + 4]; + header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[5 + i * 8 + 4] << 16); + header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[6 + i * 8 + 4] << 8); + header.BlockDescriptors[i].BlockLength += modeResponse[7 + i * 8 + 4]; } } @@ -114,24 +114,24 @@ public static partial class Modes Header = hdr.Value }; - int blkDrLength = 0; + var blkDrLength = 0; if(decoded.Header.BlockDescriptors != null) blkDrLength = decoded.Header.BlockDescriptors.Length; - int offset = 4 + (blkDrLength * 8); + int offset = 4 + blkDrLength * 8; int length = modeResponse[0] + 1; if(length != modeResponse.Length) return decoded; - List listpages = new List(); + var listpages = new List(); while(offset < modeResponse.Length) { bool isSubpage = (modeResponse[offset] & 0x40) == 0x40; var pg = new ModePage(); - byte pageNo = (byte)(modeResponse[offset] & 0x3F); + var pageNo = (byte)(modeResponse[offset] & 0x3F); if(pageNo == 0) { @@ -187,8 +187,7 @@ public static partial class Modes public static byte[] EncodeModeHeader6(ModeHeader header, PeripheralDeviceTypes deviceType) { - byte[] hdr = header.BlockDescriptors != null ? new byte[4 + (header.BlockDescriptors.Length * 8)] - : new byte[4]; + byte[] hdr = header.BlockDescriptors != null ? new byte[4 + header.BlockDescriptors.Length * 8] : new byte[4]; hdr[1] = (byte)header.MediumType; @@ -233,15 +232,15 @@ public static partial class Modes hdr[3] = (byte)(header.BlockDescriptors.Length * 8); - for(int i = 0; i < header.BlockDescriptors.Length; i++) + for(var i = 0; i < header.BlockDescriptors.Length; i++) { - hdr[0 + (i * 8) + 4] = (byte)header.BlockDescriptors[i].Density; - hdr[1 + (i * 8) + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16); - hdr[2 + (i * 8) + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8); - hdr[3 + (i * 8) + 4] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF); - hdr[5 + (i * 8) + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16); - hdr[6 + (i * 8) + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8); - hdr[7 + (i * 8) + 4] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF); + hdr[0 + i * 8 + 4] = (byte)header.BlockDescriptors[i].Density; + hdr[1 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16); + hdr[2 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8); + hdr[3 + i * 8 + 4] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF); + hdr[5 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16); + hdr[6 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8); + hdr[7 + i * 8 + 4] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF); } return hdr; @@ -249,14 +248,14 @@ public static partial class Modes public static byte[] EncodeMode6(DecodedMode mode, PeripheralDeviceTypes deviceType) { - int modeSize = 0; + var modeSize = 0; if(mode.Pages != null) modeSize += mode.Pages.Sum(page => page.PageResponse.Length); byte[] hdr = EncodeModeHeader6(mode.Header, deviceType); modeSize += hdr.Length; - byte[] md = new byte[modeSize]; + var md = new byte[modeSize]; Array.Copy(hdr, 0, md, 0, hdr.Length); diff --git a/SCSI/Modes/Structs.cs b/SCSI/Modes/Structs.cs index 84f0114..df1cf7d 100644 --- a/SCSI/Modes/Structs.cs +++ b/SCSI/Modes/Structs.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.SCSI; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static partial class Modes diff --git a/SCSI/SSC/BlockLimits.cs b/SCSI/SSC/BlockLimits.cs index c49883a..f3bc6f0 100644 --- a/SCSI/SSC/BlockLimits.cs +++ b/SCSI/SSC/BlockLimits.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI.SSC; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SCSI.SSC; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public static class BlockLimits diff --git a/SCSI/SSC/DensitySupport.cs b/SCSI/SSC/DensitySupport.cs index 7fcaffe..eaed336 100644 --- a/SCSI/SSC/DensitySupport.cs +++ b/SCSI/SSC/DensitySupport.cs @@ -30,14 +30,14 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI.SSC; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Helpers; -namespace Aaru.Decoders.SCSI.SSC; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")] public static class DensitySupport @@ -50,13 +50,13 @@ public static class DensitySupport if(response.Length <= 56) return null; - ushort responseLen = (ushort)((response[0] << 8) + response[1] + 2); + var responseLen = (ushort)((response[0] << 8) + response[1] + 2); if(response.Length != responseLen) return null; - List descriptors = new List(); - int offset = 4; + var descriptors = new List(); + var offset = 4; while(offset < response.Length) { @@ -77,7 +77,7 @@ public static class DensitySupport (response[offset + 14] << 8) + response[offset + 15]) }; - byte[] tmp = new byte[8]; + var tmp = new byte[8]; Array.Copy(response, offset + 16, tmp, 0, 8); descriptor.organization = StringHandlers.CToString(tmp).Trim(); tmp = new byte[8]; @@ -132,8 +132,8 @@ public static class DensitySupport if(descriptor.defaultDensity) sb.AppendLine("\tThis is the default density on the drive"); - sb.AppendFormat("\tDensity has {0} bits per mm, with {1} tracks in a {2} mm width tape", - descriptor.bpmm, descriptor.tracks, descriptor.width / (double)10).AppendLine(); + sb.AppendFormat("\tDensity has {0} bits per mm, with {1} tracks in a {2} mm width tape", descriptor.bpmm, + descriptor.tracks, descriptor.width / (double)10).AppendLine(); sb.AppendFormat("\tDensity maximum capacity is {0} megabytes", descriptor.capacity).AppendLine(); sb.AppendFormat("\tDensity description: {0}", descriptor.description).AppendLine(); @@ -153,13 +153,13 @@ public static class DensitySupport if(response.Length <= 60) return null; - ushort responseLen = (ushort)((response[0] << 8) + response[1] + 2); + var responseLen = (ushort)((response[0] << 8) + response[1] + 2); if(response.Length != responseLen) return null; - List descriptors = new List(); - int offset = 4; + var descriptors = new List(); + var offset = 4; while(offset < response.Length) { @@ -180,7 +180,7 @@ public static class DensitySupport descriptor.length = (ushort)((response[offset + 16] << 8) + response[offset + 17]); descriptor.reserved1 = response[offset + 18]; descriptor.reserved1 = response[offset + 19]; - byte[] tmp = new byte[8]; + var tmp = new byte[8]; Array.Copy(response, offset + 20, tmp, 0, 8); descriptor.organization = StringHandlers.CToString(tmp).Trim(); tmp = new byte[8]; @@ -224,7 +224,7 @@ public static class DensitySupport { sb.AppendFormat("\tMedium supports following density codes:"); - for(int i = 0; i < descriptor.numberOfCodes; i++) + for(var i = 0; i < descriptor.numberOfCodes; i++) sb.AppendFormat(" {0:X2}h", descriptor.densityCodes[i]); sb.AppendLine(); diff --git a/SCSI/Sense.cs b/SCSI/Sense.cs index 0d417fd..e12312f 100644 --- a/SCSI/Sense.cs +++ b/SCSI/Sense.cs @@ -30,18 +30,22 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SCSI; + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Decoders.ATA; -namespace Aaru.Decoders.SCSI; - public enum SenseType { - StandardSense, ExtendedSenseFixedCurrent, ExtendedSenseFixedPast, - ExtendedSenseDescriptorCurrent, ExtendedSenseDescriptorPast, Invalid, + StandardSense, + ExtendedSenseFixedCurrent, + ExtendedSenseFixedPast, + ExtendedSenseDescriptorCurrent, + ExtendedSenseDescriptorPast, + Invalid, Unknown } @@ -226,7 +230,7 @@ public static class Sense break; } - return decoded.Fixed is null && decoded.Descriptor is null ? (DecodedSense?)null : decoded; + return decoded.Fixed is null && decoded.Descriptor is null ? null : decoded; } public static FixedSense? DecodeFixed(byte[] sense) => DecodeFixed(sense, out _); @@ -311,7 +315,7 @@ public static class Sense senseDescription = GetSenseDescription(decoded.ASC, decoded.ASCQ); - int offset = 8; + var offset = 8; while(offset < sense.Length) if(offset + 2 < sense.Length) @@ -319,7 +323,7 @@ public static class Sense byte descType = sense[offset]; int descLen = sense[offset + 1] + 2; - byte[] desc = new byte[descLen]; + var desc = new byte[descLen]; if(offset + descLen >= sense.Length) descLen = sense.Length - offset; @@ -469,7 +473,7 @@ public static class Sense descriptor[0] != 0x00) return 0; - byte[] temp = new byte[8]; + var temp = new byte[8]; temp[0] = descriptor[11]; temp[1] = descriptor[10]; @@ -492,7 +496,7 @@ public static class Sense descriptor[0] != 0x01) return 0; - byte[] temp = new byte[8]; + var temp = new byte[8]; temp[0] = descriptor[11]; temp[1] = descriptor[10]; @@ -515,7 +519,7 @@ public static class Sense descriptor[0] != 0x02) return null; - byte[] temp = new byte[3]; + var temp = new byte[3]; Array.Copy(descriptor, 4, temp, 0, 3); return temp; @@ -566,7 +570,7 @@ public static class Sense public static void DecodeDescriptor08(byte[] descriptor) => throw new NotImplementedException("Check OSD"); - public static AtaErrorRegistersLba48 DecodeDescriptor09(byte[] descriptor) => new AtaErrorRegistersLba48 + public static AtaErrorRegistersLba48 DecodeDescriptor09(byte[] descriptor) => new() { Error = descriptor[3], SectorCount = (ushort)((descriptor[4] << 8) + descriptor[5]), diff --git a/SCSI/Types.cs b/SCSI/Types.cs index a8862ab..6027d51 100644 --- a/SCSI/Types.cs +++ b/SCSI/Types.cs @@ -30,10 +30,10 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ -using System.Diagnostics.CodeAnalysis; - namespace Aaru.Decoders.SCSI; +using System.Diagnostics.CodeAnalysis; + [SuppressMessage("ReSharper", "InconsistentNaming")] public enum MediumTypes : byte { diff --git a/SecureDigital/CID.cs b/SecureDigital/CID.cs index 10a899c..222f478 100644 --- a/SecureDigital/CID.cs +++ b/SecureDigital/CID.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SecureDigital; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Helpers; -namespace Aaru.Decoders.SecureDigital; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class CID @@ -59,7 +59,7 @@ public static partial class Decoders if(response?.Length != 4) return null; - byte[] data = new byte[16]; + var data = new byte[16]; byte[] tmp = BitConverter.GetBytes(response[0]); Array.Copy(tmp, 0, data, 0, 4); @@ -87,7 +87,7 @@ public static partial class Decoders CRC = (byte)((response[15] & 0xFE) >> 1) }; - byte[] tmp = new byte[2]; + var tmp = new byte[2]; Array.Copy(response, 1, tmp, 0, 2); cid.ApplicationID = StringHandlers.CToString(tmp); tmp = new byte[5]; diff --git a/SecureDigital/CSD.cs b/SecureDigital/CSD.cs index e43e26e..9e4b73c 100644 --- a/SecureDigital/CSD.cs +++ b/SecureDigital/CSD.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SecureDigital; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SecureDigital; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class CSD @@ -79,7 +79,7 @@ public static partial class Decoders if(response?.Length != 4) return null; - byte[] data = new byte[16]; + var data = new byte[16]; byte[] tmp = BitConverter.GetBytes(response[0]); Array.Copy(tmp, 0, data, 0, 4); @@ -148,7 +148,7 @@ public static partial class Decoders double unitFactor = 0; double multiplier = 0; - string unit = ""; + var unit = ""; var sb = new StringBuilder(); sb.AppendLine("SecureDigital Device Specific Data Register:"); @@ -601,8 +601,7 @@ public static partial class Decoders sb.AppendLine("\tDevice can't write protect regions"); } - sb.AppendFormat("\tWriting is {0} times slower than reading", Math.Pow(2, csd.WriteSpeedFactor)). - AppendLine(); + sb.AppendFormat("\tWriting is {0} times slower than reading", Math.Pow(2, csd.WriteSpeedFactor)).AppendLine(); sb.AppendFormat("\tWrite block length is {0} bytes", Math.Pow(2, csd.WriteBlockLength)).AppendLine(); diff --git a/SecureDigital/OCR.cs b/SecureDigital/OCR.cs index 8f63cd1..56f2dcd 100644 --- a/SecureDigital/OCR.cs +++ b/SecureDigital/OCR.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SecureDigital; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Helpers; -namespace Aaru.Decoders.SecureDigital; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "UnassignedField.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")] diff --git a/SecureDigital/SCR.cs b/SecureDigital/SCR.cs index 746999c..96abfab 100644 --- a/SecureDigital/SCR.cs +++ b/SecureDigital/SCR.cs @@ -30,12 +30,12 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.SecureDigital; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Aaru.Decoders.SecureDigital; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")] public class SCR @@ -56,14 +56,17 @@ public class SCR [Flags] public enum BusWidth : byte { - OneBit = 1 << 0, FourBit = 1 << 2 + OneBit = 1 << 0, + FourBit = 1 << 2 } [Flags] public enum CommandSupport : byte { - SpeedClassControl = 1 << 0, SetBlockCount = 1 << 1, ExtensionRegisterSingleBlock = 1 << 2, - ExtensionRegisterMultiBlock = 1 << 3 + SpeedClassControl = 1 << 0, + SetBlockCount = 1 << 1, + ExtensionRegisterSingleBlock = 1 << 2, + ExtensionRegisterMultiBlock = 1 << 3 } [SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "InconsistentNaming")] @@ -74,7 +77,7 @@ public static partial class Decoders if(response?.Length != 2) return null; - byte[] data = new byte[8]; + var data = new byte[8]; byte[] tmp = BitConverter.GetBytes(response[0]); Array.Copy(tmp, 0, data, 0, 4); @@ -195,8 +198,7 @@ public static partial class Decoders break; default: - sb.AppendFormat("\tDevice uses unknown CPRM specification with code {0}", scr.Security). - AppendLine(); + sb.AppendFormat("\tDevice uses unknown CPRM specification with code {0}", scr.Security).AppendLine(); break; } diff --git a/SecureDigital/VendorString.cs b/SecureDigital/VendorString.cs index 8dc747c..8965648 100644 --- a/SecureDigital/VendorString.cs +++ b/SecureDigital/VendorString.cs @@ -39,12 +39,12 @@ public static class VendorString /// SD vendor ID /// Manufacturer public static string Prettify(byte sdVendorId) => sdVendorId switch - { - 0x41 => "Kingston", - 0x02 => "Kingston", - 0x03 => "Sandisk", - 0x27 => "CnMemory", - 0xAA => "QEMU", - _ => $"Unknown manufacturer ID 0x{sdVendorId:X2}" - }; + { + 0x41 => "Kingston", + 0x02 => "Kingston", + 0x03 => "Sandisk", + 0x27 => "CnMemory", + 0xAA => "QEMU", + _ => $"Unknown manufacturer ID 0x{sdVendorId:X2}" + }; } \ No newline at end of file diff --git a/Sega/CD.cs b/Sega/CD.cs index d95a3a3..814208b 100644 --- a/Sega/CD.cs +++ b/Sega/CD.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Sega; + using System; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -38,8 +40,6 @@ using System.Text; using Aaru.Console; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Decoders.Sega; - /// Represents the IP.BIN from a SEGA CD / MEGA CD [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] @@ -67,8 +67,7 @@ public static class CD AaruConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.volume_version = \"{0:X}\"", ipbin.volume_version); - AaruConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.volume_type = 0x{0:X8}", - ipbin.volume_type); + AaruConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.volume_type = 0x{0:X8}", ipbin.volume_type); AaruConsole.DebugWriteLine("SegaCD IP.BIN Decoder", "segacd_ipbin.system_version = 0x{0:X8}", ipbin.system_version); @@ -117,8 +116,7 @@ public static class CD string id = Encoding.ASCII.GetString(ipbin.SegaHardwareID); - return id == "SEGADISCSYSTEM " || id == "SEGADATADISC " || id == "SEGAOS " ? ipbin - : (IPBin?)null; + return id == "SEGADISCSYSTEM " || id == "SEGADATADISC " || id == "SEGAOS " ? ipbin : null; } /// Pretty prints a decoded IP.BIN in SEGA CD / MEGA CD format @@ -149,8 +147,7 @@ public static class CD { try { - ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(ipbin.release_date2), "yyyy.MMM", - provider); + ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(ipbin.release_date2), "yyyy.MMM", provider); } #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch @@ -185,15 +182,13 @@ public static class CD IPBinInformation.AppendFormat("Initial program address: 0x{0:X8}", ipbin.ip_address).AppendLine(); IPBinInformation.AppendFormat("Initial program load size: {0} bytes", ipbin.ip_loadsize).AppendLine(); - IPBinInformation.AppendFormat("Initial program entry address: 0x{0:X8}", ipbin.ip_entry_address). - AppendLine(); + IPBinInformation.AppendFormat("Initial program entry address: 0x{0:X8}", ipbin.ip_entry_address).AppendLine(); IPBinInformation.AppendFormat("Initial program work RAM: {0} bytes", ipbin.ip_work_ram_size).AppendLine(); IPBinInformation.AppendFormat("System program address: 0x{0:X8}", ipbin.sp_address).AppendLine(); IPBinInformation.AppendFormat("System program load size: {0} bytes", ipbin.sp_loadsize).AppendLine(); - IPBinInformation.AppendFormat("System program entry address: 0x{0:X8}", ipbin.sp_entry_address). - AppendLine(); + IPBinInformation.AppendFormat("System program entry address: 0x{0:X8}", ipbin.sp_entry_address).AppendLine(); IPBinInformation.AppendFormat("System program work RAM: {0} bytes", ipbin.sp_work_ram_size).AppendLine(); @@ -212,8 +207,7 @@ public static class CD IPBinInformation.AppendFormat("Overseas title: {0}", Encoding.ASCII.GetString(ipbin.overseas_title)). AppendLine(); - IPBinInformation.AppendFormat("Product code: {0}", Encoding.ASCII.GetString(ipbin.product_code)). - AppendLine(); + IPBinInformation.AppendFormat("Product code: {0}", Encoding.ASCII.GetString(ipbin.product_code)).AppendLine(); IPBinInformation.AppendFormat("Peripherals:").AppendLine(); diff --git a/Sega/Dreamcast.cs b/Sega/Dreamcast.cs index 9194f56..84f5ebd 100644 --- a/Sega/Dreamcast.cs +++ b/Sega/Dreamcast.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Sega; + using System; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -38,8 +40,6 @@ using System.Text; using Aaru.Console; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Decoders.Sega; - /// Represents the IP.BIN from a SEGA Dreamcast [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] @@ -67,8 +67,7 @@ public static class Dreamcast AaruConsole.DebugWriteLine("Dreamcast IP.BIN Decoder", "dreamcast_ipbin.dreamcast_media = \"{0}\"", Encoding.ASCII.GetString(ipbin.dreamcast_media)); - AaruConsole.DebugWriteLine("Dreamcast IP.BIN Decoder", "dreamcast_ipbin.disc_no = {0}", - (char)ipbin.disc_no); + AaruConsole.DebugWriteLine("Dreamcast IP.BIN Decoder", "dreamcast_ipbin.disc_no = {0}", (char)ipbin.disc_no); AaruConsole.DebugWriteLine("Dreamcast IP.BIN Decoder", "dreamcast_ipbin.disc_no_separator = \"{0}\"", (char)ipbin.disc_no_separator); @@ -106,7 +105,7 @@ public static class Dreamcast AaruConsole.DebugWriteLine("Dreamcast IP.BIN Decoder", "dreamcast_ipbin.product_name = \"{0}\"", Encoding.ASCII.GetString(ipbin.product_name)); - return Encoding.ASCII.GetString(ipbin.SegaHardwareID) == "SEGA SEGAKATANA " ? ipbin : (IPBin?)null; + return Encoding.ASCII.GetString(ipbin.SegaHardwareID) == "SEGA SEGAKATANA " ? ipbin : null; } /// Pretty prints a decoded IP.BIN in Dreamcast format @@ -130,8 +129,7 @@ public static class Dreamcast CultureInfo provider = CultureInfo.InvariantCulture; ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(ipbin.release_date), "yyyyMMdd", provider); - IPBinInformation.AppendFormat("Product name: {0}", Encoding.ASCII.GetString(ipbin.product_name)). - AppendLine(); + IPBinInformation.AppendFormat("Product name: {0}", Encoding.ASCII.GetString(ipbin.product_name)).AppendLine(); IPBinInformation.AppendFormat("Product version: {0}", Encoding.ASCII.GetString(ipbin.product_version)). AppendLine(); @@ -139,8 +137,7 @@ public static class Dreamcast IPBinInformation.AppendFormat("Product CRC: 0x{0:X8}", ipbin.dreamcast_crc).AppendLine(); IPBinInformation.AppendFormat("Producer: {0}", Encoding.ASCII.GetString(ipbin.producer)).AppendLine(); - IPBinInformation.AppendFormat("Disc media: {0}", Encoding.ASCII.GetString(ipbin.dreamcast_media)). - AppendLine(); + IPBinInformation.AppendFormat("Disc media: {0}", Encoding.ASCII.GetString(ipbin.dreamcast_media)).AppendLine(); IPBinInformation.AppendFormat("Disc number {0} of {1}", (char)ipbin.disc_no, (char)ipbin.disc_total_nos). AppendLine(); @@ -188,7 +185,7 @@ public static class Dreamcast break; } - int iPeripherals = int.Parse(Encoding.ASCII.GetString(ipbin.peripherals), NumberStyles.HexNumber); + var iPeripherals = int.Parse(Encoding.ASCII.GetString(ipbin.peripherals), NumberStyles.HexNumber); if((iPeripherals & 0x00000001) == 0x00000001) IPBinInformation.AppendLine("Game uses Windows CE."); diff --git a/Sega/Saturn.cs b/Sega/Saturn.cs index a608a22..b4335ce 100644 --- a/Sega/Saturn.cs +++ b/Sega/Saturn.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Sega; + using System; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -38,8 +40,6 @@ using System.Text; using Aaru.Console; using Marshal = Aaru.Helpers.Marshal; -namespace Aaru.Decoders.Sega; - /// Represents the IP.BIN from a SEGA Saturn [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] @@ -96,7 +96,7 @@ public static class Saturn AaruConsole.DebugWriteLine("Saturn IP.BIN Decoder", "saturn_ipbin.product_name = \"{0}\"", Encoding.ASCII.GetString(ipbin.product_name)); - return Encoding.ASCII.GetString(ipbin.SegaHardwareID) == "SEGA SEGASATURN " ? ipbin : (IPBin?)null; + return Encoding.ASCII.GetString(ipbin.SegaHardwareID) == "SEGA SEGASATURN " ? ipbin : null; } /// Pretty prints a decoded IP.BIN in Saturn format @@ -120,11 +120,9 @@ public static class Saturn CultureInfo provider = CultureInfo.InvariantCulture; ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(ipbin.release_date), "yyyyMMdd", provider); - IPBinInformation.AppendFormat("Product name: {0}", Encoding.ASCII.GetString(ipbin.product_name)). - AppendLine(); + IPBinInformation.AppendFormat("Product name: {0}", Encoding.ASCII.GetString(ipbin.product_name)).AppendLine(); - IPBinInformation.AppendFormat("Product number: {0}", Encoding.ASCII.GetString(ipbin.product_no)). - AppendLine(); + IPBinInformation.AppendFormat("Product number: {0}", Encoding.ASCII.GetString(ipbin.product_no)).AppendLine(); IPBinInformation.AppendFormat("Product version: {0}", Encoding.ASCII.GetString(ipbin.product_version)). AppendLine(); diff --git a/Xbox/DMI.cs b/Xbox/DMI.cs index de10d3e..659b075 100644 --- a/Xbox/DMI.cs +++ b/Xbox/DMI.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Xbox; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Helpers; -namespace Aaru.Decoders.Xbox; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")] public static class DMI @@ -51,12 +51,12 @@ public static class DMI return false; // Catalogue number is two letters, five numbers, one letter - for(int i = 12; i < 14; i++) + for(var i = 12; i < 14; i++) if(dmi[i] < 0x41 || dmi[i] > 0x5A) return false; - for(int i = 14; i < 19; i++) + for(var i = 14; i < 19; i++) if(dmi[i] < 0x30 || dmi[i] > 0x39) return false; @@ -65,7 +65,7 @@ public static class DMI dmi[19] > 0x5A) return false; - long timestamp = BitConverter.ToInt64(dmi, 20); + var timestamp = BitConverter.ToInt64(dmi, 20); // Game cannot exist before the Xbox return timestamp >= 0x1BD164833DFC000; @@ -76,7 +76,7 @@ public static class DMI if(dmi?.Length != 2052) return false; - uint signature = BitConverter.ToUInt32(dmi, 0x7EC); + var signature = BitConverter.ToUInt32(dmi, 0x7EC); // "XBOX" swapped as .NET is little endian return signature == 0x584F4258; @@ -98,7 +98,7 @@ public static class DMI Timestamp = BitConverter.ToInt64(response, 20) }; - byte[] tmp = new byte[8]; + var tmp = new byte[8]; Array.Copy(response, 12, tmp, 0, 8); dmi.CatalogNumber = StringHandlers.CToString(tmp); @@ -123,11 +123,11 @@ public static class DMI }; Array.Copy(response, 36, dmi.MediaID, 0, 16); - byte[] tmp = new byte[16]; + var tmp = new byte[16]; Array.Copy(response, 68, tmp, 0, 16); dmi.CatalogNumber = StringHandlers.CToString(tmp); - return dmi.CatalogNumber == null || dmi.CatalogNumber.Length < 13 ? (Xbox360DMI?)null : dmi; + return dmi.CatalogNumber == null || dmi.CatalogNumber.Length < 13 ? null : dmi; } public static string PrettifyXbox(XboxDMI? dmi) @@ -140,12 +140,12 @@ public static class DMI sb.Append("Catalogue number: "); - for(int i = 0; i < 2; i++) + for(var i = 0; i < 2; i++) sb.AppendFormat("{0}", decoded.CatalogNumber[i]); sb.Append("-"); - for(int i = 2; i < 7; i++) + for(var i = 2; i < 7; i++) sb.AppendFormat("{0}", decoded.CatalogNumber[i]); sb.Append("-"); @@ -167,17 +167,17 @@ public static class DMI sb.Append("Catalogue number: "); - for(int i = 0; i < 2; i++) + for(var i = 0; i < 2; i++) sb.AppendFormat("{0}", decoded.CatalogNumber[i]); sb.Append("-"); - for(int i = 2; i < 6; i++) + for(var i = 2; i < 6; i++) sb.AppendFormat("{0}", decoded.CatalogNumber[i]); sb.Append("-"); - for(int i = 6; i < 8; i++) + for(var i = 6; i < 8; i++) sb.AppendFormat("{0}", decoded.CatalogNumber[i]); sb.Append("-"); @@ -185,27 +185,27 @@ public static class DMI switch(decoded.CatalogNumber.Length) { case 13: - for(int i = 8; i < 10; i++) + for(var i = 8; i < 10; i++) sb.AppendFormat("{0}", decoded.CatalogNumber[i]); sb.Append("-"); - for(int i = 10; i < 13; i++) + for(var i = 10; i < 13; i++) sb.AppendFormat("{0}", decoded.CatalogNumber[i]); break; case 14: - for(int i = 8; i < 11; i++) + for(var i = 8; i < 11; i++) sb.AppendFormat("{0}", decoded.CatalogNumber[i]); sb.Append("-"); - for(int i = 11; i < 14; i++) + for(var i = 11; i < 14; i++) sb.AppendFormat("{0}", decoded.CatalogNumber[i]); break; default: - for(int i = 8; i < decoded.CatalogNumber.Length - 3; i++) + for(var i = 8; i < decoded.CatalogNumber.Length - 3; i++) sb.AppendFormat("{0}", decoded.CatalogNumber[i]); sb.Append("-"); @@ -220,12 +220,12 @@ public static class DMI sb.Append("Media ID: "); - for(int i = 0; i < 12; i++) + for(var i = 0; i < 12; i++) sb.AppendFormat("{0:X2}", decoded.MediaID[i]); sb.Append("-"); - for(int i = 12; i < 16; i++) + for(var i = 12; i < 16; i++) sb.AppendFormat("{0:X2}", decoded.MediaID[i]); sb.AppendLine(); diff --git a/Xbox/SS.cs b/Xbox/SS.cs index 01c6a5b..5725f60 100644 --- a/Xbox/SS.cs +++ b/Xbox/SS.cs @@ -30,13 +30,13 @@ // Copyright © 2011-2022 Natalia Portillo // ****************************************************************************/ +namespace Aaru.Decoders.Xbox; + using System; using System.Diagnostics.CodeAnalysis; using System.Text; using Aaru.Decoders.DVD; -namespace Aaru.Decoders.Xbox; - [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"), SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")] public static class SS @@ -87,17 +87,16 @@ public static class SS Array.Copy(response, 720, ss.Unknown4, 0, 4); Array.Copy(response, 724, ss.Unknown5, 0, 43); - for(int i = 0; i < 23; i++) + for(var i = 0; i < 23; i++) ss.ChallengeEntries[i] = new ChallengeEntry { - Level = response[770 + (i * 11) + 0], - ChallengeId = response[770 + (i * 11) + 1], - ChallengeValue = (uint)((response[770 + (i * 11) + 2] << 24) + - (response[770 + (i * 11) + 3] << 16) + (response[770 + (i * 11) + 4] << 8) + - response[770 + (i * 11) + 5]), - ResponseModifier = response[770 + (i * 11) + 6], - ResponseValue = (uint)((response[770 + (i * 11) + 7] << 24) + (response[770 + (i * 11) + 8] << 16) + - (response[770 + (i * 11) + 9] << 8) + response[770 + (i * 11) + 10]) + Level = response[770 + i * 11 + 0], + ChallengeId = response[770 + i * 11 + 1], + ChallengeValue = (uint)((response[770 + i * 11 + 2] << 24) + (response[770 + i * 11 + 3] << 16) + + (response[770 + i * 11 + 4] << 8) + response[770 + i * 11 + 5]), + ResponseModifier = response[770 + i * 11 + 6], + ResponseValue = (uint)((response[770 + i * 11 + 7] << 24) + (response[770 + i * 11 + 8] << 16) + + (response[770 + i * 11 + 9] << 8) + response[770 + i * 11 + 10]) }; Array.Copy(response, 1052, ss.Unknown7, 0, 48); @@ -106,26 +105,26 @@ public static class SS Array.Copy(response, 1208, ss.Unknown10, 0, 303); Array.Copy(response, 1528, ss.Unknown11, 0, 104); - for(int i = 0; i < 23; i++) + for(var i = 0; i < 23; i++) ss.Extents[i] = new SecuritySectorExtent { - Unknown = (uint)((response[1633 + (i * 9) + 0] << 16) + (response[1633 + (i * 9) + 1] << 8) + - response[1633 + (i * 9) + 2]), - StartPSN = (uint)((response[1633 + (i * 9) + 3] << 16) + (response[1633 + (i * 9) + 4] << 8) + - response[1633 + (i * 9) + 5]), - EndPSN = (uint)((response[1633 + (i * 9) + 6] << 16) + (response[1633 + (i * 9) + 7] << 8) + - response[1633 + (i * 9) + 8]) + Unknown = (uint)((response[1633 + i * 9 + 0] << 16) + (response[1633 + i * 9 + 1] << 8) + + response[1633 + i * 9 + 2]), + StartPSN = (uint)((response[1633 + i * 9 + 3] << 16) + (response[1633 + i * 9 + 4] << 8) + + response[1633 + i * 9 + 5]), + EndPSN = (uint)((response[1633 + i * 9 + 6] << 16) + (response[1633 + i * 9 + 7] << 8) + + response[1633 + i * 9 + 8]) }; - for(int i = 0; i < 23; i++) + for(var i = 0; i < 23; i++) ss.ExtentsCopy[i] = new SecuritySectorExtent { - Unknown = (uint)((response[1840 + (i * 9) + 0] << 16) + (response[1840 + (i * 9) + 1] << 8) + - response[1840 + (i * 9) + 2]), - StartPSN = (uint)((response[1840 + (i * 9) + 3] << 16) + (response[1840 + (i * 9) + 4] << 8) + - response[1840 + (i * 9) + 5]), - EndPSN = (uint)((response[1840 + (i * 9) + 6] << 16) + (response[1840 + (i * 9) + 7] << 8) + - response[1840 + (i * 9) + 8]) + Unknown = (uint)((response[1840 + i * 9 + 0] << 16) + (response[1840 + i * 9 + 1] << 8) + + response[1840 + i * 9 + 2]), + StartPSN = (uint)((response[1840 + i * 9 + 3] << 16) + (response[1840 + i * 9 + 4] << 8) + + response[1840 + i * 9 + 5]), + EndPSN = (uint)((response[1840 + i * 9 + 6] << 16) + (response[1840 + i * 9 + 7] << 8) + + response[1840 + i * 9 + 8]) }; return ss; @@ -166,13 +165,11 @@ public static class SS break; case DiskCategory.DVDPRDL: - sb.AppendFormat(categorySentence, sizeString, "Xbox 360 Game Disc", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(categorySentence, sizeString, "Xbox 360 Game Disc", decoded.PartVersion).AppendLine(); break; default: - sb.AppendFormat(categorySentence, sizeString, "unknown disc type", decoded.PartVersion). - AppendLine(); + sb.AppendFormat(categorySentence, sizeString, "unknown disc type", decoded.PartVersion).AppendLine(); break; } @@ -309,7 +306,7 @@ public static class SS sb.AppendFormat("\tResponse value: 0x{0:X8}", entry.ResponseValue).AppendLine(); } - for(int i = 0; i < 16; i++) + for(var i = 0; i < 16; i++) sb.AppendFormat("Extent starts at PSN {0:X6}h and ends at PSN {1:X6}h", decoded.Extents[i].StartPSN, decoded.Extents[i].EndPSN).AppendLine();