Skip to content

Commit 4184bc0

Browse files
Merge pull request #17 from SixLabors/js/optimize-build
Optimize default build configuration and update ruleset for recent VS versions
2 parents 9b1179f + 3159911 commit 4184bc0

File tree

4 files changed

+145
-111
lines changed

4 files changed

+145
-111
lines changed

.editorconfig

Lines changed: 79 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Version: 1.6.2 (Using https://semver.org/)
2-
# Updated: 2020-11-02
1+
# Version: 2.1.0 (Using https://semver.org/)
2+
# Updated: 2021-03-03
33
# See https://github.com/RehanSaeed/EditorConfig/releases for release notes.
44
# See https://github.com/RehanSaeed/EditorConfig for updates to this file.
55
# See http://EditorConfig.org for more information about .editorconfig files.
@@ -60,87 +60,84 @@ indent_size = 2
6060
[*.{cmd,bat}]
6161
end_of_line = crlf
6262

63+
# Bash Files
64+
[*.sh]
65+
end_of_line = lf
66+
6367
# Makefiles
6468
[Makefile]
6569
indent_style = tab
6670

6771
##########################################
68-
# File Header (Uncomment to support file headers)
69-
# https://docs.microsoft.com/visualstudio/ide/reference/add-file-header
72+
# Default .NET Code Style Severities
73+
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/configuration-options#scope
7074
##########################################
7175

72-
# [*.{cs,csx,cake,vb,vbx,tt,ttinclude}]
73-
file_header_template = Copyright (c) Six Labors.\nLicensed under the Apache License, Version 2.0.
74-
75-
# SA1636: File header copyright text should match
76-
# Justification: .editorconfig supports file headers. If this is changed to a value other than "none", a stylecop.json file will need to added to the project.
77-
# dotnet_diagnostic.SA1636.severity = none
76+
[*.{cs,csx,cake,vb,vbx}]
77+
# Default Severity for all .NET Code Style rules below
78+
dotnet_analyzer_diagnostic.severity = warning
7879

7980
##########################################
80-
# .NET Language Conventions
81-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions
81+
# Language Rules
82+
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules
8283
##########################################
8384

84-
# .NET Code Style Settings
85-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#net-code-style-settings
85+
# .NET Style Rules
86+
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#net-style-rules
8687
[*.{cs,csx,cake,vb,vbx}]
8788
# "this." and "Me." qualifiers
88-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#this-and-me
8989
dotnet_style_qualification_for_field = true:warning
9090
dotnet_style_qualification_for_property = true:warning
9191
dotnet_style_qualification_for_method = true:warning
9292
dotnet_style_qualification_for_event = true:warning
9393
# Language keywords instead of framework type names for type references
94-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#language-keywords
9594
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
9695
dotnet_style_predefined_type_for_member_access = true:warning
9796
# Modifier preferences
98-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#normalize-modifiers
9997
dotnet_style_require_accessibility_modifiers = always:warning
10098
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning
10199
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:warning
102100
dotnet_style_readonly_field = true:warning
103101
# Parentheses preferences
104-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#parentheses-preferences
105102
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning
106103
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning
107104
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
108-
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
105+
dotnet_style_parentheses_in_other_operators = always_for_clarity:suggestion
109106
# Expression-level preferences
110-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-level-preferences
111107
dotnet_style_object_initializer = true:warning
112108
dotnet_style_collection_initializer = true:warning
113109
dotnet_style_explicit_tuple_names = true:warning
114110
dotnet_style_prefer_inferred_tuple_names = true:warning
115111
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
116112
dotnet_style_prefer_auto_properties = true:warning
117-
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
118113
dotnet_style_prefer_conditional_expression_over_assignment = false:suggestion
114+
dotnet_diagnostic.IDE0045.severity = suggestion
119115
dotnet_style_prefer_conditional_expression_over_return = false:suggestion
116+
dotnet_diagnostic.IDE0046.severity = suggestion
120117
dotnet_style_prefer_compound_assignment = true:warning
118+
dotnet_style_prefer_simplified_interpolation = true:warning
119+
dotnet_style_prefer_simplified_boolean_expressions = true:warning
121120
# Null-checking preferences
122-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#null-checking-preferences
123121
dotnet_style_coalesce_expression = true:warning
124122
dotnet_style_null_propagation = true:warning
125-
# Parameter preferences
126-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#parameter-preferences
127-
dotnet_code_quality_unused_parameters = all:warning
128-
# More style options (Undocumented)
129-
# https://github.com/MicrosoftDocs/visualstudio-docs/issues/3641
123+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
124+
# File header preferences
125+
file_header_template = Copyright (c) Six Labors.\nLicensed under the Apache License, Version 2.0.
126+
# SA1636: File header copyright text should match
127+
# Justification: .editorconfig supports file headers. If this is changed to a value other than "none", a stylecop.json file will need to added to the project.
128+
# dotnet_diagnostic.SA1636.severity = none
129+
130+
# Undocumented
130131
dotnet_style_operator_placement_when_wrapping = end_of_line
131-
# https://github.com/dotnet/roslyn/pull/40070
132-
dotnet_style_prefer_simplified_interpolation = true:warning
133132

134-
# C# Code Style Settings
135-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#c-code-style-settings
133+
# C# Style Rules
134+
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#c-style-rules
136135
[*.{cs,csx,cake}]
137-
# Implicit and explicit types
138-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#implicit-and-explicit-types
136+
# 'var' preferences
139137
csharp_style_var_for_built_in_types = never
140138
csharp_style_var_when_type_is_apparent = true:warning
141139
csharp_style_var_elsewhere = false:warning
142140
# Expression-bodied members
143-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-bodied-members
144141
csharp_style_expression_bodied_methods = true:warning
145142
csharp_style_expression_bodied_constructors = true:warning
146143
csharp_style_expression_bodied_operators = true:warning
@@ -149,47 +146,64 @@ csharp_style_expression_bodied_indexers = true:warning
149146
csharp_style_expression_bodied_accessors = true:warning
150147
csharp_style_expression_bodied_lambdas = true:warning
151148
csharp_style_expression_bodied_local_functions = true:warning
152-
# Pattern matching
153-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#pattern-matching
149+
# Pattern matching preferences
154150
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
155151
csharp_style_pattern_matching_over_as_with_null_check = true:warning
156-
# Inlined variable declarations
157-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#inlined-variable-declarations
158-
csharp_style_inlined_variable_declaration = true:warning
152+
csharp_style_prefer_switch_expression = true:warning
153+
csharp_style_prefer_pattern_matching = true:warning
154+
csharp_style_prefer_not_pattern = true:warning
159155
# Expression-level preferences
160-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-level-preferences
156+
csharp_style_inlined_variable_declaration = true:warning
161157
csharp_prefer_simple_default_expression = true:warning
158+
csharp_style_pattern_local_over_anonymous_function = true:warning
159+
csharp_style_deconstructed_variable_declaration = true:warning
160+
csharp_style_prefer_index_operator = true:warning
161+
csharp_style_prefer_range_operator = true:warning
162+
csharp_style_implicit_object_creation_when_type_is_apparent = true:warning
162163
# "Null" checking preferences
163-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#c-null-checking-preferences
164164
csharp_style_throw_expression = true:warning
165165
csharp_style_conditional_delegate_call = true:warning
166166
# Code block preferences
167-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#code-block-preferences
168167
csharp_prefer_braces = true:warning
169-
# Unused value preferences
170-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#unused-value-preferences
171-
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
172-
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
173-
# Index and range preferences
174-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#index-and-range-preferences
175-
csharp_style_prefer_index_operator = true:warning
176-
csharp_style_prefer_range_operator = true:warning
177-
# Miscellaneous preferences
178-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#miscellaneous-preferences
179-
csharp_style_deconstructed_variable_declaration = true:warning
180-
csharp_style_pattern_local_over_anonymous_function = true:warning
168+
csharp_prefer_simple_using_statement = true:suggestion
169+
dotnet_diagnostic.IDE0063.severity = suggestion
170+
# 'using' directive preferences
181171
csharp_using_directive_placement = outside_namespace:warning
172+
# Modifier preferences
182173
csharp_prefer_static_local_function = true:warning
183-
csharp_prefer_simple_using_statement = true:suggestion
184174

185175
##########################################
186-
# .NET Formatting Conventions
187-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-code-style-settings-reference#formatting-conventions
176+
# Unnecessary Code Rules
177+
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/unnecessary-code-rules
188178
##########################################
189179

190-
# Organize usings
191-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#organize-using-directives
180+
# .NET Unnecessary code rules
181+
[*.{cs,csx,cake,vb,vbx}]
182+
dotnet_code_quality_unused_parameters = all:warning
183+
dotnet_remove_unnecessary_suppression_exclusions = none:warning
184+
185+
# C# Unnecessary code rules
186+
[*.{cs,csx,cake}]
187+
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
188+
dotnet_diagnostic.IDE0058.severity = suggestion
189+
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
190+
dotnet_diagnostic.IDE0059.severity = suggestion
191+
192+
##########################################
193+
# Formatting Rules
194+
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules
195+
##########################################
196+
197+
# .NET formatting rules
198+
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#net-formatting-rules
199+
[*.{cs,csx,cake,vb,vbx}]
200+
# Organize using directives
192201
dotnet_sort_system_directives_first = true
202+
dotnet_separate_import_directive_groups = false
203+
204+
# C# formatting rules
205+
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#c-formatting-rules
206+
[*.{cs,csx,cake}]
193207
# Newline options
194208
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#new-line-options
195209
csharp_new_line_before_open_brace = all
@@ -231,14 +245,14 @@ csharp_space_around_declaration_statements = false
231245
csharp_space_before_open_square_brackets = false
232246
csharp_space_between_empty_square_brackets = false
233247
csharp_space_between_square_brackets = false
234-
# Wrapping options
248+
# Wrap options
235249
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#wrap-options
236250
csharp_preserve_single_line_statements = false
237251
csharp_preserve_single_line_blocks = true
238252

239253
##########################################
240-
# .NET Naming Conventions
241-
# https://docs.microsoft.com/visualstudio/ide/editorconfig-naming-conventions
254+
# .NET Naming Rules
255+
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/naming-rules
242256
##########################################
243257

244258
[*.{cs,csx,cake,vb,vbx}]
@@ -261,8 +275,9 @@ dotnet_naming_style.prefix_type_parameters_with_t_style.capitalization = pascal_
261275
dotnet_naming_style.prefix_type_parameters_with_t_style.required_prefix = T
262276
# disallowed_style - Anything that has this style applied is marked as disallowed
263277
dotnet_naming_style.disallowed_style.capitalization = pascal_case
264-
dotnet_naming_style.disallowed_style.required_prefix = ____RULE_VIOLATION____
265-
dotnet_naming_style.disallowed_style.required_suffix = ____RULE_VIOLATION____
278+
# Disabled while we investigate compatibility with VS 16.10
279+
#dotnet_naming_style.disallowed_style.required_prefix = ____RULE_VIOLATION____
280+
#dotnet_naming_style.disallowed_style.required_suffix = ____RULE_VIOLATION____
266281
# internal_error_style - This style should never occur... if it does, it indicates a bug in file or in the parser using the file
267282
dotnet_naming_style.internal_error_style.capitalization = pascal_case
268283
dotnet_naming_style.internal_error_style.required_prefix = ____INTERNAL_ERROR____

msbuild/props/SixLabors.Global.props

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,58 @@
1010
that is done by the file that imports us.
1111
-->
1212

13+
<!-- Define Environmental conditionals -->
14+
<!-- Determined by environmental settings set in build-and-test.yml-->
15+
<PropertyGroup>
16+
<IsContinuousIntegration Condition="'$(CI)' == 'true'">true</IsContinuousIntegration>
17+
<IsCodeCoverage Condition="'$(codecov)' != ''">true</IsCodeCoverage>
18+
</PropertyGroup>
19+
<Choose>
20+
<When Condition="'$(IsContinuousIntegration)'=='true'">
21+
<PropertyGroup>
22+
<DefineConstants>$(DefineConstants);ENV_CI</DefineConstants>
23+
</PropertyGroup>
24+
</When>
25+
<When Condition="'$(IsCodeCoverage)'=='true'">
26+
<PropertyGroup>
27+
<DefineConstants>$(DefineConstants);ENV_CODECOV</DefineConstants>
28+
</PropertyGroup>
29+
</When>
30+
</Choose>
31+
32+
<!--Define OS platform conditions and constants.
33+
https://docs.microsoft.com/en-us/visualstudio/msbuild/property-functions?view=vs-2019#msbuild-property-functions
34+
https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.osplatform?view=net-5.0#properties
35+
-->
36+
<PropertyGroup>
37+
<IsWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true</IsWindows>
38+
<IsOSX Condition="$([MSBuild]::IsOSPlatform('OSX'))">true</IsOSX>
39+
<IsLinux Condition="$([MSBuild]::IsOSPlatform('Linux'))">true</IsLinux>
40+
<IsFreeBSD Condition="$([MSBuild]::IsOSPlatform('FreeBSD'))">true</IsFreeBSD>
41+
</PropertyGroup>
42+
<Choose>
43+
<When Condition="'$(IsWindows)'=='true'">
44+
<PropertyGroup>
45+
<DefineConstants>$(DefineConstants);OS_WINDOWS</DefineConstants>
46+
</PropertyGroup>
47+
</When>
48+
<When Condition="'$(IsOSX)'=='true'">
49+
<PropertyGroup>
50+
<DefineConstants>$(DefineConstants);OS_OSX</DefineConstants>
51+
</PropertyGroup>
52+
</When>
53+
<When Condition="'$(IsLinux)'=='true'">
54+
<PropertyGroup>
55+
<DefineConstants>$(DefineConstants);OS_LINUX</DefineConstants>
56+
</PropertyGroup>
57+
</When>
58+
<When Condition="'$(IsFreeBSD)'=='true'">
59+
<PropertyGroup>
60+
<DefineConstants>$(DefineConstants);OS_FREEBSD</DefineConstants>
61+
</PropertyGroup>
62+
</When>
63+
</Choose>
64+
1365
<!-- Compilation settings that explicitly differ from the Sdk.props/targets defaults -->
1466
<PropertyGroup>
1567
<LangVersion Condition="'$(LangVersion)' == ''">8.0</LangVersion>
@@ -19,7 +71,7 @@
1971
<NeutralLanguage>en</NeutralLanguage>
2072
<OverwriteReadOnlyFiles>true</OverwriteReadOnlyFiles>
2173
<DebugType>portable</DebugType>
22-
<DebugType Condition="'$(codecov)' != ''">full</DebugType>
74+
<DebugType Condition="'$(IsCodeCoverage)'=='true'">full</DebugType>
2375
<NullableContextOptions>disable</NullableContextOptions>
2476
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
2577
<CheckEolTargetFramework>false</CheckEolTargetFramework>
@@ -46,7 +98,7 @@
4698

4799
<!-- Ensure deterministic builds work when triggered against individual projects. -->
48100
<!-- https://github.com/dotnet/roslyn/issues/37379#issuecomment-513371985 -->
49-
<ItemGroup Condition="'$(CI)' == 'true'">
101+
<ItemGroup Condition="'$(IsContinuousIntegration)'=='true'">
50102
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
51103
</ItemGroup>
52104

@@ -69,39 +121,6 @@
69121
<AdditionalFiles Include="$(MSBuildThisFileDirectory)..\..\stylecop.json" />
70122
</ItemGroup>
71123

72-
<!--Define OS platform conditions and constants.
73-
https://docs.microsoft.com/en-us/visualstudio/msbuild/property-functions?view=vs-2019#msbuild-property-functions
74-
https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.osplatform?view=net-5.0#properties
75-
-->
76-
<PropertyGroup>
77-
<IsWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true</IsWindows>
78-
<IsOSX Condition="$([MSBuild]::IsOSPlatform('OSX'))">true</IsOSX>
79-
<IsLinux Condition="$([MSBuild]::IsOSPlatform('Linux'))">true</IsLinux>
80-
<IsFreeBSD Condition="$([MSBuild]::IsOSPlatform('FreeBSD'))">true</IsFreeBSD>
81-
</PropertyGroup>
82-
<Choose>
83-
<When Condition="'$(IsWindows)'=='true'">
84-
<PropertyGroup>
85-
<DefineConstants>$(DefineConstants);OS_WINDOWS</DefineConstants>
86-
</PropertyGroup>
87-
</When>
88-
<When Condition="'$(IsOSX)'=='true'">
89-
<PropertyGroup>
90-
<DefineConstants>$(DefineConstants);OS_OSX</DefineConstants>
91-
</PropertyGroup>
92-
</When>
93-
<When Condition="'$(IsLinux)'=='true'">
94-
<PropertyGroup>
95-
<DefineConstants>$(DefineConstants);OS_LINUX</DefineConstants>
96-
</PropertyGroup>
97-
</When>
98-
<When Condition="'$(IsFreeBSD)'=='true'">
99-
<PropertyGroup>
100-
<DefineConstants>$(DefineConstants);OS_FREEBSD</DefineConstants>
101-
</PropertyGroup>
102-
</When>
103-
</Choose>
104-
105124
<!-- Define target framework specific constants.
106125
https://apisof.net/
107126
+===================+=======+==========+=====================+=============+=================+====================+==============+=========+============|

0 commit comments

Comments
 (0)