Skip to content

Instantly share code, notes, and snippets.

@wahidustoz
Last active November 24, 2025 07:15
Show Gist options
  • Select an option

  • Save wahidustoz/a6b28aa793214fa9072ba6dfe833e814 to your computer and use it in GitHub Desktop.

Select an option

Save wahidustoz/a6b28aa793214fa9072ba6dfe833e814 to your computer and use it in GitHub Desktop.
.NET editorconfig
root = true
# All files
[*]
indent_style = space
# Xml files
[*.xml]
indent_size = 2
# C# files
[*.cs]
#### Core EditorConfig Options ####
# Indentation and spacing
indent_size = 4
tab_width = 4
# New line preferences
end_of_line = crlf
insert_final_newline = false
#### .NET Coding Conventions ####
[*.{cs,vb}]
# Organize usings
dotnet_sort_system_directives_first = true
dotnet_diagnostic.IDE0005.severity = warning # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0005
dotnet_diagnostic.IDE0082.severity = warning # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0082
dotnet_diagnostic.IDE0160.severity = warning # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0160
dotnet_diagnostic.IDE0161.severity = warning # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0161
# Language keywords vs BCL types preferences
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
dotnet_style_predefined_type_for_member_access = true:warning
# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion
# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
# Expression-level preferences
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = 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_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_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
dotnet_style_namespace_match_folder = true:warning
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]
# Expression-bodied members
csharp_style_expression_bodied_accessors = when_on_single_line:warning
csharp_style_expression_bodied_constructors = when_on_single_line:warning
csharp_style_expression_bodied_indexers = when_on_single_line:warning
csharp_style_expression_bodied_lambdas = when_on_single_line:warning
csharp_style_expression_bodied_local_functions = when_on_single_line:warning
csharp_style_expression_bodied_methods = when_on_single_line:warning
csharp_style_expression_bodied_operators = when_on_single_line:warning
csharp_style_expression_bodied_properties = when_on_single_line: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_not_pattern = true:suggestion
csharp_style_prefer_pattern_matching = true:suggestion
csharp_style_prefer_switch_expression = true:suggestion
# Null-checking preferences
csharp_style_conditional_delegate_call = true:suggestion
# Modifier preferences
csharp_prefer_static_local_function = true:suggestion
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent
# Code-block preferences
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_namespace_declarations = file_scoped:error
# Expression-level preferences
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_pattern_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = 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:suggestion
# 'using' directive preferences
csharp_using_directive_placement = outside_namespace:silent
#### C# Formatting Rules ####
# New line preferences
csharp_new_line_before_catch = true:warning
csharp_new_line_before_else = true:warning
csharp_new_line_before_finally = true:warning
csharp_new_line_before_members_in_anonymous_types = true:warning
csharp_new_line_before_members_in_object_initializers = true:warning
csharp_new_line_before_open_braces = all:warning
csharp_new_line_between_query_expression_clauses = true:warning
# Indentation preferences
csharp_indent_block_contents = true:warning
csharp_indent_braces = false:warning
csharp_indent_case_contents = true:warning
csharp_indent_case_contents_when_block = false:warning
csharp_indent_labels = one_less_than_current
csharp_indent_switch_labels = true:warning
# Space preferences
csharp_space_after_cast = false:warning
csharp_space_after_colon_in_inheritance_clause = true:warning
csharp_space_after_comma = true:warning
csharp_space_after_dot = false:warning
csharp_space_after_keywords_in_control_flow_statements = true:warning
csharp_space_after_semicolon_in_for_statement = true:warning
csharp_space_around_binary_operators = before_and_after:warning
csharp_space_around_declaration_statements = false:warning
csharp_space_before_colon_in_inheritance_clause = true:warning
# Wrapping preferences
csharp_preserve_single_line_statements = false:warning
#### Naming styles ####
[*.{cs,vb}]
# Naming styles
dotnet_naming_style.pascalcase.capitalization = pascal_case
dotnet_naming_style.camelcase.capitalization = camel_case
dotnet_naming_style.upper_snake.capitalization = all_upper
dotnet_naming_style.upper_snake.word_separator = _
dotnet_naming_style.ipascalcase.required_prefix = I
dotnet_naming_style.ipascalcase.capitalization = pascal_case
dotnet_naming_style.tpascalcase.required_prefix = T
dotnet_naming_style.tpascalcase.capitalization = pascal_case
# Naming rules
dotnet_naming_symbols.types_and_namespaces.applicable_kinds = type, namespace
dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.severity = warning
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_symbols.interfaces.applicable_kinds = interface
dotnet_naming_rule.interfaces_should_be_ipascalcase.severity = warning
dotnet_naming_rule.interfaces_should_be_ipascalcase.symbols = interfaces
dotnet_naming_rule.interfaces_should_be_ipascalcase.style = ipascalcase
dotnet_naming_symbols.type_parameters.applicable_kinds = type_parameter
dotnet_naming_rule.type_parameters_should_be_tpascalcase.severity = warning
dotnet_naming_rule.type_parameters_should_be_tpascalcase.symbols = type_parameters
dotnet_naming_rule.type_parameters_should_be_tpascalcase.style = tpascalcase
dotnet_naming_symbols.methods.applicable_kinds = method
dotnet_naming_rule.methods_should_be_pascalcase.severity = warning
dotnet_naming_rule.methods_should_be_pascalcase.symbols = methods
dotnet_naming_rule.methods_should_be_pascalcase.style = pascalcase
dotnet_naming_symbols.properties.applicable_kinds = property
dotnet_naming_rule.properties_should_be_pascalcase.severity = warning
dotnet_naming_rule.properties_should_be_pascalcase.symbols = properties
dotnet_naming_rule.properties_should_be_pascalcase.style = pascalcase
dotnet_naming_symbols.events.applicable_kinds = event
dotnet_naming_rule.events_should_be_pascalcase.severity = warning
dotnet_naming_rule.events_should_be_pascalcase.symbols = events
dotnet_naming_rule.events_should_be_pascalcase.style = pascalcase
dotnet_naming_symbols.local_variables.applicable_kinds = local
dotnet_naming_rule.local_variables_should_be_camelcase.severity = warning
dotnet_naming_rule.local_variables_should_be_camelcase.symbols = local_variables
dotnet_naming_rule.local_variables_should_be_camelcase.style = camelcase
dotnet_naming_symbols.parameters.applicable_kinds = parameter
dotnet_naming_rule.parameters_should_be_camelcase.severity = warning
dotnet_naming_rule.parameters_should_be_camelcase.symbols = parameters
dotnet_naming_rule.parameters_should_be_camelcase.style = camelcase
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
dotnet_naming_rule.private_fields_should_be_camelcase.severity = warning
dotnet_naming_rule.private_fields_should_be_camelcase.symbols = private_fields
dotnet_naming_rule.private_fields_should_be_camelcase.style = camelcase
dotnet_naming_symbols.private_const_fields.applicable_kinds = field
dotnet_naming_symbols.private_const_fields.applicable_accessibilities = private, protected, internal
dotnet_naming_symbols.private_const_fields.required_modifiers = const
dotnet_naming_rule.private_const_fields_should_be_uppersnake.severity = warning
dotnet_naming_rule.private_const_fields_should_be_uppersnake.symbols = private_const_fields
dotnet_naming_rule.private_const_fields_should_be_uppersnake.style = upper_snake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment