Skip to content

Commit 9a95897

Browse files
committed
Update to latest .editorconfig settings, support more C# 7.3
1 parent 1a9c300 commit 9a95897

File tree

16 files changed

+244
-203
lines changed

16 files changed

+244
-203
lines changed

.editorconfig

Lines changed: 154 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# http://EditorConfig.org
1+
# http://EditorConfig.org
2+
3+
#################
4+
# Common Settings
5+
#################
26

37
# This file is the top-most EditorConfig file
48
root = true
@@ -12,6 +16,10 @@ indent_size = 4
1216
insert_final_newline = false
1317
trim_trailing_whitespace = true
1418

19+
#########################
20+
# File Extension Settings
21+
#########################
22+
1523
# Solution Files
1624
[*.sln]
1725
indent_style = tab
@@ -20,8 +28,16 @@ indent_style = tab
2028
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
2129
indent_size = 2
2230

23-
# Configuration Files
24-
[*.{json,xml,yml,config,props,targets,nuspec,resx,ruleset}]
31+
# XML Configuration Files
32+
[*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct}]
33+
indent_size = 2
34+
35+
# JSON Files
36+
[*.{json,json5}]
37+
indent_size = 2
38+
39+
# YAML Files
40+
[*.{yml,yaml}]
2541
indent_size = 2
2642

2743
# Markdown Files
@@ -33,27 +49,149 @@ trim_trailing_whitespace = false
3349
indent_size = 2
3450
insert_final_newline = true
3551

52+
# Batch Files
53+
[*.{cmd,bat}]
54+
3655
# Bash Files
3756
[*.sh]
3857
end_of_line = lf
3958

40-
# Dotnet Code Style Settings
41-
# See https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
42-
# See http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers
59+
###########################
60+
# .NET Language Conventions
61+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#language-conventions
62+
###########################
63+
64+
# .NET Code Style Settings
4365
[*.{cs,csx,cake,vb}]
44-
dotnet_sort_system_directives_first = true:warning
45-
dotnet_style_coalesce_expression = true:warning
66+
# "this." and "Me." qualifiers
67+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#this_and_me
68+
dotnet_style_qualification_for_field = true:warning
69+
dotnet_style_qualification_for_property = true:warning
70+
dotnet_style_qualification_for_method = true:warning
71+
dotnet_style_qualification_for_event = true:warning
72+
# Language keywords instead of framework type names for type references
73+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#language_keywords
74+
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
75+
dotnet_style_predefined_type_for_member_access = true:warning
76+
# Modifier preferences
77+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#normalize_modifiers
78+
dotnet_style_require_accessibility_modifiers = always:warning
79+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
80+
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async
81+
dotnet_style_readonly_field = true:warning
82+
# Expression-level preferences
83+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#expression_level
84+
dotnet_style_object_initializer = true:warning
4685
dotnet_style_collection_initializer = true:warning
4786
dotnet_style_explicit_tuple_names = true:warning
87+
dotnet_style_prefer_inferred_tuple_names = true:warning
88+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
89+
dotnet_style_prefer_auto_properties = true:warning
90+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
91+
# Null-checking preferences
92+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#null_checking
93+
dotnet_style_coalesce_expression = true:warning
4894
dotnet_style_null_propagation = true:warning
49-
dotnet_style_object_initializer = true:warning
50-
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
51-
dotnet_style_predefined_type_for_member_access = true:warning
52-
dotnet_style_qualification_for_event = true:warning
53-
dotnet_style_qualification_for_field = true:warning
54-
dotnet_style_qualification_for_method = true:warning
55-
dotnet_style_qualification_for_property = true:warning
95+
# Other (Undocumented)
96+
dotnet_style_prefer_conditional_expression_over_return = false
97+
dotnet_style_prefer_conditional_expression_over_assignment = false
98+
99+
# C# Code Style Settings
100+
[*.{cs,csx,cake}]
101+
# Implicit and explicit types
102+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#implicit-and-explicit-types
103+
csharp_style_var_for_built_in_types = true:warning
104+
csharp_style_var_when_type_is_apparent = true:warning
105+
csharp_style_var_elsewhere = true:warning
106+
# Expression-bodied members
107+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#expression_bodied_members
108+
csharp_style_expression_bodied_methods = true:warning
109+
csharp_style_expression_bodied_constructors = true:warning
110+
csharp_style_expression_bodied_operators = true:warning
111+
csharp_style_expression_bodied_properties = true:warning
112+
csharp_style_expression_bodied_indexers = true:warning
113+
csharp_style_expression_bodied_accessors = true:warning
114+
# Pattern matching
115+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#pattern_matching
116+
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
117+
csharp_style_pattern_matching_over_as_with_null_check = true:warning
118+
# Inlined variable declarations
119+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#inlined_variable_declarations
120+
csharp_style_inlined_variable_declaration = true:warning
121+
# Expression-level preferences
122+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#expression_level_csharp
123+
csharp_prefer_simple_default_expression = true:warning
124+
csharp_style_deconstructed_variable_declaration = true:warning
125+
csharp_style_pattern_local_over_anonymous_function = true:warning
126+
# "Null" checking preferences
127+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#null_checking_csharp
128+
csharp_style_throw_expression = true:warning
129+
csharp_style_conditional_delegate_call = true:warning
130+
# Code block preferences
131+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#code_block
132+
csharp_prefer_braces = true:warning
133+
134+
#############################
135+
# .NET Formatting Conventions
136+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#formatting-conventions
137+
#############################
138+
139+
# Organize usings
140+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#usings
141+
dotnet_sort_system_directives_first = true:warning
142+
# C# formatting settings
143+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#c-formatting-settings
144+
csharp_new_line_before_open_brace = all
145+
csharp_new_line_before_else = true:warning
146+
csharp_new_line_before_catch = true:warning
147+
csharp_new_line_before_finally = true:warning
148+
csharp_new_line_before_members_in_object_initializers = true:warning
149+
csharp_new_line_before_members_in_anonymous_types = true:warning
150+
csharp_new_line_between_query_expression_clauses = true:warning
151+
# Indentation options
152+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#indent
153+
csharp_indent_case_contents = true:warning
154+
csharp_indent_switch_labels = true:warning
155+
csharp_indent_labels = no_change:warning
156+
# Spacing options
157+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#spacing
158+
csharp_space_after_cast = false:warning
159+
csharp_space_after_keywords_in_control_flow_statements = true:warning
160+
csharp_space_between_method_declaration_parameter_list_parentheses = false:warning
161+
csharp_space_between_method_call_parameter_list_parentheses = false:warning
162+
csharp_space_between_parentheses = expressions:warning
163+
csharp_space_before_colon_in_inheritance_clause = true:warning
164+
csharp_space_after_colon_in_inheritance_clause = true:warning
165+
csharp_space_around_binary_operators = before_and_after:warning
166+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false:warning
167+
csharp_space_between_method_call_name_and_opening_parenthesis = false:warning
168+
csharp_space_between_method_call_empty_parameter_list_parentheses = false:warning
169+
# Wrapping options
170+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#wrapping
171+
csharp_preserve_single_line_statements = false:warning
172+
csharp_preserve_single_line_blocks = true:warning
173+
# More Indentation options (Undocumented)
174+
csharp_indent_block_contents = true:warning
175+
csharp_indent_braces = false:warning
176+
# Spacing Options (Undocumented)
177+
csharp_space_after_comma = true:warning
178+
csharp_space_after_dot = false:warning
179+
csharp_space_after_semicolon_in_for_statement = true:warning
180+
csharp_space_around_declaration_statements = do_not_ignore:warning
181+
csharp_space_before_comma = false:warning
182+
csharp_space_before_dot = false:warning
183+
csharp_space_before_semicolon_in_for_statement = false:warning
184+
csharp_space_before_open_square_brackets = false:warning
185+
csharp_space_between_empty_square_brackets = false:warning
186+
csharp_space_between_method_declaration_name_and_open_parenthesis = false:warning
187+
csharp_space_between_square_brackets = false:warning
56188

