Skip to content

Commit 77f0943

Browse files
authored
Migrate to .NET 10 (#126)
* Migrate to .NET 10 * bump system channels and system buffers * bump dotnet tooling * fix paths.fs * remove install of old dotnet sdk's * fix nupkg validator * fix test invocation * fix AOT invocation smoke tests
1 parent 8aef720 commit 77f0943

File tree

60 files changed

+393
-413
lines changed

Some content is hidden

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

60 files changed

+393
-413
lines changed

.editorconfig

Lines changed: 161 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,109 @@
11
root=true
22

3-
[*.cs]
4-
trim_trailing_whitespace=true
5-
insert_final_newline=true
6-
end_of_line = lf
7-
83
[*]
94
charset = utf-8
105
indent_style = tab
116
indent_size = 4
127

13-
[*.cshtml]
14-
indent_style = tab
15-
indent_size = 4
16-
end_of_line = lf
8+
[*.{fs,fsx,cs,vb}]
9+
file_header_template=Licensed to Elasticsearch B.V under one or more agreements.\nElasticsearch B.V licenses this file to you under the Apache 2.0 License.\nSee the LICENSE file in the project root for more information
10+
max_line_length = 160
1711

18-
[*.{fs,fsx,yml}]
12+
[*.{fs,fsx}]
1913
indent_style = space
2014
indent_size = 4
21-
end_of_line = lf
2215

23-
[*.{md,markdown,json,js,csproj,fsproj,targets,targets,props}]
16+
[*.{md,markdown,json,js,yml,yaml,csproj,fsproj,targets,targets,props}]
2417
indent_style = space
2518
indent_size = 2
26-
end_of_line = lf
19+
20+
[*.{ts,tsx}]
21+
indent_style = space
22+
indent_size = 4
23+
quote_type = single
2724

2825
# Dotnet code style settings:
2926
[*.{cs,vb}]
27+
trim_trailing_whitespace=true
28+
insert_final_newline=true
29+
# Sort using and Import directives with System.* appearing first
30+
dotnet_sort_system_directives_first = true
3031

31-
# ---
32-
# naming conventions https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions
33-
# currently not supported in Rider/Resharper so not using these for now
34-
# ---
32+
# Style rules
33+
# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/naming-rules?view=vs-2017
3534

36-
# ---
37-
# langugage conventions https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#language-conventions
35+
# Constants always pascal case
36+
dotnet_naming_rule.constants_should_be_pascal_case.symbols = consts
37+
dotnet_naming_rule.constants_should_be_pascal_case.style = consts
38+
dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion
3839

39-
# Sort using and Import directives with System.* appearing first
40-
dotnet_sort_system_directives_first = true
40+
dotnet_naming_symbols.consts.applicable_kinds = field
41+
dotnet_naming_symbols.consts.applicable_accessibilities = *
42+
dotnet_naming_symbols.consts.required_modifiers = const
43+
44+
dotnet_naming_style.consts.capitalization = pascal_case
45+
46+
# Non-public static fields always pascal case
47+
dotnet_naming_rule.non_public_static_fields_should_be_pascal_case.symbols = non_public_static_fields
48+
dotnet_naming_rule.non_public_static_fields_should_be_pascal_case.style = non_public_static_fields
49+
dotnet_naming_rule.non_public_static_fields_should_be_pascal_case.severity = suggestion
50+
51+
dotnet_naming_symbols.non_public_static_fields.applicable_kinds = field
52+
dotnet_naming_symbols.non_public_static_fields.applicable_accessibilities = private,protected,internal,protected_internal,private_protected
53+
dotnet_naming_symbols.non_public_static_fields.required_modifiers = static
54+
55+
dotnet_naming_style.non_public_static_fields.capitalization = pascal_case
56+
57+
# Non-private readonly fields are pascal case
58+
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion
59+
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields
60+
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_fields
61+
62+
dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
63+
dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public,protected,internal,protected_internal,private_protected
64+
dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly
65+
66+
dotnet_naming_style.non_private_readonly_fields.capitalization = pascal_case
67+
68+
# Private instance fields are camel case prefixed underscore
69+
dotnet_naming_rule.private_fields_should_be_camelcase_prefix_underscore.symbols = private_fields
70+
dotnet_naming_rule.private_fields_should_be_camelcase_prefix_underscore.style = private_fields
71+
dotnet_naming_rule.private_fields_should_be_camelcase_prefix_underscore.severity = suggestion
72+
73+
dotnet_naming_symbols.private_fields.applicable_kinds = field
74+
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
75+
76+
dotnet_naming_style.private_fields.capitalization = camel_case
77+
dotnet_naming_style.private_fields.required_prefix = _
78+
79+
# Locals and parameters are camel case
80+
dotnet_naming_rule.locals.severity = suggestion
81+
dotnet_naming_rule.locals.symbols = locals
82+
dotnet_naming_rule.locals.style = locals
83+
84+
dotnet_naming_symbols.locals.applicable_kinds = parameter, local
85+
86+
dotnet_naming_style.locals.capitalization = camel_case
87+
88+
# Local functions are pascal case
89+
dotnet_naming_rule.local_functions.severity = suggestion
90+
dotnet_naming_rule.local_functions.symbols = local_functions
91+
dotnet_naming_rule.local_functions.style = local_functions
92+
93+
dotnet_naming_symbols.local_functions.applicable_kinds = local_function
94+
95+
dotnet_naming_style.local_functions.capitalization = pascal_case
96+
97+
# Public members always pascal case
98+
dotnet_naming_rule.public_members_should_be_pascal_case.symbols = public_members
99+
dotnet_naming_rule.public_members_should_be_pascal_case.style = public_members
100+
dotnet_naming_rule.public_members_should_be_pascal_case.severity = suggestion
101+
102+
dotnet_naming_symbols.public_members.applicable_kinds = property,method,field,event,delegate
103+
dotnet_naming_symbols.public_members.applicable_accessibilities = public
104+
105+
dotnet_naming_style.public_members.capitalization = pascal_case
41106

42-
# Prefer this.X except for _fields
43-
# TODO can we force _ for private fields?
44-
# TODO elevate severity after code cleanup to warning minimum
45-
# TODO use language latest
46107
dotnet_style_qualification_for_field = false:error
47108
dotnet_style_qualification_for_property = false:error
48109
dotnet_style_qualification_for_method = false:error
@@ -71,12 +132,15 @@ csharp_style_var_for_built_in_types = true:error
71132
csharp_style_var_when_type_is_apparent = true:error
72133
csharp_style_var_elsewhere = true:error
73134

74-
csharp_style_expression_bodied_methods = true:error
75-
csharp_style_expression_bodied_constructors = true:error
76-
csharp_style_expression_bodied_operators = true:error
77-
csharp_style_expression_bodied_properties = true:error
78-
csharp_style_expression_bodied_indexers = true:error
79-
csharp_style_expression_bodied_accessors = true:error
135+
csharp_style_expression_bodied_methods = true:suggestion
136+
csharp_style_expression_bodied_constructors = true:suggestion
137+
csharp_style_expression_bodied_operators = true:suggestion
138+
csharp_style_expression_bodied_properties = true:suggestion
139+
csharp_style_expression_bodied_indexers = true:suggestion
140+
csharp_style_expression_bodied_accessors = true:suggestion
141+
csharp_style_expression_bodied_local_functions = when_on_single_line:error
142+
dotnet_style_prefer_conditional_expression_over_return = false
143+
80144

81145
# Suggest more modern language features when available
82146
csharp_style_pattern_matching_over_is_with_cast_check = true:error
@@ -95,59 +159,90 @@ csharp_preferred_modifier_order = public,private,protected,internal,static,exter
95159

96160
# Newline settings (Allman yo!)
97161
csharp_new_line_before_open_brace = all
98-
csharp_new_line_before_else = true:error
99-
csharp_new_line_before_catch = true:error
100-
csharp_new_line_before_finally = true:error
162+
csharp_new_line_before_else = true
163+
csharp_new_line_before_catch = true
164+
csharp_new_line_before_finally = true
101165
csharp_new_line_before_members_in_object_initializers = true
166+
102167
# just a suggestion do to our JSON tests that use anonymous types to
103168
# represent json quite a bit (makes copy paste easier).
104-
csharp_new_line_before_members_in_anonymous_types = true:suggestion
105-
csharp_new_line_between_query_expression_clauses = true:error
169+
csharp_new_line_before_members_in_anonymous_types = true
170+
csharp_new_line_between_query_expression_clauses = true
106171

107172
# Indent
108-
csharp_indent_case_contents = true:error
109-
csharp_indent_switch_labels = true:error
110-
csharp_space_after_cast = false:error
111-
csharp_space_after_keywords_in_control_flow_statements = true:error
112-
csharp_space_between_method_declaration_parameter_list_parentheses = false:error
113-
csharp_space_between_method_call_parameter_list_parentheses = false:error
173+
csharp_indent_case_contents = true
174+
csharp_indent_switch_labels = true
175+
csharp_space_after_cast = false
176+
csharp_space_after_keywords_in_control_flow_statements = true
177+
csharp_space_between_method_declaration_parameter_list_parentheses = false
178+
csharp_space_between_method_call_parameter_list_parentheses = false
114179

115180
#Wrap
116-
csharp_preserve_single_line_statements = false:error
117-
csharp_preserve_single_line_blocks = true:error
118-
119-
csharp_style_namespace_declarations = file_scoped
181+
csharp_preserve_single_line_statements = false
182+
csharp_preserve_single_line_blocks = true
183+
resharper_wrap_object_and_collection_initializer_style = chop_always
120184

121185
# Resharper
122-
resharper_csharp_braces_for_lock=required_for_complex
123-
resharper_csharp_braces_for_using=required_for_complex
124-
resharper_csharp_braces_for_while=required_for_complex
125-
resharper_csharp_braces_for_foreach=required_for_complex
126-
resharper_csharp_braces_for_for=required_for_complex
127-
resharper_csharp_braces_for_fixed=required_for_complex
128-
resharper_csharp_braces_for_ifelse=required_for_complex
186+
resharper_csharp_braces_for_lock=required_for_multiline
187+
resharper_csharp_braces_for_using=required_for_multiline
188+
resharper_csharp_braces_for_while=required_for_multiline
189+
resharper_csharp_braces_for_foreach=required_for_multiline
190+
resharper_csharp_braces_for_for=required_for_multiline
191+
resharper_csharp_braces_for_fixed=required_for_multiline
192+
resharper_csharp_braces_for_ifelse=required_for_multiline
193+
resharper_csharp_keep_existing_attribute_arrangement=true
129194

130195
resharper_csharp_accessor_owner_body=expression_body
131196

132197
resharper_redundant_case_label_highlighting=do_not_show
133198
resharper_redundant_argument_default_value_highlighting=do_not_show
134-
# Do not penalize code that explicitly lists generic arguments
135-
resharper_redundant_type_arguments_of_method_highlighting=do_not_show
199+
resharper_explicit_caller_info_argument_highlighting=hint
136200

137-
# Spell checker VS2022
138-
spelling_exclusion_path = .\exclusion.dic
201+
csharp_style_namespace_declarations = file_scoped
139202

140-
# Microsoft.VisualStudio.Threading.Analyzers
141-
dotnet_diagnostic.VSTHRD200.severity = error
203+
dotnet_analyzer_diagnostic.severity = warning
204+
dotnet_analyzer_diagnostic.category-Style.severity = warning
142205

143-
[Jenkinsfile]
144-
indent_style = space
145-
indent_size = 2
146-
end_of_line = lf
147-
charset = utf-8
148-
trim_trailing_whitespace = true
149-
insert_final_newline = true
206+
# can be made static
207+
dotnet_diagnostic.CA1822.severity = suggestion
208+
209+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1848
210+
dotnet_diagnostic.CA1848.severity = suggestion
211+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2201
212+
dotnet_diagnostic.CA2201.severity = none
213+
214+
# disable for default arm on switches, IDE0072 still covers missing enum members
215+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0010
216+
dotnet_diagnostic.IDE0010.severity = none
217+
218+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/IDE0200
219+
dotnet_diagnostic.IDE0200.severity = none
220+
dotnet_diagnostic.IDE0001.severity = none
221+
dotnet_diagnostic.IDE0057.severity = none
222+
dotnet_diagnostic.IDE0051.severity = suggestion
223+
dotnet_diagnostic.IDE0059.severity = suggestion
224+
dotnet_diagnostic.CA1859.severity = none
225+
dotnet_diagnostic.CA1816.severity = none
226+
227+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1727
228+
dotnet_diagnostic.CA1727.severity = none
229+
230+
dotnet_diagnostic.IDE0305.severity = none
231+
232+
# https://github.com/dotnet/roslyn/issues/60784
233+
# CS8509 already warns
234+
dotnet_diagnostic.IDE0072.severity = none
235+
236+
[tests/**/*.cs]
237+
dotnet_diagnostic.IDE0058.severity = none
238+
dotnet_diagnostic.IDE0022.severity = none
150239

151240
[*.{sh,bat,ps1}]
152241
trim_trailing_whitespace=true
153242
insert_final_newline=true
243+
244+
[*.sh]
245+
end_of_line = lf
246+
247+
[{LICENSE,NOTICE}]
248+
end_of_line = lf

.github/workflows/ci.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
run: dotnet publish examples/ingest-aot-smoketest
4848

4949
- name: Invoke AOT
50-
run: ./examples/ingest-aot-smoketest/bin/Release/net8.0/${{ matrix.os.folder }}/${{ matrix.os.binary }}
50+
run: ./.artifacts/publish/ingest-aot-smoketest/release/${{ matrix.os.binary }}
5151

5252
test-windows:
5353
runs-on: windows-latest
@@ -66,9 +66,6 @@ jobs:
6666
uses: actions/setup-dotnet@v5
6767
with:
6868
global-json-file: ./global.json
69-
dotnet-version: |
70-
6.x
71-
8.x
7269

7370
- name: Build
7471
run: build.bat build -s true
@@ -95,9 +92,6 @@ jobs:
9592
uses: actions/setup-dotnet@v5
9693
with:
9794
global-json-file: ./global.json
98-
dotnet-version: |
99-
6.x
100-
8.x
10195

10296
- name: Build
10397
run: ./build.sh build -s true
@@ -170,9 +164,6 @@ jobs:
170164
uses: actions/setup-dotnet@v5
171165
with:
172166
global-json-file: ./global.json
173-
dotnet-version: |
174-
6.x
175-
8.x
176167

177168
- uses: actions/download-artifact@v6
178169
with:

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,6 @@ project.lock.json
7979
src/packages/
8080
BenchmarkDotNet.Artifacts
8181

82-
/.ionide/symbolCache.db
82+
/.ionide/symbolCache.db
83+
84+
.artifacts

Directory.Build.props

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
<SolutionRoot>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.bat))</SolutionRoot>
66

