From ae42aa18c12ea7619ddb31f5ba35a75f8b068c9e Mon Sep 17 00:00:00 2001 From: Muhammad Rehan Saeed Date: Tue, 19 Sep 2023 12:10:03 +0100 Subject: [PATCH 1/6] Add new settings and reorder settings based on docs --- .editorconfig | 221 ++++++++++++++++++++++++++++---------------------- 1 file changed, 125 insertions(+), 96 deletions(-) diff --git a/.editorconfig b/.editorconfig index 3552976..0887d3d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,5 @@ -# Version: 4.1.1 (Using https://semver.org/) -# Updated: 2022-05-23 +# Version: 5.0.0 (Using https://semver.org/) +# Updated: 2023-09-19 # See https://github.com/RehanSaeed/EditorConfig/releases for release notes. # See https://github.com/RehanSaeed/EditorConfig for updates to this file. # See http://EditorConfig.org for more information about .editorconfig files. @@ -65,46 +65,36 @@ indent_style = tab ########################################## # Default .NET Code Style Severities -# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/configuration-options#scope +# https://learn.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 = warning ########################################## -# Language Rules -# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules +# Language Rules - .NET +# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules ########################################## -# .NET Style Rules -# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#net-style-rules [*.{cs,csx,cake,vb,vbx}] -# "this." and "Me." qualifiers -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 -dotnet_style_predefined_type_for_locals_parameters_members = true:warning -dotnet_style_predefined_type_for_member_access = true:warning -# Modifier preferences -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 -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 = never_if_unnecessary:warning + +# File header preferences +# file_header_template = \n© PROJECT-AUTHOR\n +# If you use StyleCop, you'll need to disable SA1636: File header copyright text should match. +# dotnet_diagnostic.SA1636.severity = none + # Expression-level preferences dotnet_style_object_initializer = true:warning dotnet_style_collection_initializer = true:warning +dotnet_style_coalesce_expression = true:warning +dotnet_style_null_propagation = true:warning +dotnet_style_prefer_auto_properties = 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 @@ -112,95 +102,134 @@ dotnet_diagnostic.IDE0046.severity = suggestion dotnet_style_prefer_compound_assignment = true:warning dotnet_style_prefer_simplified_interpolation = true:warning dotnet_style_prefer_simplified_boolean_expressions = true:warning -# Null-checking preferences -dotnet_style_coalesce_expression = true:warning -dotnet_style_null_propagation = true:warning -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning -# File header preferences -# file_header_template = \n© PROJECT-AUTHOR\n -# If you use StyleCop, you'll need to disable SA1636: File header copyright text should match. -# dotnet_diagnostic.SA1636.severity = none -# Undocumented -dotnet_style_operator_placement_when_wrapping = end_of_line:warning -csharp_style_prefer_null_check_over_type_check = true:warning +dotnet_style_namespace_match_folder = true:suggestion +dotnet_diagnostic.IDE0130.severity = suggestion +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed:warning + +# Field preferences +dotnet_style_readonly_field = true:warning # NEW + +# Language keyword vs. framework types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:warning # NEW +dotnet_style_predefined_type_for_member_access = true:warning # NEW + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = always:warning # NEW + +# Parameter preferences +dotnet_code_quality_unused_parameters = all:warning + +# 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 = never_if_unnecessary:warning + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = none:warning + +# "this."" preferences +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 Rules - C# +# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules +########################################## -# C# Style Rules -# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#c-style-rules [*.{cs,csx,cake}] -# 'var' preferences -csharp_style_var_for_built_in_types = true:warning -csharp_style_var_when_type_is_apparent = true:warning -csharp_style_var_elsewhere = true:warning + +# 'using' directive preferences +csharp_using_directive_placement = inside_namespace:warning + +# Code-block preferences +csharp_prefer_braces = true:warning +csharp_prefer_simple_using_statement = true:suggestion +dotnet_diagnostic.IDE0063.severity = suggestion +csharp_style_namespace_declarations = file_scoped:warning +csharp_style_prefer_method_group_conversion = true:warning # NEW +csharp_style_prefer_top_level_statements = true:warning # NEW + # Expression-bodied members -csharp_style_expression_bodied_methods = true:warning csharp_style_expression_bodied_constructors = true:warning +csharp_style_expression_bodied_methods = 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 preferences -csharp_style_pattern_matching_over_is_with_cast_check = true:warning -csharp_style_pattern_matching_over_as_with_null_check = true:warning -csharp_style_prefer_switch_expression = true:warning -csharp_style_prefer_pattern_matching = true:warning -csharp_style_prefer_not_pattern = true:warning + # Expression-level 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 +csharp_style_throw_expression = true:warning csharp_style_inlined_variable_declaration = true:warning csharp_prefer_simple_default_expression = true:warning -csharp_style_pattern_local_over_anonymous_function = true:warning +csharp_style_prefer_local_over_anonymous_function = true:warning # New csharp_style_deconstructed_variable_declaration = true:warning csharp_style_prefer_index_operator = true:warning csharp_style_prefer_range_operator = true:warning csharp_style_implicit_object_creation_when_type_is_apparent = true:warning -# "Null" checking preferences -csharp_style_throw_expression = true:warning -csharp_style_conditional_delegate_call = true:warning -# Code block preferences -csharp_prefer_braces = true:warning -csharp_prefer_simple_using_statement = true:suggestion -dotnet_diagnostic.IDE0063.severity = suggestion -# 'using' directive preferences -csharp_using_directive_placement = inside_namespace:warning +csharp_style_prefer_null_check_over_type_check = true:warning +csharp_style_prefer_tuple_swap = true:warning # NEW +csharp_style_prefer_utf8_string_literals = true:warning # NEW + # Modifier preferences +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning csharp_prefer_static_local_function = true:warning +csharp_style_prefer_readonly_struct = true:warning # NEW +csharp_style_prefer_readonly_struct_member = true:warning # NEW + +# "null" checking preferences +csharp_style_conditional_delegate_call = true:warning + +# Pattern-matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true:warning +csharp_style_pattern_matching_over_is_with_cast_check = true:warning +csharp_style_prefer_switch_expression = true:warning +csharp_style_prefer_pattern_matching = true:warning +csharp_style_prefer_not_pattern = true:warning +csharp_style_prefer_extended_property_pattern = true:warning # NEW + +# 'var' preferences +csharp_style_var_for_built_in_types = true:warning +csharp_style_var_when_type_is_apparent = true:warning +csharp_style_var_elsewhere = true:warning ########################################## -# Unnecessary Code Rules -# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/unnecessary-code-rules +# .NET Coding Conventions - .NET +# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/dotnet-formatting-options ########################################## -# .NET Unnecessary code rules [*.{cs,csx,cake,vb,vbx}] -dotnet_code_quality_unused_parameters = all:warning -dotnet_remove_unnecessary_suppression_exclusions = none:warning -# C# Unnecessary code rules -[*.{cs,csx,cake}] -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 +# .NET code refactoring options +# https://learn.microsoft.com/visualstudio/ide/reference/code-styles-refactoring-options +dotnet_style_operator_placement_when_wrapping = end_of_line:warning ########################################## -# Formatting Rules -# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules +# Formatting Rules - .NET +# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/dotnet-formatting-options ########################################## -# .NET formatting rules -# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#net-formatting-rules [*.{cs,csx,cake,vb,vbx}] -# Organize using directives + +# Using directive options dotnet_sort_system_directives_first = true dotnet_separate_import_directive_groups = false -# Dotnet namespace options -dotnet_style_namespace_match_folder = true:suggestion -dotnet_diagnostic.IDE0130.severity = suggestion -# C# formatting rules -# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#c-formatting-rules +########################################## +# Formatting Rules - C# +# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options +########################################## + [*.{cs,csx,cake}] + # Newline options # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#new-line-options csharp_new_line_before_open_brace = all @@ -210,6 +239,7 @@ 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/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#indentation-options csharp_indent_case_contents = true @@ -218,6 +248,7 @@ 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/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#spacing-options csharp_space_after_cast = false @@ -242,17 +273,15 @@ 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 + # Wrap options # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#wrap-options csharp_preserve_single_line_statements = false csharp_preserve_single_line_blocks = true -# Namespace options -# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#namespace-options -csharp_style_namespace_declarations = file_scoped:warning ########################################## # .NET Naming Rules -# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/naming-rules +# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/naming-rules ########################################## [*.{cs,csx,cake,vb,vbx}] @@ -285,11 +314,11 @@ dotnet_naming_style.internal_error_style.required_suffix = ____INTERNAL_ERROR___ ########################################## # .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 +# https://learn.microsoft.com/dotnet/standard/design-guidelines/ ########################################## # All public/protected/protected_internal constant fields must be PascalCase -# https://docs.microsoft.com/dotnet/standard/design-guidelines/field +# https://learn.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 @@ -298,7 +327,7 @@ dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.sty dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.severity = warning # All public/protected/protected_internal static readonly fields must be PascalCase -# https://docs.microsoft.com/dotnet/standard/design-guidelines/field +# https://learn.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 @@ -307,7 +336,7 @@ dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_r 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 +# https://learn.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 @@ -379,36 +408,36 @@ dotnet_naming_rule.sanity_check_uncovered_field_case_rule.severity = error # All of the following must be PascalCase: # - Namespaces -# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-namespaces +# https://learn.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://learn.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 +# https://learn.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 +# https://learn.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 # Interfaces use PascalCase and are prefixed with uppercase 'I' -# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces +# https://learn.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 # 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 +# https://learn.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 +# https://learn.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 From 7916184e4522434690c9b6b1bbae97bed97f6324 Mon Sep 17 00:00:00 2001 From: Muhammad Rehan Saeed Date: Tue, 19 Sep 2023 12:32:08 +0100 Subject: [PATCH 2/6] Add visual studio spell checker settings --- .editorconfig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.editorconfig b/.editorconfig index 0887d3d..9ca098e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -63,6 +63,15 @@ end_of_line = lf [Makefile] indent_style = tab +########################################## +# Visual Studio Spell Checker +# https://learn.microsoft.com/visualstudio/ide/text-spell-checker +########################################## + +spelling_languages = en-gb +spelling_error_severity = information +spelling_checkable_types = + ########################################## # Default .NET Code Style Severities # https://learn.microsoft.com/dotnet/fundamentals/code-analysis/configuration-options#scope From 9d159fec5c41823685a8a1b726c882a07373f703 Mon Sep 17 00:00:00 2001 From: Muhammad Rehan Saeed Date: Tue, 19 Sep 2023 14:31:39 +0100 Subject: [PATCH 3/6] Deprecate old severity syntax --- .editorconfig | 151 +++++++++++++++++++++++++------------------------- 1 file changed, 76 insertions(+), 75 deletions(-) diff --git a/.editorconfig b/.editorconfig index 9ca098e..1e6156d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -68,9 +68,10 @@ indent_style = tab # https://learn.microsoft.com/visualstudio/ide/text-spell-checker ########################################## -spelling_languages = en-gb -spelling_error_severity = information -spelling_checkable_types = +# Note that you must have the relevant Windows language pack installed on your machine for this to work. +spelling_languages = en-GB # NEW +spelling_error_severity = information # NEW +spelling_checkable_types = # NEW ########################################## # Default .NET Code Style Severities @@ -95,53 +96,53 @@ dotnet_analyzer_diagnostic.severity = warning # dotnet_diagnostic.SA1636.severity = none # Expression-level preferences -dotnet_style_object_initializer = true:warning -dotnet_style_collection_initializer = true:warning -dotnet_style_coalesce_expression = true:warning -dotnet_style_null_propagation = true:warning -dotnet_style_prefer_auto_properties = 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_is_null_check_over_reference_equality_method = true:warning -dotnet_style_prefer_conditional_expression_over_assignment = false:suggestion +dotnet_style_object_initializer = true +dotnet_style_collection_initializer = true +dotnet_style_coalesce_expression = true +dotnet_style_null_propagation = true +dotnet_style_prefer_auto_properties = true +dotnet_style_explicit_tuple_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_conditional_expression_over_assignment = false dotnet_diagnostic.IDE0045.severity = suggestion -dotnet_style_prefer_conditional_expression_over_return = false:suggestion +dotnet_style_prefer_conditional_expression_over_return = false dotnet_diagnostic.IDE0046.severity = suggestion -dotnet_style_prefer_compound_assignment = true:warning -dotnet_style_prefer_simplified_interpolation = true:warning -dotnet_style_prefer_simplified_boolean_expressions = true:warning -dotnet_style_namespace_match_folder = true:suggestion +dotnet_style_prefer_compound_assignment = true +dotnet_style_prefer_simplified_interpolation = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_namespace_match_folder = true dotnet_diagnostic.IDE0130.severity = suggestion -dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed:warning +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed # Field preferences -dotnet_style_readonly_field = true:warning # NEW +dotnet_style_readonly_field = true # NEW # Language keyword vs. framework types preferences -dotnet_style_predefined_type_for_locals_parameters_members = true:warning # NEW -dotnet_style_predefined_type_for_member_access = true:warning # NEW +dotnet_style_predefined_type_for_locals_parameters_members = true # NEW +dotnet_style_predefined_type_for_member_access = true # NEW # Modifier preferences -dotnet_style_require_accessibility_modifiers = always:warning # NEW +dotnet_style_require_accessibility_modifiers = always # NEW # Parameter preferences -dotnet_code_quality_unused_parameters = all:warning +dotnet_code_quality_unused_parameters = all # 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 = never_if_unnecessary:warning +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary # Suppression preferences -dotnet_remove_unnecessary_suppression_exclusions = none:warning +dotnet_remove_unnecessary_suppression_exclusions = none # "this."" preferences -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 +dotnet_style_qualification_for_field = true +dotnet_style_qualification_for_property = true +dotnet_style_qualification_for_method = true +dotnet_style_qualification_for_event = true ########################################## # Language Rules - C# @@ -151,64 +152,64 @@ dotnet_style_qualification_for_event = true:warning [*.{cs,csx,cake}] # 'using' directive preferences -csharp_using_directive_placement = inside_namespace:warning +csharp_using_directive_placement = inside_namespace # Code-block preferences -csharp_prefer_braces = true:warning -csharp_prefer_simple_using_statement = true:suggestion +csharp_prefer_braces = true +csharp_prefer_simple_using_statement = true dotnet_diagnostic.IDE0063.severity = suggestion -csharp_style_namespace_declarations = file_scoped:warning -csharp_style_prefer_method_group_conversion = true:warning # NEW -csharp_style_prefer_top_level_statements = true:warning # NEW +csharp_style_namespace_declarations = file_scoped +csharp_style_prefer_method_group_conversion = true # NEW +csharp_style_prefer_top_level_statements = true # NEW # Expression-bodied members -csharp_style_expression_bodied_constructors = true:warning -csharp_style_expression_bodied_methods = 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 +csharp_style_expression_bodied_constructors = true +csharp_style_expression_bodied_methods = true +csharp_style_expression_bodied_operators = true +csharp_style_expression_bodied_properties = true +csharp_style_expression_bodied_indexers = true +csharp_style_expression_bodied_accessors = true +csharp_style_expression_bodied_lambdas = true +csharp_style_expression_bodied_local_functions = true # Expression-level preferences -csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable dotnet_diagnostic.IDE0058.severity = suggestion -csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_assignment_preference = discard_variable dotnet_diagnostic.IDE0059.severity = suggestion -csharp_style_throw_expression = true:warning -csharp_style_inlined_variable_declaration = true:warning -csharp_prefer_simple_default_expression = true:warning -csharp_style_prefer_local_over_anonymous_function = true:warning # New -csharp_style_deconstructed_variable_declaration = true:warning -csharp_style_prefer_index_operator = true:warning -csharp_style_prefer_range_operator = true:warning -csharp_style_implicit_object_creation_when_type_is_apparent = true:warning -csharp_style_prefer_null_check_over_type_check = true:warning -csharp_style_prefer_tuple_swap = true:warning # NEW -csharp_style_prefer_utf8_string_literals = true:warning # NEW +csharp_style_throw_expression = true +csharp_style_inlined_variable_declaration = true +csharp_prefer_simple_default_expression = true +csharp_style_prefer_local_over_anonymous_function = true # New +csharp_style_deconstructed_variable_declaration = true +csharp_style_prefer_index_operator = true +csharp_style_prefer_range_operator = true +csharp_style_implicit_object_creation_when_type_is_apparent = true +csharp_style_prefer_null_check_over_type_check = true +csharp_style_prefer_tuple_swap = true # NEW +csharp_style_prefer_utf8_string_literals = true # NEW # Modifier preferences -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning -csharp_prefer_static_local_function = true:warning -csharp_style_prefer_readonly_struct = true:warning # NEW -csharp_style_prefer_readonly_struct_member = true:warning # NEW +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async +csharp_prefer_static_local_function = true +csharp_style_prefer_readonly_struct = true # NEW +csharp_style_prefer_readonly_struct_member = true # NEW # "null" checking preferences -csharp_style_conditional_delegate_call = true:warning +csharp_style_conditional_delegate_call = true # Pattern-matching preferences -csharp_style_pattern_matching_over_as_with_null_check = true:warning -csharp_style_pattern_matching_over_is_with_cast_check = true:warning -csharp_style_prefer_switch_expression = true:warning -csharp_style_prefer_pattern_matching = true:warning -csharp_style_prefer_not_pattern = true:warning -csharp_style_prefer_extended_property_pattern = true:warning # NEW +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_switch_expression = true +csharp_style_prefer_pattern_matching = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_extended_property_pattern = true # NEW # 'var' preferences -csharp_style_var_for_built_in_types = true:warning -csharp_style_var_when_type_is_apparent = true:warning -csharp_style_var_elsewhere = true:warning +csharp_style_var_for_built_in_types = true +csharp_style_var_when_type_is_apparent = true +csharp_style_var_elsewhere = true ########################################## # .NET Coding Conventions - .NET @@ -219,7 +220,7 @@ csharp_style_var_elsewhere = true:warning # .NET code refactoring options # https://learn.microsoft.com/visualstudio/ide/reference/code-styles-refactoring-options -dotnet_style_operator_placement_when_wrapping = end_of_line:warning +dotnet_style_operator_placement_when_wrapping = end_of_line ########################################## # Formatting Rules - .NET From 84d58bf6e938d965e4fa62743a32affcf90f5f8e Mon Sep 17 00:00:00 2001 From: Muhammad Rehan Saeed Date: Wed, 4 Oct 2023 15:19:13 +0100 Subject: [PATCH 4/6] Update .editorconfig Add default tab width. Note that this is not used because we default to spaces. --- .editorconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/.editorconfig b/.editorconfig index 1e6156d..9433a3f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,6 +16,7 @@ root = true charset = utf-8 indent_style = space indent_size = 4 +tab_width = 4 insert_final_newline = true trim_trailing_whitespace = true From 74315984f077b5fc7bdead7ea6eb7c69f6349ccd Mon Sep 17 00:00:00 2001 From: Muhammad Rehan Saeed Date: Wed, 4 Oct 2023 15:20:42 +0100 Subject: [PATCH 5/6] Update .editorconfig Add csharp_style_prefer_primary_constructors --- .editorconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.editorconfig b/.editorconfig index 9433a3f..e5052da 100644 --- a/.editorconfig +++ b/.editorconfig @@ -212,6 +212,10 @@ csharp_style_var_for_built_in_types = true csharp_style_var_when_type_is_apparent = true csharp_style_var_elsewhere = true +# Undocumented +# https://github.com/dotnet/docs/issues/28791 +csharp_style_prefer_primary_constructors = true # NEW + ########################################## # .NET Coding Conventions - .NET # https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/dotnet-formatting-options From 7e7344f8fbe0379dd16d7d1ccdd2071f750c12a6 Mon Sep 17 00:00:00 2001 From: Muhammad Rehan Saeed Date: Mon, 12 Feb 2024 09:37:20 +0000 Subject: [PATCH 6/6] Add file and required modifiers Co-authored-by: Kirsten Kluge --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index e5052da..192ee80 100644 --- a/.editorconfig +++ b/.editorconfig @@ -191,7 +191,7 @@ csharp_style_prefer_tuple_swap = true # NEW csharp_style_prefer_utf8_string_literals = true # NEW # Modifier preferences -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async csharp_prefer_static_local_function = true csharp_style_prefer_readonly_struct = true # NEW csharp_style_prefer_readonly_struct_member = true # NEW