Skip to content

Instantly share code, notes, and snippets.

@Ruffo324
Last active April 2, 2021 01:16
Show Gist options
  • Save Ruffo324/7f34f434c8e1442bc9ad863d495eb723 to your computer and use it in GitHub Desktop.
Save Ruffo324/7f34f434c8e1442bc9ad863d495eb723 to your computer and use it in GitHub Desktop.
Random C# Xamarin .editorconfig file
##########################################################
# EditorConfig is awesome: https://EditorConfig.org #
# Configuration for C# Xamarin application development.#
##########################################################
# "Master" setting, which can only be overwritten by other "root = true" child configurations for ther child elements.
root = true
###############################
# Core EditorConfig Options #
###############################
# All files
[**]
indent_style = tab
# Code files
[**.{cs,csx,vb,vbx}]
indent_size = 4
insert_final_newline = true
charset = utf-8
max_line_length = 180
# XML files
[**.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2
# JSON files
[**.json]
indent_size = 2
indent_style = space
# Shell script files
[**.]
end_of_line = lf
indent_size = 2
[**.cs]
###############################
# Language conventions #
###############################
#Documentation: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019
# .NET code style
## this. and me.
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_property = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_event = false:warning
## Language keywords (int instead of Int32)
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
dotnet_style_predefined_type_for_member_access = true:warning
## Modifiers
dotnet_style_require_accessibility_modifiers = always:warning
dotnet_style_readonly_field = true:warning
## Modifiers sorting
csharp_preferred_modifier_order = public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async:warning
## Parentheses
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:suggestion
dotnet_style_parentheses_in_relational_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:warning
## Expression-level preferences
dotnet_style_object_initializer = true:warning
dotnet_style_collection_initializer = true:warning
dotnet_style_explicit_tuple_names = true:warning
dotnet_style_prefer_inferred_tuple_names = false:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = false:suggestion
dotnet_style_prefer_auto_properties = true:warning
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:warning
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
## Null check
dotnet_style_coalesce_expression = true:warning
dotnet_style_null_propagation = true:warning
# C# code style
## Implicit and explicit types (Always use var.)
csharp_style_var_for_built_in_types = true:warning
csharp_style_var_when_type_is_apparent = true:warning
csharp_style_var_elsewhere = true:warning
## Expression body
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
csharp_style_expression_bodied_constructors = false:warning
csharp_style_expression_bodied_operators = when_on_single_line:suggestion
csharp_style_expression_bodied_properties = when_on_single_line:suggestion
csharp_style_expression_bodied_indexers = when_on_single_line:suggestion
csharp_style_expression_bodied_accessors = when_on_single_line:suggestion
## Pattern matching
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
csharp_style_pattern_matching_over_as_with_null_check = true:warning
## Inline variable declarations
csharp_style_inlined_variable_declaration = true:warning
## Expression-level preferences
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_deconstructed_variable_declaration = false:warning
csharp_style_pattern_local_over_anonymous_function = 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
###############################
# Formatting conventions #
###############################
# Documentation: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019
# .NET
## Usings
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false
# C#
## New line stuff
csharp_new_line_before_open_brace = accessors, control_blocks, events, local_functions, methods, object_collection_array_initializers, types
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
## Indentation
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = one_less_than_current
## Spacing
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_after_comma = true
csharp_space_after_dot = false
## Wrap options
csharp_preserve_single_line_statements = false
csharp_preserve_single_line_blocks = true
###############################
# Naming Conventions #
###############################
# Documentation: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019
# Styles
dotnet_naming_style.style_camel_case.capitalization = camel_case
dotnet_naming_style.style_pascal_case.capitalization = pascal_case
dotnet_naming_style.style_underscore_camel_case.capitalization = camel_case
dotnet_naming_style.style_underscore_camel_case.required_prefix = _
dotnet_naming_style.style_prefix_i_camel_case.capitalization = pascal_case
dotnet_naming_style.style_prefix_i_camel_case.required_prefix = I
dotnet_naming_style.style_prefix_t_camel_case.capitalization = pascal_case
dotnet_naming_style.style_prefix_t_camel_case.required_prefix = T
# Accessibilities / Symbols
## Private field, non-private field, local
dotnet_naming_symbols.symbol_private_field.applicable_kinds = field
dotnet_naming_symbols.symbol_private_field.applicable_accessibilities = private, private_protected
dotnet_naming_symbols.symbol_non_private_field.applicable_kinds = field
dotnet_naming_symbols.symbol_non_private_field.applicable_accessibilities = public, protected, internal
dotnet_naming_symbols.symbol_local.applicable_kinds = *
dotnet_naming_symbols.symbol_local.applicable_accessibilities = local
## Namespace, class, struct, interface, enum
dotnet_naming_symbols.symbol_namespace.applicable_kinds = namespace
dotnet_naming_symbols.symbol_namespace.applicable_accessibilities = *
dotnet_naming_symbols.symbol_class.applicable_kinds = class
dotnet_naming_symbols.symbol_class.applicable_accessibilities = *
dotnet_naming_symbols.symbol_struct.applicable_kinds = struct
dotnet_naming_symbols.symbol_struct.applicable_accessibilities = *
dotnet_naming_symbols.symbol_interface.applicable_kinds = interface
dotnet_naming_symbols.symbol_interface.applicable_accessibilities = *
dotnet_naming_symbols.symbol_enum.applicable_kinds = enum
dotnet_naming_symbols.symbol_enum.applicable_accessibilities = *
## Function, property, delegate, event
dotnet_naming_symbols.symbol_function.applicable_kinds = method
dotnet_naming_symbols.symbol_function.applicable_accessibilities = *
dotnet_naming_symbols.symbol_property.applicable_kinds = property
dotnet_naming_symbols.symbol_property.applicable_accessibilities = *
dotnet_naming_symbols.symbol_delegate.applicable_kinds = delegate
dotnet_naming_symbols.symbol_delegate.applicable_accessibilities = *
dotnet_naming_symbols.symbol_event.applicable_kinds = event
dotnet_naming_symbols.symbol_event.applicable_accessibilities = *
## Parameter, type parameter
dotnet_naming_symbols.symbol_parameter.applicable_kinds = parameter
dotnet_naming_symbols.symbol_parameter.applicable_accessibilities = *
dotnet_naming_symbols.symbol_type_parameter.applicable_kinds = type_parameter
dotnet_naming_symbols.symbol_type_parameter.applicable_accessibilities = *
# Rules
## Private field should be _camelCase
dotnet_naming_rule.rule_private_field_should_be_underscore_camel_case.severity = warning
dotnet_naming_rule.rule_private_field_should_be_underscore_camel_case.symbols = symbol_private_field
dotnet_naming_rule.rule_private_field_should_be_underscore_camel_case.style = style_underscore_camel_case
## Non-private field should be PascalCase
dotnet_naming_rule.rule_non_private_field_should_be_pascal_case.severity = warning
dotnet_naming_rule.rule_non_private_field_should_be_pascal_case.symbols = symbol_non_private_field
dotnet_naming_rule.rule_non_private_field_should_be_pascal_case.style = style_pascal_case
## Local stuff should be camelCase
dotnet_naming_rule.rule_local_should_be_camel_case.severity = warning
dotnet_naming_rule.rule_local_should_be_camel_case.symbols = symbol_local
dotnet_naming_rule.rule_local_should_be_camel_case.style = style_camel_case
## Namespace should be PascalCase
dotnet_naming_rule.rule_namespace_should_be_pascal_case.severity = warning
dotnet_naming_rule.rule_namespace_should_be_pascal_case.symbols = symbol_namespace
dotnet_naming_rule.rule_namespace_should_be_pascal_case.style = style_pascal_case
## Class should be PascalCase
dotnet_naming_rule.rule_class_should_be_pascal_case.severity = warning
dotnet_naming_rule.rule_class_should_be_pascal_case.symbols = symbol_class
dotnet_naming_rule.rule_class_should_be_pascal_case.style = style_pascal_case
## Struct should be PascalCase
dotnet_naming_rule.rule_struct_should_be_pascal_case.severity = warning
dotnet_naming_rule.rule_struct_should_be_pascal_case.symbols = symbol_struct
dotnet_naming_rule.rule_struct_should_be_pascal_case.style = style_pascal_case
## Interface should be IPascalCase
dotnet_naming_rule.rule_interface_should_be_pascal_case.severity = warning
dotnet_naming_rule.rule_interface_should_be_pascal_case.symbols = symbol_interface
dotnet_naming_rule.rule_interface_should_be_pascal_case.style = style_prefix_i_camel_case
## Enum should be PascalCase
dotnet_naming_rule.rule_enum_should_be_pascal_case.severity = warning
dotnet_naming_rule.rule_enum_should_be_pascal_case.symbols = symbol_enum
dotnet_naming_rule.rule_enum_should_be_pascal_case.style = style_pascal_case
## Function should be PascalCase
dotnet_naming_rule.rule_function_should_be_pascal_case.severity = warning
dotnet_naming_rule.rule_function_should_be_pascal_case.symbols = symbol_function
dotnet_naming_rule.rule_function_should_be_pascal_case.style = style_pascal_case
## Property should be PascalCase
dotnet_naming_rule.rule_property_should_be_pascal_case.severity = warning
dotnet_naming_rule.rule_property_should_be_pascal_case.symbols = symbol_property
dotnet_naming_rule.rule_property_should_be_pascal_case.style = style_pascal_case
## Delegate should be PascalCase
dotnet_naming_rule.rule_delegate_should_be_pascal_case.severity = warning
dotnet_naming_rule.rule_delegate_should_be_pascal_case.symbols = symbol_delegate
dotnet_naming_rule.rule_delegate_should_be_pascal_case.style = style_pascal_case
## Event should be PascalCase
dotnet_naming_rule.rule_event_should_be_pascal_case.severity = warning
dotnet_naming_rule.rule_event_should_be_pascal_case.symbols = symbol_event
dotnet_naming_rule.rule_event_should_be_pascal_case.style = style_pascal_case
## Parameter should be camelCase
dotnet_naming_rule.rule_parameter_should_be_camel_case.severity = warning
dotnet_naming_rule.rule_parameter_should_be_camel_case.symbols = symbol_parameter
dotnet_naming_rule.rule_parameter_should_be_camel_case.style = style_camel_case
## Type parameter <T> are TPascalCase
dotnet_naming_rule.rule_type_parameter_should_be_pascal_case.severity = warning
dotnet_naming_rule.rule_type_parameter_should_be_pascal_case.symbols = symbol_type_parameter
dotnet_naming_rule.rule_type_parameter_should_be_pascal_case.style = style_prefix_t_camel_case
###############################
# ReSharper properties #
###############################
resharper_csharp_indent_style = tab
resharper_space_within_single_line_array_initializer_braces = true
## Keep existing initializer arrangements.
csharp_keep_existing_initializer_arrangement = true
resharper_csharp_keep_existing_initializer_arrangement = true
csharp_keep_existing_arrangement = true
resharper_csharp_keep_existing_arrangement = true
keep_existing_initializer_arrangement = true
resharper_keep_existing_initializer_arrangement = true
keep_existing_arrangement = true
resharper_keep_existing_arrangement = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment