Skip to content

Commit cce2194

Browse files
authored
chore(config): add .editorconfig and .gitattributes (#35)
- Add .editorconfig for consistent code style (C# conventions) - Add .gitattributes for consistent line endings (CRLF for Windows)
1 parent d67f1a5 commit cce2194

File tree

2 files changed

+170
-0
lines changed

2 files changed

+170
-0
lines changed

.editorconfig

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# EditorConfig - https://editorconfig.org
2+
3+
root = true
4+
5+
# All files
6+
[*]
7+
indent_style = space
8+
indent_size = 4
9+
end_of_line = crlf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true
13+
14+
# XML files
15+
[*.{xml,csproj,props,targets,nuspec}]
16+
indent_size = 2
17+
18+
# JSON/YAML files
19+
[*.{json,yml,yaml}]
20+
indent_size = 2
21+
22+
# Markdown files
23+
[*.md]
24+
trim_trailing_whitespace = false
25+
26+
# C# files
27+
[*.cs]
28+
# Organize usings
29+
dotnet_sort_system_directives_first = true
30+
dotnet_separate_import_directive_groups = false
31+
32+
# this. preferences
33+
dotnet_style_qualification_for_field = false:suggestion
34+
dotnet_style_qualification_for_property = false:suggestion
35+
dotnet_style_qualification_for_method = false:suggestion
36+
dotnet_style_qualification_for_event = false:suggestion
37+
38+
# Language keywords vs BCL types preferences
39+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
40+
dotnet_style_predefined_type_for_member_access = true:suggestion
41+
42+
# Modifier preferences
43+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
44+
dotnet_style_readonly_field = true:suggestion
45+
46+
# Parentheses preferences
47+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
48+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
49+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
50+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
51+
52+
# Expression-level preferences
53+
dotnet_style_object_initializer = true:suggestion
54+
dotnet_style_collection_initializer = true:suggestion
55+
dotnet_style_explicit_tuple_names = true:suggestion
56+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
57+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
58+
dotnet_style_prefer_auto_properties = true:suggestion
59+
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
60+
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
61+
dotnet_style_prefer_compound_assignment = true:suggestion
62+
dotnet_style_prefer_simplified_interpolation = true:suggestion
63+
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
64+
65+
# Null-checking preferences
66+
dotnet_style_coalesce_expression = true:suggestion
67+
dotnet_style_null_propagation = true:suggestion
68+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
69+
70+
# var preferences
71+
csharp_style_var_for_built_in_types = false:suggestion
72+
csharp_style_var_when_type_is_apparent = true:suggestion
73+
csharp_style_var_elsewhere = false:suggestion
74+
75+
# Expression-bodied members
76+
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
77+
csharp_style_expression_bodied_constructors = false:suggestion
78+
csharp_style_expression_bodied_operators = when_on_single_line:suggestion
79+
csharp_style_expression_bodied_properties = true:suggestion
80+
csharp_style_expression_bodied_indexers = true:suggestion
81+
csharp_style_expression_bodied_accessors = true:suggestion
82+
csharp_style_expression_bodied_lambdas = true:suggestion
83+
csharp_style_expression_bodied_local_functions = when_on_single_line:suggestion
84+
85+
# Pattern matching preferences
86+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
87+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
88+
csharp_style_prefer_switch_expression = true:suggestion
89+
csharp_style_prefer_pattern_matching = true:suggestion
90+
csharp_style_prefer_not_pattern = true:suggestion
91+
92+
# Code-block preferences
93+
csharp_prefer_braces = true:suggestion
94+
csharp_prefer_simple_using_statement = true:suggestion
95+
96+
# 'using' directive preferences
97+
csharp_using_directive_placement = outside_namespace:suggestion
98+
99+
# New line preferences
100+
csharp_new_line_before_open_brace = all
101+
csharp_new_line_before_else = true
102+
csharp_new_line_before_catch = true
103+
csharp_new_line_before_finally = true
104+
csharp_new_line_before_members_in_object_initializers = true
105+
csharp_new_line_before_members_in_anonymous_types = true
106+
csharp_new_line_between_query_expression_clauses = true
107+
108+
# Indentation preferences
109+
csharp_indent_case_contents = true
110+
csharp_indent_switch_labels = true
111+
csharp_indent_labels = one_less_than_current
112+
csharp_indent_block_contents = true
113+
csharp_indent_braces = false
114+
csharp_indent_case_contents_when_block = false
115+
116+
# Space preferences
117+
csharp_space_after_cast = false
118+
csharp_space_after_keywords_in_control_flow_statements = true
119+
csharp_space_between_parentheses = false
120+
csharp_space_before_colon_in_inheritance_clause = true
121+
csharp_space_after_colon_in_inheritance_clause = true
122+
csharp_space_around_binary_operators = before_and_after
123+
csharp_space_between_method_declaration_parameter_list_parentheses = false
124+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
125+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
126+
csharp_space_between_method_call_parameter_list_parentheses = false
127+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
128+
csharp_space_between_method_call_name_and_opening_parenthesis = false
129+
csharp_space_after_comma = true
130+
csharp_space_before_comma = false
131+
csharp_space_after_dot = false
132+
csharp_space_before_dot = false
133+
csharp_space_after_semicolon_in_for_statement = true
134+
csharp_space_before_semicolon_in_for_statement = false
135+
csharp_space_around_declaration_statements = false
136+
csharp_space_before_open_square_brackets = false
137+
csharp_space_between_empty_square_brackets = false
138+
csharp_space_between_square_brackets = false
139+
140+
# Wrapping preferences
141+
csharp_preserve_single_line_statements = false
142+
csharp_preserve_single_line_blocks = true
143+
144+
# Naming conventions
145+
dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore.severity = suggestion
146+
dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore.symbols = private_fields
147+
dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore.style = camel_case_with_underscore
148+
149+
dotnet_naming_symbols.private_fields.applicable_kinds = field
150+
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
151+
152+
dotnet_naming_style.camel_case_with_underscore.capitalization = camel_case
153+
dotnet_naming_style.camel_case_with_underscore.required_prefix = _

.gitattributes

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Auto detect text files and normalize line endings
2+
* text=auto eol=crlf
3+
4+
# C# source files
5+
*.cs text eol=crlf
6+
7+
# Project files
8+
*.csproj text eol=crlf
9+
*.sln text eol=crlf
10+
*.slnx text eol=crlf
11+
12+
# Config files (use LF for cross-platform tools)
13+
*.md text eol=lf
14+
*.yml text eol=lf
15+
*.yaml text eol=lf
16+
*.json text eol=lf
17+
*.sh text eol=lf

0 commit comments

Comments
 (0)