7-
<MinVerDefaultPreReleasePhase>canary</MinVerDefaultPreReleasePhase>
8-
<MinVerMinimumMajorMinor>0.1</MinVerMinimumMajorMinor>
7+
<MinVerDefaultPreReleaseIdentifiers>canary.0</MinVerDefaultPreReleaseIdentifiers>
8+
<MinVerMinimumMajorMinor>0.2</MinVerMinimumMajorMinor>
99

1010
<LangVersion>latest</LangVersion>
1111
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -14,13 +14,17 @@
1414
<SignAssembly>true</SignAssembly>
1515
<AssemblyOriginatorKeyFile>$(SolutionRoot)\build\keys\keypair.snk</AssemblyOriginatorKeyFile>
1616

17+
<UseArtifactsOutput>true</UseArtifactsOutput>
18+
<SolutionRoot>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.sh))</SolutionRoot>
19+
<ArtifactsPath>$(MSBuildThisFileDirectory).artifacts</ArtifactsPath>
20+
1721
<DefineConstants Condition="'$(TargetFramework)'=='net461'">$(DefineConstants);FULLFRAMEWORK</DefineConstants>
1822
<DefineConstants Condition="$(DefineConstants.Contains(FULLFRAMEWORK)) == False">$(DefineConstants);DOTNETCORE</DefineConstants>
1923
</PropertyGroup>
2024
<PropertyGroup Condition="">
2125
</PropertyGroup>
2226
<ItemGroup>
23-
<PackageReference Include="MinVer" Version="4.2.0" PrivateAssets="all" />
27+
<PackageReference Include="MinVer" Version="6.0.0" PrivateAssets="all" />
2428
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.3" PrivateAssets="all"/>
2529
</ItemGroup>
2630
</Project>

