Skip to content

Instantly share code, notes, and snippets.

@jmarolf
Last active January 21, 2020 15:30
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jmarolf/0e165b27a498b49e3b3512004ea9d8b8 to your computer and use it in GitHub Desktop.
Save jmarolf/0e165b27a498b49e3b3512004ea9d8b8 to your computer and use it in GitHub Desktop.

Advanced

editorconfig name possible values
dotnet_sort_system_directives_first true , false

Indentation Options

editorconfig name possible values
csharp_indent_block_contents true , false
csharp_indent_braces true , false
csharp_indent_case_contents true , false
csharp_indent_case_labels true , false
csharp_indent_labels left_most , no_indent , one_less_than_current

New Line Options

editorconfig name possible values
csharp_new_line_before_open_brace types, methods, properties, indexers, events, event_accessors, anonymous_methods, control_blocks, anonymous_types, object_collections, array_initializers, lambdas, local_functions, all, none (or separate with ';')
csharp_new_line_before_else true , false
csharp_new_line_before_catch true , false
csharp_new_line_before_finally true , false
csharp_new_line_before_members_in_object_initializers true , false
csharp_new_line_before_members_in_anonymouse_types true , false
csharp_new_line_within_query_expression_clauses true , false

Spacing Options

editorconfig name possible values
csharp_space_after_cast true , false
csharp_space_in_declaration_statements true , false
csharp_space_before_open_square_brackets true , false
csharp_space_within_empty_square_brackets true , false
csharp_space_within_square_brackets true , false
csharp_space_after_colon_for_base_or_interface_in_type_declaration true , false
csharp_space_after_comma true , false
csharp_space_after_dot true , false
csharp_space_after_semicolon_in_for_statement true , false
csharp_space_before_colon_for_base_or_interface_in_type_declaration true , false
csharp_space_before_comma true , false
csharp_space_before_dot true , false
csharp_space_before_semicolon_in_for_statement true , false
csharp_space_between_method_declaration_name_and_open_parenthesis true , false
csharp_space_within_method_declaration_parameter_list_parenthesis true , false
csharp_space_within_method_declaration_empty_parameter_list_parentheses true , false
csharp_space_between_method_call_name_and_opening_parenthesis true , false
csharp_space_within_method_call_parameter_list_parenthesis true , false
csharp_space_within_method_call_empty_parameter_list_parentheses true , false
csharp_space_after_keywords_in_control_flow_statements true , false
csharp_space_within_parentheses expressions, type_casts, control_flow_statements
csharp_space_around_operators none, before_and_after, ignore

Wrapping Options

editorconfig name possible values
csharp_wrap_block_on_single_line true , false
csharp_wrap_statements_and_member_declarations_on_same_line true , false

Code Style Options

editorconfig name possible values
csharp_style_this_qualification_for_field yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_this_qualification_for_property yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_this_qualification_for_method yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_this_qualification_for_event yes; none,suggestion,warning,error , no; none,suggestion,warning,error
visualbasic_style_me_qualification_for_field yes; none,suggestion,warning,error , no; none,suggestion,warning,error
visualbasic_style_me_qualification_for_property yes; none,suggestion,warning,error , no; none,suggestion,warning,error
visualbasic_style_me_qualification_for_method yes; none,suggestion,warning,error , no; none,suggestion,warning,error
visualbasic_style_me_qualification_for_event yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_var_for_locals yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_predefined_type_for_locals_parameters_members yes; none,suggestion,warning,error , no; none,suggestion,warning,error
chsarp_style_predefined_type_for_member_access yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_var_for_built_in_types yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_var_when_type_is_apparent yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_var_for_elsewhere yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_expression_bodied_methods yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_expression_bodied_constructors yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_expression_bodied_operators yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_expression_bodied_properties yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_expression_bodied_indexers yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_expression_bodied_accessors yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_object_initializer yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_pattern_matching_over_is_with_cast_check yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_pattern_matching_over_as_with_null_check yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_inlined_variable_declaration yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_throw_expression yes; none,suggestion,warning,error , no; none,suggestion,warning,error
csharp_style_conditional_delegate_call yes; none,suggestion,warning,error , no; none,suggestion,warning,error

