Skip to content

Commit b921e69

Browse files
authored
feat: Switched to NetEvolve.Defaults and .NET 9.0 (#355)
* feat: Switched to `NetEvolve.Defaults` and `.NET 9.0` * chore: Removed `eng` submodule * ci: Switched to `vars.NE_DOTNET_TARGETFRAMEWORKS`
1 parent fddef2f commit b921e69

14 files changed

+208
-71
lines changed

.editorconfig

+190
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,193 @@ indent_style = tab
8787
[*.{received,verified}.txt]
8888
insert_final_newline = false
8989
trim_trailing_whitespace = false
90+
91+
[*.{cs,csx,vb,vbx}]
92+
# .NET Code Style Settings
93+
# See https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
94+
dotnet_sort_system_directives_first = true
95+
dotnet_separate_import_directive_groups = false
96+
97+
# Don't use 'this.'/'Me.' prefix for anything
98+
dotnet_style_qualification_for_field = false : error
99+
dotnet_style_qualification_for_property = false : error
100+
dotnet_style_qualification_for_method = false : error
101+
dotnet_style_qualification_for_event = false : error
102+
103+
# Use language keywords over framework type names for type references
104+
# i.e. prefer 'string' over 'String'
105+
dotnet_style_predefined_type_for_locals_parameters_members = true : error
106+
dotnet_style_predefined_type_for_member_access = true : error
107+
108+
# Prefer object/collection initializers
109+
# This is a suggestion because there are cases where this is necessary
110+
dotnet_style_object_initializer = true : warning
111+
dotnet_style_collection_initializer = true : warning
112+
113+
# C# 7: Prefer using named tuple names over '.Item1', '.Item2', etc.
114+
dotnet_style_explicit_tuple_names = true : error
115+
116+
# Prefer using 'foo ?? bar' over 'foo is not null ? foo : bar'
117+
dotnet_style_coalesce_expression = true : error
118+
119+
# Prefer using '?.' over ternary null checking where possible
120+
dotnet_style_null_propagation = true : error
121+
122+
# Modifier preferences
123+
# See https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#normalize-modifiers
124+
dotnet_style_require_accessibility_modifiers = always : error
125+
dotnet_style_readonly_field = true : warning
126+
127+
# Required Styles
128+
dotnet_naming_style.all_const.capitalization = pascal_case
129+
dotnet_naming_symbols.all_const.applicable_kinds = field
130+
dotnet_naming_symbols.all_const.required_modifiers = const
131+
dotnet_naming_rule.all_const.severity = error
132+
dotnet_naming_rule.all_const.style = all_elements
133+
dotnet_naming_rule.all_const.symbols = all_const
134+
135+
dotnet_naming_style.all_fields.required_prefix = _
136+
dotnet_naming_style.all_fields.capitalization = camel_case
137+
dotnet_naming_symbols.all_fields.applicable_kinds = field
138+
dotnet_naming_rule.all_fields.severity = error
139+
dotnet_naming_rule.all_fields.style = all_fields
140+
dotnet_naming_rule.all_fields.symbols = all_fields
141+
142+
dotnet_naming_style.all_interfaces.required_prefix = I
143+
dotnet_naming_style.all_interfaces.capitalization = pascal_case
144+
dotnet_naming_symbols.all_interfaces.applicable_kinds = interface
145+
dotnet_naming_rule.all_interfaces.severity = error
146+
dotnet_naming_rule.all_interfaces.style = all_interfaces
147+
dotnet_naming_rule.all_interfaces.symbols = all_interfaces
148+
149+
dotnet_naming_style.all_type_parameter.required_prefix = T
150+
dotnet_naming_style.all_type_parameter.capitalization = pascal_case
151+
dotnet_naming_symbols.all_type_parameter.applicable_kinds = type_parameter
152+
dotnet_naming_rule.all_type_parameter.severity = error
153+
dotnet_naming_rule.all_type_parameter.style = all_type_parameter
154+
dotnet_naming_rule.all_type_parameter.symbols = all_type_parameter
155+
156+
dotnet_naming_style.abstract_class.required_suffix = Base
157+
dotnet_naming_style.abstract_class.capitalization = pascal_case
158+
dotnet_naming_symbols.abstract_class.applicable_kinds = class
159+
dotnet_naming_symbols.abstract_class.required_modifiers = abstract
160+
dotnet_naming_rule.abstract_class.severity = warning
161+
dotnet_naming_rule.abstract_class.style = abstract_class
162+
dotnet_naming_rule.abstract_class.symbols = abstract_class
163+
164+
dotnet_naming_style.method_async.required_suffix = Async
165+
dotnet_naming_style.method_async.capitalization = pascal_case
166+
dotnet_naming_symbols.method_async.applicable_kinds = method
167+
dotnet_naming_symbols.method_async.required_modifiers = async
168+
dotnet_naming_rule.method_async.severity = warning
169+
dotnet_naming_rule.method_async.style = method_async
170+
dotnet_naming_rule.method_async.symbols = method_async
171+
172+
dotnet_naming_style.all_elements.capitalization = pascal_case
173+
dotnet_naming_symbols.all_elements.applicable_kinds = namespace,class,struct,enum,property,method,event,delegate,local_function
174+
dotnet_naming_rule.all_elements.severity = error
175+
dotnet_naming_rule.all_elements.style = all_elements
176+
dotnet_naming_rule.all_elements.symbols = all_elements
177+
178+
dotnet_naming_style.all_parameters.capitalization = camel_case
179+
dotnet_naming_symbols.all_parameters.applicable_kinds = parameter,local
180+
dotnet_naming_rule.all_parameters.severity = error
181+
dotnet_naming_rule.all_parameters.style = all_parameters
182+
dotnet_naming_rule.all_parameters.symbols = all_parameters
183+
184+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
185+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true : suggestion
186+
dotnet_style_prefer_auto_properties = true : silent
187+
188+
# Placement for using directives
189+
csharp_using_directive_placement = inside_namespace : warning
190+
191+
# Use 'var' in all cases where it can be used
192+
csharp_style_var_for_built_in_types = true : error
193+
csharp_style_var_when_type_is_apparent = true : error
194+
csharp_style_var_elsewhere = true : error
195+
196+
# Unused value preferences
197+
csharp_style_unused_value_expression_statement_preference = discard_variable : warning
198+
csharp_style_unused_value_assignment_preference = discard_variable : warning
199+
200+
# C# 7: Prefer using pattern matching over "if(x is T) { var t = (T)x; }" and "var t = x as T; if(t is not null) { ... }"
201+
csharp_style_pattern_matching_over_is_with_cast_check = true : warning
202+
csharp_style_pattern_matching_over_as_with_null_check = true : warning
203+
204+
# C# 7: Prefer using 'out var' where possible
205+
csharp_style_inlined_variable_declaration = true : error
206+
207+
# C# 7: Use throw expressions when null-checking
208+
csharp_style_throw_expression = false : error
209+
210+
# Prefer using "func?.Invoke(args)" over "if(func is not null) { func(args); }"
211+
csharp_style_conditional_delegate_call = true : error
212+
213+
# Newline settings
214+
csharp_indent_braces = false
215+
csharp_open_brace_on_new_line = all
216+
csharp_new_line_before_open_brace = all
217+
csharp_new_line_before_else = true
218+
csharp_new_line_before_catch = true
219+
csharp_new_line_before_finally = true
220+
csharp_new_line_before_members_in_object_initializers = true
221+
csharp_new_line_before_members_in_anonymous_types = true
222+
223+
# Prefer expression-bodied methods, constructors, operators, etc.
224+
csharp_style_expression_bodied_methods = true : warning
225+
csharp_style_expression_bodied_constructors = true : warning
226+
csharp_style_expression_bodied_operators = true : warning
227+
csharp_style_expression_bodied_properties = true : warning
228+
csharp_style_expression_bodied_indexers = true : warning
229+
csharp_style_expression_bodied_accessors = true : warning
230+
231+
# Prefer Braces even for one line of code, because of
232+
csharp_prefer_braces = true : error
233+
csharp_type_declaration_braces = next_line
234+
csharp_invocable_declaration_braces = next_line
235+
csharp_anonymous_method_declaration_braces = next_line
236+
csharp_accessor_owner_declaration_braces = next_line
237+
csharp_accessor_declaration_braces = next_line
238+
csharp_case_block_braces = next_line
239+
csharp_initializer_braces = next_line
240+
csharp_other_braces = next_line
241+
242+
# Tuple Preferences
243+
csharp_style_deconstructed_variable_declaration = true : warning
244+
245+
# Simplify new expression (IDE0090)
246+
csharp_style_implicit_object_creation_when_type_is_apparent = false
247+
csharp_style_namespace_declarations = file_scoped : warning
248+
csharp_prefer_simple_using_statement = false : suggestion
249+
csharp_indent_labels = one_less_than_current
250+
csharp_style_expression_bodied_lambdas = true : silent
251+
csharp_style_expression_bodied_local_functions = false : silent
252+
253+
# Use Compound assignment
254+
dotnet_style_prefer_compound_assignment = false
255+
256+
# Prefer if-else statement
257+
dotnet_style_prefer_conditional_expression_over_return = false
258+
dotnet_diagnostic.IDE0046.severity = suggestion
259+
260+
# Prefer standard constructors
261+
csharp_style_prefer_primary_constructors = false
262+
dotnet_diagnostic.IDE0290.severity = suggestion
263+
264+
# [CSharpier] Incompatible rules deactivated
265+
# https://csharpier.com/docs/IntegratingWithLinters#code-analysis-rules
266+
dotnet_diagnostic.IDE0055.severity = none
267+
dotnet_diagnostic.SA1000.severity = none
268+
dotnet_diagnostic.SA1009.severity = none
269+
dotnet_diagnostic.SA1111.severity = none
270+
dotnet_diagnostic.SA1118.severity = none
271+
dotnet_diagnostic.SA1137.severity = none
272+
dotnet_diagnostic.SA1413.severity = none
273+
dotnet_diagnostic.SA1500.severity = none
274+
dotnet_diagnostic.SA1501.severity = none
275+
dotnet_diagnostic.SA1502.severity = none
276+
dotnet_diagnostic.SA1504.severity = none
277+
dotnet_diagnostic.SA1515.severity = none
278+
dotnet_diagnostic.SA1516.severity = none
279+

.github/workflows/cicd.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ jobs:
2626
enableSonarQube: true
2727
dotnet-logging: ${{ inputs.dotnet-logging }}
2828
dotnet-quality: ga
29-
dotnet-version: |
30-
3.1.x
31-
5.x
32-
6.x
33-
7.x
34-
8.x
29+
dotnet-version: ${{ vars.NE_DOTNET_TARGETFRAMEWORKS }}
3530
solution: ./Guard.sln
3631
secrets: inherit

.gitmodules

-4
This file was deleted.

Directory.Build.props

-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
<Project>
22

3-
<PropertyGroup>
4-
<DirEngineering>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'eng'))</DirEngineering>
5-
<DirEngineeringSettings>$([MSBuild]::NormalizeDirectory('$(DirEngineering)', 'settings'))</DirEngineeringSettings>
6-
</PropertyGroup>
7-
8-
<Import Project="$(DirEngineeringSettings)sln.build.props" />
9-
<Import Project="$(DirEngineeringSettings)src.build.props" Condition=" !$(MSBuildProjectName.Contains('.Tests')) " />
10-
<Import Project="$(DirEngineeringSettings)tests.build.props" Condition=" $(MSBuildProjectName.Contains('.Tests')) " />
11-
123
<PropertyGroup>
134
<!-- Workaround, until https://github.com/GitTools/GitVersion/pull/4206 is released -->
145
<GitVersionTargetFramework>net8.0</GitVersionTargetFramework>

Directory.Build.targets

-7
This file was deleted.

Directory.Packages.props

+1-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<GlobalPackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0" />
1111
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
1212
<GlobalPackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.12.19" />
13-
<GlobalPackageReference Include="NetEvolve.Defaults" Version="1.2.1" />
13+
<GlobalPackageReference Include="NetEvolve.Defaults" Version="1.3.9" />
1414
<GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="10.3.0.106239" Condition=" '$(BuildingInsideVisualStudio)' == 'true' " />
1515
</ItemGroup>
1616
<ItemGroup>
@@ -21,12 +21,6 @@
2121
<PackageVersion Include="NetEvolve.Extensions.XUnit" Version="2.3.57" />
2222
<PackageVersion Include="Polyfill" Version="7.5.0" />
2323
<PackageVersion Include="xunit" Version="2.9.2" />
24-
</ItemGroup>
25-
26-
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' Or '$(TargetFramework)' == 'netcoreapp3.1' ">
27-
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
28-
</ItemGroup>
29-
<ItemGroup Condition=" '$(TargetFramework)' != 'net5.0' And '$(TargetFramework)' != 'netcoreapp3.1' ">
3024
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
3125
</ItemGroup>
3226
</Project>

Directory.Solution.props

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
<Project>
2-
32
<PropertyGroup>
4-
<DirEngineering>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'eng'))</DirEngineering>
5-
<DirEngineeringSettings>$([MSBuild]::NormalizeDirectory('$(DirEngineering)', 'settings'))</DirEngineeringSettings>
3+
<!-- For solution restore, msbuild doesn't honor the property set in Directory.Build.props. -->
4+
<RestoreUseStaticGraphEvaluation>true</RestoreUseStaticGraphEvaluation>
65
</PropertyGroup>
7-
8-
<Import Project="$(DirEngineeringSettings)sln.solution.props" />
9-
106
</Project>