189+
#########################
190+
# .NET Naming conventions
191+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions
192+
#########################
193+
194+
[*.{cs,csx,cake,vb}]
57195
# Naming Symbols
58196
# constant_fields - Define constant fields
59197
dotnet_naming_symbols.constant_fields.applicable_kinds = field
@@ -136,65 +274,4 @@ dotnet_naming_rule.non_interface_types_must_be_pascal_case.style = pascal_case
136274
# Interfaces must be PascalCase and start with an 'I'
137275
dotnet_naming_rule.interface_types_must_be_prefixed_with_i.severity = warning
138276
dotnet_naming_rule.interface_types_must_be_prefixed_with_i.symbols = interface_types
139-
dotnet_naming_rule.interface_types_must_be_prefixed_with_i.style = prefix_interface_interface_with_i
140-
141-
# C# Code Style Settings
142-
# See https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
143-
# See http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers
144-
[*.{cs,csx,cake}]
145-
# Indentation Options
146-
csharp_indent_block_contents = true:warning
147-
csharp_indent_braces = false:warning
148-
csharp_indent_case_contents = true:warning
149-
csharp_indent_labels = no_change:warning
150-
csharp_indent_switch_labels = true:warning
151-
# Style Options
152-
csharp_style_conditional_delegate_call = true:warning
153-
csharp_style_expression_bodied_accessors = true:warning
154-
csharp_style_expression_bodied_constructors = true:warning
155-
csharp_style_expression_bodied_indexers = true:warning
156-
csharp_style_expression_bodied_methods = true:warning
157-
csharp_style_expression_bodied_operators = true:warning
158-
csharp_style_expression_bodied_properties = true:warning
159-
csharp_style_inlined_variable_declaration = true:warning
160-
csharp_style_pattern_matching_over_as_with_null_check = true:warning
161-
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
162-
csharp_style_throw_expression = true:warning
163-
csharp_style_var_elsewhere = true:warning
164-
csharp_style_var_for_built_in_types = true:warning
165-
csharp_style_var_when_type_is_apparent = true:warning
166-
# New Line Options
167-
csharp_new_line_before_catch = true:warning
168-
csharp_new_line_before_else = true:warning
169-
csharp_new_line_before_finally = true:warning
170-
csharp_new_line_before_members_in_anonymous_types = true:warning
171-
csharp_new_line_before_members_in_object_initializers = true:warning
172-
# BUG: Warning level cannot be set https://github.com/dotnet/roslyn/issues/18010
173-
csharp_new_line_before_open_brace = all
174-
csharp_new_line_between_query_expression_clauses = true:warning
175-
# Spacing Options
176-
csharp_space_after_cast = false:warning
177-
csharp_space_after_colon_in_inheritance_clause = true:warning
178-
csharp_space_after_comma = true:warning
179-
csharp_space_after_dot = false:warning
180-
csharp_space_after_keywords_in_control_flow_statements = true:warning
181-
csharp_space_after_semicolon_in_for_statement = true:warning
182-
csharp_space_around_binary_operators = before_and_after:warning
183-
csharp_space_around_declaration_statements = do_not_ignore:warning
184-
csharp_space_before_colon_in_inheritance_clause = true:warning
185-
csharp_space_before_comma = false:warning
186-
csharp_space_before_dot = false:warning
187-
csharp_space_before_semicolon_in_for_statement = false:warning
188-
csharp_space_before_open_square_brackets = false:warning
189-
csharp_space_between_empty_square_brackets = false:warning
190-
csharp_space_between_method_declaration_name_and_open_parenthesis = false:warning
191-
csharp_space_between_method_declaration_parameter_list_parentheses = false:warning
192-
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false:warning
193-
csharp_space_between_method_call_name_and_opening_parenthesis = false:warning
194-
csharp_space_between_method_call_parameter_list_parentheses = false:warning
195-
csharp_space_between_method_call_empty_parameter_list_parentheses = false:warning
196-
csharp_space_between_parentheses = expressions:warning
197-
csharp_space_between_square_brackets = false:warning
198-
# Wrapping Options
199-
csharp_preserve_single_line_blocks = true:warning
200-
csharp_preserve_single_line_statements = false:warning
277+
dotnet_naming_rule.interface_types_must_be_prefixed_with_i.style = prefix_interface_interface_with_i

Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Structs/OpenGraphMenuItemVariation.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,8 @@ public class OpenGraphMenuItemVariation
1515
/// <exception cref="System.ArgumentNullException">name or price is <c>null</c>.</exception>
1616
public OpenGraphMenuItemVariation(string name, OpenGraphCurrency price)
1717
{
18-
if (name == null)
19-
{
20-
throw new ArgumentNullException(nameof(name));
21-
}
22-
23-
if (price == null)
24-
{
25-
throw new ArgumentNullException(nameof(price));
26-
}
27-
28-
this.Name = name;
29-
this.Price = price;
18+
this.Name = name ?? throw new ArgumentNullException(nameof(name));
19+
this.Price = price ?? throw new ArgumentNullException(nameof(price));
3020
}
3121

3222
/// <summary>

Source/Boxed.AspNetCore/Filters/RedirectToCanonicalUrlAttribute.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ public class RedirectToCanonicalUrlAttribute : Attribute, IResourceFilter
2222
{
2323
private const char SlashCharacter = '/';
2424

25-
private readonly bool appendTrailingSlash;
26-
private readonly bool lowercaseUrls;
27-
2825
/// <summary>
2926
/// Initializes a new instance of the <see cref="RedirectToCanonicalUrlAttribute"/> class.
3027
/// </summary>
@@ -44,8 +41,8 @@ public RedirectToCanonicalUrlAttribute(
4441
bool appendTrailingSlash,
4542
bool lowercaseUrls)
4643
{
47-
this.appendTrailingSlash = appendTrailingSlash;
48-
this.lowercaseUrls = lowercaseUrls;
44+
this.AppendTrailingSlash = appendTrailingSlash;
45+
this.LowercaseUrls = lowercaseUrls;
4946
}
5047

5148
/// <summary>
@@ -54,15 +51,15 @@ public RedirectToCanonicalUrlAttribute(
5451
/// <value>
5552
/// <c>true</c> if appending trailing slashes; otherwise, strip trailing slashes.
5653
/// </value>
57-
public bool AppendTrailingSlash => this.appendTrailingSlash;
54+
public bool AppendTrailingSlash { get; }
5855

5956
/// <summary>
6057
/// Gets a value indicating whether to lower-case all URL's.
6158
/// </summary>
6259
/// <value>
6360
/// <c>true</c> if lower-casing URL's; otherwise, <c>false</c>.
6461
/// </value>
65-
public bool LowercaseUrls => this.lowercaseUrls;
62+
public bool LowercaseUrls { get; }
6663

6764
/// <summary>
6865
/// Executes the resource filter. Called before execution of the remainder of the pipeline. Determines whether
@@ -74,7 +71,7 @@ public void OnResourceExecuting(ResourceExecutingContext context)
7471
{
7572
if (HttpMethods.IsGet(context.HttpContext.Request.Method))
7673
{
77-
if (!this.TryGetCanonicalUrl(context, out string canonicalUrl))
74+
if (!this.TryGetCanonicalUrl(context, out var canonicalUrl))
7875
{
7976
this.HandleNonCanonicalRequest(context, canonicalUrl);
8077
}
@@ -108,7 +105,7 @@ protected virtual bool TryGetCanonicalUrl(ResourceExecutingContext context, out
108105
{
109106
var hasTrailingSlash = request.Path.Value[request.Path.Value.Length - 1] == SlashCharacter;
110107

111-
if (this.appendTrailingSlash)
108+
if (this.AppendTrailingSlash)
112109
{
113110
// Append a trailing slash to the end of the URL.
114111
if (!hasTrailingSlash && !this.HasAttribute<NoTrailingSlashAttribute>(context))
@@ -130,7 +127,7 @@ protected virtual bool TryGetCanonicalUrl(ResourceExecutingContext context, out
130127

131128
if (hasPath || request.QueryString.HasValue)
132129
{
133-
if (this.lowercaseUrls && !this.HasAttribute<NoTrailingSlashAttribute>(context))
130+
if (this.LowercaseUrls && !this.HasAttribute<NoTrailingSlashAttribute>(context))
134131
{
135132
foreach (var character in request.Path.Value)
136133
{

0 commit comments

Comments
 (0)