benchmarks/Elastic.Ingest.Elasticsearch.Benchmarks/Benchmarks/BulkIngestionBenchmarks.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Elastic.Ingest.Elasticsearch.Benchmarks;
99

1010
[SimpleJob(RunStrategy.Monitoring, invocationCount: 10, id: "BulkIngestionJob")]
11-
public class BulkIngestionBenchmarks
11+
public class BulkIngestionBenchmarks : IDisposable
1212
{
1313
private static readonly int MaxExportSize = 5_000;
1414

@@ -72,4 +72,6 @@ public void BulkAll()
7272

7373
_waitHandle.WaitOne();
7474
}
75+
76+
public void Dispose() => _waitHandle.Dispose();
7577
}

benchmarks/Elastic.Ingest.Elasticsearch.Benchmarks/Benchmarks/BulkRequestCreationForDataStreamBenchmarks.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Elastic.Ingest.Elasticsearch.Benchmarks.Benchmarks;
1010

11-
public class BulkRequestCreationForDataStreamBenchmarks
11+
public class BulkRequestCreationForDataStreamBenchmarks : IDisposable
1212
{
1313
private static readonly int DocumentsToIndex = 1_000;
1414

@@ -48,4 +48,10 @@ public async Task WriteToStreamAsync()
4848
var postData = PostData.ReadOnlyMemory(bytes);
4949
await postData.WriteAsync(MemoryStream, _transportConfiguration!, false, CancellationToken.None);
5050
}
51+
52+
public void Dispose()
53+
{
54+
MemoryStream.Dispose();
55+
_transportConfiguration?.Dispose();
56+
}
5157
}

0 commit comments

Comments
 (0)