Skip to content

Commit 17e501f

Browse files
committed
CSHARP-3084: Add .editorconfig file to solution.
1 parent 2119acc commit 17e501f

File tree

2 files changed

+191
-2
lines changed

2 files changed

+191
-2
lines changed

.editorconfig

+188
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
# To learn more about .editorconfig see https://aka.ms/editorconfigdocs
2+
# editorconfig.org
3+
4+
# top-most EditorConfig file
5+
root = true
6+
7+
# Default settings:
8+
# A newline ending every file
9+
# Use 4 spaces as indentation
10+
[*]
11+
insert_final_newline = true
12+
indent_style = space
13+
indent_size = 4
14+
trim_trailing_whitespace = true
15+
16+
[project.json]
17+
indent_size = 2
18+
19+
# C# files
20+
[*.cs]
21+
# New line preferences
22+
csharp_new_line_before_open_brace = all
23+
csharp_new_line_before_else = true
24+
csharp_new_line_before_catch = true
25+
csharp_new_line_before_finally = true
26+
csharp_new_line_before_members_in_object_initializers = true
27+
csharp_new_line_before_members_in_anonymous_types = true
28+
csharp_new_line_between_query_expression_clauses = true
29+
30+
# Indentation preferences
31+
csharp_indent_block_contents = true
32+
csharp_indent_braces = false
33+
csharp_indent_case_contents = true
34+
csharp_indent_case_contents_when_block = true
35+
csharp_indent_switch_labels = true
36+
csharp_indent_labels = one_less_than_current
37+
38+
# Modifier preferences
39+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
40+
41+
# avoid this. unless absolutely necessary
42+
dotnet_style_qualification_for_field = false:suggestion
43+
dotnet_style_qualification_for_property = false:suggestion
44+
dotnet_style_qualification_for_method = false:suggestion
45+
dotnet_style_qualification_for_event = false:suggestion
46+
47+
# Types: use keywords instead of BCL types, and permit var only when the type is clear
48+
csharp_style_var_for_built_in_types = false:suggestion
49+
csharp_style_var_when_type_is_apparent = false:none
50+
csharp_style_var_elsewhere = false:suggestion
51+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
52+
dotnet_style_predefined_type_for_member_access = true:suggestion
53+
54+
# name all constant fields using PascalCase
55+
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
56+
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
57+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
58+
dotnet_naming_symbols.constant_fields.applicable_kinds = field
59+
dotnet_naming_symbols.constant_fields.required_modifiers = const
60+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
61+
62+
# static fields should have s_ prefix
63+
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
64+
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
65+
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
66+
dotnet_naming_symbols.static_fields.applicable_kinds = field
67+
dotnet_naming_symbols.static_fields.required_modifiers = static
68+
dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
69+
dotnet_naming_style.static_prefix_style.required_prefix = s_
70+
dotnet_naming_style.static_prefix_style.capitalization = camel_case
71+
72+
# internal and private fields should be _camelCase
73+
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
74+
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
75+
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
76+
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
77+
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
78+
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
79+
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
80+
81+
# Code style defaults
82+
csharp_using_directive_placement = outside_namespace:suggestion
83+
dotnet_sort_system_directives_first = true
84+
csharp_prefer_braces = true:refactoring
85+
csharp_preserve_single_line_blocks = true:none
86+
csharp_preserve_single_line_statements = false:none
87+
csharp_prefer_static_local_function = true:suggestion
88+
csharp_prefer_simple_using_statement = false:none
89+
csharp_style_prefer_switch_expression = true:suggestion
90+
91+
# Code quality
92+
dotnet_style_readonly_field = true:suggestion
93+
dotnet_code_quality_unused_parameters = non_public:suggestion
94+
95+
# Expression-level preferences
96+
dotnet_style_object_initializer = true:suggestion
97+
dotnet_style_collection_initializer = true:suggestion
98+
dotnet_style_explicit_tuple_names = true:suggestion
99+
dotnet_style_coalesce_expression = true:suggestion
100+
dotnet_style_null_propagation = true:suggestion
101+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
102+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
103+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
104+
dotnet_style_prefer_auto_properties = true:suggestion
105+
dotnet_style_prefer_conditional_expression_over_assignment = true:refactoring
106+
dotnet_style_prefer_conditional_expression_over_return = true:refactoring
107+
csharp_prefer_simple_default_expression = true:suggestion
108+
109+
# Expression-bodied members
110+
csharp_style_expression_bodied_methods = true:refactoring
111+
csharp_style_expression_bodied_constructors = true:refactoring
112+
csharp_style_expression_bodied_operators = true:refactoring
113+
csharp_style_expression_bodied_properties = true:refactoring
114+
csharp_style_expression_bodied_indexers = true:refactoring
115+
csharp_style_expression_bodied_accessors = true:refactoring
116+
csharp_style_expression_bodied_lambdas = true:refactoring
117+
csharp_style_expression_bodied_local_functions = true:refactoring
118+
119+
# Pattern matching
120+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
121+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
122+
csharp_style_inlined_variable_declaration = true:suggestion
123+
124+
# Null checking preferences
125+
csharp_style_throw_expression = true:suggestion
126+
csharp_style_conditional_delegate_call = true:suggestion
127+
128+
# Other features
129+
csharp_style_prefer_index_operator = false:none
130+
csharp_style_prefer_range_operator = false:none
131+
csharp_style_pattern_local_over_anonymous_function = false:none
132+
133+
# Space preferences
134+
csharp_space_after_cast = false
135+
csharp_space_after_colon_in_inheritance_clause = true
136+
csharp_space_after_comma = true
137+
csharp_space_after_dot = false
138+
csharp_space_after_keywords_in_control_flow_statements = true
139+
csharp_space_after_semicolon_in_for_statement = true
140+
csharp_space_around_binary_operators = before_and_after
141+
csharp_space_around_declaration_statements = do_not_ignore
142+
csharp_space_before_colon_in_inheritance_clause = true
143+
csharp_space_before_comma = false
144+
csharp_space_before_dot = false
145+
csharp_space_before_open_square_brackets = false
146+
csharp_space_before_semicolon_in_for_statement = false
147+
csharp_space_between_empty_square_brackets = false
148+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
149+
csharp_space_between_method_call_name_and_opening_parenthesis = false
150+
csharp_space_between_method_call_parameter_list_parentheses = false
151+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
152+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
153+
csharp_space_between_method_declaration_parameter_list_parentheses = false
154+
csharp_space_between_parentheses = false
155+
csharp_space_between_square_brackets = false
156+
157+
# Analyzers
158+
dotnet_code_quality.ca1802.api_surface = private, internal
159+
160+
# C++ Files
161+
[*.{cpp,h,in}]
162+
curly_bracket_next_line = true
163+
indent_brace_style = Allman
164+
165+
# Xml project files
166+
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
167+
indent_size = 2
168+
169+
[*.{csproj,vbproj,proj,nativeproj,locproj}]
170+
charset = utf-8
171+
172+
# Xml build files
173+
[*.builds]
174+
indent_size = 2
175+
176+
# Xml files
177+
[*.{xml,stylecop,resx,ruleset}]
178+
indent_size = 2
179+
180+
# Xml config files
181+
[*.{props,targets,config,nuspec}]
182+
indent_size = 2
183+
184+
# Shell scripts
185+
[*.sh]
186+
end_of_line = lf
187+
[*.{cmd, bat}]
188+
end_of_line = crlf

CSharpDriver.sln

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27703.2042
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30011.22
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D2012971-32BB-4C5F-BFC4-30A9994AB152}"
77
EndProject
@@ -43,6 +43,7 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MongoDB.Driver.Legacy.VB.Te
4343
EndProject
4444
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B071AF36-EED4-4CFF-A006-ECDAD0A87F99}"
4545
ProjectSection(SolutionItems) = preProject
46+
.editorconfig = .editorconfig
4647
MongoDB.ruleset = MongoDB.ruleset
4748
MongoDBLegacy.ruleset = MongoDBLegacy.ruleset
4849
MongoDBLegacyTest.ruleset = MongoDBLegacyTest.ruleset

0 commit comments

Comments
 (0)