Skip to content

Commit d6c1cd8

Browse files
Add .editorConfig File and set some rules.
1 parent 0553817 commit d6c1cd8

File tree

6 files changed

+288
-12
lines changed

6 files changed

+288
-12
lines changed

.editorconfig

Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
# Schema: http://EditorConfig.org
2+
# Docs: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
3+
4+
# top-most EditorConfig file
5+
root = true
6+
7+
# Don't use tabs for indentation.
8+
[*]
9+
indent_style = space
10+
trim_trailing_whitespace = true
11+
guidelines = 140
12+
max_line_length = 140
13+
14+
# Code files
15+
[*.{cs,csx,vb,vbx}]
16+
indent_size = 4
17+
insert_final_newline = true
18+
#charset = utf-8-bom
19+
20+
# Xml project files
21+
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
22+
indent_size = 4
23+
24+
# Xml config files
25+
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct,xml,stylecop}]
26+
indent_size = 2
27+
28+
# JSON files
29+
[*.json]
30+
indent_size = 2
31+
32+
# Powershell files
33+
[*.ps1]
34+
indent_size = 2
35+
36+
# Shell scripts
37+
[*.sh]
38+
end_of_line = lf
39+
indent_size = 2
40+
41+
[*.{cmd,bat}]
42+
end_of_line = crlf
43+
indent_size = 2
44+
45+
## Language conventions
46+
# Dotnet code style settings:
47+
[*.{cs,vb}]
48+
# "This." and "Me." qualifiers
49+
dotnet_style_qualification_for_field = false:suggestion
50+
dotnet_style_qualification_for_property = false:suggestion
51+
dotnet_style_qualification_for_method = false:suggestion
52+
dotnet_style_qualification_for_event = false:suggestion
53+
54+
# Language keywords instead of framework type names for type references
55+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
56+
dotnet_style_predefined_type_for_member_access = true:suggestion
57+
58+
# Modifier preferences
59+
dotnet_style_require_accessibility_modifiers = always:suggestion
60+
dotnet_style_readonly_field = true:warning
61+
62+
# Parentheses preferences
63+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
64+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
65+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
66+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
67+
68+
# Expression-level preferences
69+
dotnet_style_object_initializer = true:suggestion
70+
dotnet_style_collection_initializer = true:suggestion
71+
dotnet_style_explicit_tuple_names = true:suggestion
72+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
73+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
74+
dotnet_style_prefer_auto_properties = true:silent
75+
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
76+
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
77+
78+
# Null-checking preferences
79+
dotnet_style_coalesce_expression = true:suggestion
80+
dotnet_style_null_propagation = true:suggestion
81+
82+
# CSharp code style settings:
83+
[*.cs]
84+
# Modifier preferences
85+
csharp_preferred_modifier_order = public,private,protected,internal,const,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
86+
87+
# Implicit and explicit types
88+
csharp_style_var_for_built_in_types = true:suggestion
89+
csharp_style_var_when_type_is_apparent = true:suggestion
90+
csharp_style_var_elsewhere = true:suggestion
91+
92+
# Expression-bodied members
93+
# Explicitly disabled due to difference in coding style between source and tests
94+
#csharp_style_expression_bodied_methods = false:silent
95+
#csharp_style_expression_bodied_constructors = false:silent
96+
csharp_style_expression_bodied_operators = false:silent
97+
csharp_style_expression_bodied_properties = true:suggestion
98+
csharp_style_expression_bodied_indexers = true:suggestion
99+
csharp_style_expression_bodied_accessors = true:suggestion
100+
101+
# Pattern matching
102+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
103+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
104+
105+
# Inlined variable declarations
106+
csharp_style_inlined_variable_declaration = true:suggestion
107+
108+
# Expression-level preferences
109+
csharp_prefer_simple_default_expression = true:suggestion
110+
csharp_style_deconstructed_variable_declaration = true:suggestion
111+
csharp_style_pattern_local_over_anonymous_function = true:suggestion
112+
113+
# Null-checking preference
114+
csharp_style_throw_expression = true:suggestion
115+
csharp_style_conditional_delegate_call = true:suggestion
116+
117+
# Code block preferences
118+
csharp_prefer_braces = false:suggestion
119+
120+
# Primary constructors
121+
csharp_style_prefer_primary_constructors = true:suggestion
122+
123+
## Formatting conventions
124+
# Dotnet formatting settings:
125+
[*.{cs,vb}]
126+
# Organize usings
127+
dotnet_sort_system_directives_first = true
128+
dotnet_separate_import_directive_groups = false
129+
130+
# CSharp formatting settings:
131+
[*.cs]
132+
# Newline options
133+
csharp_new_line_before_open_brace = all
134+
csharp_new_line_before_else = true
135+
csharp_new_line_before_catch = true
136+
csharp_new_line_before_finally = true
137+
csharp_new_line_before_members_in_object_initializers = true
138+
csharp_new_line_before_members_in_anonymous_types = true
139+
csharp_new_line_between_query_expression_clauses = true
140+
141+
# Identation options
142+
csharp_indent_block_contents = true
143+
csharp_indent_braces = false
144+
csharp_indent_case_contents_when_block = false
145+
csharp_indent_switch_labels = true
146+
csharp_indent_case_contents = true
147+
csharp_indent_labels = no_change
148+
149+
# Spacing options
150+
csharp_space_after_cast = false
151+
csharp_space_after_keywords_in_control_flow_statements = true
152+
csharp_space_between_method_declaration_parameter_list_parentheses = false
153+
csharp_space_between_method_call_parameter_list_parentheses = false
154+
csharp_space_between_parentheses = false
155+
csharp_space_before_colon_in_inheritance_clause = true
156+
csharp_space_after_colon_in_inheritance_clause = true
157+
csharp_space_around_binary_operators = before_and_after
158+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
159+
csharp_space_between_method_call_name_and_opening_parenthesis = false
160+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
161+
csharp_space_after_comma = true
162+
csharp_space_after_dot = false
163+
csharp_space_after_semicolon_in_for_statement = true
164+
csharp_space_around_declaration_statements = do_not_ignore
165+
csharp_space_before_comma = false
166+
csharp_space_before_dot = false
167+
csharp_space_before_open_square_brackets = false
168+
csharp_space_before_semicolon_in_for_statement = false
169+
csharp_space_between_empty_square_brackets = false
170+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
171+
csharp_space_between_square_brackets = false
172+
173+
# Wrap options
174+
csharp_preserve_single_line_statements = true
175+
csharp_preserve_single_line_blocks = true
176+
csharp_using_directive_placement = outside_namespace:silent
177+
csharp_prefer_simple_using_statement = true:suggestion
178+
csharp_style_namespace_declarations = file_scoped:silent
179+
csharp_style_prefer_method_group_conversion = true:silent
180+
csharp_style_prefer_top_level_statements = true:silent
181+
csharp_style_expression_bodied_methods = true:suggestion
182+
csharp_style_expression_bodied_constructors = false:silent
183+
csharp_style_expression_bodied_lambdas = true:silent
184+
csharp_style_expression_bodied_local_functions = false:silent
185+
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
186+
187+
## Naming conventions
188+
[*.{cs,vb}]
189+
190+
## Naming styles
191+
192+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
193+
dotnet_naming_style.camel_case_style.capitalization = camel_case
194+
195+
# PascalCase with I prefix
196+
dotnet_naming_style.interface_style.capitalization = pascal_case
197+
dotnet_naming_style.interface_style.required_prefix = I
198+
199+
# PascalCase with T prefix
200+
dotnet_naming_style.type_parameter_style.capitalization = pascal_case
201+
dotnet_naming_style.type_parameter_style.required_prefix = T
202+
203+
# camelCase with _ prefix
204+
dotnet_naming_style._camelCase.capitalization = camel_case
205+
dotnet_naming_style._camelCase.required_prefix = _
206+
207+
## Rules
208+
# Interfaces
209+
dotnet_naming_symbols.interface_symbol.applicable_kinds = interface
210+
dotnet_naming_symbols.interface_symbol.applicable_accessibilities = *
211+
dotnet_naming_rule.interface_naming.symbols = interface_symbol
212+
dotnet_naming_rule.interface_naming.style = interface_style
213+
dotnet_naming_rule.interface_naming.severity = suggestion
214+
215+
# Classes, Structs, Enums, Properties, Methods, Local Functions, Events, Namespaces
216+
dotnet_naming_symbols.class_symbol.applicable_kinds = class, struct, enum, property, method, local_function, event, namespace, delegate
217+
dotnet_naming_symbols.class_symbol.applicable_accessibilities = *
218+
219+
dotnet_naming_rule.class_naming.symbols = class_symbol
220+
dotnet_naming_rule.class_naming.style = pascal_case_style
221+
dotnet_naming_rule.class_naming.severity = suggestion
222+
223+
# Type Parameters
224+
dotnet_naming_symbols.type_parameter_symbol.applicable_kinds = type_parameter
225+
dotnet_naming_symbols.type_parameter_symbol.applicable_accessibilities = *
226+
227+
dotnet_naming_rule.type_parameter_naming.symbols = type_parameter_symbol
228+
dotnet_naming_rule.type_parameter_naming.style = type_parameter_style
229+
dotnet_naming_rule.type_parameter_naming.severity = suggestion
230+
231+
# Visible Fields
232+
dotnet_naming_symbols.public_field_symbol.applicable_kinds = field
233+
dotnet_naming_symbols.public_field_symbol.applicable_accessibilities = public, internal, protected, protected_internal, private_protected
234+
235+
dotnet_naming_rule.public_field_naming.symbols = public_field_symbol
236+
dotnet_naming_rule.public_field_naming.style = pascal_case_style
237+
dotnet_naming_rule.public_field_naming.severity = suggestion
238+
239+
# Private constant Fields
240+
dotnet_naming_symbols.const_field_symbol.applicable_kinds = field
241+
dotnet_naming_symbols.const_field_symbol.applicable_accessibilities = private
242+
dotnet_naming_symbols.const_field_symbol.required_modifiers = const
243+
244+
dotnet_naming_rule.const_field_naming.symbols = const_field_symbol
245+
dotnet_naming_rule.const_field_naming.style = pascal_case_style
246+
dotnet_naming_rule.const_field_naming.severity = suggestion
247+
248+
# Parameters
249+
dotnet_naming_symbols.parameter_symbol.applicable_kinds = parameter
250+
dotnet_naming_symbols.parameter_symbol.applicable_accessibilities = *
251+
252+
dotnet_naming_rule.parameter_naming.symbols = parameter_symbol
253+
dotnet_naming_rule.parameter_naming.style = camel_case_style
254+
dotnet_naming_rule.parameter_naming.severity = suggestion
255+
256+
# Everything Local
257+
dotnet_naming_symbols.everything_else.applicable_kinds = local
258+
dotnet_naming_symbols.everything_else.applicable_accessibilities = *
259+
260+
dotnet_naming_rule.everything_else_naming.symbols = everything_else
261+
dotnet_naming_rule.everything_else_naming.style = camel_case_style
262+
dotnet_naming_rule.everything_else_naming.severity = suggestion
263+
264+
# Microsoft .NET properties
265+
csharp_style_expression_bodied_methods = true:suggestion
266+
267+
# ReSharper properties
268+
resharper_local_function_body = expression_body
269+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
270+
tab_width = 4
271+
end_of_line = crlf
272+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
273+
dotnet_style_prefer_collection_expression = true:suggestion
274+
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
275+
dotnet_style_prefer_compound_assignment = true:suggestion
276+
dotnet_style_prefer_simplified_interpolation = true:suggestion

SwiftLink.sln

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0143A2D3-97FF-4B41-B2C8-B482BF0508A5}"
99
ProjectSection(SolutionItems) = preProject
1010
changelog.md = changelog.md
11+
.editorconfig = .editorconfig
1112
Dockerfile = Dockerfile
1213
LICENSE = LICENSE
1314
README.md = README.md
@@ -29,7 +30,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{19001328
2930
EndProject
3031
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SwiftLink.Application.UnitTests", "tests\SwiftLink.Application.UnitTests\SwiftLink.Application.UnitTests.csproj", "{B3286D3F-2DCC-4729-BE35-63C32886F8A5}"
3132
EndProject
32-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwiftLink.Shared.Tests", "tests\SwiftLink.Shared.Tests\SwiftLink.Shared.Tests.csproj", "{FA883A80-6BE4-4FA8-84B2-D0B1BF6D1425}"
33+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SwiftLink.Shared.Tests", "tests\SwiftLink.Shared.Tests\SwiftLink.Shared.Tests.csproj", "{FA883A80-6BE4-4FA8-84B2-D0B1BF6D1425}"
3334
EndProject
3435
Global
3536
GlobalSection(SolutionConfigurationPlatforms) = preSolution

src/SwiftLink.Application/Behaviors/LoggingBehavior.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TRe
1414
{
1515
var requestName = typeof(TRequest).Name;
1616

17-
_logger.LogInformation($"SwiftLink Request: {requestName} {_sharedContext.Get(nameof(Subscriber.Id))} {_sharedContext.Get(nameof(Subscriber.Name))} {request}");
17+
_logger.LogInformation("SwiftLink Request: {requestName} {@subscriberId} {@subscriberName} {@Request}",
18+
requestName, _sharedContext.Get(nameof(Subscriber.Id)), _sharedContext.Get(nameof(Subscriber.Name)), request);
19+
1820
var response = await next();
19-
_logger.LogInformation($"SwiftLink Response: {requestName} {response}");
2021

22+
_logger.LogInformation("SwiftLink Response: {requestName} {@Response}", requestName, response);
2123
return response;
2224
}
2325
}

src/SwiftLink.Application/Notifications/VisitLinkNotificationHandler.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using MediatR;
2-
using SwiftLink.Application.Common.Interfaces;
1+
using SwiftLink.Application.Common.Interfaces;
32

43
namespace SwiftLink.Application.Notifications;
54

src/SwiftLink.Application/UseCases/Links/Commands/DisableLink/DisableLinkCommandHandler.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ public class DisableLinkCommandHandler(IApplicationDbContext dbContext) : IReque
99

1010
public async Task<Result<bool>> Handle(DisableLinkCommand request, CancellationToken cancellationToken)
1111
{
12-
var link = await _dbContext.Set<Link>().Where(x => x.Id == request.Id).FirstOrDefaultAsync();
12+
var link = await _dbContext.Set<Link>().Where(x => x.Id == request.Id)
13+
.FirstOrDefaultAsync(cancellationToken);
14+
1315
if (link is null)
1416
return Result.Failure<bool>(LinkMessages.LinkIsNotFound);
1517

1618
link.Disable();
1719
var dbResult = await _dbContext.SaveChangesAsync(cancellationToken);
1820

19-
if (dbResult.IsFailure)
20-
return Result.Failure<bool>(CommonMessages.Database.UpdateFailed);
21-
22-
return Result.Success(true);
21+
return dbResult.IsFailure ? Result.Failure<bool>(CommonMessages.Database.UpdateFailed) : Result.Success(true);
2322
}
2423
}

src/SwiftLink.Application/UseCases/Links/Commands/GenerateShortCode/GenerateShortCodeCommandHandler.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using MediatR;
2-
using Microsoft.Extensions.Options;
1+
using Microsoft.Extensions.Options;
32
using SwiftLink.Application.Common;
43
using SwiftLink.Application.Common.Interfaces;
54
using SwiftLink.Application.Dtos;

0 commit comments

Comments
 (0)