-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.editorconfig
More file actions
141 lines (116 loc) · 6.93 KB
/
Copy path.editorconfig
File metadata and controls
141 lines (116 loc) · 6.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
# 🔒 Prevent fallback to parent .editorconfig files
root = true
# 🧠 Apply all rules to C# source files
[*.cs]
##############################
# ✍️ File formatting
##############################
charset = utf-8 # Ensures UTF-8 encoding—standard and cross-platform safe
end_of_line = crlf # Uses Windows-style line endings (CRLF)
insert_final_newline = true # Adds a newline at end of files for consistency
trim_trailing_whitespace = true # Removes spaces/tabs at the end of lines
indent_style = space # Uses spaces (not tabs) for indentation—clean and universal
indent_size = 4 # Sets indentation depth to 4 spaces
tab_width = 4 # Controls how editors visually render tabs
##############################
# 📦 Using directives
##############################
dotnet_remove_unnecessary_imports = true
dotnet_sort_system_directives_first = true # Puts System namespaces at the top
dotnet_separate_import_directive_groups = true # Adds a blank line between using groups
csharp_using_directive_placement = outside_namespace:error # Places using statements outside the namespace (enforced)
csharp_prefer_simple_using_statement = true:error # Prefer simplified C# 8 `using` form (with disposal)
# Report unused usings as errors
dotnet_diagnostic.IDE0005.severity = error
# Just a suggestion (won’t fail build)
dotnet_diagnostic.IDE0046.severity = suggestion
##############################
# 🧬 Code style: var usage
##############################
# ❌ Prevent use of 'var' even if type is obvious—enforce explicit types
csharp_style_var_for_built_in_types = false:error
csharp_style_var_when_type_is_apparent = false:error
csharp_style_var_elsewhere = true:suggestion # Allow 'var' only when type is complex or unclear
##############################
# 📐 Code style: expression-bodied members
##############################
# Choose when to allow expression-bodied members (arrow functions)
csharp_style_expression_bodied_methods = false:error # Force full method bodies
csharp_style_expression_bodied_properties = true:error # Allow for simple properties
csharp_style_expression_bodied_constructors = false:error # Avoid compact constructors
csharp_style_expression_bodied_operators = false:error # Use full-bodied operators
csharp_style_expression_bodied_indexers = true:error # Indexers can be concise
csharp_style_expression_bodied_accessors = true:error # Allow simple get/set as expression-bodied
csharp_style_expression_bodied_lambdas = true:error # Support concise lambda bodies
csharp_style_expression_bodied_local_functions = false:error # Enforce full local function syntax
##############################
# 🧱 Braces and structure
##############################
csharp_prefer_braces = true:error # Always require braces for control flow (if, while, etc.)
##############################
# 🎯 Miscellaneous style preferences
##############################
dotnet_style_prefer_auto_properties = true:error # Prefer get/set over full backing fields
dotnet_style_object_initializer = true:error # Encourage object initializers
dotnet_style_collection_initializer = true:error # Favor collection initializers like `new[] { }`
dotnet_style_prefer_simplified_boolean_expressions = true:error
dotnet_style_prefer_conditional_expression_over_assignment = true:error
dotnet_style_prefer_conditional_expression_over_return = true:error
dotnet_style_coalesce_expression = true:error # Prefer `??` operator
dotnet_style_null_propagation = true:error # Prefer `?.` null-safe access
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error
dotnet_style_prefer_inferred_tuple_names = true:error
dotnet_style_explicit_tuple_names = true:error
dotnet_style_prefer_inferred_anonymous_type_member_names = true:error
dotnet_style_prefer_compound_assignment = true:error # Prefer `+=` over `x = x + y`
dotnet_style_prefer_simplified_interpolation = true:error # Encourage $"{name}" style
##############################
# 🧭 Top-level and modern features
##############################
csharp_style_namespace_declarations = file_scoped:error # Prefer file-scoped namespaces (C# 10+)
csharp_style_prefer_top_level_statements = true:error # Use top-level `Main` entry (C# 9+)
csharp_style_prefer_primary_constructors = true:error # Enforce primary constructors (C# 12+)
csharp_prefer_system_threading_lock = true:error # Prefer `System.Threading.Lock` for clarity
##############################
# 🔓 Modifiers and accessibility
##############################
dotnet_style_require_accessibility_modifiers = always:error # Enforce use of public/private/etc.
##############################
# 🔤 Naming conventions
##############################
# 👤 Private readonly fields: _camelCase
dotnet_naming_rule.private_fields_should_be_camel_case.severity = error
dotnet_naming_rule.private_fields_should_be_camel_case.symbols = private_fields
dotnet_naming_rule.private_fields_should_be_camel_case.style = camel_case
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
dotnet_naming_symbols.private_fields.required_modifiers = readonly
dotnet_naming_style.camel_case.capitalization = camel_case
dotnet_naming_style.camel_case.required_prefix = _
dotnet_naming_style.camel_case.word_separator = _
# 👤 Private non-readonly fields: _camelCase
dotnet_naming_rule.private_nonreadonly_fields_should_be_camel_case.severity = error
dotnet_naming_rule.private_nonreadonly_fields_should_be_camel_case.symbols = private_nonreadonly_fields
dotnet_naming_rule.private_nonreadonly_fields_should_be_camel_case.style = camel_case_with_underscore
dotnet_naming_symbols.private_nonreadonly_fields.applicable_kinds = field
dotnet_naming_symbols.private_nonreadonly_fields.applicable_accessibilities = private
dotnet_naming_symbols.private_nonreadonly_fields.required_modifiers =
# Note: No required_modifiers means it matches fields without readonly modifier
dotnet_naming_style.camel_case_with_underscore.capitalization = camel_case
dotnet_naming_style.camel_case_with_underscore.required_prefix = _
dotnet_naming_style.camel_case_with_underscore.word_separator =
# 🧾 Method parameters: camelCase (no prefix)
dotnet_naming_rule.parameters_should_be_camel_case.severity = error
dotnet_naming_rule.parameters_should_be_camel_case.symbols = method_parameters
dotnet_naming_rule.parameters_should_be_camel_case.style = simple_camel_case
dotnet_naming_symbols.method_parameters.applicable_kinds = parameter
dotnet_naming_style.simple_camel_case.capitalization = camel_case
dotnet_naming_style.simple_camel_case.required_prefix =
dotnet_naming_style.simple_camel_case.word_separator =
##############################
# 🎛 Visual Studio file types
##############################
[*.{cs,vb}]
tab_width = 4
indent_size = 4
end_of_line = crlf