Guard.sln

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1818
.gitignore = .gitignore
1919
.gitmodules = .gitmodules
2020
Directory.Build.props = Directory.Build.props
21-
Directory.Build.targets = Directory.Build.targets
2221
Directory.Packages.props = Directory.Packages.props
2322
Directory.Solution.props = Directory.Solution.props
2423
GitVersion.yml = GitVersion.yml

eng

-1
This file was deleted.

logo.png

-28.6 KB
Loading

src/NetEvolve.Guard/NetEvolve.Guard.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
55

66
<DisableBannedApiForPerformance>true</DisableBannedApiForPerformance>
77

tests/NetEvolve.Guard.Tests.Unit/EnsureObjectTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Diagnostics.CodeAnalysis;
6-
using System.Linq;
76
using NetEvolve.Extensions.XUnit;
87
using Xunit;
98

tests/NetEvolve.Guard.Tests.Unit/EnsureThatTests.cs

+12-27
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,15 @@ public sealed class EnsureThatTests
1515
public void That_Object_Theory_Expected(string? parameterName)
1616
{
1717
var value = new string('-', 10);
18-
if (parameterName is null)
19-
{
20-
_ = Assert.Throws<ArgumentNullException>(
18+
_ = parameterName is null
19+
? Assert.Throws<ArgumentNullException>(
2120
nameof(parameterName),
2221
() => _ = Ensure.That(value, parameterName!)
23-
);
24-
}
25-
else
26-
{
27-
_ = Assert.Throws<ArgumentException>(
22+
)
23+
: Assert.Throws<ArgumentException>(
2824
nameof(parameterName),
2925
() => _ = Ensure.That(value, parameterName!)
3026
);
31-
}
3227
}
3328

3429
[Theory]
@@ -37,20 +32,15 @@ public void That_Object_Theory_Expected(string? parameterName)
3732
public void That_Struct_Theory_Expected(string? parameterName)
3833
{
3934
var value = 5;
40-
if (parameterName is null)
41-
{
42-
_ = Assert.Throws<ArgumentNullException>(
35+
_ = parameterName is null
36+
? Assert.Throws<ArgumentNullException>(
4337
nameof(parameterName),
4438
() => _ = Ensure.That(value, parameterName!)
45-
);
46-
}
47-
else
48-
{
49-
_ = Assert.Throws<ArgumentException>(
39+
)
40+
: Assert.Throws<ArgumentException>(
5041
nameof(parameterName),
5142
() => _ = Ensure.That(value, parameterName!)
5243
);
53-
}
5444
}
5545

5646
[Theory]
@@ -59,19 +49,14 @@ public void That_Struct_Theory_Expected(string? parameterName)
5949
public void That_NullableStruct_Theory_Expected(string? parameterName)
6050
{
6151
int? value = null;
62-
if (parameterName is null)
63-
{
64-
_ = Assert.Throws<ArgumentNullException>(
52+
_ = parameterName is null
53+
? Assert.Throws<ArgumentNullException>(
6554
nameof(parameterName),
6655
() => _ = Ensure.That(value, parameterName!)
67-
);
68-
}
69-
else
70-
{
71-
_ = Assert.Throws<ArgumentException>(
56+
)
57+
: Assert.Throws<ArgumentException>(
7258
nameof(parameterName),
7359
() => _ = Ensure.That(value, parameterName!)
7460
);
75-
}
7661
}
7762
}

tests/NetEvolve.Guard.Tests.Unit/NetEvolve.Guard.Tests.Unit.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
55
<NoWarn>$(NoWarn);NU1701;CA1861;S3459;S3236</NoWarn>
66
</PropertyGroup>
77

0 commit comments

Comments
 (0)