Skip to content

Commit b584710

Browse files
authored
Add editorconfig and reformat code (#239)
1 parent 4976887 commit b584710

File tree

144 files changed

+749
-515
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+749
-515
lines changed

.editorconfig

Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# Create portable, custom editor settings with EditorConfig
4+
# https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options
5+
6+
# .NET coding convention settings for EditorConfig
7+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2019
8+
9+
# Language conventions
10+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019
11+
12+
# Formatting conventions
13+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019
14+
15+
# .NET naming conventions for EditorConfig
16+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019
17+
18+
# Top-most EditorConfig file
19+
root = true
20+
21+
# Editor default newlines with a newline ending every file
22+
[*]
23+
insert_final_newline = true
24+
charset = utf-8
25+
indent_style = space
26+
indent_size = 2
27+
trim_trailing_whitespace = true
28+
29+
[*.cs]
30+
indent_size = 4
31+
32+
# Do not insert newline for ApiApprovalTests
33+
[*.txt]
34+
insert_final_newline = false
35+
36+
# Code files
37+
[*.{cs,vb}]
38+
39+
# .NET code style settings - "This." and "Me." qualifiers
40+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#this-and-me
41+
dotnet_style_qualification_for_field = false:warning
42+
dotnet_style_qualification_for_property = false:warning
43+
dotnet_style_qualification_for_method = false:warning
44+
dotnet_style_qualification_for_event = false:warning
45+
46+
# .NET code style settings - Language keywords instead of framework type names for type references
47+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#language-keywords
48+
dotnet_style_predefined_type_for_locals_parameters_members = true:error
49+
dotnet_style_predefined_type_for_member_access = true:error
50+
51+
# .NET code style settings - Modifier preferences
52+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#normalize-modifiers
53+
dotnet_style_require_accessibility_modifiers = always:warning
54+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning
55+
dotnet_style_readonly_field = true:warning
56+
57+
# .NET code style settings - Parentheses preferences
58+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#parentheses-preferences
59+
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:suggestion
60+
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:suggestion
61+
dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:suggestion
62+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
63+
64+
# .NET code style settings - Expression-level preferences
65+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#expression-level-preferences
66+
dotnet_style_object_initializer = true:error
67+
dotnet_style_collection_initializer = true:error
68+
dotnet_style_explicit_tuple_names = true:warning
69+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
70+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
71+
dotnet_style_prefer_auto_properties = true:warning
72+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
73+
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
74+
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
75+
dotnet_style_prefer_compound_assignment = true:warning
76+
77+
# .NET code style settings - Null-checking preferences
78+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#null-checking-preferences
79+
dotnet_style_coalesce_expression = true:warning
80+
dotnet_style_null_propagation = true:error
81+
82+
# .NET code quality settings - Parameter preferences
83+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#parameter-preferences
84+
dotnet_code_quality_unused_parameters = all:warning
85+
86+
# C# code style settings - Implicit and explicit types
87+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#implicit-and-explicit-types
88+
csharp_style_var_for_built_in_types = false:suggestion
89+
csharp_style_var_when_type_is_apparent = true:warning
90+
csharp_style_var_elsewhere = true:suggestion
91+
92+
# C# code style settings - Expression-bodied members
93+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#expression-bodied-members
94+
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
95+
csharp_style_expression_bodied_constructors = false:warning
96+
csharp_style_expression_bodied_operators = when_on_single_line:warning
97+
csharp_style_expression_bodied_properties = when_on_single_line:warning
98+
csharp_style_expression_bodied_indexers = when_on_single_line:warning
99+
csharp_style_expression_bodied_accessors = when_on_single_line:warning
100+
csharp_style_expression_bodied_lambdas = when_on_single_line:warning
101+
csharp_style_expression_bodied_local_functions = when_on_single_line:warning
102+
103+
# C# code style settings - Pattern matching
104+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#pattern-matching
105+
csharp_style_pattern_matching_over_is_with_cast_check = true:error
106+
csharp_style_pattern_matching_over_as_with_null_check = true:error
107+
108+
# C# code style settings - Inlined variable declaration
109+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#inlined-variable-declarations
110+
csharp_style_inlined_variable_declaration = true:error
111+
112+
# C# code style settings - C# expression-level preferences
113+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#c-expression-level-preferences
114+
csharp_prefer_simple_default_expression = true:suggestion
115+
116+
# C# code style settings - C# null-checking preferences
117+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#c-null-checking-preferences
118+
csharp_style_throw_expression = true:warning
119+
csharp_style_conditional_delegate_call = true:warning
120+
121+
# C# code style settings - Code block preferences
122+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#code-block-preferences
123+
csharp_prefer_braces = false:suggestion
124+
125+
# C# code style - Unused value preferences
126+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#unused-value-preferences
127+
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
128+
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
129+
130+
# C# code style - Index and range preferences
131+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#index-and-range-preferences
132+
csharp_style_prefer_index_operator = true:warning
133+
csharp_style_prefer_range_operator = true:warning
134+
135+
# C# code style - Miscellaneous preferences
136+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#miscellaneous-preferences
137+
csharp_style_deconstructed_variable_declaration = true:suggestion
138+
csharp_style_pattern_local_over_anonymous_function = true:suggestion
139+
csharp_using_directive_placement = outside_namespace:warning
140+
csharp_prefer_static_local_function = true:suggestion
141+
csharp_prefer_simple_using_statement = false:suggestion
142+
csharp_style_prefer_switch_expression = true:suggestion
143+
144+
# .NET formatting settings - Organize using directives
145+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019#organize-using-directives
146+
dotnet_sort_system_directives_first = true
147+
dotnet_separate_import_directive_groups = false
148+
149+
# C# formatting settings - New-line options
150+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019#new-line-options
151+
csharp_new_line_before_open_brace = all
152+
csharp_new_line_before_else = true
153+
csharp_new_line_before_catch = true
154+
csharp_new_line_before_finally = true
155+
csharp_new_line_before_members_in_object_initializers = true
156+
csharp_new_line_before_members_in_anonymous_types = true
157+
csharp_new_line_between_query_expression_clauses = true
158+
159+
# C# formatting settings - Indentation options
160+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019#indentation-options
161+
csharp_indent_case_contents = true
162+
csharp_indent_switch_labels = true
163+
csharp_indent_labels = one_less_than_current
164+
csharp_indent_block_contents = true
165+
csharp_indent_braces = false
166+
csharp_indent_case_contents_when_block = false
167+
168+
# C# formatting settings - Spacing options
169+
csharp_space_after_cast = false
170+
csharp_space_after_keywords_in_control_flow_statements = true
171+
csharp_space_between_parentheses = false
172+
csharp_space_before_colon_in_inheritance_clause = true
173+
csharp_space_after_colon_in_inheritance_clause = true
174+
csharp_space_around_binary_operators = before_and_after
175+
csharp_space_between_method_declaration_parameter_list_parentheses = false
176+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
177+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
178+
csharp_space_between_method_call_parameter_list_parentheses = false
179+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
180+
csharp_space_between_method_call_name_and_opening_parenthesis = false
181+
csharp_space_after_comma = true
182+
csharp_space_before_comma = false
183+
csharp_space_after_dot = false
184+
csharp_space_before_dot = false
185+
csharp_space_after_semicolon_in_for_statement = true
186+
csharp_space_before_semicolon_in_for_statement = false
187+
csharp_space_around_declaration_statements = false
188+
csharp_space_before_open_square_brackets = false
189+
csharp_space_between_empty_square_brackets = false
190+
csharp_space_between_square_brackets = false
191+
192+
# C# formatting settings - Wrap options
193+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019#wrap-options
194+
csharp_preserve_single_line_blocks = true
195+
csharp_preserve_single_line_statements = false
196+
197+
# C# formatting settings - Namespace options
198+
csharp_style_namespace_declarations = file_scoped:suggestion
199+
200+
########## name all private fields using camelCase with underscore prefix ##########
201+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019
202+
# dotnet_naming_rule.<namingRuleTitle>.symbols = <symbolTitle>
203+
dotnet_naming_rule.private_fields_with_underscore.symbols = private_fields
204+
205+
# dotnet_naming_symbols.<symbolTitle>.<property> = <value>
206+
dotnet_naming_symbols.private_fields.applicable_kinds = field
207+
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
208+
209+
# dotnet_naming_rule.<namingRuleTitle>.style = <styleTitle>
210+
dotnet_naming_rule.private_fields_with_underscore.style = prefix_underscore
211+
212+
# dotnet_naming_style.<styleTitle>.<property> = <value>
213+
dotnet_naming_style.prefix_underscore.capitalization = camel_case
214+
dotnet_naming_style.prefix_underscore.required_prefix = _
215+
216+
# dotnet_naming_rule.<namingRuleTitle>.severity = <value>
217+
dotnet_naming_rule.private_fields_with_underscore.severity = warning
218+
219+
########## name all constant fields using UPPER_CASE ##########
220+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019
221+
# dotnet_naming_rule.<namingRuleTitle>.symbols = <symbolTitle>
222+
dotnet_naming_rule.constant_fields_should_be_upper_case.symbols = constant_fields
223+
224+
# dotnet_naming_symbols.<symbolTitle>.<property> = <value>
225+
dotnet_naming_symbols.constant_fields.applicable_kinds = field
226+
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
227+
dotnet_naming_symbols.constant_fields.required_modifiers = const
228+
229+
# dotnet_naming_rule.<namingRuleTitle>.style = <styleTitle>
230+
dotnet_naming_rule.constant_fields_should_be_upper_case.style = upper_case_style
231+
232+
# dotnet_naming_style.<styleTitle>.<property> = <value>
233+
dotnet_naming_style.upper_case_style.capitalization = all_upper
234+
dotnet_naming_style.upper_case_style.word_separator = _
235+
236+
# dotnet_naming_rule.<namingRuleTitle>.severity = <value>
237+
dotnet_naming_rule.constant_fields_should_be_upper_case.severity = warning
238+
239+
########## Async methods should have "Async" suffix ##########
240+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019
241+
# dotnet_naming_rule.<namingRuleTitle>.symbols = <symbolTitle>
242+
dotnet_naming_rule.async_methods_end_in_async.symbols = any_async_methods
243+
244+
# dotnet_naming_symbols.<symbolTitle>.<property> = <value>
245+
dotnet_naming_symbols.any_async_methods.applicable_kinds = method
246+
dotnet_naming_symbols.any_async_methods.applicable_accessibilities = *
247+
dotnet_naming_symbols.any_async_methods.required_modifiers = async
248+
249+
# dotnet_naming_rule.<namingRuleTitle>.style = <styleTitle>
250+
dotnet_naming_rule.async_methods_end_in_async.style = end_in_async_style
251+
252+
# dotnet_naming_style.<styleTitle>.<property> = <value>
253+
dotnet_naming_style.end_in_async_style.capitalization = pascal_case
254+
dotnet_naming_style.end_in_async_style.word_separator =
255+
dotnet_naming_style.end_in_async_style.required_prefix =
256+
dotnet_naming_style.end_in_async_style.required_suffix = Async
257+
258+
# dotnet_naming_rule.<namingRuleTitle>.severity = <value>
259+
dotnet_naming_rule.async_methods_end_in_async.severity = warning
260+
261+
# IDE1006: Naming Styles (Async methods should have "Async" suffix, see rule above)
262+
dotnet_diagnostic.IDE1006.severity = suggestion
263+
264+
# Remove unnecessary import https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0005
265+
dotnet_diagnostic.IDE0005.severity = error
266+
267+
# Enforce formatting https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#rule-id-ide0055-fix-formatting
268+
dotnet_diagnostic.IDE0055.severity = error
269+
270+
# Disable IDE0057: substring can be simplified (not compatible with .NET Standard 2.0)
271+
dotnet_diagnostic.IDE0057.severity = none
272+
273+
# Disable IDE0060: Remove unused parameter
274+
dotnet_diagnostic.IDE0060.severity = suggestion

Conventions.sln

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
3131
EndProject
3232
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".Solution Items", ".Solution Items", "{5A8618B7-7299-4507-A665-CC9CEE8B4674}"
3333
ProjectSection(SolutionItems) = preProject
34-
global.json = global.json
34+
.editorconfig = .editorconfig
35+
Directory.build.props = Directory.build.props
3536
LICENSE.md = LICENSE.md
3637
README.md = README.md
3738
EndProjectSection
3839
EndProject
3940
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples' Tests", "Samples' Tests", "{F9132124-0747-427F-B607-B7BAD25332F7}"
4041
EndProject
41-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubscriptionExample.Tests", "test\SubscriptionExample.Tests\SubscriptionExample.Tests.csproj", "{0BDE134F-0332-4D46-B762-DC861B6B126D}"
42+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SubscriptionExample.Tests", "test\SubscriptionExample.Tests\SubscriptionExample.Tests.csproj", "{0BDE134F-0332-4D46-B762-DC861B6B126D}"
4243
EndProject
4344
Global
4445
GlobalSection(SolutionConfigurationPlatforms) = preSolution

Directory.build.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project>
2+
<PropertyGroup>
3+
<NoWarn>$(NoWarn);IDE0060;IDE0057;CA1848;CA2254</NoWarn>
4+
<NoWarn>$(NoWarn);CA1310</NoWarn><!-- locale -->
5+
<AnalysisLevel>6.0-recommended</AnalysisLevel>
6+
</PropertyGroup>
7+
</Project>

global.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

samples/DataLoaderWithEFCore/DataLoaderWithEFCore/Data/Models/Actor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.ComponentModel.DataAnnotations;
33

44
namespace DataLoaderWithEFCore.Data.Models

samples/DataLoaderWithEFCore/DataLoaderWithEFCore/Data/Models/Country.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.ComponentModel.DataAnnotations;
1+
using System.ComponentModel.DataAnnotations;
22

33
namespace DataLoaderWithEFCore.Data.Models
44
{

samples/DataLoaderWithEFCore/DataLoaderWithEFCore/Data/Models/Movie.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.ComponentModel.DataAnnotations;
33

44
namespace DataLoaderWithEFCore.Data.Models

samples/DataLoaderWithEFCore/DataLoaderWithEFCore/Data/MovieDbContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using DataLoaderWithEFCore.Data.Models;
33
using Microsoft.EntityFrameworkCore;
44

samples/DataLoaderWithEFCore/DataLoaderWithEFCore/Data/Repositories/ActorRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading.Tasks;

samples/DataLoaderWithEFCore/DataLoaderWithEFCore/Data/Repositories/CountryRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.Linq;
33
using System.Threading.Tasks;
44
using DataLoaderWithEFCore.Data.Models;

0 commit comments

Comments
 (0)