Skip to content

Instantly share code, notes, and snippets.

@niclaslindstedt
Created January 28, 2021 10:24
Show Gist options
  • Save niclaslindstedt/b5afdeebecc11f6268ae6fd8a7061ddc to your computer and use it in GitHub Desktop.
Save niclaslindstedt/b5afdeebecc11f6268ae6fd8a7061ddc to your computer and use it in GitHub Desktop.
ReSharper-compatible editorconfig for C# projects
root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = space
insert_final_newline = true
[*.yml]
indent_size = 2
quote_type = single
[*.{json,xml,csproj,sln,props}]
indent_size = 2
[*.{cs,csx}]
charset = utf-8
indent_size = 4
indent_style = space
# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/
csharp_prefer_braces = true:error
csharp_prefer_simple_default_expression = true:error
csharp_style_expression_bodied_lambdas = true:error
csharp_style_expression_bodied_methods = false:error
csharp_style_pattern_matching_over_as_with_null_check = true:error
csharp_style_pattern_matching_over_is_with_cast_check = true:error
csharp_style_prefer_index_operator = true:error
csharp_style_prefer_range_operator = true:error
dotnet_style_coalesce_expression = true:error
dotnet_style_collection_initializer = true:error
dotnet_style_null_propagation = true:error
dotnet_style_object_initializer = true:error
dotnet_style_prefer_compound_assignment = true:error
dotnet_style_readonly_field = true:error
# https://www.jetbrains.com/help/resharper/EditorConfig_CSHARP_BlankLinesPageScheme.html
resharper_csharp_blank_lines_around_region = true
resharper_csharp_blank_lines_inside_region = 1
resharper_csharp_blank_lines_before_single_line_comment = 1
resharper_csharp_keep_blank_lines_in_declarations = 1
resharper_csharp_remove_blank_lines_near_braces_in_declarations = true
resharper_csharp_blank_lines_after_start_comment = 0
resharper_csharp_blank_lines_between_using_groups = 0
resharper_csharp_blank_lines_after_using_list = 1
resharper_csharp_blank_lines_around_namespace = 1
resharper_csharp_blank_lines_inside_namespace = 0
resharper_csharp_blank_lines_around_type = 2
resharper_csharp_blank_lines_inside_type = 0
resharper_csharp_blank_lines_around_field = 1
resharper_csharp_blank_lines_around_single_line_field = 0
resharper_csharp_blank_lines_around_property = 1
resharper_csharp_blank_lines_around_single_line_property = 0
resharper_csharp_blank_lines_around_auto_property = 1
resharper_csharp_blank_lines_around_single_line_auto_property = 0
resharper_csharp_blank_lines_around_invocable = 1
resharper_csharp_blank_lines_around_single_line_invocable = 0
resharper_csharp_keep_blank_lines_in_code = 2
resharper_csharp_remove_blank_lines_near_braces_in_code = 0
resharper_csharp_blank_lines_around_local_method = 1
resharper_csharp_blank_lines_around_single_line_local_method = 0
resharper_csharp_blank_lines_before_control_transfer_statements = 0
resharper_csharp_blank_lines_after_control_transfer_statements = 1
resharper_csharp_blank_lines_after_block_statements = 1
resharper_csharp_blank_lines_around_block_case_section = 1
resharper_csharp_blank_lines_around_multiline_case_section = 1
resharper_csharp_blank_lines_before_case = 0
resharper_csharp_blank_lines_after_case = 0
# https://www.jetbrains.com/help/resharper/EditorConfig_CSHARP_BracesPageSchema.html
resharper_csharp_type_declaration_braces = next_line
resharper_csharp_indent_inside_namespace = true
resharper_csharp_invocable_declaration_braces = next_line
resharper_csharp_anonymous_method_declaration_braces = next_line
resharper_csharp_accessor_owner_declaration_braces = end_of_line
resharper_csharp_accessor_declaration_braces = end_of_line
resharper_csharp_case_block_braces = next_line
resharper_csharp_initializer_braces = next_line
resharper_csharp_use_continuous_indent_inside_initializer_braces = true
resharper_csharp_other_braces = next_line
resharper_csharp_allow_comment_after_lbrace = true
resharper_csharp_empty_block_style = together_same_line
# https://www.jetbrains.com/help/resharper/EditorConfig_CSHARP_CSharpCodeStylePageImplSchema.html
resharper_csharp_for_built_in_types = use_var_when_evident
resharper_csharp_for_simple_types = use_var_when_evident
resharper_csharp_for_other_types = use_var_when_evident
resharper_csharp_use_roslyn_logic_for_evident_types = true
resharper_csharp_prefer_separate_deconstructed_variables_declaration = false
resharper_csharp_prefer_explicit_discard_declaration = false
resharper_csharp_instance_members_qualify_members = none
resharper_csharp_instance_members_qualify_declared_in = base_class
resharper_csharp_static_members_qualify_with = current_type
resharper_csharp_static_members_qualify_members = none
resharper_csharp_builtin_type_reference_style = use_keyword
resharper_csharp_builtin_type_reference_for_member_access_style = use_keyword
resharper_csharp_prefer_qualified_reference = false
resharper_csharp_add_imports_to_deepest_scope = false
resharper_csharp_sort_usings_with_system_first = false
resharper_csharp_qualified_using_at_nested_scope = true
resharper_csharp_allow_alias = true
resharper_csharp_can_use_global_alias = false
resharper_csharp_default_private_modifier = explicit
resharper_csharp_default_internal_modifier = explicit
resharper_csharp_arguments_skip_single = true
resharper_csharp_parentheses_redundancy_style = remove_if_not_clarifies_precedence
resharper_csharp_parentheses_non_obvious_operations = arithmetic
resharper_csharp_parentheses_group_non_obvious_operations = arithmetic
resharper_csharp_braces_for_ifelse = required
resharper_csharp_braces_for_for = required
resharper_csharp_braces_for_foreach = required
resharper_csharp_braces_for_while = required
resharper_csharp_braces_for_dowhile = required
resharper_csharp_braces_for_using = required
resharper_csharp_braces_for_lock = required
resharper_csharp_braces_for_fixed = required
resharper_csharp_braces_redundant = true
resharper_csharp_method_or_operator_body = expression_body
resharper_csharp_local_function_body = expression_body
resharper_csharp_constructor_or_destructor_body = block_body
resharper_csharp_accessor_owner_body = accessors_with_expression_body
resharper_csharp_use_heuristics_for_body_style = false
resharper_csharp_force_attribute_style = separate
resharper_csharp_trailing_comma_in_multiline_lists = true
resharper_csharp_trailing_comma_in_singleline_lists = false
# https://www.jetbrains.com/help/resharper/EditorConfig_CSHARP_CSharpIndentStylePageSchema.html
resharper_csharp_indent_style = space
resharper_csharp_indent_size = 4
resharper_csharp_tab_width = 4
resharper_csharp_continuous_indent_multiplier = 1
resharper_csharp_indent_nested_usings_stmt = false
resharper_csharp_indent_nested_fixed_stmt = false
resharper_csharp_indent_nested_lock_stmt = false
resharper_csharp_indent_nested_for_stmt = true
resharper_csharp_indent_nested_foreach_stmt = true
resharper_csharp_indent_nested_while_stmt = true
resharper_csharp_use_continuous_indent_inside_parens = true
resharper_csharp_indent_method_decl_pars = outside_and_inside
resharper_csharp_indent_invocation_pars = outside_and_inside
resharper_csharp_indent_statement_pars = outside_and_inside
resharper_csharp_indent_typeparam_angles = outside_and_inside
resharper_csharp_indent_typearg_angles = outside_and_inside
resharper_csharp_indent_pars = outside_and_inside
resharper_csharp_indent_preprocessor_if = no_indent
resharper_csharp_indent_preprocessor_region = no_indent
resharper_csharp_indent_preprocessor_other = no_indent
resharper_indent_switch_labels = true
resharper_csharp_indent_type_constraints = true
resharper_csharp_stick_comment = false
resharper_csharp_place_comments_at_first_column = false
resharper_csharp_use_indent_from_previous_element = true
resharper_csharp_alignment_tab_fill_style = use_spaces
resharper_csharp_align_multiline_parameter = false
resharper_csharp_align_multiline_extends_list = false
resharper_csharp_align_linq_query = false
resharper_csharp_align_multiline_binary_expressions_chain = false
resharper_csharp_outdent_binary_ops = true
resharper_csharp_align_multiline_calls_chain = false
resharper_csharp_outdent_dots = false
resharper_csharp_align_multiline_array_and_object_initializer = false
resharper_csharp_align_multiline_switch_expression = false
resharper_csharp_indent_anonymous_method_block = false
resharper_csharp_align_first_arg_by_paren = false
resharper_csharp_align_multiline_argument = false
resharper_csharp_align_tuple_components = true
resharper_csharp_align_multiline_expression = false
resharper_csharp_align_multiline_for_stmt = true
resharper_csharp_align_multiple_declaration = true
resharper_csharp_align_multline_type_parameter_list = false
resharper_csharp_align_multline_type_parameter_constrains = true
resharper_csharp_outdent_commas = false
resharper_csharp_int_align_fields = true
resharper_csharp_int_align_properties = true
resharper_csharp_int_align_methods = false
resharper_csharp_int_align_parameters = false
resharper_csharp_int_align_variables = true
resharper_csharp_int_align_assignments = true
resharper_csharp_int_align_nested_ternary = false
resharper_csharp_int_align_invocations = false
resharper_csharp_int_align_binary_expressions = false
resharper_csharp_int_align_comments = true
resharper_csharp_int_align_switch_sections = true
resharper_csharp_int_align_switch_expressions = true
# https://www.jetbrains.com/help/resharper/EditorConfig_CSHARP_LineBreaksPageSchema.html
resharper_csharp_keep_user_linebreaks = false
resharper_csharp_max_line_length = 140
resharper_csharp_wrap_before_comma = false
resharper_csharp_special_else_if_treatment = true
resharper_csharp_insert_final_newline = true
resharper_csharp_max_attribute_length_for_same_line = 80
resharper_csharp_keep_existing_attribute_arrangement = false
resharper_csharp_place_type_attribute_on_same_line = never
resharper_csharp_place_method_attribute_on_same_line = never
resharper_csharp_place_accessorholder_attribute_on_same_line = never
resharper_csharp_place_accessor_attribute_on_same_line = never
resharper_csharp_place_field_attribute_on_same_line = never
resharper_csharp_wrap_parameters_style = chop_if_long
resharper_csharp_max_formal_parameters_on_line = 2
resharper_csharp_keep_existing_declaration_parens_arrangement = false
resharper_csharp_wrap_before_declaration_lpar = false
resharper_csharp_wrap_after_declaration_lpar = true
resharper_csharp_wrap_before_declaration_rpar = false
resharper_csharp_place_constructor_initializer_on_same_line = false
resharper_csharp_keep_existing_expr_member_arrangement = false
resharper_csharp_place_expr_method_on_single_line = never
resharper_csharp_place_expr_property_on_single_line = if_owner_is_single_line
resharper_csharp_place_expr_accessor_on_single_line = if_owner_is_single_line
resharper_csharp_wrap_before_arrow_with_expressions = true
resharper_csharp_place_type_constraints_on_same_line = true
resharper_csharp_wrap_before_first_type_parameter_constraint = false
resharper_csharp_wrap_multiple_type_parameter_constraints_style = chop_always
resharper_csharp_wrap_before_type_parameter_langle = true
resharper_csharp_wrap_before_extends_colon = true
resharper_csharp_wrap_extends_list_style = chop_always
resharper_csharp_keep_existing_declaration_block_arrangement = false
resharper_csharp_place_abstract_accessorholder_on_single_line = true
resharper_csharp_place_simple_accessorholder_on_single_line = true
resharper_csharp_place_accessor_with_attrs_holder_on_single_line = false
resharper_csharp_place_simple_accessor_on_single_line = true
resharper_csharp_place_simple_method_on_single_line = false
resharper_csharp_keep_existing_enum_arrangement = false
resharper_csharp_max_enum_members_on_line = 1
resharper_csharp_place_simple_enum_on_single_line = false
resharper_csharp_wrap_enum_declaration = chop_always
resharper_new_line_before_else = true
resharper_csharp_new_line_before_while = false
resharper_new_line_before_catch = true
resharper_new_line_before_finally = true
resharper_csharp_wrap_for_stmt_header_style = chop_if_long
resharper_csharp_wrap_multiple_declaration_style = wrap_if_long
resharper_csharp_keep_existing_embedded_arrangement = false
resharper_csharp_place_simple_embedded_statement_on_same_line = if_owner_is_single_line
resharper_csharp_place_simple_case_statement_on_same_line = if_owner_is_single_line
resharper_csharp_keep_existing_embedded_block_arrangement = false
resharper_csharp_place_simple_embedded_block_on_same_line = true
resharper_csharp_place_simple_anonymousmethod_on_single_line = true
resharper_csharp_keep_existing_switch_expression_arrangement = false
resharper_csharp_place_simple_switch_expression_on_single_line = false
resharper_csharp_wrap_switch_expression = chop_always
resharper_csharp_keep_existing_initializer_arrangement = true
resharper_csharp_place_simple_initializer_on_single_line = true
resharper_csharp_max_initializer_elements_on_line = 2
resharper_csharp_wrap_object_and_collection_initializer_style = chop_if_long
resharper_csharp_max_array_initializer_elements_on_line = 3
resharper_csharp_wrap_array_initializer_style = chop_if_long
resharper_csharp_wrap_arguments_style = chop_if_long
resharper_csharp_max_invocation_arguments_on_line = 3
resharper_csharp_keep_existing_invocation_parens_arrangement = false
resharper_csharp_wrap_before_invocation_lpar = false
resharper_csharp_wrap_after_invocation_lpar = true
resharper_csharp_wrap_before_invocation_rpar = false
resharper_csharp_wrap_after_dot_in_method_calls = false
resharper_csharp_wrap_chained_method_calls = chop_if_long
resharper_csharp_wrap_before_binary_opsign = true
resharper_csharp_wrap_chained_binary_expressions = chop_if_long
resharper_csharp_force_chop_compound_if_expression = false
resharper_csharp_force_chop_compound_while_expression = false
resharper_csharp_force_chop_compound_do_expression = false
resharper_csharp_wrap_before_ternary_opsigns = true
resharper_csharp_wrap_ternary_expr_style = chop_if_long
resharper_csharp_nested_ternary_style = expanded
resharper_csharp_wrap_linq_expressions = chop_always
resharper_csharp_wrap_before_linq_expression = false
resharper_csharp_place_linq_into_on_new_line = true
resharper_csharp_wrap_verbatim_interpolated_strings = no_wrap
# https://www.jetbrains.com/help/resharper/EditorConfig_CSHARP_SpacesPageSchema.html
resharper_csharp_extra_spaces = remove_all
resharper_csharp_space_before_if_parentheses = true
resharper_csharp_space_before_while_parentheses = true
resharper_csharp_space_before_catch_parentheses = true
resharper_csharp_space_before_switch_parentheses = true
resharper_csharp_space_before_for_parentheses = true
resharper_csharp_space_before_foreach_parentheses = true
resharper_csharp_space_before_using_parentheses = true
resharper_csharp_space_before_lock_parentheses = true
resharper_csharp_space_before_fixed_parentheses = true
resharper_csharp_space_before_method_call_parentheses = false
resharper_csharp_space_before_empty_method_call_parentheses = false
resharper_csharp_space_before_method_parentheses = false
resharper_csharp_space_before_empty_method_parentheses = false
resharper_csharp_space_before_typeof_parentheses = false
resharper_csharp_space_before_default_parentheses = false
resharper_csharp_space_before_checked_parentheses = false
resharper_csharp_space_before_sizeof_parentheses = false
resharper_csharp_space_before_nameof_parentheses = false
resharper_csharp_space_between_keyword_and_expression = false
resharper_csharp_space_between_keyword_and_type = true
resharper_csharp_space_within_if_parentheses = false
resharper_csharp_space_within_while_parentheses = false
resharper_csharp_space_within_catch_parentheses = false
resharper_csharp_space_within_switch_parentheses = false
resharper_csharp_space_within_for_parentheses = false
resharper_csharp_space_within_foreach_parentheses = false
resharper_csharp_space_within_using_parentheses = false
resharper_csharp_space_within_lock_parentheses = false
resharper_csharp_space_within_fixed_parentheses = false
resharper_csharp_space_within_parentheses = false
resharper_csharp_space_between_typecast_parentheses = false
resharper_space_between_method_declaration_parameter_list_parentheses = false
resharper_space_between_method_declaration_empty_parameter_list_parentheses = false
resharper_space_between_method_call_parameter_list_parentheses = false
resharper_space_between_method_call_empty_parameter_list_parentheses = false
resharper_csharp_space_within_typeof_parentheses = false
resharper_csharp_space_within_default_parentheses = false
resharper_csharp_space_within_checked_parentheses = false
resharper_csharp_space_within_sizeof_parentheses = false
resharper_csharp_space_within_nameof_parentheses = false
resharper_csharp_space_before_array_access_brackets = false
resharper_csharp_space_before_array_rank_brackets = false
resharper_csharp_space_within_array_access_brackets = false
resharper_csharp_space_within_array_rank_brackets = false
resharper_csharp_space_within_array_rank_empty_brackets = false
resharper_csharp_space_before_type_parameter_angle = false
resharper_csharp_space_before_type_argument_angle = false
resharper_csharp_space_within_type_parameter_angles = false
resharper_csharp_space_within_type_argument_angles = false
resharper_csharp_space_before_singleline_accessorholder = true
resharper_csharp_space_in_singleline_accessorholder = true
resharper_csharp_space_between_accessors_in_singleline_property = true
resharper_csharp_space_within_empty_braces = true
resharper_csharp_space_in_singleline_method = true
resharper_csharp_space_in_singleline_anonymous_method = true
resharper_csharp_space_within_single_line_array_initializer_braces = true
resharper_csharp_space_around_assignment_op = true
resharper_csharp_space_around_logical_op = true
resharper_csharp_space_around_equality_op = true
resharper_csharp_space_around_relational_op = true
resharper_csharp_space_around_bitwise_op = true
resharper_csharp_space_around_additive_op = true
resharper_csharp_space_around_multiplicative_op = true
resharper_csharp_space_around_shift_op = true
resharper_csharp_space_around_nullcoalescing_op = true
resharper_csharp_space_around_arrow_op = true
resharper_csharp_space_after_logical_not_op = false
resharper_csharp_space_after_unary_minus_op = false
resharper_csharp_space_after_unary_plus_op = false
resharper_csharp_space_after_ampersand_op = false
resharper_csharp_space_after_asterik_op = false
resharper_csharp_space_near_postfix_and_prefix_op = false
resharper_csharp_space_before_ternary_quest = true
resharper_csharp_space_after_ternary_quest = true
resharper_csharp_space_before_ternary_colon = true
resharper_csharp_space_after_ternary_colon = true
resharper_space_before_comma = false
resharper_csharp_space_after_comma = true
resharper_space_before_semicolon_in_for_statement = false
resharper_space_after_semicolon_in_for_statement = true
resharper_csharp_space_before_semicolon = false
resharper_space_before_colon_in_inheritance_clause = true
resharper_space_after_colon_in_inheritance_clause = true
resharper_csharp_space_before_type_parameter_constraint_colon = true
resharper_csharp_space_after_type_parameter_constraint_colon = true
resharper_csharp_space_before_colon_in_case = false
resharper_csharp_space_after_colon_in_case = true
resharper_csharp_space_before_attribute_colon = false
resharper_csharp_space_after_attribute_colon = true
resharper_csharp_space_between_attribute_sections = false
resharper_csharp_space_within_attribute_brackets = false
resharper_csharp_space_after_attributes = true
resharper_space_after_cast = false
resharper_csharp_space_around_dot = false
resharper_csharp_space_around_lambda_arrow = true
resharper_csharp_space_before_pointer_asterik_declaration = false
resharper_csharp_space_before_nullable_mark = false
resharper_csharp_space_around_alias_eq = true
resharper_csharp_space_before_trailing_comment = true
resharper_csharp_space_after_operator_keyword = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment