diff --git a/.editorconfig b/.editorconfig index d36b9a2..252ca96 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,127 +9,167 @@ ## https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ ## https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ ## Microsoft Rules -## - root = true -# EditorConfig is awesome: http://EditorConfig.org -# top-most EditorConfig file - -# Global settings +# All files [*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true - -# Xml project files -[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] indent_style = space + +# Xml files +[*.xml] indent_size = 2 -# Xml config files -[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] -indent_style = space -indent_size = 2 - -[*.{md,json}] -indent_style = space -indent_size = 4 - +# C# files [*.cs] -indent_style = space -indent_size = 4 -max_line_length = 100 -# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +tab_width = 4 +max_line_length = 120 + +# New line preferences +insert_final_newline = false + +#### .NET Coding Conventions #### +[*.{cs,vb}] + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = true +file_header_template = unset + +# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview?#enable-on-build +# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/language-rules#option-format +# this. and Me. preferences +dotnet_style_qualification_for_event = false:silent +dotnet_style_qualification_for_field = false:silent +dotnet_style_qualification_for_method = false:silent +dotnet_style_qualification_for_property = false:silent + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_predefined_type_for_member_access = true:silent + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent + +# Expression-level preferences +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_namespace_match_folder = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_object_initializer = true:suggestion +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true:suggestion +dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion +dotnet_style_prefer_conditional_expression_over_return = true:suggestion +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion + +# Field preferences +dotnet_style_readonly_field = true:warning + +# Parameter preferences +dotnet_code_quality_unused_parameters = all:suggestion + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = none + +#### C# Coding Conventions #### +[*.cs] + +# var preferences +csharp_style_var_elsewhere = false:silent +csharp_style_var_for_built_in_types = false:silent +csharp_style_var_when_type_is_apparent = false:silent + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_lambdas = true:suggestion +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_prefer_extended_property_pattern = true:suggestion +csharp_style_prefer_not_pattern = true:suggestion +csharp_style_prefer_pattern_matching = true:silent +csharp_style_prefer_switch_expression = true:suggestion + +# Null-checking preferences +csharp_style_conditional_delegate_call = true:suggestion + +# Modifier preferences +csharp_prefer_static_anonymous_function = true:suggestion +csharp_prefer_static_local_function = true:warning +csharp_preferred_modifier_order = public,private,protected,internal,file,const,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion +csharp_style_prefer_readonly_struct = true:suggestion +csharp_style_prefer_readonly_struct_member = true:suggestion + +# Code-block preferences +csharp_prefer_braces = true:silent +csharp_prefer_simple_using_statement = true:suggestion +csharp_style_namespace_declarations = file_scoped:suggestion +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_primary_constructors = true:suggestion +csharp_style_prefer_top_level_statements = true:silent + +# Expression-level preferences +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_local_over_anonymous_function = true:suggestion +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_prefer_tuple_swap = true:suggestion +csharp_style_prefer_utf8_string_literals = true:suggestion +csharp_style_throw_expression = true:suggestion +csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:silent + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace:silent + +#### C# Formatting Rules #### + # New line preferences -csharp_new_line_before_open_brace = all -csharp_new_line_before_else = true csharp_new_line_before_catch = true +csharp_new_line_before_else = true csharp_new_line_before_finally = true -csharp_new_line_before_members_in_object_initializers = true csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all csharp_new_line_between_query_expression_clauses = true -# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options#indentation-options # Indentation preferences csharp_indent_block_contents = true csharp_indent_braces = false csharp_indent_case_contents = true -csharp_indent_switch_labels = true +csharp_indent_case_contents_when_block = true csharp_indent_labels = one_less_than_current - -# avoid this. unless absolutely 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 - -# only use var when it's obvious what the variable type is -# csharp_style_var_for_built_in_types = false:none -# csharp_style_var_when_type_is_apparent = false:none -# csharp_style_var_elsewhere = false:suggestion - -# use language keywords instead of BCL types -dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion -dotnet_style_predefined_type_for_member_access = true:suggestion - -# name all constant fields using PascalCase -dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields -dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style - -dotnet_naming_symbols.constant_fields.applicable_kinds = field -dotnet_naming_symbols.constant_fields.required_modifiers = const - -dotnet_naming_style.pascal_case_style.capitalization = pascal_case - -dotnet_naming_symbols.static_fields.applicable_kinds = field -dotnet_naming_symbols.static_fields.required_modifiers = static - -dotnet_naming_style.static_prefix_style.required_prefix = s_ -dotnet_naming_style.static_prefix_style.capitalization = camel_case - -# internal and private fields should be _camelCase -dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion -dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields -dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style - -dotnet_naming_symbols.private_internal_fields.applicable_kinds = field -dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal - -dotnet_naming_style.camel_case_underscore_style.required_prefix = _ -dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case - -# Code style defaults -dotnet_sort_system_directives_first = true -csharp_preserve_single_line_blocks = true -csharp_preserve_single_line_statements = false - -# Expression-level preferences -dotnet_style_object_initializer = true:suggestion -dotnet_style_collection_initializer = true:suggestion -dotnet_style_explicit_tuple_names = true:suggestion -dotnet_style_coalesce_expression = true:suggestion -dotnet_style_null_propagation = true:suggestion - -# Expression-bodied members -csharp_style_expression_bodied_methods = false:none -csharp_style_expression_bodied_constructors = false:none -csharp_style_expression_bodied_operators = false:none -csharp_style_expression_bodied_properties = true:none -csharp_style_expression_bodied_indexers = true:none -csharp_style_expression_bodied_accessors = true:none - -# Pattern matching -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 - -# Null checking preferences -csharp_style_throw_expression = true:suggestion -csharp_style_conditional_delegate_call = true:suggestion +csharp_indent_switch_labels = true # Space preferences csharp_space_after_cast = false @@ -139,6 +179,7 @@ csharp_space_after_dot = false csharp_space_after_keywords_in_control_flow_statements = true csharp_space_after_semicolon_in_for_statement = true csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false csharp_space_before_colon_in_inheritance_clause = true csharp_space_before_comma = false csharp_space_before_dot = false @@ -154,6 +195,200 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false csharp_space_between_parentheses = false csharp_space_between_square_brackets = false +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### +[*.{cs,vb}] + +# Naming rules + +dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.symbols = types_and_namespaces +dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.interfaces_should_be_ipascalcase.severity = suggestion +dotnet_naming_rule.interfaces_should_be_ipascalcase.symbols = interfaces +dotnet_naming_rule.interfaces_should_be_ipascalcase.style = ipascalcase + +dotnet_naming_rule.type_parameters_should_be_tpascalcase.severity = suggestion +dotnet_naming_rule.type_parameters_should_be_tpascalcase.symbols = type_parameters +dotnet_naming_rule.type_parameters_should_be_tpascalcase.style = tpascalcase + +dotnet_naming_rule.methods_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.methods_should_be_pascalcase.symbols = methods +dotnet_naming_rule.methods_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.properties_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.properties_should_be_pascalcase.symbols = properties +dotnet_naming_rule.properties_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.events_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.events_should_be_pascalcase.symbols = events +dotnet_naming_rule.events_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.local_variables_should_be_camelcase.severity = suggestion +dotnet_naming_rule.local_variables_should_be_camelcase.symbols = local_variables +dotnet_naming_rule.local_variables_should_be_camelcase.style = camelcase + +dotnet_naming_rule.local_constants_should_be_camelcase.severity = suggestion +dotnet_naming_rule.local_constants_should_be_camelcase.symbols = local_constants +dotnet_naming_rule.local_constants_should_be_camelcase.style = camelcase + +dotnet_naming_rule.parameters_should_be_camelcase.severity = suggestion +dotnet_naming_rule.parameters_should_be_camelcase.symbols = parameters +dotnet_naming_rule.parameters_should_be_camelcase.style = camelcase + +dotnet_naming_rule.public_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_fields_should_be_pascalcase.symbols = public_fields +dotnet_naming_rule.public_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.private_fields_should_be__camelcase.severity = suggestion +dotnet_naming_rule.private_fields_should_be__camelcase.symbols = private_fields +dotnet_naming_rule.private_fields_should_be__camelcase.style = _camelcase + +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.severity = suggestion +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.symbols = private_static_fields +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.style = s_camelcase + +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.symbols = public_constant_fields +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.symbols = private_constant_fields +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.symbols = public_static_readonly_fields +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.symbols = private_static_readonly_fields +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.enums_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.enums_should_be_pascalcase.symbols = enums +dotnet_naming_rule.enums_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.local_functions_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.local_functions_should_be_pascalcase.symbols = local_functions +dotnet_naming_rule.local_functions_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.non_field_members_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascalcase.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascalcase.style = pascalcase + +# Symbol specifications + +dotnet_naming_symbols.interfaces.applicable_kinds = interface +dotnet_naming_symbols.interfaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interfaces.required_modifiers = + +dotnet_naming_symbols.enums.applicable_kinds = enum +dotnet_naming_symbols.enums.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.enums.required_modifiers = + +dotnet_naming_symbols.events.applicable_kinds = event +dotnet_naming_symbols.events.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.events.required_modifiers = + +dotnet_naming_symbols.methods.applicable_kinds = method +dotnet_naming_symbols.methods.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.methods.required_modifiers = + +dotnet_naming_symbols.properties.applicable_kinds = property +dotnet_naming_symbols.properties.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.properties.required_modifiers = + +dotnet_naming_symbols.public_fields.applicable_kinds = field +dotnet_naming_symbols.public_fields.applicable_accessibilities = public, internal +dotnet_naming_symbols.public_fields.required_modifiers = + +dotnet_naming_symbols.private_fields.applicable_kinds = field +dotnet_naming_symbols.private_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_fields.required_modifiers = + +dotnet_naming_symbols.private_static_fields.applicable_kinds = field +dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_static_fields.required_modifiers = static + +dotnet_naming_symbols.types_and_namespaces.applicable_kinds = namespace, class, struct, interface, enum +dotnet_naming_symbols.types_and_namespaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types_and_namespaces.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +dotnet_naming_symbols.type_parameters.applicable_kinds = namespace +dotnet_naming_symbols.type_parameters.applicable_accessibilities = * +dotnet_naming_symbols.type_parameters.required_modifiers = + +dotnet_naming_symbols.private_constant_fields.applicable_kinds = field +dotnet_naming_symbols.private_constant_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_constant_fields.required_modifiers = const + +dotnet_naming_symbols.local_variables.applicable_kinds = local +dotnet_naming_symbols.local_variables.applicable_accessibilities = local +dotnet_naming_symbols.local_variables.required_modifiers = + +dotnet_naming_symbols.local_constants.applicable_kinds = local +dotnet_naming_symbols.local_constants.applicable_accessibilities = local +dotnet_naming_symbols.local_constants.required_modifiers = const + +dotnet_naming_symbols.parameters.applicable_kinds = parameter +dotnet_naming_symbols.parameters.applicable_accessibilities = * +dotnet_naming_symbols.parameters.required_modifiers = + +dotnet_naming_symbols.public_constant_fields.applicable_kinds = field +dotnet_naming_symbols.public_constant_fields.applicable_accessibilities = public, internal +dotnet_naming_symbols.public_constant_fields.required_modifiers = const + +dotnet_naming_symbols.public_static_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.public_static_readonly_fields.applicable_accessibilities = public, internal +dotnet_naming_symbols.public_static_readonly_fields.required_modifiers = readonly, static + +dotnet_naming_symbols.private_static_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.private_static_readonly_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = readonly, static + +dotnet_naming_symbols.local_functions.applicable_kinds = local_function +dotnet_naming_symbols.local_functions.applicable_accessibilities = * +dotnet_naming_symbols.local_functions.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascalcase.required_prefix = +dotnet_naming_style.pascalcase.required_suffix = +dotnet_naming_style.pascalcase.word_separator = +dotnet_naming_style.pascalcase.capitalization = pascal_case + +dotnet_naming_style.ipascalcase.required_prefix = I +dotnet_naming_style.ipascalcase.required_suffix = +dotnet_naming_style.ipascalcase.word_separator = +dotnet_naming_style.ipascalcase.capitalization = pascal_case + +dotnet_naming_style.tpascalcase.required_prefix = T +dotnet_naming_style.tpascalcase.required_suffix = +dotnet_naming_style.tpascalcase.word_separator = +dotnet_naming_style.tpascalcase.capitalization = pascal_case + +dotnet_naming_style._camelcase.required_prefix = _ +dotnet_naming_style._camelcase.required_suffix = +dotnet_naming_style._camelcase.word_separator = +dotnet_naming_style._camelcase.capitalization = camel_case + +dotnet_naming_style.camelcase.required_prefix = +dotnet_naming_style.camelcase.required_suffix = +dotnet_naming_style.camelcase.word_separator = +dotnet_naming_style.camelcase.capitalization = camel_case + +dotnet_naming_style.s_camelcase.required_prefix = s_ +dotnet_naming_style.s_camelcase.required_suffix = +dotnet_naming_style.s_camelcase.word_separator = +dotnet_naming_style.s_camelcase.capitalization = camel_case ################################################################################## # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ @@ -175,7 +410,7 @@ dotnet_diagnostic.CA1304.severity = error # CA1307: Specify StringComparison for clarity dotnet_diagnostic.CA1307.severity = error # CA1308: Normalize strings to uppercase -dotnet_diagnostic.CA1308.severity = error +dotnet_diagnostic.CA1308.severity = none # CA1309: Use ordinal StringComparison dotnet_diagnostic.CA1309.severity = error # CA1724: Type names should not match namespaces @@ -210,7 +445,16 @@ dotnet_diagnostic.ca1848.severity = Suggestion dotnet_diagnostic.ca1810.severity = Suggestion # CA1725: Parameter names should match base declaration dotnet_diagnostic.ca1725.severity = Suggestion -# https://csharpier.com/docs/IntegratingWithLinters#code-analysis-rules +# CA1515: Consider making public types internal +dotnet_diagnostic.CA1515.severity = None +# CA2000: Dispose objects before losing scope +dotnet_diagnostic.CA2000.severity = Suggestion +# CA1707: Identifiers should not contain underscores +dotnet_diagnostic.CA1707.severity = None +# CA1716: Identifiers should not match keywords +dotnet_diagnostic.CA1716.severity = Suggestion +# CA1032: Implement standard exception constructors +dotnet_diagnostic.CA1032.severity = Suggestion ################################################################################## # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ @@ -220,7 +464,7 @@ dotnet_diagnostic.ca1725.severity = Suggestion dotnet_diagnostic.IDE0048.severity = Suggestion dotnet_diagnostic.IDE0028.severity = Suggestion dotnet_diagnostic.IDE0029.severity = Suggestion -dotnet_diagnostic.IDE0030.severity = Suggestion +dotnet_diagnostic.IDE0030 .severity = Suggestion dotnet_diagnostic.IDE0004.severity = error # IDE0005: Remove unnecessary usings/imports @@ -230,21 +474,21 @@ dotnet_diagnostic.IDE0005.severity = warning dotnet_diagnostic.IDE0051.severity = Suggestion # IDE0052: Remove unread private members (writes but no reads) -dotnet_diagnostic.IDE0052.severity = error +dotnet_diagnostic.IDE0052.severity = warning + +# Remove unnecessary using directives (IDE0005) +dotnet_diagnostic.IDE0005.severity = none + +# CS1574: XML comment on 'construct' has syntactically incorrect cref attribute 'name' +dotnet_diagnostic.CS1574.severity = error # IDE0055: Fix formatting # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/dotnet-formatting-options # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0055 -dotnet_diagnostic.IDE0055.severity = suggestion - -# CS1574: XML comment on 'construct' has syntactically incorrect cref attribute 'name' -dotnet_diagnostic.CS1574.severity = error - -# IDE0160, IDE0161: Report violations when block-scoped namespaces are used -dotnet_diagnostic.IDE0160.severity = none -dotnet_diagnostic.IDE0161.severity = none +# https://csharpier.com/docs/IntegratingWithLinters#code-analysis-rules +dotnet_diagnostic.IDE0055.severity = none ################################################################################## # https://jetbrains.com.xy2401.com/help/resharper/EditorConfig_Index.html @@ -378,59 +622,6 @@ resharper_blank_lines_before_multiline_statements = 1 resharper_parentheses_non_obvious_operations = arithmetic, multiplicative, equality, relational, additive resharper_parentheses_redundancy_style = remove_if_not_clarifies_precedence -################################################################################## -## https://github.com/bkoelman/CSharpGuidelinesAnalyzer -## CSharpGuidelines -################################################################################## - -dotnet_diagnostic.AV1561.max_parameter_count = 5 -# AV1008: Class should be non-static or its name should be suffixed with Extensions -dotnet_diagnostic.AV1008.severity = none -# AV1010: Type hides inherited member -dotnet_diagnostic.AV1010.severity = none -# AV1115: Member or local function contains the word 'and', which suggests doing multiple things -dotnet_diagnostic.AV1115.severity = suggestion -# AV1130: Return type in signature for Type should be a collection interface instead of a concrete type -dotnet_diagnostic.AV1130.severity = none -# AV1135: null is returned from method which has return type of string, collection or task -dotnet_diagnostic.AV1135.severity = none # re-enable if we can distinguish between string, collection and task -# AV1210: Catch a specific exception instead of Exception, SystemException or ApplicationException -dotnet_diagnostic.AV1210.severity = none -# AV1250: Evaluate LINQ query before returning it -dotnet_diagnostic.AV1250.severity = suggestion -# AV1500: Method 'CallerIdentifier.DetermineCallerIdentity()' contains 10 statements, which exceeds the maximum of 7 statements -dotnet_diagnostic.AV1500.severity = none -# AV1532: Loop statement contains nested loop -dotnet_diagnostic.AV1532.severity = suggestion -# AV1535: Missing block in case or default clause of switch statement -dotnet_diagnostic.AV1535.severity = none # re-enable if we can adjust the formatting to not indent the scope braces -# AV1537: If-else-if construct should end with an unconditional else clause -dotnet_diagnostic.AV1537.severity = suggestion -# AV1551: Method overload with the most parameters should be virtual -dotnet_diagnostic.AV1551.severity = none -# AV1555: Avoid using non-(nullable-)boolean named arguments -dotnet_diagnostic.AV1555.severity = suggestion -# AV1561: Method contains 5 parameters, which exceeds the maximum of 3 parameters -dotnet_diagnostic.AV1561.severity = suggestion -# AV1564: Parameter in public or internal member is of type bool or bool? -dotnet_diagnostic.AV1564.severity = suggestion -# AV1554: Do not use optional parameters in interface methods or their concrete implementations -dotnet_diagnostic.AV1554.severity = none -# AV1580: Argument for parameter calls nested method -dotnet_diagnostic.AV1580.severity = none -# AV1706: Parameter 'p' should have a more descriptive name -dotnet_diagnostic.AV1706.severity = warning -# AV1708: Type name contains term that should be avoided -dotnet_diagnostic.AV1708.severity = suggestion -# AV1710: Field contains the name of its containing type -dotnet_diagnostic.AV1710.severity = none -# AV2202: Replace call to Nullable.HasValue with null check -dotnet_diagnostic.AV2202.severity = none -# AV2305: Missing XML comment for internally visible type or member -dotnet_diagnostic.AV2305.severity = none -# AV2407: Region should be removed -dotnet_diagnostic.AV2407.severity = none - ################################################################################## ## https://github.com/DotNetAnalyzers/StyleCopAnalyzers/tree/master/documentation ## https://documentation.help/StyleCop/StyleCop.html @@ -553,16 +744,85 @@ dotnet_diagnostic.sa1101.severity = None # The keywords within the declaration of an element do not follow a standard ordering scheme. dotnet_diagnostic.SA1206.severity = None -# A single-line comment within C# code is not preceded by a blank line. -dotnet_diagnostic.SA1515.severity = Suggestion +dotnet_diagnostic.SA1106.severity = None + +# https://csharpier.com/docs/IntegratingWithLinters#stylecopanalyzers +# IDE0055: Fix formatting +# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options +# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/dotnet-formatting-options +# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0055 + +# StyleCopAnalyzers +dotnet_diagnostic.SA1000.severity = none +dotnet_diagnostic.SA1009.severity = none +dotnet_diagnostic.SA1111.severity = none +dotnet_diagnostic.SA1118.severity = none +dotnet_diagnostic.SA1137.severity = none +dotnet_diagnostic.SA1413.severity = none +dotnet_diagnostic.SA1500.severity = none +dotnet_diagnostic.SA1501.severity = none +dotnet_diagnostic.SA1502.severity = none +dotnet_diagnostic.SA1504.severity = none +dotnet_diagnostic.SA1515.severity = none +dotnet_diagnostic.SA1516.severity = none + +# for csharpier <= 0.21.0 +dotnet_diagnostic.SA1127.severity = none +dotnet_diagnostic.SA1128.severity = none + +dotnet_diagnostic.SA1001.severity = none +dotnet_diagnostic.SA1002.severity = none +dotnet_diagnostic.SA1003.severity = none +dotnet_diagnostic.SA1007.severity = none +dotnet_diagnostic.SA1008.severity = none +dotnet_diagnostic.SA1010.severity = none +dotnet_diagnostic.SA1011.severity = none +dotnet_diagnostic.SA1012.severity = none +dotnet_diagnostic.SA1013.severity = none +dotnet_diagnostic.SA1014.severity = none +dotnet_diagnostic.SA1015.severity = none +dotnet_diagnostic.SA1016.severity = none +dotnet_diagnostic.SA1017.severity = none +dotnet_diagnostic.SA1018.severity = none +dotnet_diagnostic.SA1019.severity = none +dotnet_diagnostic.SA1020.severity = none +dotnet_diagnostic.SA1021.severity = none +dotnet_diagnostic.SA1022.severity = none +dotnet_diagnostic.SA1023.severity = none +dotnet_diagnostic.SA1024.severity = none +dotnet_diagnostic.SA1025.severity = none +dotnet_diagnostic.SA1026.severity = none +dotnet_diagnostic.SA1027.severity = none +dotnet_diagnostic.SA1028.severity = none +dotnet_diagnostic.SA1102.severity = none +dotnet_diagnostic.SA1103.severity = none +dotnet_diagnostic.SA1104.severity = none +dotnet_diagnostic.SA1105.severity = none +dotnet_diagnostic.SA1107.severity = none +dotnet_diagnostic.SA1110.severity = none +dotnet_diagnostic.SA1112.severity = none +dotnet_diagnostic.SA1113.severity = none +dotnet_diagnostic.SA1114.severity = none +dotnet_diagnostic.SA1115.severity = none +dotnet_diagnostic.SA1116.severity = none +dotnet_diagnostic.SA1117.severity = none +dotnet_diagnostic.SA1127.severity = none +dotnet_diagnostic.SA1128.severity = none +dotnet_diagnostic.SA1136.severity = none +dotnet_diagnostic.SA1505.severity = none +dotnet_diagnostic.SA1506.severity = none +dotnet_diagnostic.SA1507.severity = none +dotnet_diagnostic.SA1508.severity = none +dotnet_diagnostic.SA1509.severity = none +dotnet_diagnostic.SA1510.severity = none +dotnet_diagnostic.SA1511.severity = none +dotnet_diagnostic.SA1517.severity = none +dotnet_diagnostic.SA1518.severity = none ################################################################################## ## https://github.com/meziantou/Meziantou.Analyzer/tree/main/docs ## Meziantou.Analyzer -# MA0049: Type name should not match containing namespace -dotnet_diagnostic.ma0049.severity = Suggestion - # MA0048: File name must match type name dotnet_diagnostic.ma0048.severity = Suggestion @@ -616,11 +876,14 @@ dotnet_diagnostic.MA0047.severity = none # Use an overload of 'GetHashCode' that has a StringComparison parameter dotnet_diagnostic.MA0074.severity = none +# MA0049: Type name should not match containing namespace +dotnet_diagnostic.MA0049.severity = none + ################################################################################## -## http://pihrt.net/Roslynator/Analyzers -## http://pihrt.net/Roslynator/Refactorings ## https://github.com/JosefPihrt/Roslynator/blob/main/docs/Configuration.md +## https://josefpihrt.github.io/docs/ ## Roslynator +################################################################################## # RCS1036 - Remove redundant empty line. dotnet_diagnostic.rcs1036.severity = None @@ -655,7 +918,6 @@ dotnet_diagnostic.rcs1047.severity = error # RCS1174: Remove redundant async/await dotnet_diagnostic.rcs1174.severity = Suggestion - # Combine 'Enumerable.Where' method chain. It doesn't make it more readable in all cases. dotnet_diagnostic.RCS1112.severity = suggestion @@ -693,6 +955,30 @@ dotnet_diagnostic.RCS1237.severity = none # RCS1228: Unused element in documentation comment. (Equivalent to SA1614) dotnet_diagnostic.RCS1228.severity = suggestion +# RCS1047: Non-asynchronous method name should not end with 'Async' +#dotnet_diagnostic.RCS1047.severity = suggestion + +################################################################################## +## https://github.com/semihokur/asyncfixer +## AsyncFixer01 +################################################################################## + +# https://cezarypiatek.github.io/post/async-analyzers-p1/#1-redundant-asyncawait +# AsyncFixer01: Unnecessary async/await usage +dotnet_diagnostic.asyncfixer01.severity = Suggestion + +# https://cezarypiatek.github.io/post/async-analyzers-p1/#2-calling-synchronous-method-inside-the-async-method +# AsyncFixer02: Long-running or blocking operations inside an async method +dotnet_diagnostic.asyncfixer02.severity = error + +# https://cezarypiatek.github.io/post/async-analyzers-p1/#3-async-void-method +# AsyncFixer03: Fire & forget async void methods +dotnet_diagnostic.asyncfixer03.severity = error + +# https://cezarypiatek.github.io/post/async-analyzers-p1/#6-not-awaited-task-inside-the-using-block +# AsyncFixer04: Fire & forget async call inside a using block +dotnet_diagnostic.asyncfixer04.severity = error + ################################################################################## ## https://github.com/microsoft/vs-threading ## Microsoft.VisualStudio.Threading.Analyzers @@ -702,7 +988,6 @@ dotnet_diagnostic.RCS1228.severity = suggestion # VSTHRD103: Call async methods when in an async method dotnet_diagnostic.vsthrd103.severity = Suggestion - # https://cezarypiatek.github.io/post/async-analyzers-p1/#3-async-void-method # VSTHRD100: Avoid async void methods dotnet_diagnostic.vsthrd100.severity = error @@ -738,3 +1023,20 @@ dotnet_diagnostic.vsthrd200.severity = Suggestion # https://cezarypiatek.github.io/post/async-analyzers-p2/#12-non-asynchronous-method-names-shouldnt-end-with-async # VSTHRD200: Use "Async" suffix for async methods dotnet_diagnostic.vsthrd200.severity = Suggestion + +# VSTHRD003 Avoid awaiting foreign Tasks +dotnet_diagnostic.VSTHRD003.severity = Suggestion + + +################################################################################## +## https://github.com/hvanbakel/Asyncify-CSharp +## Asyncify +################################################################################## + +# https://cezarypiatek.github.io/post/async-analyzers-p2/#8-synchronous-waits +# AsyncifyInvocation: Use Task Async +dotnet_diagnostic.asyncifyinvocation.severity = error + +# https://cezarypiatek.github.io/post/async-analyzers-p2/#8-synchronous-waits +# AsyncifyVariable: Use Task Async +dotnet_diagnostic.asyncifyvariable.severity = error