mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-11-18 02:11:57 +00:00
start new editorconfig: file namespaces and use collection expressions
This commit is contained in:
738
.editorconfig
738
.editorconfig
@@ -12,6 +12,7 @@
|
||||
root = true
|
||||
|
||||
# All Files
|
||||
# Don't use tabs for indentation.
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
@@ -19,6 +20,17 @@ indent_size = 4
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
# Microsoft .NET properties
|
||||
csharp_using_directive_placement = outside_namespace:silent
|
||||
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
|
||||
dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none
|
||||
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
|
||||
|
||||
|
||||
# Standard properties
|
||||
insert_final_newline = true
|
||||
|
||||
##########################################
|
||||
# File Extension Settings
|
||||
##########################################
|
||||
@@ -68,501 +80,307 @@ indent_style = tab
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/configuration-options#scope
|
||||
##########################################
|
||||
|
||||
[*.{cs,csx,cake,vb,vbx}]
|
||||
# Default Severity for all .NET Code Style rules below
|
||||
dotnet_analyzer_diagnostic.severity = silent
|
||||
# Xml project files
|
||||
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
|
||||
indent_size = 2
|
||||
space_after_last_pi_attribute = false
|
||||
# Xml config files
|
||||
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
|
||||
indent_size = 2
|
||||
space_after_last_pi_attribute = false
|
||||
|
||||
##########################################
|
||||
# File Header (Uncomment to support file headers)
|
||||
# https://docs.microsoft.com/visualstudio/ide/reference/add-file-header
|
||||
##########################################
|
||||
# JSON files
|
||||
[*.json]
|
||||
indent_size = 2
|
||||
|
||||
# [*.{cs,csx,cake,vb,vbx}]
|
||||
# file_header_template = <copyright file="{fileName}" company="PROJECT-AUTHOR">\n© PROJECT-AUTHOR\n</copyright>
|
||||
|
||||
# SA1636: File header copyright text should match
|
||||
# Justification: .editorconfig supports file headers. If this is changed to a value other than "none", a stylecop.json file will need to added to the project.
|
||||
# dotnet_diagnostic.SA1636.severity = none
|
||||
|
||||
##########################################
|
||||
# .NET Language Conventions
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions
|
||||
##########################################
|
||||
|
||||
# .NET Code Style Settings
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#net-code-style-settings
|
||||
[*.{cs,csx,cake,vb,vbx}]
|
||||
# "this." and "Me." qualifiers
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#this-and-me
|
||||
#dotnet_style_qualification_for_field = true:warning
|
||||
#dotnet_style_qualification_for_property = true:warning
|
||||
#dotnet_style_qualification_for_method = true:warning
|
||||
#dotnet_style_qualification_for_event = true:warning
|
||||
# Language keywords instead of framework type names for type references
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#language-keywords
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
|
||||
dotnet_style_predefined_type_for_member_access = true:warning
|
||||
# Modifier preferences
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#normalize-modifiers
|
||||
dotnet_style_require_accessibility_modifiers = always:warning
|
||||
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning
|
||||
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:warning
|
||||
dotnet_style_readonly_field = true:warning
|
||||
# Parentheses preferences
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#parentheses-preferences
|
||||
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:suggestion
|
||||
# Expression-level preferences
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-level-preferences
|
||||
dotnet_style_object_initializer = true:warning
|
||||
dotnet_style_collection_initializer = true:warning
|
||||
dotnet_style_explicit_tuple_names = true:warning
|
||||
dotnet_style_prefer_inferred_tuple_names = true:warning
|
||||
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
|
||||
dotnet_style_prefer_auto_properties = true:warning
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
|
||||
dotnet_style_prefer_conditional_expression_over_assignment = false:suggestion
|
||||
dotnet_diagnostic.IDE0045.severity = suggestion
|
||||
dotnet_style_prefer_conditional_expression_over_return = false:suggestion
|
||||
dotnet_diagnostic.IDE0046.severity = suggestion
|
||||
dotnet_style_prefer_compound_assignment = true:warning
|
||||
# Null-checking preferences
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#null-checking-preferences
|
||||
dotnet_style_coalesce_expression = true:warning
|
||||
dotnet_style_null_propagation = true:warning
|
||||
# Parameter preferences
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#parameter-preferences
|
||||
dotnet_code_quality_unused_parameters = all:warning
|
||||
# More style options (Undocumented)
|
||||
# https://github.com/MicrosoftDocs/visualstudio-docs/issues/3641
|
||||
dotnet_style_operator_placement_when_wrapping = end_of_line
|
||||
# https://github.com/dotnet/roslyn/pull/40070
|
||||
dotnet_style_prefer_simplified_interpolation = true:warning
|
||||
|
||||
# C# Code Style Settings
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#c-code-style-settings
|
||||
[*.{cs,csx,cake}]
|
||||
# Implicit and explicit types
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#implicit-and-explicit-types
|
||||
csharp_style_var_for_built_in_types = true:warning
|
||||
csharp_style_var_when_type_is_apparent = true:warning
|
||||
csharp_style_var_elsewhere = true:warning
|
||||
# Expression-bodied members
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-bodied-members
|
||||
csharp_style_expression_bodied_methods = true:warning
|
||||
csharp_style_expression_bodied_constructors = true:warning
|
||||
csharp_style_expression_bodied_operators = true:warning
|
||||
csharp_style_expression_bodied_properties = true:warning
|
||||
csharp_style_expression_bodied_indexers = true:warning
|
||||
csharp_style_expression_bodied_accessors = true:warning
|
||||
csharp_style_expression_bodied_lambdas = true:warning
|
||||
csharp_style_expression_bodied_local_functions = true:warning
|
||||
# Pattern matching
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#pattern-matching
|
||||
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
|
||||
csharp_style_pattern_matching_over_as_with_null_check = true:warning
|
||||
# Inlined variable declarations
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#inlined-variable-declarations
|
||||
csharp_style_inlined_variable_declaration = true:warning
|
||||
# Expression-level preferences
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-level-preferences
|
||||
csharp_prefer_simple_default_expression = true:warning
|
||||
# "Null" checking preferences
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#c-null-checking-preferences
|
||||
csharp_style_throw_expression = true:warning
|
||||
csharp_style_conditional_delegate_call = true:warning
|
||||
# Code block preferences
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#code-block-preferences
|
||||
csharp_prefer_braces = true:warning
|
||||
# Unused value preferences
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#unused-value-preferences
|
||||
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
|
||||
dotnet_diagnostic.IDE0058.severity = suggestion
|
||||
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
|
||||
dotnet_diagnostic.IDE0059.severity = suggestion
|
||||
# Index and range preferences
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#index-and-range-preferences
|
||||
csharp_style_prefer_index_operator = true:warning
|
||||
csharp_style_prefer_range_operator = true:warning
|
||||
# Miscellaneous preferences
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#miscellaneous-preferences
|
||||
csharp_style_deconstructed_variable_declaration = true:warning
|
||||
csharp_style_pattern_local_over_anonymous_function = true:warning
|
||||
csharp_using_directive_placement = outside_namespace:warning
|
||||
csharp_prefer_static_local_function = true:warning
|
||||
csharp_prefer_simple_using_statement = true:suggestion
|
||||
dotnet_diagnostic.IDE0063.severity = suggestion
|
||||
|
||||
##########################################
|
||||
# .NET Formatting Conventions
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-code-style-settings-reference#formatting-conventions
|
||||
##########################################
|
||||
|
||||
# Organize usings
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#organize-using-directives
|
||||
# Code files
|
||||
[*.{cs,csx,vb,vbx}]
|
||||
# Sort using and Import directives with System.* appearing first
|
||||
dotnet_sort_system_directives_first = true
|
||||
# Newline options
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#new-line-options
|
||||
dotnet_separate_import_directive_groups = false
|
||||
|
||||
# Avoid "this." and "Me." if not necessary
|
||||
dotnet_style_qualification_for_field = false:suggestion
|
||||
dotnet_style_qualification_for_property = false:suggestion
|
||||
dotnet_style_qualification_for_method = false:suggestion
|
||||
dotnet_style_qualification_for_event = false:suggestion
|
||||
|
||||
# Use language keywords instead of framework type names for type references
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
|
||||
dotnet_style_predefined_type_for_member_access = true:suggestion
|
||||
# Parentheses preferences
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:silent
|
||||
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:silent
|
||||
dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:silent
|
||||
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
|
||||
|
||||
# Modifier preferences
|
||||
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
|
||||
dotnet_style_readonly_field = true:suggestion
|
||||
|
||||
# Expression-level preferences
|
||||
dotnet_style_object_initializer = true:suggestion
|
||||
dotnet_style_collection_initializer = true:suggestion
|
||||
dotnet_style_coalesce_expression = true:suggestion
|
||||
dotnet_style_null_propagation = true:suggestion
|
||||
dotnet_style_explicit_tuple_names = true:suggestion
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
|
||||
dotnet_style_prefer_inferred_tuple_names = true:suggestion
|
||||
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
|
||||
dotnet_style_prefer_auto_properties = true:warning
|
||||
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
|
||||
dotnet_style_prefer_conditional_expression_over_return = true:silent
|
||||
|
||||
|
||||
# CSharp code style settings:
|
||||
[*.cs]
|
||||
# Prefer "var" everywhere
|
||||
csharp_style_var_elsewhere = false:none
|
||||
csharp_style_var_for_built_in_types = false:none
|
||||
csharp_style_var_when_type_is_apparent = false:none
|
||||
|
||||
# Prefer method-like constructs to have a block body
|
||||
csharp_style_expression_bodied_methods = true:suggestion
|
||||
csharp_style_expression_bodied_constructors = false:suggestion
|
||||
csharp_style_expression_bodied_operators = true:suggestion
|
||||
|
||||
# Prefer property-like constructs to have an expression-body
|
||||
csharp_style_expression_bodied_properties = true:suggestion
|
||||
csharp_style_expression_bodied_indexers = true:suggestion
|
||||
csharp_style_expression_bodied_accessors = true:suggestion
|
||||
|
||||
# Suggest more modern language features when available
|
||||
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
|
||||
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
|
||||
csharp_style_inlined_variable_declaration = true:suggestion
|
||||
csharp_style_throw_expression = true:suggestion
|
||||
csharp_style_conditional_delegate_call = true:suggestion
|
||||
csharp_style_namespace_declarations = file_scoped
|
||||
|
||||
# Newline settings
|
||||
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
|
||||
# Indentation options
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#indentation-options
|
||||
csharp_indent_case_contents = true
|
||||
csharp_indent_switch_labels = true
|
||||
csharp_indent_labels = no_change
|
||||
csharp_indent_block_contents = true
|
||||
csharp_indent_braces = false
|
||||
csharp_indent_case_contents_when_block = false
|
||||
# Spacing options
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#spacing-options
|
||||
|
||||
# Space preferences
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = true
|
||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = false
|
||||
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_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_name_and_open_parenthesis = false
|
||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_after_comma = true
|
||||
csharp_space_before_comma = false
|
||||
csharp_space_after_dot = false
|
||||
csharp_space_before_dot = false
|
||||
csharp_space_after_semicolon_in_for_statement = true
|
||||
csharp_space_before_semicolon_in_for_statement = false
|
||||
csharp_space_around_declaration_statements = false
|
||||
csharp_space_before_open_square_brackets = false
|
||||
csharp_space_between_empty_square_brackets = false
|
||||
csharp_space_between_square_brackets = false
|
||||
# Wrapping options
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#wrap-options
|
||||
csharp_preserve_single_line_statements = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
|
||||
# Wrapping preferences
|
||||
csharp_preserve_single_line_statements = true
|
||||
csharp_preserve_single_line_blocks = true
|
||||
|
||||
csharp_style_namespace_declarations = file_scoped
|
||||
|
||||
##########################################
|
||||
# .NET Naming Conventions
|
||||
# https://docs.microsoft.com/visualstudio/ide/editorconfig-naming-conventions
|
||||
##########################################
|
||||
|
||||
[*.{cs,csx,cake,vb,vbx}]
|
||||
dotnet_diagnostic.CA1000.severity = suggestion
|
||||
dotnet_diagnostic.CA1001.severity = error
|
||||
dotnet_diagnostic.CA1018.severity = error
|
||||
dotnet_diagnostic.CA1036.severity = silent
|
||||
dotnet_diagnostic.CA1051.severity = suggestion
|
||||
dotnet_diagnostic.CA1068.severity = error
|
||||
dotnet_diagnostic.CA1069.severity = error
|
||||
dotnet_diagnostic.CA1304.severity = error
|
||||
dotnet_diagnostic.CA1305.severity = suggestion
|
||||
dotnet_diagnostic.CA1307.severity = suggestion
|
||||
dotnet_diagnostic.CA1309.severity = suggestion
|
||||
dotnet_diagnostic.CA1310.severity = error
|
||||
dotnet_diagnostic.CA1507.severity = suggestion
|
||||
dotnet_diagnostic.CA1513.severity = suggestion
|
||||
dotnet_diagnostic.CA1707.severity = suggestion
|
||||
dotnet_diagnostic.CA1708.severity = suggestion
|
||||
dotnet_diagnostic.CA1711.severity = suggestion
|
||||
dotnet_diagnostic.CA1716.severity = suggestion
|
||||
dotnet_diagnostic.CA1720.severity = suggestion
|
||||
dotnet_diagnostic.CA1725.severity = suggestion
|
||||
dotnet_diagnostic.CA1805.severity = suggestion
|
||||
dotnet_diagnostic.CA1816.severity = suggestion
|
||||
dotnet_diagnostic.CA1822.severity = suggestion
|
||||
dotnet_diagnostic.CA1825.severity = error
|
||||
dotnet_diagnostic.CA1826.severity = silent
|
||||
dotnet_diagnostic.CA1827.severity = error
|
||||
dotnet_diagnostic.CA1829.severity = suggestion
|
||||
dotnet_diagnostic.CA1834.severity = error
|
||||
dotnet_diagnostic.CA1845.severity = suggestion
|
||||
dotnet_diagnostic.CA1848.severity = suggestion
|
||||
dotnet_diagnostic.CA1852.severity = suggestion
|
||||
dotnet_diagnostic.CA1860.severity = silent
|
||||
dotnet_diagnostic.CA2016.severity = suggestion
|
||||
dotnet_diagnostic.CA2201.severity = error
|
||||
dotnet_diagnostic.CA2206.severity = error
|
||||
dotnet_diagnostic.CA2208.severity = error
|
||||
dotnet_diagnostic.CA2211.severity = error
|
||||
dotnet_diagnostic.CA2249.severity = error
|
||||
dotnet_diagnostic.CA2251.severity = error
|
||||
dotnet_diagnostic.CA2252.severity = none
|
||||
dotnet_diagnostic.CA2254.severity = suggestion
|
||||
# SYMBOL NAMING RULES
|
||||
# Copied from https://github.com/dotnet/roslyn/blob/main/.editorconfig
|
||||
# Adapted rules:
|
||||
# - Constants are ALL_UPPER
|
||||
# - Non-private fields are PascalCase
|
||||
|
||||
dotnet_diagnostic.CS0169.severity = error
|
||||
dotnet_diagnostic.CS0219.severity = error
|
||||
dotnet_diagnostic.CS0649.severity = suggestion
|
||||
dotnet_diagnostic.CS1998.severity = error
|
||||
dotnet_diagnostic.CS8602.severity = error
|
||||
dotnet_diagnostic.CS8604.severity = error
|
||||
dotnet_diagnostic.CS8618.severity = error
|
||||
dotnet_diagnostic.CS0618.severity = suggestion
|
||||
dotnet_diagnostic.CS1998.severity = error
|
||||
dotnet_diagnostic.CS4014.severity = error
|
||||
dotnet_diagnostic.CS8600.severity = error
|
||||
dotnet_diagnostic.CS8603.severity = error
|
||||
dotnet_diagnostic.CS8625.severity = error
|
||||
# Non-private fields are PascalCase
|
||||
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = warning
|
||||
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields
|
||||
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_field_style
|
||||
|
||||
dotnet_diagnostic.BL0005.severity = suggestion
|
||||
dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
|
||||
dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected
|
||||
|
||||
dotnet_diagnostic.MVC1000.severity = suggestion
|
||||
dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_case
|
||||
|
||||
dotnet_diagnostic.RZ10012.severity = error
|
||||
# Constants are ALL_UPPER
|
||||
dotnet_naming_rule.constants_should_be_all_upper.severity = warning
|
||||
dotnet_naming_rule.constants_should_be_all_upper.symbols = constants
|
||||
dotnet_naming_rule.constants_should_be_all_upper.style = constant_style
|
||||
|
||||
dotnet_diagnostic.IDE0004.severity = error # redundant cast
|
||||
dotnet_diagnostic.IDE0005.severity = suggestion
|
||||
dotnet_diagnostic.IDE0007.severity = error # Use var
|
||||
dotnet_diagnostic.IDE0011.severity = error # Use braces on if statements
|
||||
dotnet_diagnostic.IDE0010.severity = silent # populate switch
|
||||
dotnet_diagnostic.IDE0017.severity = suggestion # initialization can be simplified
|
||||
dotnet_diagnostic.IDE0021.severity = silent # expression body for constructors
|
||||
dotnet_diagnostic.IDE0022.severity = silent # expression body for methods
|
||||
dotnet_diagnostic.IDE0023.severity = suggestion # use expression body for operators
|
||||
dotnet_diagnostic.IDE0024.severity = silent # expression body for operators
|
||||
dotnet_diagnostic.IDE0025.severity = suggestion # use expression body for properties
|
||||
dotnet_diagnostic.IDE0027.severity = suggestion # Use expression body for accessors
|
||||
dotnet_diagnostic.IDE0028.severity = silent # expression body for accessors
|
||||
dotnet_diagnostic.IDE0032.severity = suggestion # Use auto property
|
||||
dotnet_diagnostic.IDE0033.severity = error # prefer tuple name
|
||||
dotnet_diagnostic.IDE0037.severity = suggestion # simplify anonymous type
|
||||
dotnet_diagnostic.IDE0040.severity = error # modifiers required
|
||||
dotnet_diagnostic.IDE0041.severity = error # simplify null
|
||||
dotnet_diagnostic.IDE0042.severity = error # deconstruct variable
|
||||
dotnet_diagnostic.IDE0044.severity = suggestion # make field only when possible
|
||||
dotnet_diagnostic.IDE0047.severity = suggestion # parameter name
|
||||
dotnet_diagnostic.IDE0051.severity = error # unused field
|
||||
dotnet_diagnostic.IDE0052.severity = error # unused member
|
||||
dotnet_diagnostic.IDE0053.severity = suggestion # lambda not needed
|
||||
dotnet_diagnostic.IDE0055.severity = suggestion # Fix formatting
|
||||
dotnet_diagnostic.IDE0057.severity = suggestion # substring can be simplified
|
||||
dotnet_diagnostic.IDE0060.severity = suggestion # unused parameters
|
||||
dotnet_diagnostic.IDE0061.severity = suggestion # local expression body
|
||||
dotnet_diagnostic.IDE0062.severity = suggestion # local to static
|
||||
dotnet_diagnostic.IDE0063.severity = error # simplify using
|
||||
dotnet_diagnostic.IDE0066.severity = suggestion # switch expression
|
||||
dotnet_diagnostic.IDE0072.severity = suggestion # Populate switch - forces population of all cases even when default specified
|
||||
dotnet_diagnostic.IDE0078.severity = suggestion # use pattern matching
|
||||
dotnet_diagnostic.IDE0090.severity = suggestion # new can be simplified
|
||||
dotnet_diagnostic.IDE0130.severity = suggestion # namespace folder structure
|
||||
dotnet_diagnostic.IDE0160.severity = silent # Use block namespaces ARE NOT required
|
||||
dotnet_diagnostic.IDE0161.severity = error # Please use file namespaces
|
||||
dotnet_diagnostic.IDE0200.severity = suggestion # lambda not needed
|
||||
dotnet_diagnostic.IDE1006.severity = suggestion # Naming rule violation: These words cannot contain lower case characters
|
||||
dotnet_diagnostic.IDE0260.severity = suggestion # Use pattern matching
|
||||
dotnet_diagnostic.IDE0270.severity = suggestion # Null check simplifcation
|
||||
dotnet_diagnostic.IDE0290.severity = error # Primary Constructor
|
||||
dotnet_diagnostic.IDE0300.severity = suggestion # Collection
|
||||
dotnet_diagnostic.IDE0305.severity = suggestion # Collection ToList
|
||||
dotnet_naming_symbols.constants.applicable_kinds = field, local
|
||||
dotnet_naming_symbols.constants.required_modifiers = const
|
||||
|
||||
dotnet_diagnostic.NX0001.severity = error
|
||||
dotnet_diagnostic.NX0002.severity = silent
|
||||
dotnet_diagnostic.NX0003.severity = silent
|
||||
dotnet_naming_style.constant_style.capitalization = all_upper
|
||||
|
||||
##########################################
|
||||
# Styles
|
||||
##########################################
|
||||
# Private static fields are camelCase and start with s_
|
||||
dotnet_naming_rule.static_fields_should_be_camel_case.severity = warning
|
||||
dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields
|
||||
dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style
|
||||
|
||||
dotnet_naming_symbols.static_fields.applicable_accessibilities = private
|
||||
dotnet_naming_symbols.static_fields.applicable_kinds = field
|
||||
dotnet_naming_symbols.static_fields.required_modifiers = static
|
||||
|
||||
dotnet_naming_style.static_field_style.capitalization = camel_case
|
||||
dotnet_naming_style.static_field_style.required_prefix = s_
|
||||
|
||||
|
||||
# Instance fields are camelCase and start with _
|
||||
dotnet_naming_rule.instance_fields_should_be_camel_case.severity = warning
|
||||
dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields
|
||||
dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style
|
||||
|
||||
dotnet_naming_symbols.instance_fields.applicable_kinds = field
|
||||
|
||||
dotnet_naming_style.instance_field_style.capitalization = camel_case
|
||||
dotnet_naming_style.instance_field_style.required_prefix = _
|
||||
|
||||
# Locals and parameters are camelCase
|
||||
dotnet_naming_rule.locals_should_be_camel_case.severity = warning
|
||||
dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters
|
||||
dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style
|
||||
|
||||
dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local
|
||||
|
||||
# camel_case_style - Define the camelCase style
|
||||
dotnet_naming_style.camel_case_style.capitalization = camel_case
|
||||
# pascal_case_style - Define the PascalCase style
|
||||
|
||||
# Local functions are PascalCase
|
||||
dotnet_naming_rule.local_functions_should_be_pascal_case.severity = warning
|
||||
dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions
|
||||
dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style
|
||||
|
||||
dotnet_naming_symbols.local_functions.applicable_kinds = local_function
|
||||
|
||||
dotnet_naming_style.local_function_style.capitalization = pascal_case
|
||||
|
||||
# By default, name items with PascalCase
|
||||
dotnet_naming_rule.members_should_be_pascal_case.severity = warning
|
||||
dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members
|
||||
dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style
|
||||
|
||||
dotnet_naming_symbols.all_members.applicable_kinds = *
|
||||
|
||||
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
|
||||
# constant_case - Define the CONSTANT_CASE style
|
||||
dotnet_naming_style.constant_case.capitalization = all_upper
|
||||
dotnet_naming_style.constant_case.word_separator = _
|
||||
# first_upper_style - The first character must start with an upper-case character
|
||||
dotnet_naming_style.first_upper_style.capitalization = first_word_upper
|
||||
# prefix_interface_with_i_style - Interfaces must be PascalCase and the first character of an interface must be an 'I'
|
||||
dotnet_naming_style.prefix_interface_with_i_style.capitalization = pascal_case
|
||||
dotnet_naming_style.prefix_interface_with_i_style.required_prefix = I
|
||||
# prefix_type_parameters_with_t_style - Generic Type Parameters must be PascalCase and the first character must be a 'T'
|
||||
dotnet_naming_style.prefix_type_parameters_with_t_style.capitalization = pascal_case
|
||||
dotnet_naming_style.prefix_type_parameters_with_t_style.required_prefix = T
|
||||
# disallowed_style - Anything that has this style applied is marked as disallowed
|
||||
dotnet_naming_style.disallowed_style.capitalization = pascal_case
|
||||
dotnet_naming_style.disallowed_style.required_prefix = ____RULE_VIOLATION____
|
||||
dotnet_naming_style.disallowed_style.required_suffix = ____RULE_VIOLATION____
|
||||
# internal_error_style - This style should never occur... if it does, it indicates a bug in file or in the parser using the file
|
||||
dotnet_naming_style.internal_error_style.capitalization = pascal_case
|
||||
dotnet_naming_style.internal_error_style.required_prefix = ____INTERNAL_ERROR____
|
||||
dotnet_naming_style.internal_error_style.required_suffix = ____INTERNAL_ERROR____
|
||||
|
||||
# prefix_interface_with_i_style - Interfaces must be PascalCase and the first character of an interface must be an 'I'
|
||||
dotnet_naming_style.underscore_camel_case_style.capitalization = camel_case
|
||||
dotnet_naming_style.underscore_camel_case_style.required_prefix = _
|
||||
|
||||
##########################################
|
||||
# .NET Design Guideline Field Naming Rules
|
||||
# Naming rules for fields follow the .NET Framework design guidelines
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/index
|
||||
##########################################
|
||||
|
||||
# All public/protected/protected_internal constant fields must be constant_case
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/field
|
||||
dotnet_naming_symbols.public_protected_constant_fields_group.applicable_accessibilities = public, protected, protected_internal
|
||||
dotnet_naming_symbols.public_protected_constant_fields_group.required_modifiers = const
|
||||
dotnet_naming_symbols.public_protected_constant_fields_group.applicable_kinds = field
|
||||
dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.symbols = public_protected_constant_fields_group
|
||||
dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.style = constant_case
|
||||
dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.severity = warning
|
||||
|
||||
# All public/protected/protected_internal static readonly fields must be constant_case
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/field
|
||||
dotnet_naming_symbols.public_protected_static_readonly_fields_group.applicable_accessibilities = public, protected, protected_internal
|
||||
dotnet_naming_symbols.public_protected_static_readonly_fields_group.required_modifiers = static, readonly
|
||||
dotnet_naming_symbols.public_protected_static_readonly_fields_group.applicable_kinds = field
|
||||
dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.symbols = public_protected_static_readonly_fields_group
|
||||
dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.style = constant_case
|
||||
dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.severity = warning
|
||||
|
||||
# No other public/protected/protected_internal fields are allowed
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/field
|
||||
dotnet_naming_symbols.other_public_protected_fields_group.applicable_accessibilities = public, protected, protected_internal
|
||||
dotnet_naming_symbols.other_public_protected_fields_group.applicable_kinds = field
|
||||
dotnet_naming_rule.other_public_protected_fields_disallowed_rule.symbols = other_public_protected_fields_group
|
||||
dotnet_naming_rule.other_public_protected_fields_disallowed_rule.style = disallowed_style
|
||||
dotnet_naming_rule.other_public_protected_fields_disallowed_rule.severity = error
|
||||
|
||||
##########################################
|
||||
# StyleCop Field Naming Rules
|
||||
# Naming rules for fields follow the StyleCop analyzers
|
||||
# This does not override any rules using disallowed_style above
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers
|
||||
##########################################
|
||||
|
||||
# All constant fields must be constant_case
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1303.md
|
||||
dotnet_naming_symbols.stylecop_constant_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected, private
|
||||
dotnet_naming_symbols.stylecop_constant_fields_group.required_modifiers = const
|
||||
dotnet_naming_symbols.stylecop_constant_fields_group.applicable_kinds = field
|
||||
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.symbols = stylecop_constant_fields_group
|
||||
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.style = constant_case
|
||||
dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.severity = warning
|
||||
|
||||
# All static readonly fields must be constant_case
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1311.md
|
||||
dotnet_naming_symbols.stylecop_static_readonly_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected, private
|
||||
dotnet_naming_symbols.stylecop_static_readonly_fields_group.required_modifiers = static, readonly
|
||||
dotnet_naming_symbols.stylecop_static_readonly_fields_group.applicable_kinds = field
|
||||
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.symbols = stylecop_static_readonly_fields_group
|
||||
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.style = constant_case
|
||||
dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.severity = warning
|
||||
|
||||
# No non-private instance fields are allowed
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1401.md
|
||||
dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected
|
||||
dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_kinds = field
|
||||
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.symbols = stylecop_fields_must_be_private_group
|
||||
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.style = disallowed_style
|
||||
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.severity = error
|
||||
|
||||
# Private fields must be camelCase
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1306.md
|
||||
dotnet_naming_symbols.stylecop_private_fields_group.applicable_accessibilities = private
|
||||
dotnet_naming_symbols.stylecop_private_fields_group.applicable_kinds = field
|
||||
dotnet_naming_rule.stylecop_private_fields_must_be_camel_case_rule.symbols = stylecop_private_fields_group
|
||||
dotnet_naming_rule.stylecop_private_fields_must_be_camel_case_rule.style = underscore_camel_case_style
|
||||
dotnet_naming_rule.stylecop_private_fields_must_be_camel_case_rule.severity = warning
|
||||
|
||||
# Local variables must be camelCase
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1312.md
|
||||
dotnet_naming_symbols.stylecop_local_fields_group.applicable_accessibilities = local
|
||||
dotnet_naming_symbols.stylecop_local_fields_group.applicable_kinds = local
|
||||
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.symbols = stylecop_local_fields_group
|
||||
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.style = camel_case_style
|
||||
dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.severity = warning
|
||||
|
||||
# This rule should never fire. However, it's included for at least two purposes:
|
||||
# First, it helps to understand, reason about, and root-case certain types of issues, such as bugs in .editorconfig parsers.
|
||||
# Second, it helps to raise immediate awareness if a new field type is added (as occurred recently in C#).
|
||||
dotnet_naming_symbols.sanity_check_uncovered_field_case_group.applicable_accessibilities = *
|
||||
dotnet_naming_symbols.sanity_check_uncovered_field_case_group.applicable_kinds = field
|
||||
dotnet_naming_rule.sanity_check_uncovered_field_case_rule.symbols = sanity_check_uncovered_field_case_group
|
||||
dotnet_naming_rule.sanity_check_uncovered_field_case_rule.style = internal_error_style
|
||||
dotnet_naming_rule.sanity_check_uncovered_field_case_rule.severity = error
|
||||
|
||||
|
||||
##########################################
|
||||
# Other Naming Rules
|
||||
##########################################
|
||||
# Analyzer settings
|
||||
dotnet_analyzer_diagnostic.category-Style.severity = warning # All rules will use this severity unless overriden
|
||||
dotnet_diagnostic.ide0055.severity = none # Formatting rule: Incompatible with CSharpier
|
||||
dotnet_diagnostic.ide0007.severity = none # Use var instead of explicit type: Preference
|
||||
dotnet_diagnostic.ide0009.severity = none # Add this or Me qualification: Preference
|
||||
dotnet_diagnostic.ide0200.severity = none # Remove unnecessary lambda expression: may be performance reasons not to
|
||||
dotnet_diagnostic.ide0058.severity = none # Remove unnecessary expression value: Subjective
|
||||
dotnet_diagnostic.ide0010.severity = none # Add missing cases to switch statement: Too verbose
|
||||
dotnet_diagnostic.ide0200.severity = none # Remove unnecessary lambda expression: may be performance reasons not to
|
||||
dotnet_diagnostic.ide0058.severity = none # Remove unnecessary expression value: Subjective
|
||||
dotnet_diagnostic.ide0305.severity = none # Use collection expression for fluent: Can obfuscate intent
|
||||
dotnet_diagnostic.ide0001.severity = suggestion # Name can be simplified: Non enforceable in build
|
||||
dotnet_diagnostic.ide0046.severity = suggestion # Use conditional expression for return: Subjective
|
||||
dotnet_diagnostic.ide0045.severity = suggestion # Use conditional expression for assignment: Subjective
|
||||
dotnet_diagnostic.ide0078.severity = suggestion # Use pattern matching: Subjective
|
||||
dotnet_diagnostic.ide0260.severity = suggestion # Use pattern matching: Subjective
|
||||
dotnet_diagnostic.ide0022.severity = suggestion # Use expression body for method: Subjective
|
||||
dotnet_diagnostic.ide0061.severity = suggestion # Use expression body for local functions: Subjective
|
||||
dotnet_diagnostic.ide0063.severity = suggestion # Using directive can be simplified
|
||||
dotnet_diagnostic.ide0066.severity = suggestion # Use switch expression: Subjective
|
||||
dotnet_diagnostic.ide0029.severity = suggestion # Null check can be simplified: Subjective
|
||||
dotnet_diagnostic.ide0030.severity = suggestion # Null check can be simplified: Subjective
|
||||
dotnet_diagnostic.ide0270.severity = suggestion # Null check can be simplified: Subjective
|
||||
dotnet_diagnostic.ide0042.severity = suggestion # Deconstruct variable declaration: Subjective
|
||||
dotnet_diagnostic.ide0039.severity = suggestion # Use local function instead of lambda: Subjective
|
||||
dotnet_diagnostic.ide0029.severity = suggestion # Null check can be simplified: Subjective
|
||||
dotnet_diagnostic.ide0030.severity = suggestion # Null check can be simplified: Subjective
|
||||
dotnet_diagnostic.ide0270.severity = suggestion # Null check can be simplified: Subjective
|
||||
dotnet_diagnostic.ide0042.severity = suggestion # Deconstruct variable declaration: Subjective
|
||||
dotnet_diagnostic.ide0028.severity = suggestion # Use collection initializers: Subjective
|
||||
dotnet_diagnostic.ide0072.severity = suggestion # Populate switch statement: Subjective
|
||||
dotnet_diagnostic.ide0074.severity = suggestion # Use compound assignment: Subjective
|
||||
dotnet_diagnostic.ide0300.severity = suggestion # Use collection expression for array: Subjective, maybe aspirational
|
||||
dotnet_diagnostic.ide0290.severity = suggestion # primary constructors: subjective, and readonly properties are not a thing
|
||||
dotnet_diagnostic.ide0290.severity = suggestion # Use primary constructor: Subjective
|
||||
dotnet_diagnostic.ide0037.severity = suggestion # Use inferred member names: Sometimes its nice to be explicit
|
||||
dotnet_diagnostic.ide0301.severity = suggestion # Use collection expression for empty: Subjective, intent
|
||||
dotnet_diagnostic.ide0021.severity = suggestion # Use expression body for constructors : Subjective
|
||||
dotnet_diagnostic.ide0090.severity = suggestion # Simplify new expression : Subjective
|
||||
|
||||
# All of the following must be PascalCase:
|
||||
# - Namespaces
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-namespaces
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1300.md
|
||||
# - Classes and Enumerations
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces
|
||||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1300.md
|
||||
# - Delegates
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces#names-of-common-types
|
||||
# - Constructors, Properties, Events, Methods
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-type-members
|
||||
dotnet_naming_symbols.element_group.applicable_kinds = namespace, class, enum, struct, delegate, event, method, property
|
||||
dotnet_naming_rule.element_rule.symbols = element_group
|
||||
dotnet_naming_rule.element_rule.style = pascal_case_style
|
||||
dotnet_naming_rule.element_rule.severity = warning
|
||||
dotnet_diagnostic.ide0047.severity = suggestion # Parentheses preferences: IDEs don't properly pick it up
|
||||
dotnet_diagnostic.ide0130.severity = suggestion # Namespace does not match folder structure : Aspirational
|
||||
dotnet_diagnostic.ide1006.severity = suggestion # Naming rule violation : Aspirational
|
||||
|
||||
# Interfaces use PascalCase and are prefixed with uppercase 'I'
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces
|
||||
dotnet_naming_symbols.interface_group.applicable_kinds = interface
|
||||
dotnet_naming_rule.interface_rule.symbols = interface_group
|
||||
dotnet_naming_rule.interface_rule.style = prefix_interface_with_i_style
|
||||
dotnet_naming_rule.interface_rule.severity = warning
|
||||
# Maintainability rules
|
||||
dotnet_diagnostic.ca1501.severity = warning # Avoid excessive inheritance
|
||||
dotnet_diagnostic.ca1502.severity = warning # Avoid excessive complexity
|
||||
dotnet_diagnostic.ca1505.severity = warning # Avoid unmaintainable code
|
||||
dotnet_diagnostic.ca1506.severity = warning # Avoid excessive class coupling
|
||||
dotnet_diagnostic.ca1507.severity = warning # Use nameof in place of string
|
||||
dotnet_diagnostic.ca1508.severity = warning # Avoid dead conditional code
|
||||
dotnet_diagnostic.ca1509.severity = warning # Invalid entry in code metrics configuration file
|
||||
dotnet_diagnostic.ca1861.severity = suggestion # Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)
|
||||
|
||||
# Generics Type Parameters use PascalCase and are prefixed with uppercase 'T'
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces
|
||||
dotnet_naming_symbols.type_parameter_group.applicable_kinds = type_parameter
|
||||
dotnet_naming_rule.type_parameter_rule.symbols = type_parameter_group
|
||||
dotnet_naming_rule.type_parameter_rule.style = prefix_type_parameters_with_t_style
|
||||
dotnet_naming_rule.type_parameter_rule.severity = warning
|
||||
|
||||
# Function parameters use camelCase
|
||||
# https://docs.microsoft.com/dotnet/standard/design-guidelines/naming-parameters
|
||||
dotnet_naming_symbols.parameters_group.applicable_kinds = parameter
|
||||
dotnet_naming_rule.parameters_rule.symbols = parameters_group
|
||||
dotnet_naming_rule.parameters_rule.style = camel_case_style
|
||||
dotnet_naming_rule.parameters_rule.severity = warning
|
||||
# Performance rules
|
||||
dotnet_diagnostic.ca1849.severity = suggestion # Call async methods when in an async method: May decrease performance
|
||||
dotnet_diagnostic.ca1822.severity = suggestion # Mark member as static
|
||||
dotnet_diagnostic.ca1859.severity = suggestion # Use concrete types when possible for improved performance
|
||||
|
||||
##########################################
|
||||
# License
|
||||
##########################################
|
||||
# The following applies as to the .editorconfig file ONLY, and is
|
||||
# included below for reference, per the requirements of the license
|
||||
# corresponding to this .editorconfig file.
|
||||
# See: https://github.com/RehanSaeed/EditorConfig
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2017-2019 Muhammad Rehan Saeed
|
||||
# Copyright (c) 2019 Henry Gabryjelski
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any
|
||||
# person obtaining a copy of this software and associated
|
||||
# documentation files (the "Software"), to deal in the
|
||||
# Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute,
|
||||
# sublicense, and/or sell copies of the Software, and to permit
|
||||
# persons to whom the Software is furnished to do so, subject
|
||||
# to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
##########################################
|
||||
# Design rule
|
||||
dotnet_diagnostic.ca1002.severity = suggestion # Do not expose generic lists
|
||||
dotnet_diagnostic.ca1051.severity = warning # Do not declare visible instance fields
|
||||
dotnet_diagnostic.ca1056.severity = suggestion # URI properties should not be strings
|
||||
dotnet_diagnostic.ca1062.severity = none # Public method must check all parameters for null
|
||||
|
||||
# Naming
|
||||
dotnet_diagnostic.ca1707.severity = none # Remove underscores in names
|
||||
|
||||
# Usage
|
||||
dotnet_diagnostic.ca2227.severity = suggestion # Collection props should be read-only
|
||||
|
||||
dotnet_code_quality.ca1051.exclude_structs = true # CA1051 is excluded in structs
|
||||
dotnet_code_quality.dispose_ownership_transfer_at_constructor = true # CA2000 has a lot of false positives without this
|
||||
dotnet_code_quality.dispose_ownership_transfer_at_method_call = true # CA2000 has a lot of false positives without this
|
||||
dotnet_code_quality.dispose_analysis_kind = NonExceptionPathsOnlyNotDisposed # CA2000 has a lot of false positives without this
|
||||
|
||||
# NUnit
|
||||
dotnet_diagnostic.NUnit2001.severity = warning # Consider using Assert.That(expr, Is.False) instead of Assert.False(expr)
|
||||
dotnet_diagnostic.NUnit2002.severity = warning # Consider using Assert.That(expr, Is.False) instead of Assert.IsFalse(expr)
|
||||
dotnet_diagnostic.NUnit2003.severity = warning # Consider using Assert.That(expr, Is.True) instead of Assert.IsTrue(expr)
|
||||
dotnet_diagnostic.NUnit2004.severity = warning # Consider using Assert.That(expr, Is.True) instead of Assert.True(expr)
|
||||
dotnet_diagnostic.NUnit2005.severity = warning # Consider using Assert.That(actual, Is.EqualTo(expected)) instead of Assert.AreEqual(expected, actual)
|
||||
dotnet_diagnostic.NUnit2006.severity = warning # Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of Assert.AreNotEqual(expected, actual)
|
||||
|
||||
dotnet_diagnostic.NUnit2010.severity = warning # Use EqualConstraint for better assertion messages in case of failure
|
||||
dotnet_diagnostic.NUnit2011.severity = warning # Use ContainsConstraint for better assertion messages in case of failure
|
||||
dotnet_diagnostic.NUnit2011.severity = warning # Use StartsWithConstraint for better assertion messages in case of failure
|
||||
dotnet_diagnostic.NUnit2011.severity = warning # Use EndsWithConstraint for better assertion messages in case of failure
|
||||
dotnet_diagnostic.NUnit2014.severity = warning # Use SomeItemsConstraint for better assertion messages in case of failure
|
||||
|
||||
dotnet_diagnostic.NUnit2015.severity = warning # Consider using Assert.That(actual, Is.SameAs(expected)) instead of Assert.AreSame(expected, actual)
|
||||
dotnet_diagnostic.NUnit2016.severity = warning # Consider using Assert.That(expr, Is.Null) instead of Assert.Null(expr)
|
||||
dotnet_diagnostic.NUnit2017.severity = warning # Consider using Assert.That(expr, Is.Null) instead of Assert.IsNull(expr)
|
||||
dotnet_diagnostic.NUnit2018.severity = warning # Consider using Assert.That(expr, Is.Not.Null) instead of Assert.NotNull(expr)
|
||||
dotnet_diagnostic.NUnit2028.severity = warning # Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of Assert.GreaterOrEqual(actual, expected)
|
||||
dotnet_diagnostic.NUnit2027.severity = warning # Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of Assert.Greater(actual, expected)
|
||||
dotnet_diagnostic.NUnit2029.severity = warning # Consider using Assert.That(actual, Is.LessThan(expected)) instead of Assert.Less(actual, expected)
|
||||
dotnet_diagnostic.NUnit2030.severity = warning # Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of Assert.LessOrEqual(actual, expected)
|
||||
dotnet_diagnostic.NUnit2031.severity = warning # Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of Assert.AreNotSame(expected, actual)
|
||||
dotnet_diagnostic.NUnit2032.severity = warning # Consider using Assert.That(expr, Is.Zero) instead of Assert.Zero(expr)
|
||||
dotnet_diagnostic.NUnit2033.severity = warning # Consider using Assert.That(expr, Is.Not.Zero) instead of Assert.NotZero(expr)
|
||||
dotnet_diagnostic.NUnit2034.severity = warning # Consider using Assert.That(expr, Is.NaN) instead of Assert.IsNaN(expr)
|
||||
dotnet_diagnostic.NUnit2035.severity = warning # Consider using Assert.That(collection, Is.Empty) instead of Assert.IsEmpty(collection)
|
||||
dotnet_diagnostic.NUnit2036.severity = warning # Consider using Assert.That(collection, Is.Not.Empty) instead of Assert.IsNotEmpty(collection)
|
||||
dotnet_diagnostic.NUnit2037.severity = warning # Consider using Assert.That(collection, Does.Contain(instance)) instead of Assert.Contains(instance, collection)
|
||||
dotnet_diagnostic.NUnit2038.severity = warning # Consider using Assert.That(actual, Is.InstanceOf(expected)) instead of Assert.IsInstanceOf(expected, actual)
|
||||
dotnet_diagnostic.NUnit2039.severity = warning # Consider using Assert.That(actual, Is.Not.InstanceOf(expected)) instead of Assert.IsNotInstanceOf(expected, actual)
|
||||
|
||||
[*.{appxmanifest,asax,ascx,aspx,axaml,build,c,c++,cc,cginc,compute,cp,cpp,cs,cshtml,cu,cuh,cxx,dtd,fs,fsi,fsscript,fsx,fx,fxh,h,hh,hlsl,hlsli,hlslinc,hpp,hxx,inc,inl,ino,ipp,ixx,master,ml,mli,mpp,mq4,mq5,mqh,nuspec,paml,razor,resw,resx,shader,skin,tpp,usf,ush,vb,xaml,xamlx,xoml,xsd}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
tab_width = 2
|
||||
|
||||
# Verify
|
||||
[*.{received,verified}.{json}]
|
||||
charset = utf-8-bom
|
||||
end_of_line = lf
|
||||
indent_size = unset
|
||||
indent_style = unset
|
||||
insert_final_newline = false
|
||||
tab_width = unset
|
||||
trim_trailing_whitespace = false
|
||||
@@ -3,14 +3,37 @@
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<AnalysisMode>Recommended</AnalysisMode>
|
||||
<WarningsAsErrors>true</WarningsAsErrors>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
|
||||
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<RunAnalyzersDuringLiveAnalysis>False</RunAnalyzersDuringLiveAnalysis>
|
||||
<RunAnalyzersDuringBuild>False</RunAnalyzersDuringBuild>
|
||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Analyers">
|
||||
<EnableNetAnalyzers>true</EnableNetAnalyzers>
|
||||
<AnalysisLevel>latest-AllEnabledByDefault</AnalysisLevel>
|
||||
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors>true</WarningsAsErrors>
|
||||
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
|
||||
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<NoWarn>
|
||||
<!--Disabled by design-->
|
||||
CA5399;CA1812;
|
||||
<!--XML comment-->
|
||||
CS1591;CS1573;
|
||||
<!-- Globalization rules -->
|
||||
CA1303;CA1304;CA1305;CA1307;CA1308;CA1309;CA1310;CA1311;
|
||||
<!-- Logging -->
|
||||
CA1848;CA1727;
|
||||
<!-- Others we don't want -->
|
||||
CA1815;CA1725;
|
||||
<!-- Naming things is hard enough -->
|
||||
CA1710;CA1711;CA1720;CA1724;
|
||||
<!-- Aspirational, slowly add -->
|
||||
CA1502;CA1716;NETSDK1206;IDE0017;IDE0040;IDE0044;IDE0051;IDE0052;IDE0060;IDE1006;IDE1007;IDE1033;IDE1036;IDE1040;IDE1041;IDE1045;IDE1050;IDE1051;IDE1055;IDE1060;IDE1063;IDE1070;IDE1071;IDE1075;IDE1080;IDE1090;CA1034;CA1051;CA1063;
|
||||
$(NoWarn)
|
||||
</NoWarn
|
||||
>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -92,4 +92,4 @@ Target(
|
||||
|
||||
Target("default", [Publish], () => Console.WriteLine("Done!"));
|
||||
|
||||
await RunTargetsAndExitAsync(args);
|
||||
await RunTargetsAndExitAsync(args).ConfigureAwait(false);
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if SUPPORTS_RUNTIME_INTRINSICS
|
||||
using System.Runtime.Intrinsics;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
@@ -108,9 +107,8 @@ internal static class Adler32 // From https://github.com/SixLabors/ImageSharp/bl
|
||||
|
||||
// The C# compiler emits this as a compile-time constant embedded in the PE file.
|
||||
private static ReadOnlySpan<byte> Tap1Tap2 =>
|
||||
new byte[]
|
||||
{
|
||||
32,
|
||||
[
|
||||
32,
|
||||
31,
|
||||
30,
|
||||
29,
|
||||
@@ -141,8 +139,8 @@ internal static class Adler32 // From https://github.com/SixLabors/ImageSharp/bl
|
||||
4,
|
||||
3,
|
||||
2,
|
||||
1, // tap2
|
||||
};
|
||||
1 // tap2
|
||||
];
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -37,8 +37,8 @@ public abstract class AbstractArchive<TEntry, TVolume> : IArchive, IArchiveExtra
|
||||
{
|
||||
Type = type;
|
||||
ReaderOptions = new();
|
||||
_lazyVolumes = new LazyReadOnlyCollection<TVolume>(Enumerable.Empty<TVolume>());
|
||||
_lazyEntries = new LazyReadOnlyCollection<TEntry>(Enumerable.Empty<TEntry>());
|
||||
_lazyVolumes = new LazyReadOnlyCollection<TVolume>([]);
|
||||
_lazyEntries = new LazyReadOnlyCollection<TEntry>([]);
|
||||
}
|
||||
|
||||
public ArchiveType Type { get; }
|
||||
|
||||
@@ -31,10 +31,10 @@ public abstract class AbstractWritableArchive<TEntry, TVolume>
|
||||
}
|
||||
}
|
||||
|
||||
private readonly List<TEntry> newEntries = new();
|
||||
private readonly List<TEntry> removedEntries = new();
|
||||
private readonly List<TEntry> newEntries = [];
|
||||
private readonly List<TEntry> removedEntries = [];
|
||||
|
||||
private readonly List<TEntry> modifiedEntries = new();
|
||||
private readonly List<TEntry> modifiedEntries = [];
|
||||
private bool hasModifications;
|
||||
private bool pauseRebuilding;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using SharpCompress.Readers;
|
||||
|
||||
namespace SharpCompress.Archives;
|
||||
|
||||
class AutoArchiveFactory : IArchiveFactory
|
||||
internal class AutoArchiveFactory : IArchiveFactory
|
||||
{
|
||||
public string Name => nameof(AutoArchiveFactory);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using SharpCompress.Common;
|
||||
using SharpCompress.Readers;
|
||||
|
||||
@@ -1,20 +1,6 @@
|
||||
namespace SharpCompress.Archives;
|
||||
|
||||
/// <summary>
|
||||
/// Decorator for <see cref="Factories.Factory"/> used to declare an archive format as able to create writeable archives
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Implemented by:<br/>
|
||||
/// <list type="table">
|
||||
/// <item><see cref="Factories.TarFactory"/></item>
|
||||
/// <item><see cref="Factories.ZipFactory"/></item>
|
||||
/// <item><see cref="Factories.GZipFactory"/></item>
|
||||
/// </list>
|
||||
public interface IWriteableArchiveFactory : Factories.IFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new, empty archive, ready to be written.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IWritableArchive CreateWriteableArchive();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using SharpCompress.Common;
|
||||
using SharpCompress.Common.Rar;
|
||||
using SharpCompress.Common.Rar.Headers;
|
||||
using SharpCompress.Compressors.Rar;
|
||||
using SharpCompress.Compressors.Rar.UnpackV2017;
|
||||
using SharpCompress.IO;
|
||||
using SharpCompress.Readers;
|
||||
using SharpCompress.Readers.Rar;
|
||||
@@ -16,7 +17,7 @@ public class RarArchive : AbstractArchive<RarArchiveEntry, RarVolume>
|
||||
{
|
||||
private bool _disposed;
|
||||
internal Lazy<IRarUnpack> UnpackV2017 { get; } =
|
||||
new(() => new Compressors.Rar.UnpackV2017.Unpack());
|
||||
new(() => new Unpack());
|
||||
internal Lazy<IRarUnpack> UnpackV1 { get; } = new(() => new Compressors.Rar.UnpackV1.Unpack());
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -32,7 +32,7 @@ public class RarArchiveEntry : RarEntry, IArchiveEntry
|
||||
|
||||
public IArchive Archive => archive;
|
||||
|
||||
internal override IEnumerable<FilePart> Parts => parts.Cast<FilePart>();
|
||||
internal override IEnumerable<FilePart> Parts => parts;
|
||||
|
||||
internal override FileHeader FileHeader => parts.First().FileHeader;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ internal static class RarArchiveEntryFactory
|
||||
if (!fp.FileHeader.IsSplitAfter)
|
||||
{
|
||||
yield return groupedParts;
|
||||
groupedParts = new List<RarFilePart>();
|
||||
groupedParts = [];
|
||||
}
|
||||
}
|
||||
if (groupedParts.Count > 0)
|
||||
|
||||
@@ -113,7 +113,7 @@ public class SevenZipArchive : AbstractArchive<SevenZipArchiveEntry, SevenZipVol
|
||||
protected override IEnumerable<SevenZipVolume> LoadVolumes(SourceStream sourceStream)
|
||||
{
|
||||
sourceStream.NotNull("SourceStream is null").LoadAllParts(); //request all streams
|
||||
return new SevenZipVolume(sourceStream, ReaderOptions, 0).AsEnumerable(); //simple single volume or split, multivolume not supported
|
||||
return new SevenZipVolume(sourceStream, ReaderOptions).AsEnumerable(); //simple single volume or split, multivolume not supported
|
||||
}
|
||||
|
||||
public static bool IsSevenZipFile(string filePath) => IsSevenZipFile(new FileInfo(filePath));
|
||||
@@ -139,7 +139,7 @@ public class SevenZipArchive : AbstractArchive<SevenZipArchiveEntry, SevenZipVol
|
||||
LoadFactory(stream);
|
||||
if (_database is null)
|
||||
{
|
||||
return Enumerable.Empty<SevenZipArchiveEntry>();
|
||||
return [];
|
||||
}
|
||||
var entries = new SevenZipArchiveEntry[_database._files.Count];
|
||||
for (var i = 0; i < _database._files.Count; i++)
|
||||
@@ -187,7 +187,7 @@ public class SevenZipArchive : AbstractArchive<SevenZipArchiveEntry, SevenZipVol
|
||||
}
|
||||
|
||||
private static ReadOnlySpan<byte> Signature =>
|
||||
new byte[] { (byte)'7', (byte)'z', 0xBC, 0xAF, 0x27, 0x1C };
|
||||
[(byte)'7', (byte)'z', 0xBC, 0xAF, 0x27, 0x1C];
|
||||
|
||||
private static bool SignatureMatch(Stream stream)
|
||||
{
|
||||
@@ -216,7 +216,7 @@ public class SevenZipArchive : AbstractArchive<SevenZipArchiveEntry, SevenZipVol
|
||||
private CFileItem? _currentItem;
|
||||
|
||||
internal SevenZipReader(ReaderOptions readerOptions, SevenZipArchive archive)
|
||||
: base(readerOptions, ArchiveType.SevenZip) => this._archive = archive;
|
||||
: base(readerOptions, ArchiveType.SevenZip) => _archive = archive;
|
||||
|
||||
public override SevenZipVolume Volume => _archive.Volumes.Single();
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ public class ZipArchive : AbstractWritableArchive<ZipArchiveEntry, ZipVolume>
|
||||
/// Constructor with a SourceStream able to handle FileInfo and Streams.
|
||||
/// </summary>
|
||||
/// <param name="sourceStream"></param>
|
||||
/// <param name="options"></param>
|
||||
internal ZipArchive(SourceStream sourceStream)
|
||||
: base(ArchiveType.Zip, sourceStream) =>
|
||||
headerFactory = new SeekableZipHeaderFactory(
|
||||
@@ -287,7 +286,7 @@ public class ZipArchive : AbstractWritableArchive<ZipArchiveEntry, ZipVolume>
|
||||
break;
|
||||
case ZipHeaderType.DirectoryEnd:
|
||||
{
|
||||
var bytes = ((DirectoryEndHeader)h).Comment ?? Array.Empty<byte>();
|
||||
var bytes = ((DirectoryEndHeader)h).Comment ?? [];
|
||||
vols.Last().Comment = ReaderOptions.ArchiveEncoding.Decode(bytes);
|
||||
yield break;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.Common.GZip;
|
||||
using SharpCompress.Common.Tar;
|
||||
|
||||
namespace SharpCompress.Common.Arc;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace SharpCompress.Common.Arc;
|
||||
@@ -18,7 +17,7 @@ public class ArcEntryHeader
|
||||
|
||||
public ArcEntryHeader(ArchiveEncoding archiveEncoding)
|
||||
{
|
||||
this.ArchiveEncoding = archiveEncoding;
|
||||
ArchiveEncoding = archiveEncoding;
|
||||
}
|
||||
|
||||
public ArcEntryHeader? ReadHeader(Stream stream)
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.Common.GZip;
|
||||
using SharpCompress.Common.Tar;
|
||||
using SharpCompress.Common.Tar.Headers;
|
||||
using SharpCompress.Common.Zip.Headers;
|
||||
using SharpCompress.Compressors.Lzw;
|
||||
using SharpCompress.Compressors.ArcLzw;
|
||||
using SharpCompress.Compressors.RLE90;
|
||||
using SharpCompress.Compressors.Squeezed;
|
||||
using SharpCompress.IO;
|
||||
@@ -51,7 +43,7 @@ public class ArcFilePart : FilePart
|
||||
compressedStream = new SqueezeStream(_stream, (int)Header.CompressedSize);
|
||||
break;
|
||||
case CompressionType.Crunched:
|
||||
compressedStream = new ArcLzwStream(_stream, (int)Header.CompressedSize, true);
|
||||
compressedStream = new ArcLzwStream(_stream, (int)Header.CompressedSize);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException(
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.Readers;
|
||||
|
||||
namespace SharpCompress.Common.Arc;
|
||||
|
||||
@@ -37,7 +37,7 @@ internal sealed class GZipFilePart : FilePart
|
||||
internal override string? FilePartName => _name;
|
||||
|
||||
internal override Stream GetCompressedStream() =>
|
||||
new DeflateStream(_stream, CompressionMode.Decompress, CompressionLevel.Default);
|
||||
new DeflateStream(_stream, CompressionMode.Decompress);
|
||||
|
||||
internal override Stream GetRawStream() => _stream;
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@ namespace SharpCompress.Common.Rar;
|
||||
|
||||
internal class CryptKey5 : ICryptKey
|
||||
{
|
||||
const int AES_256 = 256;
|
||||
const int DERIVED_KEY_LENGTH = 0x10;
|
||||
const int SHA256_DIGEST_SIZE = 32;
|
||||
private const int AES_256 = 256;
|
||||
private const int DERIVED_KEY_LENGTH = 0x10;
|
||||
private const int SHA256_DIGEST_SIZE = 32;
|
||||
|
||||
private string _password;
|
||||
private Rar5CryptoInfo _cryptoInfo;
|
||||
private byte[] _pswCheck = { };
|
||||
private byte[] _hashKey = { };
|
||||
private byte[] _pswCheck = [];
|
||||
private byte[] _hashKey = [];
|
||||
|
||||
public CryptKey5(string? password, Rar5CryptoInfo rar5CryptoInfo)
|
||||
{
|
||||
|
||||
@@ -49,9 +49,9 @@ internal class Rar5CryptoInfo
|
||||
|
||||
public int LG2Count = 0;
|
||||
|
||||
public byte[] InitV = { };
|
||||
public byte[] InitV = [];
|
||||
|
||||
public byte[] Salt = { };
|
||||
public byte[] Salt = [];
|
||||
|
||||
public byte[] PswCheck = { };
|
||||
public byte[] PswCheck = [];
|
||||
}
|
||||
|
||||
@@ -15,15 +15,15 @@ internal class ArchiveDatabase
|
||||
internal long _startPositionAfterHeader;
|
||||
internal long _dataStartPosition;
|
||||
|
||||
internal List<long> _packSizes = new();
|
||||
internal List<uint?> _packCrCs = new();
|
||||
internal List<CFolder> _folders = new();
|
||||
internal List<long> _packSizes = [];
|
||||
internal List<uint?> _packCrCs = [];
|
||||
internal List<CFolder> _folders = [];
|
||||
internal List<int> _numUnpackStreamsVector;
|
||||
internal List<CFileItem> _files = new();
|
||||
internal List<CFileItem> _files = [];
|
||||
|
||||
internal List<long> _packStreamStartPositions = new();
|
||||
internal List<int> _folderStartFileIndex = new();
|
||||
internal List<int> _fileIndexToFolderIndexMap = new();
|
||||
internal List<long> _packStreamStartPositions = [];
|
||||
internal List<int> _folderStartFileIndex = [];
|
||||
internal List<int> _fileIndexToFolderIndexMap = [];
|
||||
|
||||
internal IPasswordProvider PasswordProvider { get; }
|
||||
|
||||
|
||||
@@ -1387,7 +1387,7 @@ internal class ArchiveReader
|
||||
{
|
||||
internal int _fileIndex;
|
||||
internal int _folderIndex;
|
||||
internal List<bool> _extractStatuses = new();
|
||||
internal List<bool> _extractStatuses = [];
|
||||
|
||||
internal CExtractFolderInfo(int fileIndex, int folderIndex)
|
||||
{
|
||||
|
||||
@@ -6,11 +6,11 @@ namespace SharpCompress.Common.SevenZip;
|
||||
|
||||
internal class CFolder
|
||||
{
|
||||
internal List<CCoderInfo> _coders = new();
|
||||
internal List<CBindPair> _bindPairs = new();
|
||||
internal List<int> _packStreams = new();
|
||||
internal List<CCoderInfo> _coders = [];
|
||||
internal List<CBindPair> _bindPairs = [];
|
||||
internal List<int> _packStreams = [];
|
||||
internal int _firstPackStreamId;
|
||||
internal List<long> _unpackSizes = new();
|
||||
internal List<long> _unpackSizes = [];
|
||||
internal uint? _unpackCrc;
|
||||
|
||||
internal bool UnpackCrcDefined => _unpackCrc != null;
|
||||
|
||||
@@ -306,16 +306,16 @@ internal sealed class TarHeader
|
||||
}
|
||||
|
||||
private static readonly byte[] eightSpaces =
|
||||
{
|
||||
[
|
||||
(byte)' ',
|
||||
(byte)' ',
|
||||
(byte)' ',
|
||||
(byte)' ',
|
||||
(byte)' ',
|
||||
(byte)' ',
|
||||
(byte)' ',
|
||||
(byte)' ',
|
||||
(byte)' ',
|
||||
};
|
||||
(byte)' '
|
||||
];
|
||||
|
||||
internal static bool checkChecksum(byte[] buf)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ internal abstract class ZipFileEntry : ZipHeader
|
||||
protected ZipFileEntry(ZipHeaderType type, ArchiveEncoding archiveEncoding)
|
||||
: base(type)
|
||||
{
|
||||
Extra = new List<ExtraData>();
|
||||
Extra = [];
|
||||
ArchiveEncoding = archiveEncoding;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace SharpCompress.Common.Zip;
|
||||
internal class PkwareTraditionalEncryptionData
|
||||
{
|
||||
private static readonly CRC32 CRC32 = new();
|
||||
private readonly uint[] _keys = { 0x12345678, 0x23456789, 0x34567890 };
|
||||
private readonly uint[] _keys = [0x12345678, 0x23456789, 0x34567890];
|
||||
private readonly ArchiveEncoding _archiveEncoding;
|
||||
|
||||
private PkwareTraditionalEncryptionData(string password, ArchiveEncoding archiveEncoding)
|
||||
|
||||
@@ -113,7 +113,7 @@ internal sealed class SeekableZipHeaderFactory : ZipHeaderFactory
|
||||
? (int)stream.Length
|
||||
: MAX_SEARCH_LENGTH_FOR_EOCD;
|
||||
// We search for marker in reverse to find the first occurance
|
||||
byte[] needle = { 0x06, 0x05, 0x4b, 0x50 };
|
||||
byte[] needle = [0x06, 0x05, 0x4b, 0x50];
|
||||
|
||||
stream.Seek(-len, SeekOrigin.End);
|
||||
|
||||
|
||||
@@ -3,229 +3,230 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using SharpCompress.Compressors.RLE90;
|
||||
using SharpCompress.Compressors.Squeezed;
|
||||
using SharpCompress.IO;
|
||||
|
||||
namespace SharpCompress.Compressors.ArcLzw;
|
||||
|
||||
public partial class ArcLzwStream : Stream, IStreamStack
|
||||
{
|
||||
#if DEBUG_STREAMS
|
||||
long IStreamStack.InstanceId { get; set; }
|
||||
#endif
|
||||
int IStreamStack.DefaultBufferSize { get; set; }
|
||||
int IStreamStack.DefaultBufferSize { get; set; }
|
||||
|
||||
Stream IStreamStack.BaseStream() => _stream;
|
||||
Stream IStreamStack.BaseStream() => _stream;
|
||||
|
||||
int IStreamStack.BufferSize
|
||||
{
|
||||
get => 0;
|
||||
set { }
|
||||
}
|
||||
int IStreamStack.BufferPosition
|
||||
{
|
||||
get => 0;
|
||||
set { }
|
||||
}
|
||||
int IStreamStack.BufferSize
|
||||
{
|
||||
get => 0;
|
||||
set { }
|
||||
}
|
||||
int IStreamStack.BufferPosition
|
||||
{
|
||||
get => 0;
|
||||
set { }
|
||||
}
|
||||
|
||||
void IStreamStack.SetPosition(long position) { }
|
||||
void IStreamStack.SetPosition(long position) { }
|
||||
|
||||
private Stream _stream;
|
||||
private bool _processed;
|
||||
private bool _useCrunched;
|
||||
private int _compressedSize;
|
||||
private Stream _stream;
|
||||
private bool _processed;
|
||||
private bool _useCrunched;
|
||||
private int _compressedSize;
|
||||
|
||||
private const int BITS = 12;
|
||||
private const int CRUNCH_BITS = 12;
|
||||
private const int SQUASH_BITS = 13;
|
||||
private const int INIT_BITS = 9;
|
||||
private const ushort FIRST = 257;
|
||||
private const ushort CLEAR = 256;
|
||||
private const int BITS = 12;
|
||||
private const int CRUNCH_BITS = 12;
|
||||
private const int SQUASH_BITS = 13;
|
||||
private const int INIT_BITS = 9;
|
||||
private const ushort FIRST = 257;
|
||||
private const ushort CLEAR = 256;
|
||||
|
||||
private ushort oldcode;
|
||||
private byte finchar;
|
||||
private int n_bits;
|
||||
private ushort maxcode;
|
||||
private ushort[] prefix = new ushort[8191];
|
||||
private byte[] suffix = new byte[8191];
|
||||
private bool clearFlag;
|
||||
private Stack<byte> stack = new Stack<byte>();
|
||||
private ushort freeEnt;
|
||||
private ushort maxcodemax;
|
||||
private ushort oldcode;
|
||||
private byte finchar;
|
||||
private int n_bits;
|
||||
private ushort maxcode;
|
||||
private ushort[] prefix = new ushort[8191];
|
||||
private byte[] suffix = new byte[8191];
|
||||
private bool clearFlag;
|
||||
private Stack<byte> stack = new Stack<byte>();
|
||||
private ushort freeEnt;
|
||||
private ushort maxcodemax;
|
||||
|
||||
public ArcLzwStream(Stream stream, int compressedSize, bool useCrunched = true)
|
||||
{
|
||||
_stream = stream;
|
||||
public ArcLzwStream(Stream stream, int compressedSize, bool useCrunched = true)
|
||||
{
|
||||
_stream = stream;
|
||||
#if DEBUG_STREAMS
|
||||
this.DebugConstruct(typeof(ArcLzwStream));
|
||||
#endif
|
||||
_useCrunched = useCrunched;
|
||||
_compressedSize = compressedSize;
|
||||
_useCrunched = useCrunched;
|
||||
_compressedSize = compressedSize;
|
||||
|
||||
oldcode = 0;
|
||||
finchar = 0;
|
||||
n_bits = 0;
|
||||
maxcode = 0;
|
||||
clearFlag = false;
|
||||
freeEnt = FIRST;
|
||||
maxcodemax = 0;
|
||||
}
|
||||
oldcode = 0;
|
||||
finchar = 0;
|
||||
n_bits = 0;
|
||||
maxcode = 0;
|
||||
clearFlag = false;
|
||||
freeEnt = FIRST;
|
||||
maxcodemax = 0;
|
||||
}
|
||||
|
||||
private ushort? GetCode(BitReader reader)
|
||||
private ushort? GetCode(ArcLzwStream.BitReader reader)
|
||||
{
|
||||
if (clearFlag || freeEnt > maxcode)
|
||||
{
|
||||
if (clearFlag || freeEnt > maxcode)
|
||||
{
|
||||
if (freeEnt > maxcode)
|
||||
{
|
||||
n_bits++;
|
||||
maxcode = (n_bits == BITS) ? maxcodemax : (ushort)((1 << n_bits) - 1);
|
||||
}
|
||||
if (clearFlag)
|
||||
{
|
||||
clearFlag = false;
|
||||
n_bits = INIT_BITS;
|
||||
maxcode = (ushort)((1 << n_bits) - 1);
|
||||
}
|
||||
}
|
||||
return (ushort?)reader.ReadBits(n_bits);
|
||||
}
|
||||
|
||||
public List<byte> Decompress(byte[] input, bool useCrunched)
|
||||
{
|
||||
var result = new List<byte>();
|
||||
int bits = useCrunched ? CRUNCH_BITS : SQUASH_BITS;
|
||||
|
||||
if (useCrunched)
|
||||
{
|
||||
if (input[0] != BITS)
|
||||
{
|
||||
throw new InvalidDataException($"File packed with {input[0]}, expected {BITS}.");
|
||||
}
|
||||
|
||||
input = input.Skip(1).ToArray();
|
||||
}
|
||||
|
||||
maxcodemax = (ushort)(1 << bits);
|
||||
if (freeEnt > maxcode)
|
||||
{
|
||||
n_bits++;
|
||||
maxcode = (n_bits == BITS) ? maxcodemax : (ushort)((1 << n_bits) - 1);
|
||||
}
|
||||
if (clearFlag)
|
||||
{
|
||||
clearFlag = false;
|
||||
n_bits = INIT_BITS;
|
||||
maxcode = (ushort)((1 << n_bits) - 1);
|
||||
}
|
||||
}
|
||||
return (ushort?)reader.ReadBits(n_bits);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
suffix[i] = (byte)i;
|
||||
}
|
||||
public List<byte> Decompress(byte[] input, bool useCrunched)
|
||||
{
|
||||
var result = new List<byte>();
|
||||
int bits = useCrunched ? CRUNCH_BITS : SQUASH_BITS;
|
||||
|
||||
var reader = new BitReader(input);
|
||||
freeEnt = FIRST;
|
||||
if (useCrunched)
|
||||
{
|
||||
if (input[0] != BITS)
|
||||
{
|
||||
throw new InvalidDataException($"File packed with {input[0]}, expected {BITS}.");
|
||||
}
|
||||
|
||||
if (GetCode(reader) is ushort old)
|
||||
{
|
||||
oldcode = old;
|
||||
finchar = (byte)oldcode;
|
||||
result.Add(finchar);
|
||||
}
|
||||
|
||||
while (GetCode(reader) is ushort code)
|
||||
{
|
||||
if (code == CLEAR)
|
||||
{
|
||||
Array.Clear(prefix, 0, prefix.Length);
|
||||
clearFlag = true;
|
||||
freeEnt = (ushort)(FIRST - 1);
|
||||
|
||||
if (GetCode(reader) is ushort c)
|
||||
{
|
||||
code = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ushort incode = code;
|
||||
|
||||
if (code >= freeEnt)
|
||||
{
|
||||
stack.Push(finchar);
|
||||
code = oldcode;
|
||||
}
|
||||
|
||||
while (code >= 256)
|
||||
{
|
||||
stack.Push(suffix[code]);
|
||||
code = prefix[code];
|
||||
}
|
||||
|
||||
finchar = suffix[code];
|
||||
stack.Push(finchar);
|
||||
|
||||
while (stack.Count > 0)
|
||||
{
|
||||
result.Add(stack.Pop());
|
||||
}
|
||||
code = freeEnt;
|
||||
if (code < maxcodemax)
|
||||
{
|
||||
prefix[code] = oldcode;
|
||||
suffix[code] = finchar;
|
||||
freeEnt = (ushort)(code + 1);
|
||||
}
|
||||
|
||||
oldcode = incode;
|
||||
}
|
||||
|
||||
return result;
|
||||
input = input.Skip(1).ToArray();
|
||||
}
|
||||
|
||||
// Stream base class implementation
|
||||
public override bool CanRead => true;
|
||||
public override bool CanSeek => false;
|
||||
public override bool CanWrite => false;
|
||||
public override long Length => throw new NotImplementedException();
|
||||
public override long Position
|
||||
maxcodemax = (ushort)(1 << bits);
|
||||
clearFlag = false;
|
||||
n_bits = INIT_BITS;
|
||||
maxcode = (ushort)((1 << n_bits) - 1);
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
get => _stream.Position;
|
||||
set => throw new NotImplementedException();
|
||||
suffix[i] = (byte)i;
|
||||
}
|
||||
|
||||
public override void Flush() => throw new NotImplementedException();
|
||||
var reader = new ArcLzwStream.BitReader(input);
|
||||
freeEnt = FIRST;
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
if (GetCode(reader) is ushort old)
|
||||
{
|
||||
if (_processed)
|
||||
oldcode = old;
|
||||
finchar = (byte)oldcode;
|
||||
result.Add(finchar);
|
||||
}
|
||||
|
||||
while (GetCode(reader) is ushort code)
|
||||
{
|
||||
if (code == CLEAR)
|
||||
{
|
||||
Array.Clear(prefix, 0, prefix.Length);
|
||||
clearFlag = true;
|
||||
freeEnt = (ushort)(FIRST - 1);
|
||||
|
||||
if (GetCode(reader) is ushort c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
_processed = true;
|
||||
var data = new byte[_compressedSize];
|
||||
_stream.Read(data, 0, _compressedSize);
|
||||
var decoded = Decompress(data, _useCrunched);
|
||||
var result = decoded.Count();
|
||||
if (_useCrunched)
|
||||
{
|
||||
var unpacked = RLE.UnpackRLE(decoded.ToArray());
|
||||
unpacked.CopyTo(buffer, 0);
|
||||
result = unpacked.Count;
|
||||
code = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
decoded.CopyTo(buffer, 0);
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ushort incode = code;
|
||||
|
||||
if (code >= freeEnt)
|
||||
{
|
||||
stack.Push(finchar);
|
||||
code = oldcode;
|
||||
}
|
||||
|
||||
while (code >= 256)
|
||||
{
|
||||
stack.Push(suffix[code]);
|
||||
code = prefix[code];
|
||||
}
|
||||
|
||||
finchar = suffix[code];
|
||||
stack.Push(finchar);
|
||||
|
||||
while (stack.Count > 0)
|
||||
{
|
||||
result.Add(stack.Pop());
|
||||
}
|
||||
code = freeEnt;
|
||||
if (code < maxcodemax)
|
||||
{
|
||||
prefix[code] = oldcode;
|
||||
suffix[code] = finchar;
|
||||
freeEnt = (ushort)(code + 1);
|
||||
}
|
||||
|
||||
oldcode = incode;
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin) =>
|
||||
throw new NotImplementedException();
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void SetLength(long value) => throw new NotImplementedException();
|
||||
// Stream base class implementation
|
||||
public override bool CanRead => true;
|
||||
public override bool CanSeek => false;
|
||||
public override bool CanWrite => false;
|
||||
public override long Length => throw new NotImplementedException();
|
||||
public override long Position
|
||||
{
|
||||
get => _stream.Position;
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count) =>
|
||||
throw new NotImplementedException();
|
||||
public override void Flush() => throw new NotImplementedException();
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (_processed)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
_processed = true;
|
||||
var data = new byte[_compressedSize];
|
||||
_stream.Read(data, 0, _compressedSize);
|
||||
var decoded = Decompress(data, _useCrunched);
|
||||
var result = decoded.Count();
|
||||
if (_useCrunched)
|
||||
{
|
||||
var unpacked = RLE.UnpackRLE(decoded.ToArray());
|
||||
unpacked.CopyTo(buffer, 0);
|
||||
result = unpacked.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
decoded.CopyTo(buffer, 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin) =>
|
||||
throw new NotImplementedException();
|
||||
|
||||
public override void SetLength(long value) => throw new NotImplementedException();
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count) =>
|
||||
throw new NotImplementedException();
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
#if DEBUG_STREAMS
|
||||
this.DebugDispose(typeof(ArcLzwStream));
|
||||
#endif
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,64 @@
|
||||
using System;
|
||||
|
||||
namespace SharpCompress.Compressors.ArcLzw;
|
||||
|
||||
public partial class ArcLzwStream
|
||||
{
|
||||
public class BitReader
|
||||
public class BitReader
|
||||
{
|
||||
private readonly byte[] data;
|
||||
private int bitPosition;
|
||||
private int bytePosition;
|
||||
|
||||
public BitReader(byte[] inputData)
|
||||
{
|
||||
private readonly byte[] data;
|
||||
private int bitPosition;
|
||||
private int bytePosition;
|
||||
|
||||
public BitReader(byte[] inputData)
|
||||
{
|
||||
data = inputData;
|
||||
bitPosition = 0;
|
||||
bytePosition = 0;
|
||||
}
|
||||
|
||||
public int? ReadBits(int bitCount)
|
||||
{
|
||||
if (bitCount <= 0 || bitCount > 16)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(
|
||||
nameof(bitCount),
|
||||
"Bit count must be between 1 and 16"
|
||||
);
|
||||
}
|
||||
|
||||
if (bytePosition >= data.Length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
int bitsRead = 0;
|
||||
|
||||
while (bitsRead < bitCount)
|
||||
{
|
||||
if (bytePosition >= data.Length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int bitsAvailable = 8 - bitPosition;
|
||||
int bitsToRead = Math.Min(bitCount - bitsRead, bitsAvailable);
|
||||
|
||||
int mask = (1 << bitsToRead) - 1;
|
||||
result |= ((data[bytePosition] >> bitPosition) & mask) << bitsRead;
|
||||
|
||||
bitPosition += bitsToRead;
|
||||
bitsRead += bitsToRead;
|
||||
|
||||
if (bitPosition >= 8)
|
||||
{
|
||||
bitPosition = 0;
|
||||
bytePosition++;
|
||||
}
|
||||
}
|
||||
|
||||
return (ushort)result;
|
||||
}
|
||||
data = inputData;
|
||||
bitPosition = 0;
|
||||
bytePosition = 0;
|
||||
}
|
||||
|
||||
public int? ReadBits(int bitCount)
|
||||
{
|
||||
if (bitCount <= 0 || bitCount > 16)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(
|
||||
nameof(bitCount),
|
||||
"Bit count must be between 1 and 16"
|
||||
);
|
||||
}
|
||||
|
||||
if (bytePosition >= data.Length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
int bitsRead = 0;
|
||||
|
||||
while (bitsRead < bitCount)
|
||||
{
|
||||
if (bytePosition >= data.Length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int bitsAvailable = 8 - bitPosition;
|
||||
int bitsToRead = Math.Min(bitCount - bitsRead, bitsAvailable);
|
||||
|
||||
int mask = (1 << bitsToRead) - 1;
|
||||
result |= ((data[bytePosition] >> bitPosition) & mask) << bitsRead;
|
||||
|
||||
bitPosition += bitsToRead;
|
||||
bitsRead += bitsToRead;
|
||||
|
||||
if (bitPosition >= 8)
|
||||
{
|
||||
bitPosition = 0;
|
||||
bytePosition++;
|
||||
}
|
||||
}
|
||||
|
||||
return (ushort)result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ internal class BZip2Constants
|
||||
public const int NUM_OVERSHOOT_BYTES = 20;
|
||||
|
||||
public static int[] rNums =
|
||||
{
|
||||
619,
|
||||
[
|
||||
619,
|
||||
720,
|
||||
127,
|
||||
481,
|
||||
@@ -555,6 +555,6 @@ internal class BZip2Constants
|
||||
858,
|
||||
364,
|
||||
936,
|
||||
638,
|
||||
};
|
||||
638
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1843,8 +1843,8 @@ internal sealed class CBZip2OutputStream : Stream, IStreamStack
|
||||
*/
|
||||
|
||||
private readonly int[] incs =
|
||||
{
|
||||
1,
|
||||
[
|
||||
1,
|
||||
4,
|
||||
13,
|
||||
40,
|
||||
@@ -1857,8 +1857,8 @@ internal sealed class CBZip2OutputStream : Stream, IStreamStack
|
||||
88573,
|
||||
265720,
|
||||
797161,
|
||||
2391484,
|
||||
};
|
||||
2391484
|
||||
];
|
||||
|
||||
private void AllocateCompressStructures()
|
||||
{
|
||||
|
||||
@@ -32,8 +32,8 @@ namespace SharpCompress.Compressors.BZip2;
|
||||
internal class CRC
|
||||
{
|
||||
public static int[] crc32Table =
|
||||
{
|
||||
0x00000000,
|
||||
[
|
||||
0x00000000,
|
||||
0x04c11db7,
|
||||
0x09823b6e,
|
||||
0x0d4326d9,
|
||||
@@ -288,8 +288,8 @@ internal class CRC
|
||||
unchecked((int)0xbcb4666d),
|
||||
unchecked((int)0xb8757bda),
|
||||
unchecked((int)0xb5365d03),
|
||||
unchecked((int)0xb1f740b4),
|
||||
};
|
||||
unchecked((int)0xb1f740b4)
|
||||
];
|
||||
|
||||
public CRC() => InitialiseCRC();
|
||||
|
||||
|
||||
@@ -77,8 +77,8 @@ internal sealed partial class DeflateManager
|
||||
{
|
||||
// extra bits for each length code
|
||||
internal static readonly int[] ExtraLengthBits =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -106,13 +106,13 @@ internal sealed partial class DeflateManager
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
0,
|
||||
};
|
||||
0
|
||||
];
|
||||
|
||||
// extra bits for each distance code
|
||||
internal static readonly int[] ExtraDistanceBits =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -141,8 +141,8 @@ internal sealed partial class DeflateManager
|
||||
12,
|
||||
12,
|
||||
13,
|
||||
13,
|
||||
};
|
||||
13
|
||||
];
|
||||
|
||||
internal enum BlockState
|
||||
{
|
||||
@@ -203,9 +203,9 @@ internal sealed partial class DeflateManager
|
||||
public static Config Lookup(CompressionLevel level) => Table[(int)level];
|
||||
|
||||
static Config() =>
|
||||
Table = new[]
|
||||
{
|
||||
new Config(0, 0, 0, 0, DeflateFlavor.Store),
|
||||
Table =
|
||||
[
|
||||
new Config(0, 0, 0, 0, DeflateFlavor.Store),
|
||||
new Config(4, 4, 8, 4, DeflateFlavor.Fast),
|
||||
new Config(4, 5, 16, 8, DeflateFlavor.Fast),
|
||||
new Config(4, 6, 32, 32, DeflateFlavor.Fast),
|
||||
@@ -214,8 +214,8 @@ internal sealed partial class DeflateManager
|
||||
new Config(8, 16, 128, 128, DeflateFlavor.Slow),
|
||||
new Config(8, 32, 128, 256, DeflateFlavor.Slow),
|
||||
new Config(32, 128, 258, 1024, DeflateFlavor.Slow),
|
||||
new Config(32, 258, 258, 4096, DeflateFlavor.Slow),
|
||||
};
|
||||
new Config(32, 258, 258, 4096, DeflateFlavor.Slow)
|
||||
];
|
||||
|
||||
private static readonly Config[] Table;
|
||||
}
|
||||
@@ -223,8 +223,8 @@ internal sealed partial class DeflateManager
|
||||
private CompressFunc DeflateFunction;
|
||||
|
||||
private static readonly string[] _ErrorMessage =
|
||||
{
|
||||
"need dictionary",
|
||||
[
|
||||
"need dictionary",
|
||||
"stream end",
|
||||
"",
|
||||
"file error",
|
||||
@@ -233,8 +233,8 @@ internal sealed partial class DeflateManager
|
||||
"insufficient memory",
|
||||
"buffer error",
|
||||
"incompatible version",
|
||||
"",
|
||||
};
|
||||
""
|
||||
];
|
||||
|
||||
// preset dictionary flag in zlib header
|
||||
private const int PRESET_DICT = 0x20;
|
||||
|
||||
@@ -79,8 +79,8 @@ internal sealed class InfTree
|
||||
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'fixed_tl'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] fixed_tl =
|
||||
{
|
||||
96,
|
||||
[
|
||||
96,
|
||||
7,
|
||||
256,
|
||||
0,
|
||||
@@ -1615,13 +1615,13 @@ internal sealed class InfTree
|
||||
79,
|
||||
0,
|
||||
9,
|
||||
255,
|
||||
};
|
||||
255
|
||||
];
|
||||
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'fixed_td'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] fixed_td =
|
||||
{
|
||||
80,
|
||||
[
|
||||
80,
|
||||
5,
|
||||
1,
|
||||
87,
|
||||
@@ -1716,14 +1716,14 @@ internal sealed class InfTree
|
||||
193,
|
||||
192,
|
||||
5,
|
||||
24577,
|
||||
};
|
||||
24577
|
||||
];
|
||||
|
||||
// Tables for deflate from PKZIP's appnote.txt.
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'cplens'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] cplens =
|
||||
{
|
||||
3,
|
||||
[
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
@@ -1753,14 +1753,14 @@ internal sealed class InfTree
|
||||
227,
|
||||
258,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
0
|
||||
];
|
||||
|
||||
// see note #13 above about 258
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'cplext'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] cplext =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -1790,13 +1790,13 @@ internal sealed class InfTree
|
||||
5,
|
||||
0,
|
||||
112,
|
||||
112,
|
||||
};
|
||||
112
|
||||
];
|
||||
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'cpdist'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] cpdist =
|
||||
{
|
||||
1,
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
@@ -1825,13 +1825,13 @@ internal sealed class InfTree
|
||||
8193,
|
||||
12289,
|
||||
16385,
|
||||
24577,
|
||||
};
|
||||
24577
|
||||
];
|
||||
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'cpdext'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] cpdext =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -1860,8 +1860,8 @@ internal sealed class InfTree
|
||||
12,
|
||||
12,
|
||||
13,
|
||||
13,
|
||||
};
|
||||
13
|
||||
];
|
||||
|
||||
// If BMAX needs to be larger than 16, then h and x[] should be uLong.
|
||||
internal int[] c; // bit length count table
|
||||
|
||||
@@ -74,8 +74,8 @@ internal sealed class InflateBlocks
|
||||
|
||||
// Table for deflate from PKZIP's appnote.txt.
|
||||
internal static readonly int[] border =
|
||||
{
|
||||
16,
|
||||
[
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
0,
|
||||
@@ -93,8 +93,8 @@ internal sealed class InflateBlocks
|
||||
2,
|
||||
14,
|
||||
1,
|
||||
15,
|
||||
};
|
||||
15
|
||||
];
|
||||
|
||||
internal ZlibCodec _codec; // pointer back to this zlib stream
|
||||
internal int[] bb = new int[1]; // bit length tree depth
|
||||
@@ -825,8 +825,8 @@ internal static class InternalInflateConstants
|
||||
{
|
||||
// And'ing with mask[n] masks the lower n bits
|
||||
internal static readonly int[] InflateMask =
|
||||
{
|
||||
0x00000000,
|
||||
[
|
||||
0x00000000,
|
||||
0x00000001,
|
||||
0x00000003,
|
||||
0x00000007,
|
||||
@@ -842,8 +842,8 @@ internal static class InternalInflateConstants
|
||||
0x00001fff,
|
||||
0x00003fff,
|
||||
0x00007fff,
|
||||
0x0000ffff,
|
||||
};
|
||||
0x0000ffff
|
||||
];
|
||||
}
|
||||
|
||||
internal sealed class InflateCodes
|
||||
@@ -1628,7 +1628,7 @@ internal sealed class InflateManager
|
||||
private const int PRESET_DICT = 0x20;
|
||||
|
||||
private const int Z_DEFLATED = 8;
|
||||
private static readonly byte[] mark = { 0, 0, 0xff, 0xff };
|
||||
private static readonly byte[] mark = [0, 0, 0xff, 0xff];
|
||||
|
||||
internal ZlibCodec _codec; // pointer back to this zlib stream
|
||||
internal InflateBlocks blocks; // current inflate_blocks state
|
||||
|
||||
@@ -76,8 +76,8 @@ internal sealed partial class DeflateManager
|
||||
private static readonly int HEAP_SIZE = ((2 * InternalConstants.L_CODES) + 1);
|
||||
|
||||
internal static readonly sbyte[] bl_order =
|
||||
{
|
||||
16,
|
||||
[
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
0,
|
||||
@@ -95,8 +95,8 @@ internal sealed partial class DeflateManager
|
||||
2,
|
||||
14,
|
||||
1,
|
||||
15,
|
||||
};
|
||||
15
|
||||
];
|
||||
|
||||
// The lengths of the bit length codes are sent in order of decreasing
|
||||
// probability, to avoid transmitting the lengths for unused bit
|
||||
@@ -106,8 +106,8 @@ internal sealed partial class DeflateManager
|
||||
//internal const int DIST_CODE_LEN = 512;
|
||||
|
||||
private static readonly sbyte[] _dist_code =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
@@ -618,12 +618,12 @@ internal sealed partial class DeflateManager
|
||||
29,
|
||||
29,
|
||||
29,
|
||||
29,
|
||||
};
|
||||
29
|
||||
];
|
||||
|
||||
internal static readonly sbyte[] LengthCode =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
@@ -878,12 +878,12 @@ internal sealed partial class DeflateManager
|
||||
27,
|
||||
27,
|
||||
27,
|
||||
28,
|
||||
};
|
||||
28
|
||||
];
|
||||
|
||||
internal static readonly int[] LengthBase =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
@@ -911,12 +911,12 @@ internal sealed partial class DeflateManager
|
||||
160,
|
||||
192,
|
||||
224,
|
||||
0,
|
||||
};
|
||||
0
|
||||
];
|
||||
|
||||
internal static readonly int[] DistanceBase =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
@@ -945,8 +945,8 @@ internal sealed partial class DeflateManager
|
||||
8192,
|
||||
12288,
|
||||
16384,
|
||||
24576,
|
||||
};
|
||||
24576
|
||||
];
|
||||
|
||||
internal short[] dyn_tree; // the dynamic tree
|
||||
internal int max_code; // largest code with non zero frequency
|
||||
|
||||
@@ -283,8 +283,8 @@ internal static class InternalConstants
|
||||
internal sealed class StaticTree
|
||||
{
|
||||
internal static readonly short[] lengthAndLiteralsTreeCodes =
|
||||
{
|
||||
12,
|
||||
[
|
||||
12,
|
||||
8,
|
||||
140,
|
||||
8,
|
||||
@@ -859,12 +859,12 @@ internal sealed class StaticTree
|
||||
99,
|
||||
8,
|
||||
227,
|
||||
8,
|
||||
};
|
||||
8
|
||||
];
|
||||
|
||||
internal static readonly short[] distTreeCodes =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
5,
|
||||
16,
|
||||
5,
|
||||
@@ -923,13 +923,13 @@ internal sealed class StaticTree
|
||||
7,
|
||||
5,
|
||||
23,
|
||||
5,
|
||||
};
|
||||
5
|
||||
];
|
||||
|
||||
// extra bits for each bit length code
|
||||
internal static readonly int[] extra_blbits =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -947,8 +947,8 @@ internal sealed class StaticTree
|
||||
0,
|
||||
2,
|
||||
3,
|
||||
7,
|
||||
};
|
||||
7
|
||||
];
|
||||
|
||||
internal static readonly StaticTree Literals;
|
||||
internal static readonly StaticTree Distances;
|
||||
|
||||
@@ -12,9 +12,8 @@ internal static class FastEncoderStatics
|
||||
// static information for encoding, DO NOT MODIFY
|
||||
|
||||
internal static ReadOnlySpan<byte> FAST_ENCODER_TREE_STRUCTURE_DATA =>
|
||||
new byte[]
|
||||
{
|
||||
0xec,
|
||||
[
|
||||
0xec,
|
||||
0xbd,
|
||||
0x07,
|
||||
0x60,
|
||||
@@ -111,13 +110,12 @@ internal static class FastEncoderStatics
|
||||
0x7e,
|
||||
0x7c,
|
||||
0x1f,
|
||||
0x3f,
|
||||
};
|
||||
0x3f
|
||||
];
|
||||
|
||||
internal static ReadOnlySpan<byte> B_FINAL_FAST_ENCODER_TREE_STRUCTURE_DATA =>
|
||||
new byte[]
|
||||
{
|
||||
0xed,
|
||||
[
|
||||
0xed,
|
||||
0xbd,
|
||||
0x07,
|
||||
0x60,
|
||||
@@ -214,8 +212,8 @@ internal static class FastEncoderStatics
|
||||
0x7e,
|
||||
0x7c,
|
||||
0x1f,
|
||||
0x3f,
|
||||
};
|
||||
0x3f
|
||||
];
|
||||
|
||||
// Output a currentMatch with length matchLen (>= MIN_MATCH) and displacement matchPos
|
||||
//
|
||||
@@ -248,8 +246,8 @@ internal static class FastEncoderStatics
|
||||
// and the rest is the code bits.
|
||||
|
||||
internal static readonly uint[] FAST_ENCODER_LITERAL_CODE_INFO =
|
||||
{
|
||||
0x0000d7ee,
|
||||
[
|
||||
0x0000d7ee,
|
||||
0x0004d7ee,
|
||||
0x0002d7ee,
|
||||
0x0006d7ee,
|
||||
@@ -761,12 +759,12 @@ internal static class FastEncoderStatics
|
||||
0x0039e7f1,
|
||||
0x003be7f1,
|
||||
0x003de7f1,
|
||||
0x000047eb,
|
||||
};
|
||||
0x000047eb
|
||||
];
|
||||
|
||||
internal static readonly uint[] FAST_ENCODER_DISTANCE_CODE_INFO =
|
||||
{
|
||||
0x00000f06,
|
||||
[
|
||||
0x00000f06,
|
||||
0x0001ff0a,
|
||||
0x0003ff0b,
|
||||
0x0007ff0b,
|
||||
@@ -797,12 +795,12 @@ internal static class FastEncoderStatics
|
||||
0x000007d5,
|
||||
0x000017d5,
|
||||
0x00000000,
|
||||
0x00000100,
|
||||
};
|
||||
0x00000100
|
||||
];
|
||||
|
||||
internal static readonly uint[] BIT_MASK =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
1,
|
||||
3,
|
||||
7,
|
||||
@@ -817,11 +815,11 @@ internal static class FastEncoderStatics
|
||||
4095,
|
||||
8191,
|
||||
16383,
|
||||
32767,
|
||||
};
|
||||
32767
|
||||
];
|
||||
internal static readonly byte[] EXTRA_LENGTH_BITS =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -849,11 +847,11 @@ internal static class FastEncoderStatics
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
0,
|
||||
};
|
||||
0
|
||||
];
|
||||
internal static readonly byte[] EXTRA_DISTANCE_BITS =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -884,8 +882,8 @@ internal static class FastEncoderStatics
|
||||
13,
|
||||
13,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
0
|
||||
];
|
||||
internal const int NUM_CHARS = 256;
|
||||
internal const int NUM_LENGTH_BASE_CODES = 29;
|
||||
internal const int NUM_DIST_BASE_CODES = 30;
|
||||
|
||||
@@ -40,9 +40,8 @@ internal sealed class InflaterManaged
|
||||
|
||||
// Extra bits for length code 257 - 285.
|
||||
private static ReadOnlySpan<byte> S_EXTRA_LENGTH_BITS =>
|
||||
new byte[]
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -70,14 +69,14 @@ internal sealed class InflaterManaged
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
16,
|
||||
};
|
||||
16
|
||||
];
|
||||
|
||||
// The base length for length code 257 - 285.
|
||||
// The formula to get the real length for a length code is lengthBase[code - 257] + (value stored in extraBits)
|
||||
private static readonly int[] S_LENGTH_BASE =
|
||||
{
|
||||
3,
|
||||
[
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
@@ -105,14 +104,14 @@ internal sealed class InflaterManaged
|
||||
163,
|
||||
195,
|
||||
227,
|
||||
3,
|
||||
};
|
||||
3
|
||||
];
|
||||
|
||||
// The base distance for distance code 0 - 31
|
||||
// The real distance for a distance code is distanceBasePosition[code] + (value stored in extraBits)
|
||||
private static readonly int[] S_DISTANCE_BASE_POSITION =
|
||||
{
|
||||
1,
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
@@ -143,17 +142,16 @@ internal sealed class InflaterManaged
|
||||
16385,
|
||||
24577,
|
||||
32769,
|
||||
49153,
|
||||
};
|
||||
49153
|
||||
];
|
||||
|
||||
// code lengths for code length alphabet is stored in following order
|
||||
private static ReadOnlySpan<byte> S_CODE_ORDER =>
|
||||
new byte[] { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
|
||||
[16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
|
||||
|
||||
private static ReadOnlySpan<byte> S_STATIC_DISTANCE_TREE_TABLE =>
|
||||
new byte[]
|
||||
{
|
||||
0x00,
|
||||
[
|
||||
0x00,
|
||||
0x10,
|
||||
0x08,
|
||||
0x18,
|
||||
@@ -184,8 +182,8 @@ internal sealed class InflaterManaged
|
||||
0x07,
|
||||
0x17,
|
||||
0x0f,
|
||||
0x1f,
|
||||
};
|
||||
0x1f
|
||||
];
|
||||
|
||||
private readonly OutputWindow _output;
|
||||
private readonly InputBuffer _input;
|
||||
|
||||
@@ -116,9 +116,9 @@ public class ExplodeStream : Stream, IStreamStack
|
||||
set { }
|
||||
}
|
||||
|
||||
static uint[] mask_bits = new uint[]
|
||||
{
|
||||
0x0000,
|
||||
static uint[] mask_bits =
|
||||
[
|
||||
0x0000,
|
||||
0x0001,
|
||||
0x0003,
|
||||
0x0007,
|
||||
@@ -134,13 +134,13 @@ public class ExplodeStream : Stream, IStreamStack
|
||||
0x1fff,
|
||||
0x3fff,
|
||||
0x7fff,
|
||||
0xffff,
|
||||
};
|
||||
0xffff
|
||||
];
|
||||
|
||||
/* Tables for length and distance */
|
||||
static int[] cplen2 = new int[]
|
||||
{
|
||||
2,
|
||||
static int[] cplen2 =
|
||||
[
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
@@ -203,12 +203,12 @@ public class ExplodeStream : Stream, IStreamStack
|
||||
62,
|
||||
63,
|
||||
64,
|
||||
65,
|
||||
};
|
||||
65
|
||||
];
|
||||
|
||||
static int[] cplen3 = new int[]
|
||||
{
|
||||
3,
|
||||
static int[] cplen3 =
|
||||
[
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
@@ -271,11 +271,12 @@ public class ExplodeStream : Stream, IStreamStack
|
||||
63,
|
||||
64,
|
||||
65,
|
||||
66,
|
||||
};
|
||||
66
|
||||
];
|
||||
|
||||
static int[] extra = new int[]
|
||||
{
|
||||
static int[] extra =
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -338,13 +339,12 @@ public class ExplodeStream : Stream, IStreamStack
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
8,
|
||||
};
|
||||
8
|
||||
];
|
||||
|
||||
static int[] cpdist4 = new int[]
|
||||
{
|
||||
1,
|
||||
static int[] cpdist4 =
|
||||
[
|
||||
1,
|
||||
65,
|
||||
129,
|
||||
193,
|
||||
@@ -407,12 +407,12 @@ public class ExplodeStream : Stream, IStreamStack
|
||||
3841,
|
||||
3905,
|
||||
3969,
|
||||
4033,
|
||||
};
|
||||
4033
|
||||
];
|
||||
|
||||
static int[] cpdist8 = new int[]
|
||||
{
|
||||
1,
|
||||
static int[] cpdist8 =
|
||||
[
|
||||
1,
|
||||
129,
|
||||
257,
|
||||
385,
|
||||
@@ -475,8 +475,8 @@ public class ExplodeStream : Stream, IStreamStack
|
||||
7681,
|
||||
7809,
|
||||
7937,
|
||||
8065,
|
||||
};
|
||||
8065
|
||||
];
|
||||
|
||||
private int get_tree(int[] arrBitLengths, int numberExpected)
|
||||
/* Get the bit lengths for a code representation from the compressed
|
||||
|
||||
@@ -5,18 +5,18 @@ namespace SharpCompress.Compressors.Filters;
|
||||
internal class BCJFilter : Filter
|
||||
{
|
||||
private static readonly bool[] MASK_TO_ALLOWED_STATUS =
|
||||
{
|
||||
true,
|
||||
[
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
};
|
||||
false
|
||||
];
|
||||
|
||||
private static readonly int[] MASK_TO_BIT_NUMBER = { 0, 1, 2, 2, 3, 3, 3, 3 };
|
||||
private static readonly int[] MASK_TO_BIT_NUMBER = [0, 1, 2, 2, 3, 3, 3, 3];
|
||||
|
||||
private int _pos;
|
||||
private int _prevMask;
|
||||
|
||||
@@ -7,8 +7,8 @@ internal class BCJFilterIA64 : Filter
|
||||
private int _pos;
|
||||
|
||||
private static readonly int[] BRANCH_TABLE =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -39,8 +39,8 @@ internal class BCJFilterIA64 : Filter
|
||||
4,
|
||||
4,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
0
|
||||
];
|
||||
|
||||
public BCJFilterIA64(bool isEncoder, Stream baseStream)
|
||||
: base(isEncoder, baseStream, 16) => _pos = 0;
|
||||
|
||||
@@ -177,8 +177,8 @@ internal sealed class AesDecoderStream : DecoderStream2, IStreamStack
|
||||
|
||||
if ((bt & 0xC0) == 0)
|
||||
{
|
||||
salt = Array.Empty<byte>();
|
||||
iv = Array.Empty<byte>();
|
||||
salt = [];
|
||||
iv = [];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1709,7 +1709,7 @@ internal class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties
|
||||
_alignPriceCount = 0;
|
||||
}
|
||||
|
||||
private static readonly string[] K_MATCH_FINDER_I_DS = { "BT2", "BT4" };
|
||||
private static readonly string[] K_MATCH_FINDER_I_DS = ["BT2", "BT4"];
|
||||
|
||||
private static int FindMatchFinder(string s)
|
||||
{
|
||||
|
||||
@@ -29,27 +29,27 @@ public class LzmaEncoderProperties
|
||||
var algorithm = 2;
|
||||
var mf = "bt4";
|
||||
|
||||
_propIDs = new[]
|
||||
{
|
||||
CoderPropId.DictionarySize,
|
||||
_propIDs =
|
||||
[
|
||||
CoderPropId.DictionarySize,
|
||||
CoderPropId.PosStateBits,
|
||||
CoderPropId.LitContextBits,
|
||||
CoderPropId.LitPosBits,
|
||||
CoderPropId.Algorithm,
|
||||
CoderPropId.NumFastBytes,
|
||||
CoderPropId.MatchFinder,
|
||||
CoderPropId.EndMarker,
|
||||
};
|
||||
_properties = new object[]
|
||||
{
|
||||
dictionary,
|
||||
CoderPropId.EndMarker
|
||||
];
|
||||
_properties =
|
||||
[
|
||||
dictionary,
|
||||
posStateBits,
|
||||
litContextBits,
|
||||
litPosBits,
|
||||
algorithm,
|
||||
numFastBytes,
|
||||
mf,
|
||||
eos,
|
||||
};
|
||||
eos
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,10 +605,10 @@ public class LzwStream : Stream, IStreamStack
|
||||
|
||||
private const int TBL_FIRST = TBL_CLEAR + 1;
|
||||
|
||||
private int[] tabPrefix = new int[0]; //
|
||||
private byte[] tabSuffix = new byte[0]; //
|
||||
private int[] tabPrefix = []; //
|
||||
private byte[] tabSuffix = []; //
|
||||
private readonly int[] zeros = new int[256];
|
||||
private byte[] stack = new byte[0]; //
|
||||
private byte[] stack = []; //
|
||||
|
||||
// various state
|
||||
private bool blockMode;
|
||||
|
||||
@@ -124,16 +124,16 @@ internal class ModelPpm
|
||||
private readonly int[][] _binSumm = new int[128][]; // binary SEE-contexts
|
||||
|
||||
private static readonly int[] INIT_BIN_ESC =
|
||||
{
|
||||
0x3CDD,
|
||||
[
|
||||
0x3CDD,
|
||||
0x1F3F,
|
||||
0x59BF,
|
||||
0x48F3,
|
||||
0x64A1,
|
||||
0x5ABC,
|
||||
0x6632,
|
||||
0x6051,
|
||||
};
|
||||
0x6051
|
||||
];
|
||||
|
||||
// Temp fields
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'tempState1 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
|
||||
@@ -60,7 +60,7 @@ internal class PpmContext : Pointer
|
||||
private int _suffix; // pointer ppmcontext
|
||||
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'ExpEscape'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
public static readonly int[] EXP_ESCAPE = { 25, 14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 };
|
||||
public static readonly int[] EXP_ESCAPE = [25, 14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2];
|
||||
|
||||
// Temp fields
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'tempState1 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
|
||||
@@ -51,19 +51,19 @@ internal partial class Model
|
||||
private readonly PpmState[] _decodeStates = new PpmState[256];
|
||||
|
||||
private static readonly ushort[] INITIAL_BINARY_ESCAPES =
|
||||
{
|
||||
0x3CDD,
|
||||
[
|
||||
0x3CDD,
|
||||
0x1F3F,
|
||||
0x59BF,
|
||||
0x48F3,
|
||||
0x64A1,
|
||||
0x5ABC,
|
||||
0x6632,
|
||||
0x6051,
|
||||
};
|
||||
0x6051
|
||||
];
|
||||
|
||||
private static ReadOnlySpan<byte> EXPONENTIAL_ESCAPES =>
|
||||
new byte[] { 25, 14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 };
|
||||
[25, 14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2];
|
||||
|
||||
#region Public Methods
|
||||
|
||||
|
||||
@@ -9,10 +9,8 @@ public static class RLE
|
||||
|
||||
/// <summary>
|
||||
/// Unpacks an RLE compressed buffer.
|
||||
/// Format: <char> DLE <count>, where count == 0 -> DLE
|
||||
/// Format: char DLE count, where count == 0 -> DLE
|
||||
/// </summary>
|
||||
/// <param name="compressedBuffer">The compressed buffer to unpack.</param>
|
||||
/// <returns>A list of unpacked bytes.</returns>
|
||||
public static List<byte> UnpackRLE(byte[] compressedBuffer)
|
||||
{
|
||||
var result = new List<byte>(compressedBuffer.Length * 2); // Optimized initial capacity
|
||||
|
||||
@@ -39,30 +39,30 @@ internal class RarBLAKE2spStream : RarStream, IStreamStack
|
||||
const uint BLAKE2S_INIT_IV_SIZE = 8;
|
||||
|
||||
static readonly UInt32[] k_BLAKE2S_IV =
|
||||
{
|
||||
0x6A09E667U,
|
||||
[
|
||||
0x6A09E667U,
|
||||
0xBB67AE85U,
|
||||
0x3C6EF372U,
|
||||
0xA54FF53AU,
|
||||
0x510E527FU,
|
||||
0x9B05688CU,
|
||||
0x1F83D9ABU,
|
||||
0x5BE0CD19U,
|
||||
};
|
||||
0x5BE0CD19U
|
||||
];
|
||||
|
||||
static readonly byte[][] k_BLAKE2S_Sigma =
|
||||
{
|
||||
new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
new byte[] { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
new byte[] { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
new byte[] { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
new byte[] { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
new byte[] { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
|
||||
new byte[] { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
|
||||
new byte[] { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
|
||||
new byte[] { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
|
||||
new byte[] { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 },
|
||||
};
|
||||
[
|
||||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
||||
[14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3],
|
||||
[11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4],
|
||||
[7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8],
|
||||
[9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13],
|
||||
[2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9],
|
||||
[12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11],
|
||||
[13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10],
|
||||
[6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5],
|
||||
[10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0]
|
||||
];
|
||||
|
||||
internal class BLAKE2S
|
||||
{
|
||||
@@ -101,7 +101,7 @@ internal class RarBLAKE2spStream : RarStream, IStreamStack
|
||||
|
||||
BLAKE2SP _blake2sp;
|
||||
|
||||
byte[] _hash = { };
|
||||
byte[] _hash = [];
|
||||
|
||||
public RarBLAKE2spStream(
|
||||
IRarUnpack unpack,
|
||||
|
||||
@@ -72,14 +72,14 @@ internal sealed partial class Unpack : BitInput, IRarUnpack, IDisposable
|
||||
private readonly RarVM rarVM = new();
|
||||
|
||||
// Filters code, one entry per filter
|
||||
private readonly List<UnpackFilter> filters = new();
|
||||
private readonly List<UnpackFilter> filters = [];
|
||||
|
||||
// Filters stack, several entrances of same filter are possible
|
||||
private readonly List<UnpackFilter> prgStack = new();
|
||||
private readonly List<UnpackFilter> prgStack = [];
|
||||
|
||||
// lengths of preceding blocks, one length per filter. Used to reduce size
|
||||
// required to write block length if lengths are repeating
|
||||
private readonly List<int> oldFilterLengths = new();
|
||||
private readonly List<int> oldFilterLengths = [];
|
||||
|
||||
private int lastFilter;
|
||||
|
||||
@@ -100,8 +100,8 @@ internal sealed partial class Unpack : BitInput, IRarUnpack, IDisposable
|
||||
private int lowDistRepCount;
|
||||
|
||||
private static readonly int[] DBitLengthCounts =
|
||||
{
|
||||
4,
|
||||
[
|
||||
4,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
@@ -119,8 +119,8 @@ internal sealed partial class Unpack : BitInput, IRarUnpack, IDisposable
|
||||
2,
|
||||
14,
|
||||
0,
|
||||
12,
|
||||
};
|
||||
12
|
||||
];
|
||||
|
||||
private FileHeader fileHeader;
|
||||
|
||||
|
||||
@@ -77,8 +77,8 @@ internal partial class Unpack
|
||||
private const int STARTL1 = 2;
|
||||
|
||||
private static readonly int[] DecL1 =
|
||||
{
|
||||
0x8000,
|
||||
[
|
||||
0x8000,
|
||||
0xa000,
|
||||
0xc000,
|
||||
0xd000,
|
||||
@@ -88,16 +88,16 @@ internal partial class Unpack
|
||||
0xf000,
|
||||
0xf200,
|
||||
0xf200,
|
||||
0xffff,
|
||||
};
|
||||
0xffff
|
||||
];
|
||||
|
||||
private static readonly int[] PosL1 = { 0, 0, 0, 2, 3, 5, 7, 11, 16, 20, 24, 32, 32 };
|
||||
private static readonly int[] PosL1 = [0, 0, 0, 2, 3, 5, 7, 11, 16, 20, 24, 32, 32];
|
||||
|
||||
private const int STARTL2 = 3;
|
||||
|
||||
private static readonly int[] DecL2 =
|
||||
{
|
||||
0xa000,
|
||||
[
|
||||
0xa000,
|
||||
0xc000,
|
||||
0xd000,
|
||||
0xe000,
|
||||
@@ -106,16 +106,16 @@ internal partial class Unpack
|
||||
0xf000,
|
||||
0xf200,
|
||||
0xf240,
|
||||
0xffff,
|
||||
};
|
||||
0xffff
|
||||
];
|
||||
|
||||
private static readonly int[] PosL2 = { 0, 0, 0, 0, 5, 7, 9, 13, 18, 22, 26, 34, 36 };
|
||||
private static readonly int[] PosL2 = [0, 0, 0, 0, 5, 7, 9, 13, 18, 22, 26, 34, 36];
|
||||
|
||||
private const int STARTHF0 = 4;
|
||||
|
||||
private static readonly int[] DecHf0 =
|
||||
{
|
||||
0x8000,
|
||||
[
|
||||
0x8000,
|
||||
0xc000,
|
||||
0xe000,
|
||||
0xf200,
|
||||
@@ -123,69 +123,69 @@ internal partial class Unpack
|
||||
0xf200,
|
||||
0xf200,
|
||||
0xf200,
|
||||
0xffff,
|
||||
};
|
||||
0xffff
|
||||
];
|
||||
|
||||
private static readonly int[] PosHf0 = { 0, 0, 0, 0, 0, 8, 16, 24, 33, 33, 33, 33, 33 };
|
||||
private static readonly int[] PosHf0 = [0, 0, 0, 0, 0, 8, 16, 24, 33, 33, 33, 33, 33];
|
||||
|
||||
private const int STARTHF1 = 5;
|
||||
|
||||
private static readonly int[] DecHf1 =
|
||||
{
|
||||
0x2000,
|
||||
[
|
||||
0x2000,
|
||||
0xc000,
|
||||
0xe000,
|
||||
0xf000,
|
||||
0xf200,
|
||||
0xf200,
|
||||
0xf7e0,
|
||||
0xffff,
|
||||
};
|
||||
0xffff
|
||||
];
|
||||
|
||||
private static readonly int[] PosHf1 = { 0, 0, 0, 0, 0, 0, 4, 44, 60, 76, 80, 80, 127 };
|
||||
private static readonly int[] PosHf1 = [0, 0, 0, 0, 0, 0, 4, 44, 60, 76, 80, 80, 127];
|
||||
|
||||
private const int STARTHF2 = 5;
|
||||
|
||||
private static readonly int[] DecHf2 =
|
||||
{
|
||||
0x1000,
|
||||
[
|
||||
0x1000,
|
||||
0x2400,
|
||||
0x8000,
|
||||
0xc000,
|
||||
0xfa00,
|
||||
0xffff,
|
||||
0xffff,
|
||||
0xffff,
|
||||
};
|
||||
0xffff
|
||||
];
|
||||
|
||||
private static readonly int[] PosHf2 = { 0, 0, 0, 0, 0, 0, 2, 7, 53, 117, 233, 0, 0 };
|
||||
private static readonly int[] PosHf2 = [0, 0, 0, 0, 0, 0, 2, 7, 53, 117, 233, 0, 0];
|
||||
|
||||
private const int STARTHF3 = 6;
|
||||
|
||||
private static readonly int[] DecHf3 =
|
||||
{
|
||||
0x800,
|
||||
[
|
||||
0x800,
|
||||
0x2400,
|
||||
0xee00,
|
||||
0xfe80,
|
||||
0xffff,
|
||||
0xffff,
|
||||
0xffff,
|
||||
};
|
||||
0xffff
|
||||
];
|
||||
|
||||
private static readonly int[] PosHf3 = { 0, 0, 0, 0, 0, 0, 0, 2, 16, 218, 251, 0, 0 };
|
||||
private static readonly int[] PosHf3 = [0, 0, 0, 0, 0, 0, 0, 2, 16, 218, 251, 0, 0];
|
||||
|
||||
private const int STARTHF4 = 8;
|
||||
|
||||
private static readonly int[] DecHf4 = { 0xff00, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff };
|
||||
private static readonly int[] DecHf4 = [0xff00, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff];
|
||||
|
||||
private static readonly int[] PosHf4 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0 };
|
||||
private static readonly int[] PosHf4 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0];
|
||||
|
||||
private static readonly int[] ShortLen1 = { 1, 3, 4, 4, 5, 6, 7, 8, 8, 4, 4, 5, 6, 6, 4, 0 };
|
||||
private static readonly int[] ShortLen1 = [1, 3, 4, 4, 5, 6, 7, 8, 8, 4, 4, 5, 6, 6, 4, 0];
|
||||
|
||||
private static readonly int[] ShortXor1 =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0xa0,
|
||||
0xd0,
|
||||
0xe0,
|
||||
@@ -199,14 +199,14 @@ internal partial class Unpack
|
||||
0x90,
|
||||
0x98,
|
||||
0x9c,
|
||||
0xb0,
|
||||
};
|
||||
0xb0
|
||||
];
|
||||
|
||||
private static readonly int[] ShortLen2 = { 2, 3, 3, 3, 4, 4, 5, 6, 6, 4, 4, 5, 6, 6, 4, 0 };
|
||||
private static readonly int[] ShortLen2 = [2, 3, 3, 3, 4, 4, 5, 6, 6, 4, 4, 5, 6, 6, 4, 0];
|
||||
|
||||
private static readonly int[] ShortXor2 =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0x40,
|
||||
0x60,
|
||||
0xa0,
|
||||
@@ -220,8 +220,8 @@ internal partial class Unpack
|
||||
0x90,
|
||||
0x98,
|
||||
0x9c,
|
||||
0xb0,
|
||||
};
|
||||
0xb0
|
||||
];
|
||||
|
||||
private void unpack15(bool solid)
|
||||
{
|
||||
|
||||
@@ -14,13 +14,13 @@ namespace SharpCompress.Compressors.Rar.UnpackV1;
|
||||
|
||||
internal partial class Unpack
|
||||
{
|
||||
private readonly MultDecode[] MD = new[]
|
||||
{
|
||||
private readonly MultDecode[] MD =
|
||||
[
|
||||
new MultDecode(),
|
||||
new MultDecode(),
|
||||
new MultDecode(),
|
||||
new MultDecode(),
|
||||
new MultDecode(),
|
||||
};
|
||||
new MultDecode()
|
||||
];
|
||||
|
||||
private readonly byte[] UnpOldTable20 = new byte[PackDef.MC20 * 4];
|
||||
|
||||
@@ -42,8 +42,8 @@ internal partial class Unpack
|
||||
private readonly BitDecode BD = new();
|
||||
|
||||
private static readonly int[] LDecode =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
@@ -70,13 +70,12 @@ internal partial class Unpack
|
||||
128,
|
||||
160,
|
||||
192,
|
||||
224,
|
||||
};
|
||||
224
|
||||
];
|
||||
|
||||
private static ReadOnlySpan<byte> LBits =>
|
||||
new byte[]
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -103,12 +102,12 @@ internal partial class Unpack
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
};
|
||||
5
|
||||
];
|
||||
|
||||
private static readonly int[] DDecode =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
@@ -155,12 +154,12 @@ internal partial class Unpack
|
||||
786432,
|
||||
851968,
|
||||
917504,
|
||||
983040,
|
||||
};
|
||||
983040
|
||||
];
|
||||
|
||||
private static readonly int[] DBits =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -207,12 +206,12 @@ internal partial class Unpack
|
||||
16,
|
||||
16,
|
||||
16,
|
||||
16,
|
||||
};
|
||||
16
|
||||
];
|
||||
|
||||
private static readonly int[] SDDecode = { 0, 4, 8, 16, 32, 64, 128, 192 };
|
||||
private static readonly int[] SDDecode = [0, 4, 8, 16, 32, 64, 128, 192];
|
||||
|
||||
private static readonly int[] SDBits = { 2, 2, 3, 4, 5, 6, 6, 6 };
|
||||
private static readonly int[] SDBits = [2, 2, 3, 4, 5, 6, 6, 6];
|
||||
|
||||
private void unpack20(bool solid)
|
||||
{
|
||||
|
||||
@@ -8,8 +8,8 @@ internal partial class Unpack
|
||||
private const int STARTL1 = 2;
|
||||
|
||||
private static readonly uint[] DecL1 =
|
||||
{
|
||||
0x8000,
|
||||
[
|
||||
0x8000,
|
||||
0xa000,
|
||||
0xc000,
|
||||
0xd000,
|
||||
@@ -19,16 +19,16 @@ internal partial class Unpack
|
||||
0xf000,
|
||||
0xf200,
|
||||
0xf200,
|
||||
0xffff,
|
||||
};
|
||||
0xffff
|
||||
];
|
||||
|
||||
private static readonly uint[] PosL1 = { 0, 0, 0, 2, 3, 5, 7, 11, 16, 20, 24, 32, 32 };
|
||||
private static readonly uint[] PosL1 = [0, 0, 0, 2, 3, 5, 7, 11, 16, 20, 24, 32, 32];
|
||||
|
||||
private const int STARTL2 = 3;
|
||||
|
||||
private static readonly uint[] DecL2 =
|
||||
{
|
||||
0xa000,
|
||||
[
|
||||
0xa000,
|
||||
0xc000,
|
||||
0xd000,
|
||||
0xe000,
|
||||
@@ -37,16 +37,16 @@ internal partial class Unpack
|
||||
0xf000,
|
||||
0xf200,
|
||||
0xf240,
|
||||
0xffff,
|
||||
};
|
||||
0xffff
|
||||
];
|
||||
|
||||
private static readonly uint[] PosL2 = { 0, 0, 0, 0, 5, 7, 9, 13, 18, 22, 26, 34, 36 };
|
||||
private static readonly uint[] PosL2 = [0, 0, 0, 0, 5, 7, 9, 13, 18, 22, 26, 34, 36];
|
||||
|
||||
private const int STARTHF0 = 4;
|
||||
|
||||
private static readonly uint[] DecHf0 =
|
||||
{
|
||||
0x8000,
|
||||
[
|
||||
0x8000,
|
||||
0xc000,
|
||||
0xe000,
|
||||
0xf200,
|
||||
@@ -54,61 +54,61 @@ internal partial class Unpack
|
||||
0xf200,
|
||||
0xf200,
|
||||
0xf200,
|
||||
0xffff,
|
||||
};
|
||||
0xffff
|
||||
];
|
||||
|
||||
private static readonly uint[] PosHf0 = { 0, 0, 0, 0, 0, 8, 16, 24, 33, 33, 33, 33, 33 };
|
||||
private static readonly uint[] PosHf0 = [0, 0, 0, 0, 0, 8, 16, 24, 33, 33, 33, 33, 33];
|
||||
|
||||
private const int STARTHF1 = 5;
|
||||
|
||||
private static readonly uint[] DecHf1 =
|
||||
{
|
||||
0x2000,
|
||||
[
|
||||
0x2000,
|
||||
0xc000,
|
||||
0xe000,
|
||||
0xf000,
|
||||
0xf200,
|
||||
0xf200,
|
||||
0xf7e0,
|
||||
0xffff,
|
||||
};
|
||||
0xffff
|
||||
];
|
||||
|
||||
private static readonly uint[] PosHf1 = { 0, 0, 0, 0, 0, 0, 4, 44, 60, 76, 80, 80, 127 };
|
||||
private static readonly uint[] PosHf1 = [0, 0, 0, 0, 0, 0, 4, 44, 60, 76, 80, 80, 127];
|
||||
|
||||
private const int STARTHF2 = 5;
|
||||
|
||||
private static readonly uint[] DecHf2 =
|
||||
{
|
||||
0x1000,
|
||||
[
|
||||
0x1000,
|
||||
0x2400,
|
||||
0x8000,
|
||||
0xc000,
|
||||
0xfa00,
|
||||
0xffff,
|
||||
0xffff,
|
||||
0xffff,
|
||||
};
|
||||
0xffff
|
||||
];
|
||||
|
||||
private static readonly uint[] PosHf2 = { 0, 0, 0, 0, 0, 0, 2, 7, 53, 117, 233, 0, 0 };
|
||||
private static readonly uint[] PosHf2 = [0, 0, 0, 0, 0, 0, 2, 7, 53, 117, 233, 0, 0];
|
||||
|
||||
private const int STARTHF3 = 6;
|
||||
|
||||
private static readonly uint[] DecHf3 =
|
||||
{
|
||||
0x800,
|
||||
[
|
||||
0x800,
|
||||
0x2400,
|
||||
0xee00,
|
||||
0xfe80,
|
||||
0xffff,
|
||||
0xffff,
|
||||
0xffff,
|
||||
};
|
||||
0xffff
|
||||
];
|
||||
|
||||
private static readonly uint[] PosHf3 = { 0, 0, 0, 0, 0, 0, 0, 2, 16, 218, 251, 0, 0 };
|
||||
private static readonly uint[] PosHf3 = [0, 0, 0, 0, 0, 0, 0, 2, 16, 218, 251, 0, 0];
|
||||
|
||||
private const int STARTHF4 = 8;
|
||||
private static readonly uint[] DecHf4 = { 0xff00, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff };
|
||||
private static readonly uint[] PosHf4 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0 };
|
||||
private static readonly uint[] DecHf4 = [0xff00, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff];
|
||||
private static readonly uint[] PosHf4 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0];
|
||||
|
||||
private void Unpack15(bool Solid)
|
||||
{
|
||||
@@ -209,8 +209,8 @@ internal partial class Unpack
|
||||
internal static class Unpack15Local
|
||||
{
|
||||
public static readonly uint[] ShortLen1 =
|
||||
{
|
||||
1,
|
||||
[
|
||||
1,
|
||||
3,
|
||||
4,
|
||||
4,
|
||||
@@ -225,11 +225,11 @@ internal partial class Unpack
|
||||
6,
|
||||
6,
|
||||
4,
|
||||
0,
|
||||
};
|
||||
0
|
||||
];
|
||||
public static readonly uint[] ShortXor1 =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0xa0,
|
||||
0xd0,
|
||||
0xe0,
|
||||
@@ -243,11 +243,11 @@ internal partial class Unpack
|
||||
0x90,
|
||||
0x98,
|
||||
0x9c,
|
||||
0xb0,
|
||||
};
|
||||
0xb0
|
||||
];
|
||||
public static readonly uint[] ShortLen2 =
|
||||
{
|
||||
2,
|
||||
[
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
@@ -262,11 +262,11 @@ internal partial class Unpack
|
||||
6,
|
||||
6,
|
||||
4,
|
||||
0,
|
||||
};
|
||||
0
|
||||
];
|
||||
public static readonly uint[] ShortXor2 =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0x40,
|
||||
0x60,
|
||||
0xa0,
|
||||
@@ -280,8 +280,8 @@ internal partial class Unpack
|
||||
0x90,
|
||||
0x98,
|
||||
0x9c,
|
||||
0xb0,
|
||||
};
|
||||
0xb0
|
||||
];
|
||||
}
|
||||
|
||||
private void ShortLZ()
|
||||
|
||||
@@ -24,8 +24,8 @@ internal partial class Unpack
|
||||
internal static class Unpack20Local
|
||||
{
|
||||
public static readonly byte[] LDecode =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
@@ -52,11 +52,11 @@ internal partial class Unpack
|
||||
128,
|
||||
160,
|
||||
192,
|
||||
224,
|
||||
};
|
||||
224
|
||||
];
|
||||
public static readonly byte[] LBits =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -83,11 +83,11 @@ internal partial class Unpack
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
};
|
||||
5
|
||||
];
|
||||
public static readonly uint[] DDecode =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
@@ -134,11 +134,11 @@ internal partial class Unpack
|
||||
786432,
|
||||
851968,
|
||||
917504,
|
||||
983040,
|
||||
};
|
||||
983040
|
||||
];
|
||||
public static readonly byte[] DBits =
|
||||
{
|
||||
0,
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -185,10 +185,10 @@ internal partial class Unpack
|
||||
16,
|
||||
16,
|
||||
16,
|
||||
16,
|
||||
};
|
||||
public static readonly byte[] SDDecode = { 0, 4, 8, 16, 32, 64, 128, 192 };
|
||||
public static readonly byte[] SDBits = { 2, 2, 3, 4, 5, 6, 6, 6 };
|
||||
16
|
||||
];
|
||||
public static readonly byte[] SDDecode = [0, 4, 8, 16, 32, 64, 128, 192];
|
||||
public static readonly byte[] SDBits = [2, 2, 3, 4, 5, 6, 6, 6];
|
||||
}
|
||||
|
||||
private void Unpack20(bool Solid)
|
||||
|
||||
@@ -264,11 +264,11 @@ internal partial class Unpack
|
||||
byte *ReadBufMT;
|
||||
#endif*/
|
||||
|
||||
private byte[] FilterSrcMemory = Array.Empty<byte>();
|
||||
private byte[] FilterDstMemory = Array.Empty<byte>();
|
||||
private byte[] FilterSrcMemory = [];
|
||||
private byte[] FilterDstMemory = [];
|
||||
|
||||
// Filters code, one entry per filter.
|
||||
private readonly List<UnpackFilter> Filters = new();
|
||||
private readonly List<UnpackFilter> Filters = [];
|
||||
|
||||
private readonly uint[] OldDist = new uint[4];
|
||||
private uint OldDistPtr;
|
||||
@@ -395,15 +395,15 @@ internal partial class Unpack
|
||||
private readonly BitInput VMCodeInp = new(true);
|
||||
|
||||
// Filters code, one entry per filter.
|
||||
private readonly List<UnpackFilter30> Filters30 = new();
|
||||
private readonly List<UnpackFilter30> Filters30 = [];
|
||||
|
||||
// Filters stack, several entrances of same filter are possible.
|
||||
private readonly List<UnpackFilter30> PrgStack = new();
|
||||
private readonly List<UnpackFilter30> PrgStack = [];
|
||||
|
||||
// Lengths of preceding data blocks, one length of one last block
|
||||
// for every filter. Used to reduce the size required to write
|
||||
// the data block length if lengths are repeating.
|
||||
private readonly List<int> OldFilterLengths = new();
|
||||
private readonly List<int> OldFilterLengths = [];
|
||||
|
||||
/*#if RarV2017_RAR_SMP
|
||||
// More than 8 threads are unlikely to provide a noticeable gain
|
||||
|
||||
@@ -1108,15 +1108,15 @@ internal sealed class RarVM : BitInput
|
||||
private VMStandardFilters IsStandardFilter(ReadOnlySpan<byte> code, int codeSize)
|
||||
{
|
||||
VMStandardFilterSignature[] stdList =
|
||||
{
|
||||
new(53, 0xad576887, VMStandardFilters.VMSF_E8),
|
||||
[
|
||||
new(53, 0xad576887, VMStandardFilters.VMSF_E8),
|
||||
new(57, 0x3cd7e57e, VMStandardFilters.VMSF_E8E9),
|
||||
new(120, 0x3769893f, VMStandardFilters.VMSF_ITANIUM),
|
||||
new(29, 0x0e06077d, VMStandardFilters.VMSF_DELTA),
|
||||
new(149, 0x1c2c5dc8, VMStandardFilters.VMSF_RGB),
|
||||
new(216, 0xbc85e701, VMStandardFilters.VMSF_AUDIO),
|
||||
new(40, 0x46b9c560, VMStandardFilters.VMSF_UPCASE),
|
||||
};
|
||||
new(40, 0x46b9c560, VMStandardFilters.VMSF_UPCASE)
|
||||
];
|
||||
var CodeCRC = RarCRC.CheckCrc(0xffffffff, code, 0, code.Length) ^ 0xffffffff;
|
||||
for (var i = 0; i < stdList.Length; i++)
|
||||
{
|
||||
@@ -1199,7 +1199,7 @@ internal sealed class RarVM : BitInput
|
||||
var curPos = 0;
|
||||
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'Masks '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
byte[] Masks = { 4, 4, 6, 6, 0, 0, 7, 7, 4, 4, 0, 0, 4, 4, 0, 0 };
|
||||
byte[] Masks = [4, 4, 6, 6, 0, 0, 7, 7, 4, 4, 0, 0, 4, 4, 0, 0];
|
||||
fileOffset = Utility.URShift(fileOffset, 4);
|
||||
|
||||
while (curPos < dataSize - 21)
|
||||
|
||||
@@ -13,8 +13,8 @@ internal class VMCmdFlags
|
||||
public const byte VMCF_CHFLAGS = 64;
|
||||
|
||||
public static byte[] VM_CmdFlags =
|
||||
{
|
||||
VMCF_OP2 | VMCF_BYTEMODE,
|
||||
[
|
||||
VMCF_OP2 | VMCF_BYTEMODE,
|
||||
VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS,
|
||||
VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS,
|
||||
VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS,
|
||||
@@ -53,6 +53,6 @@ internal class VMCmdFlags
|
||||
VMCF_OP2 | VMCF_BYTEMODE,
|
||||
VMCF_OP2 | VMCF_BYTEMODE | VMCF_USEFLAGS | VMCF_CHFLAGS,
|
||||
VMCF_OP2 | VMCF_BYTEMODE | VMCF_USEFLAGS | VMCF_CHFLAGS,
|
||||
VMCF_OP0,
|
||||
};
|
||||
VMCF_OP0
|
||||
];
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ namespace SharpCompress.Compressors.Rar.VM;
|
||||
|
||||
internal class VMPreparedProgram
|
||||
{
|
||||
internal List<VMPreparedCommand> Commands = new();
|
||||
internal List<VMPreparedCommand> AltCommands = new();
|
||||
internal List<VMPreparedCommand> Commands = [];
|
||||
internal List<VMPreparedCommand> AltCommands = [];
|
||||
|
||||
public int CommandCount { get; set; }
|
||||
|
||||
internal List<byte> GlobalData = new();
|
||||
internal List<byte> StaticData = new();
|
||||
internal List<byte> GlobalData = [];
|
||||
internal List<byte> StaticData = [];
|
||||
|
||||
// static data contained in DB operators
|
||||
internal int[] InitR = new int[7];
|
||||
|
||||
@@ -113,9 +113,9 @@ public class ReduceStream : Stream, IStreamStack
|
||||
private const int RunLengthCode = 144;
|
||||
private const int WSIZE = 0x4000;
|
||||
|
||||
private readonly uint[] mask_bits = new uint[]
|
||||
{
|
||||
0x0000,
|
||||
private readonly uint[] mask_bits =
|
||||
[
|
||||
0x0000,
|
||||
0x0001,
|
||||
0x0003,
|
||||
0x0007,
|
||||
@@ -131,8 +131,8 @@ public class ReduceStream : Stream, IStreamStack
|
||||
0x1fff,
|
||||
0x3fff,
|
||||
0x7fff,
|
||||
0xffff,
|
||||
};
|
||||
0xffff
|
||||
];
|
||||
|
||||
private int bitBufferCount;
|
||||
private ulong bitBuffer;
|
||||
@@ -168,7 +168,7 @@ public class ReduceStream : Stream, IStreamStack
|
||||
|
||||
private void LoadBitLengthTable()
|
||||
{
|
||||
byte[] bitPos = { 0, 2, 4, 8, 16, 32, 64, 128, 255 };
|
||||
byte[] bitPos = [0, 2, 4, 8, 16, 32, 64, 128, 255];
|
||||
bitCountTable = new byte[256];
|
||||
|
||||
for (byte i = 1; i <= 8; i++)
|
||||
|
||||
@@ -8,9 +8,9 @@ internal class BitStream
|
||||
private int _bitIdx;
|
||||
private int _bitsLeft;
|
||||
private ulong _bitBuffer;
|
||||
private static uint[] _maskBits = new uint[17]
|
||||
{
|
||||
0U,
|
||||
private static uint[] _maskBits =
|
||||
[
|
||||
0U,
|
||||
1U,
|
||||
3U,
|
||||
7U,
|
||||
@@ -26,8 +26,8 @@ internal class BitStream
|
||||
8191U,
|
||||
16383U,
|
||||
(uint)short.MaxValue,
|
||||
(uint)ushort.MaxValue,
|
||||
};
|
||||
(uint)ushort.MaxValue
|
||||
];
|
||||
|
||||
public BitStream(byte[] src, int srcLen)
|
||||
{
|
||||
|
||||
@@ -1,51 +1,53 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace SharpCompress.Compressors.Squeezed;
|
||||
|
||||
public class BitReader
|
||||
{
|
||||
private readonly Stream _stream;
|
||||
private int _bitBuffer;
|
||||
private int _bitCount;
|
||||
private readonly Stream _stream;
|
||||
private int _bitBuffer;
|
||||
private int _bitCount;
|
||||
|
||||
public BitReader(Stream stream)
|
||||
public BitReader(Stream stream)
|
||||
{
|
||||
_stream = stream;
|
||||
_bitBuffer = 0;
|
||||
_bitCount = 0;
|
||||
}
|
||||
|
||||
public bool ReadBit()
|
||||
{
|
||||
if (_bitCount == 0)
|
||||
{
|
||||
_stream = stream;
|
||||
_bitBuffer = 0;
|
||||
_bitCount = 0;
|
||||
int nextByte = _stream.ReadByte();
|
||||
if (nextByte == -1)
|
||||
{
|
||||
throw new EndOfStreamException();
|
||||
}
|
||||
|
||||
_bitBuffer = nextByte;
|
||||
_bitCount = 8;
|
||||
}
|
||||
|
||||
public bool ReadBit()
|
||||
bool bit = (_bitBuffer & 1) != 0;
|
||||
_bitBuffer >>= 1;
|
||||
_bitCount--;
|
||||
return bit;
|
||||
}
|
||||
|
||||
public int ReadBits(int count)
|
||||
{
|
||||
if (count < 1 || count > 32)
|
||||
{
|
||||
if (_bitCount == 0)
|
||||
{
|
||||
int nextByte = _stream.ReadByte();
|
||||
if (nextByte == -1)
|
||||
{
|
||||
throw new EndOfStreamException();
|
||||
}
|
||||
|
||||
_bitBuffer = nextByte;
|
||||
_bitCount = 8;
|
||||
}
|
||||
|
||||
bool bit = (_bitBuffer & 1) != 0;
|
||||
_bitBuffer >>= 1;
|
||||
_bitCount--;
|
||||
return bit;
|
||||
throw new ArgumentOutOfRangeException(nameof(count), "Count must be between 1 and 32.");
|
||||
}
|
||||
|
||||
public int ReadBits(int count)
|
||||
int value = 0;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (count < 1 || count > 32)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count), "Count must be between 1 and 32.");
|
||||
}
|
||||
|
||||
int value = 0;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
value = (value << 1) | (ReadBit() ? 1 : 0);
|
||||
}
|
||||
return value;
|
||||
value = (value << 1) | (ReadBit() ? 1 : 0);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class Lzma2Filter : BlockFilter
|
||||
public override void ValidateFilter() { }
|
||||
|
||||
public override void SetBaseStream(Stream stream) =>
|
||||
BaseStream = new LzmaStream(new[] { _dictionarySize }, stream);
|
||||
BaseStream = new LzmaStream([_dictionarySize], stream);
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count) =>
|
||||
BaseStream.Read(buffer, offset, count);
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace SharpCompress.Compressors.Xz;
|
||||
public class XZHeader
|
||||
{
|
||||
private readonly BinaryReader _reader;
|
||||
private readonly byte[] MagicHeader = { 0xFD, 0x37, 0x7A, 0x58, 0x5a, 0x00 };
|
||||
private readonly byte[] MagicHeader = [0xFD, 0x37, 0x7A, 0x58, 0x5a, 0x00];
|
||||
|
||||
public CheckType BlockCheckType { get; private set; }
|
||||
public int BlockCheckSize => 4 << ((((int)BlockCheckType + 2) / 3) - 1);
|
||||
|
||||
@@ -14,7 +14,7 @@ public class XZIndex
|
||||
private readonly BinaryReader _reader;
|
||||
public long StreamStartPosition { get; private set; }
|
||||
public ulong NumberOfRecords { get; private set; }
|
||||
public List<XZIndexRecord> Records { get; } = new();
|
||||
public List<XZIndexRecord> Records { get; } = [];
|
||||
|
||||
private readonly bool _indexMarkerAlreadyVerified;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public abstract class Factory : IFactory
|
||||
RegisterFactory(new ArcFactory());
|
||||
}
|
||||
|
||||
private static readonly HashSet<Factory> _factories = new();
|
||||
private static readonly HashSet<Factory> _factories = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of registered <see cref="IFactory"/>.
|
||||
|
||||
@@ -31,7 +31,7 @@ public class DataDescriptorStream : Stream, IStreamStack
|
||||
private bool _isDisposed;
|
||||
private bool _done;
|
||||
|
||||
private static byte[] _dataDescriptorMarker = new byte[] { 0x50, 0x4b, 0x07, 0x08 };
|
||||
private static byte[] _dataDescriptorMarker = [0x50, 0x4b, 0x07, 0x08];
|
||||
private static long _dataDescriptorSize = 24;
|
||||
|
||||
public DataDescriptorStream(Stream stream)
|
||||
|
||||
@@ -50,8 +50,8 @@ public class SourceStream : Stream, IStreamStack
|
||||
)
|
||||
{
|
||||
ReaderOptions = options;
|
||||
_files = new List<FileInfo>();
|
||||
_streams = new List<Stream>();
|
||||
_files = [];
|
||||
_streams = [];
|
||||
IsFileMode = file != null;
|
||||
IsVolumes = false;
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace SharpCompress.IO;
|
||||
|
||||
@@ -46,7 +44,7 @@ internal static class StackStreamExtensions
|
||||
buffStream = current;
|
||||
buffStream.BufferPosition -= Math.Min(buffStream.BufferPosition, count);
|
||||
}
|
||||
current = current?.BaseStream() as IStreamStack;
|
||||
current = current.BaseStream() as IStreamStack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +177,6 @@ internal static class StackStreamExtensions
|
||||
)
|
||||
{
|
||||
var baseStream = stream.BaseStream();
|
||||
var thisStream = (Stream)stream;
|
||||
var current = stream;
|
||||
buffStream = null;
|
||||
baseReadCount = -1;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace SharpCompress.Helpers;
|
||||
|
||||
internal sealed class LazyReadOnlyCollection<T> : ICollection<T>
|
||||
{
|
||||
private readonly List<T> backing = new();
|
||||
private readonly List<T> backing = [];
|
||||
private readonly IEnumerator<T> source;
|
||||
private bool fullyLoaded;
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ internal static class NotNullExtensions
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static IEnumerable<T> Empty<T>(this IEnumerable<T>? source) =>
|
||||
source ?? Enumerable.Empty<T>();
|
||||
source ?? [];
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static IEnumerable<T> Empty<T>(this T? source)
|
||||
{
|
||||
if (source is null)
|
||||
{
|
||||
return Enumerable.Empty<T>();
|
||||
return [];
|
||||
}
|
||||
return source.AsEnumerable();
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ internal class ZipCentralDirectoryEntry
|
||||
usedCompression = ZipCompressionMethod.None;
|
||||
}
|
||||
|
||||
Span<byte> intBuf = stackalloc byte[] { 80, 75, 1, 2, version, 0, version, 0 };
|
||||
Span<byte> intBuf = [80, 75, 1, 2, version, 0, version, 0];
|
||||
//constant sig, then version made by, then version to extract
|
||||
outputStream.Write(intBuf);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ZipWriter : AbstractWriter
|
||||
{
|
||||
private readonly CompressionType compressionType;
|
||||
private readonly int compressionLevel;
|
||||
private readonly List<ZipCentralDirectoryEntry> entries = new();
|
||||
private readonly List<ZipCentralDirectoryEntry> entries = [];
|
||||
private readonly string zipComment;
|
||||
private long streamPosition;
|
||||
private PpmdProperties? ppmdProps;
|
||||
@@ -162,16 +162,16 @@ public class ZipWriter : AbstractWriter
|
||||
{
|
||||
if (OutputStream.CanSeek && useZip64)
|
||||
{
|
||||
OutputStream.Write(stackalloc byte[] { 45, 0 }); //smallest allowed version for zip64
|
||||
OutputStream.Write([45, 0]); //smallest allowed version for zip64
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputStream.Write(stackalloc byte[] { 20, 0 }); //older version which is more compatible
|
||||
OutputStream.Write([20, 0]); //older version which is more compatible
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputStream.Write(stackalloc byte[] { 63, 0 }); //version says we used PPMd or LZMA
|
||||
OutputStream.Write([63, 0]); //version says we used PPMd or LZMA
|
||||
}
|
||||
var flags = Equals(WriterOptions.ArchiveEncoding.GetEncoding(), Encoding.UTF8)
|
||||
? HeaderFlags.Efs
|
||||
@@ -197,7 +197,7 @@ public class ZipWriter : AbstractWriter
|
||||
OutputStream.Write(intBuf);
|
||||
|
||||
// zipping date and time
|
||||
OutputStream.Write(stackalloc byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
OutputStream.Write([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
// unused CRC, un/compressed size, updated later
|
||||
BinaryPrimitives.WriteUInt16LittleEndian(intBuf, (ushort)encodedFilename.Length);
|
||||
@@ -250,7 +250,7 @@ public class ZipWriter : AbstractWriter
|
||||
var recordlen = 2 + 2 + 4 + 4 + 8 + 8 + 8 + 8;
|
||||
|
||||
// Write zip64 end of central directory record
|
||||
OutputStream.Write(stackalloc byte[] { 80, 75, 6, 6 });
|
||||
OutputStream.Write([80, 75, 6, 6]);
|
||||
|
||||
BinaryPrimitives.WriteUInt64LittleEndian(intBuf, (ulong)recordlen);
|
||||
OutputStream.Write(intBuf); // Size of zip64 end of central directory record
|
||||
@@ -273,7 +273,7 @@ public class ZipWriter : AbstractWriter
|
||||
OutputStream.Write(intBuf); // Disk offset
|
||||
|
||||
// Write zip64 end of central directory locator
|
||||
OutputStream.Write(stackalloc byte[] { 80, 75, 6, 7 });
|
||||
OutputStream.Write([80, 75, 6, 7]);
|
||||
|
||||
BinaryPrimitives.WriteUInt32LittleEndian(intBuf, 0);
|
||||
OutputStream.Write(intBuf.Slice(0, 4)); // Entry disk
|
||||
@@ -286,7 +286,7 @@ public class ZipWriter : AbstractWriter
|
||||
}
|
||||
|
||||
// Write normal end of central directory record
|
||||
OutputStream.Write(stackalloc byte[] { 80, 75, 5, 6, 0, 0, 0, 0 });
|
||||
OutputStream.Write([80, 75, 5, 6, 0, 0, 0, 0]);
|
||||
BinaryPrimitives.WriteUInt16LittleEndian(
|
||||
intBuf,
|
||||
(ushort)(entries.Count < 0xFFFF ? entries.Count : 0xFFFF)
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ArchiveTests : ReaderTests
|
||||
protected void ArchiveStreamReadExtractAll(string testArchive, CompressionType compression)
|
||||
{
|
||||
testArchive = Path.Combine(TEST_ARCHIVES_PATH, testArchive);
|
||||
ArchiveStreamReadExtractAll(new[] { testArchive }, compression);
|
||||
ArchiveStreamReadExtractAll([testArchive], compression);
|
||||
}
|
||||
|
||||
protected void ArchiveStreamReadExtractAll(
|
||||
|
||||
@@ -14,7 +14,7 @@ public class BZip2ReaderTests : ReaderTests
|
||||
public void BZip2_Reader_Factory()
|
||||
{
|
||||
Stream stream = new MemoryStream(
|
||||
new byte[] { 0x42, 0x5a, 0x68, 0x34, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0x35 }
|
||||
[0x42, 0x5a, 0x68, 0x34, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0x35]
|
||||
);
|
||||
Assert.Throws(typeof(InvalidOperationException), () => ReaderFactory.Open(stream));
|
||||
}
|
||||
|
||||
@@ -417,47 +417,44 @@ public class RarArchiveTests : ArchiveTests
|
||||
public void Rar_GetPartsSplit() =>
|
||||
//uses first part to search for all parts and compares against this array
|
||||
ArchiveGetParts(
|
||||
new[]
|
||||
{
|
||||
"Rar4.split.001",
|
||||
[
|
||||
"Rar4.split.001",
|
||||
"Rar4.split.002",
|
||||
"Rar4.split.003",
|
||||
"Rar4.split.004",
|
||||
"Rar4.split.005",
|
||||
"Rar4.split.006",
|
||||
}
|
||||
"Rar4.split.006"
|
||||
]
|
||||
);
|
||||
|
||||
[Fact]
|
||||
public void Rar_GetPartsOld() =>
|
||||
//uses first part to search for all parts and compares against this array
|
||||
ArchiveGetParts(
|
||||
new[]
|
||||
{
|
||||
"Rar2.multi.rar",
|
||||
[
|
||||
"Rar2.multi.rar",
|
||||
"Rar2.multi.r00",
|
||||
"Rar2.multi.r01",
|
||||
"Rar2.multi.r02",
|
||||
"Rar2.multi.r03",
|
||||
"Rar2.multi.r04",
|
||||
"Rar2.multi.r05",
|
||||
}
|
||||
"Rar2.multi.r05"
|
||||
]
|
||||
);
|
||||
|
||||
[Fact]
|
||||
public void Rar_GetPartsNew() =>
|
||||
//uses first part to search for all parts and compares against this array
|
||||
ArchiveGetParts(
|
||||
new[]
|
||||
{
|
||||
"Rar4.multi.part01.rar",
|
||||
[
|
||||
"Rar4.multi.part01.rar",
|
||||
"Rar4.multi.part02.rar",
|
||||
"Rar4.multi.part03.rar",
|
||||
"Rar4.multi.part04.rar",
|
||||
"Rar4.multi.part05.rar",
|
||||
"Rar4.multi.part06.rar",
|
||||
"Rar4.multi.part07.rar",
|
||||
}
|
||||
"Rar4.multi.part07.rar"
|
||||
]
|
||||
);
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace SharpCompress.Test.Zip;
|
||||
/// </summary>
|
||||
internal class TestPseudoTextStream : Stream
|
||||
{
|
||||
private static readonly char[] _vowels = { 'a', 'e', 'i', 'o', 'u' };
|
||||
private static readonly char[] _vowels = ['a', 'e', 'i', 'o', 'u'];
|
||||
private static readonly char[] _consonants = "bcdfghjklmnpqrstvwxyz".ToCharArray();
|
||||
|
||||
private long _position = 0;
|
||||
|
||||
@@ -150,7 +150,9 @@ public class Zip64Tests : WriterTests
|
||||
var opts = new ZipWriterOptions(CompressionType.Deflate) { UseZip64 = setZip64 };
|
||||
|
||||
// Use no compression to ensure we hit the limits (actually inflates a bit, but seems better than using method==Store)
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var eo = new ZipWriterEntryOptions { DeflateCompressionLevel = CompressionLevel.None };
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
using var zip = File.OpenWrite(filename);
|
||||
using var st = forwardOnly ? (Stream)new ForwardOnlyStream(zip) : zip;
|
||||
|
||||
@@ -107,26 +107,25 @@ public class ZipArchiveTests : ArchiveTests
|
||||
[Fact]
|
||||
public void Zip_GetParts() =>
|
||||
//uses first part to search for all parts and compares against this array
|
||||
ArchiveGetParts(new[] { "Infozip.nocomp.multi.zip", "Infozip.nocomp.multi.z01" });
|
||||
ArchiveGetParts(["Infozip.nocomp.multi.zip", "Infozip.nocomp.multi.z01"]);
|
||||
|
||||
[Fact]
|
||||
public void ZipX_GetParts() =>
|
||||
//uses first part to search for all parts and compares against this array
|
||||
ArchiveGetParts(new[] { "WinZip26.nocomp.multi.zipx", "WinZip26.nocomp.multi.zx01" });
|
||||
ArchiveGetParts(["WinZip26.nocomp.multi.zipx", "WinZip26.nocomp.multi.zx01"]);
|
||||
|
||||
[Fact]
|
||||
public void Zip_GetPartsSplit() =>
|
||||
//uses first part to search for all parts and compares against this array
|
||||
ArchiveGetParts(
|
||||
new[]
|
||||
{
|
||||
"Zip.deflate.split.001",
|
||||
[
|
||||
"Zip.deflate.split.001",
|
||||
"Zip.deflate.split.002",
|
||||
"Zip.deflate.split.003",
|
||||
"Zip.deflate.split.004",
|
||||
"Zip.deflate.split.005",
|
||||
"Zip.deflate.split.006",
|
||||
}
|
||||
"Zip.deflate.split.006"
|
||||
]
|
||||
);
|
||||
|
||||
//will detect and load other files
|
||||
@@ -622,7 +621,7 @@ public class ZipArchiveTests : ArchiveTests
|
||||
|
||||
using (var zipWriter = WriterFactory.Open(stream, ArchiveType.Zip, CompressionType.Deflate))
|
||||
{
|
||||
zipWriter.Write("foo.txt", new MemoryStream(Array.Empty<byte>()));
|
||||
zipWriter.Write("foo.txt", new MemoryStream([]));
|
||||
zipWriter.Write("foo2.txt", new MemoryStream(new byte[10]));
|
||||
}
|
||||
|
||||
|
||||
@@ -247,7 +247,7 @@ public class ZipReaderTests : ReaderTests
|
||||
{
|
||||
var expected = new[]
|
||||
{
|
||||
new Tuple<string, byte[]>("foo.txt", Array.Empty<byte>()),
|
||||
new Tuple<string, byte[]>("foo.txt", []),
|
||||
new Tuple<string, byte[]>("foo2.txt", new byte[10]),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user