Naming Style Options

editorconfig name possible values
dotnet_naming_rule.<naming rule title>.severity none , suggestion , warning , error
dotnet_naming_rule.<naming rule title>.symbols <naming symbols title>
dotnet_naming_rule.<naming rule title>.style <naming stlye title>
dotnet_naming_symbols.<naming symbols title>.applicable_kinds class;struct;interface;enum;property;method;field;event;namespace;delegate;type_parameter
dotnet_naming_symbols.<naming symbols title>.applicable_accessibilities public;internal;private;protected;protected_internal
dotnet_naming_symbols.<naming symbols title>.required_modifiers abstract;async;cont;readonly;static
dotnet_naming_style.<naming style title>.required_prefix string
dotnet_naming_style.<naming style title>.required_suffix string
dotnet_naming_style.<naming style title>.word_separator string
dotnet_naming_style.<naming style title>.capitalization pascal_case , camel_case , first_word_upper , all_upper , all_lower

Naming Style Examples

# Example: Pascal Casing
[*.{cs,vb}]
dotnet_naming_rule.methods_and_properties_must_be_pascal_case.severity = warning
dotnet_naming_rule.methods_and_properties_must_be_pascal_case.symbols  = method_and_property_symbols
dotnet_naming_rule.methods_and_properties_must_be_pascal_case.style    = pascal_case_style

dotnet_naming_symbols.method_and_property_symbols.applicable_kinds           = method;property
dotnet_naming_symbols.method_and_property_symbols.applicable_accessibilities = *

dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# Example: async methods end in Async
[*.{cs,vb}]
dotnet_naming_rule.async_methods_must_end_with_async.severity = warning
dotnet_naming_rule.async_methods_must_end_with_async.symbols  = method_symbols
dotnet_naming_rule.async_methods_must_end_with_async.style    = end_in_async_style

dotnet_naming_symbols.method_symbols.applicable_kinds   = method
dotnet_naming_symbols.method_symbols.required_modifiers = async

dotnet_naming_style.end_in_async_style.capitalization  = pascal_case
dotnet_naming_style.end_in_async_style.required_suffix = Async
# Example: public members must be capitalized
[*.{cs,vb}]
dotnet_naming_rule.public_members_must_be_capitalized.severity = warning
dotnet_naming_rule.public_members_must_be_capitalized.symbols  = public_symbols
dotnet_naming_rule.public_members_must_be_capitalized.style    = first_word_upper_case_style

dotnet_naming_symbols.public_symbols.applicable_kinds   = property;method;field;event;delegate
dotnet_naming_symbols.public_symbols.required_modifiers = public;internal;protected;protected_internal

dotnet_naming_style.first_word_upper_case_style.capitalization = first_word_upper
# Example: non-public members must be lower-case
[*.{cs,vb}]
dotnet_naming_rule.non_public_members_must_be_lower_case.severity = warning
dotnet_naming_rule.non_public_members_must_be_lower_case.symbols  = non_public_symbols
dotnet_naming_rule.non_public_members_must_be_lower_case.style    = all_lower_case_style

dotnet_naming_symbols.non_public_symbols.applicable_kinds   = property;method;field;event;delegate
dotnet_naming_symbols.non_public_symbols.required_modifiers = private

dotnet_naming_style.all_lower_case_style.capitalization = all_lower

0

@leopignataro
Copy link

This document is pure, solid gold. I couldn't find some of this info anywhere else. Thank you!!!

@danrozenberg
Copy link

Thanks for this.

@danrozenberg
Copy link

danrozenberg commented Jun 23, 2017

csharp_style_var_for_elsewhere should be csharp_style_var_elsewhere, I think...

@LokiMidgard
Copy link

I needed to use comma instead of semicolon for
dotnet_naming_symbols.public_symbols.applicable_kinds = property,method,field,event,delegate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment