.editorconfig 10.5 KB
Newer Older
K
Kexy Biscuit 已提交
1
# EditorConfig is awesome: https://EditorConfig.org
S
Shapkin Arkady 已提交
2 3 4 5

# top-most EditorConfig file
root = true

6
# Don't use tabs for indentation.
S
Shapkin Arkady 已提交
7 8
[*]
indent_style = space
9 10 11
# (Please don't specify an indent_size here; that has too many unintended consequences.)

# Code files
12
[*.{cs,csx,vb,vbx}]
S
Shapkin Arkady 已提交
13
indent_size = 4
14
insert_final_newline = true
15
charset = utf-8-bom
S
Shapkin Arkady 已提交
16

K
Kexy Biscuit 已提交
17
# XML project files
S
Shapkin Arkady 已提交
18 19 20
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2

K
Kexy Biscuit 已提交
21
# XML config files
S
Shapkin Arkady 已提交
22 23
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2
24 25 26 27

# JSON files
[*.json]
indent_size = 2
28

29 30 31 32
# Powershell files
[*.ps1]
indent_size = 2

K
Kexy Biscuit 已提交
33
# Shell script files
34
[*.sh]
T
Tomáš Matoušek 已提交
35 36 37
end_of_line = lf
indent_size = 2

38
# Dotnet code style settings:
39
[*.{cs,vb}]
40 41 42 43

# IDE0055: Fix formatting
dotnet_diagnostic.IDE0055.severity = warning

44 45
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true
46
dotnet_separate_import_directive_groups = false
47
# Avoid "this." and "Me." if not necessary
C
CyrusNajmabadi 已提交
48 49 50 51
dotnet_style_qualification_for_field = false:refactoring
dotnet_style_qualification_for_property = false:refactoring
dotnet_style_qualification_for_method = false:refactoring
dotnet_style_qualification_for_event = false:refactoring
52

53
# Use language keywords instead of framework type names for type references
54 55
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion
56 57

# Suggest more modern language features when available
58 59 60 61
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
62
dotnet_style_explicit_tuple_names = true:suggestion
63

64 65 66 67 68 69
# Non-private static fields are PascalCase
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style

dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field
70
dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected
71 72 73 74
dotnet_naming_symbols.non_private_static_fields.required_modifiers = static

dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case

75 76 77 78 79 80
# Non-private readonly fields are PascalCase
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_field_style

dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
81
dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected
82 83 84
dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly

dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_case
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143

# Constants are PascalCase
dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants
dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style

dotnet_naming_symbols.constants.applicable_kinds = field, local
dotnet_naming_symbols.constants.required_modifiers = const

dotnet_naming_style.constant_style.capitalization = pascal_case

# Static fields are camelCase and start with s_
dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion
dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields
dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style

dotnet_naming_symbols.static_fields.applicable_kinds = field
dotnet_naming_symbols.static_fields.required_modifiers = static

dotnet_naming_style.static_field_style.capitalization = camel_case
dotnet_naming_style.static_field_style.required_prefix = s_

# Instance fields are camelCase and start with _
dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion
dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields
dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style

dotnet_naming_symbols.instance_fields.applicable_kinds = field

dotnet_naming_style.instance_field_style.capitalization = camel_case
dotnet_naming_style.instance_field_style.required_prefix = _

# Locals and parameters are camelCase
dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion
dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters
dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style

dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local

dotnet_naming_style.camel_case_style.capitalization = camel_case

# Local functions are PascalCase
dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions
dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style

dotnet_naming_symbols.local_functions.applicable_kinds = local_function

dotnet_naming_style.local_function_style.capitalization = pascal_case

# By default, name items with PascalCase
dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members
dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style

dotnet_naming_symbols.all_members.applicable_kinds = *

dotnet_naming_style.pascal_case_style.capitalization = pascal_case

144 145 146
# error RS2008: Enable analyzer release tracking for the analyzer project containing rule '{0}'
dotnet_diagnostic.RS2008.severity = none

147 148 149 150
# IDE0073: File header
dotnet_diagnostic.IDE0073.severity = warning
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.\nSee the LICENSE file in the project root for more information.

151
# CSharp code style settings:
152
[*.cs]
153
# Newline settings
154 155 156 157 158 159 160 161
csharp_new_line_before_open_brace = all
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

S
Sam Harwell 已提交
162 163 164 165
# Indentation preferences
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
166
csharp_indent_case_contents_when_block = true
S
Sam Harwell 已提交
167 168 169
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left

170
# Prefer "var" everywhere
171 172
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
K
Kasey Uhlenhuth 已提交
173
csharp_style_var_elsewhere = true:suggestion
174 175

# Prefer method-like constructs to have a block body
176
csharp_style_expression_bodied_methods = false:none
177 178
csharp_style_expression_bodied_constructors = false:none
csharp_style_expression_bodied_operators = false:none
179 180

# Prefer property-like constructs to have an expression-body
181 182 183
csharp_style_expression_bodied_properties = true:none
csharp_style_expression_bodied_indexers = true:none
csharp_style_expression_bodied_accessors = true:none
184 185

# Suggest more modern language features when available
186 187 188 189
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_throw_expression = true:suggestion
190 191
csharp_style_conditional_delegate_call = true:suggestion

192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
# Space preferences
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = do_not_ignore
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false

216 217
# Blocks are allowed
csharp_prefer_braces = true:silent
218 219
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true
220 221 222

# warning RS0037: PublicAPI.txt is missing '#nullable enable'
dotnet_diagnostic.RS0037.severity = none
S
Sam Harwell 已提交
223 224 225 226

[src/CodeStyle/**.{cs,vb}]
# warning RS0005: Do not use generic CodeAction.Create to create CodeAction
dotnet_diagnostic.RS0005.severity = none
227 228 229 230

[src/{Analyzers,CodeStyle,Features,Workspaces}/**/*.{cs,vb}]
# IDE0005: Remove unnecessary usings/imports
dotnet_diagnostic.IDE0005.severity = warning
231

232 233
# IDE0011: Add braces
csharp_prefer_braces = when_multiline:warning
234 235
# NOTE: We need the below severity entry for Add Braces due to https://github.com/dotnet/roslyn/issues/44201
dotnet_diagnostic.IDE0011.severity = warning
236 237 238 239

# IDE0035: Remove unreachable code
dotnet_diagnostic.IDE0035.severity = warning

240 241 242 243 244 245
# IDE0036: Order modifiers
dotnet_diagnostic.IDE0036.severity = warning

# IDE0040: Add accessibility modifiers
dotnet_diagnostic.IDE0040.severity = warning

246 247 248
# IDE0043: Format string contains invalid placeholder
dotnet_diagnostic.IDE0043.severity = warning

249
# IDE0044: Make field readonly
250
dotnet_diagnostic.IDE0044.severity = warning
251

M
Manish Vasani 已提交
252
# CONSIDER: Are IDE0051 and IDE0052 too noisy to be warnings for IDE editing scenarios? Should they be made build-only warnings?
253 254 255 256 257
# IDE0051: Remove unused private member
dotnet_diagnostic.IDE0051.severity = warning

# IDE0052: Remove unread private member
dotnet_diagnostic.IDE0052.severity = warning
258 259 260

# IDE0059: Unnecessary assignment to a value
dotnet_diagnostic.IDE0059.severity = warning