Skip to content

Commit 6fa9901

Browse files
authored
Update to .NET 9 SDK (#26)
* Update to .NET 9 SDK * update * add formatting check * formatting * update
1 parent b637886 commit 6fa9901

20 files changed

+112
-82
lines changed

.editorconfig

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ charset = utf-8
2525
indent_style = space
2626
indent_size = 2
2727
trim_trailing_whitespace = true
28+
max_line_length = 140
2829

2930
[*.json]
3031
insert_final_newline = false
@@ -88,7 +89,7 @@ dotnet_code_quality_unused_parameters = all:warning
8889

8990
# C# code style settings - Implicit and explicit types
9091
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#implicit-and-explicit-types
91-
csharp_style_var_for_built_in_types = false:suggestion
92+
csharp_style_var_for_built_in_types = true:suggestion
9293
csharp_style_var_when_type_is_apparent = true:warning
9394
csharp_style_var_elsewhere = true:suggestion
9495

@@ -140,8 +141,9 @@ csharp_style_prefer_range_operator = true:warning
140141
csharp_style_deconstructed_variable_declaration = true:suggestion
141142
csharp_style_pattern_local_over_anonymous_function = true:suggestion
142143
csharp_using_directive_placement = outside_namespace:warning
144+
csharp_style_namespace_declarations = file_scoped:warning
143145
csharp_prefer_static_local_function = true:suggestion
144-
csharp_prefer_simple_using_statement = false:suggestion
146+
csharp_prefer_simple_using_statement = true:warning
145147
csharp_style_prefer_switch_expression = true:suggestion
146148

147149
# .NET formatting settings - Organize using directives
@@ -151,7 +153,7 @@ dotnet_separate_import_directive_groups = false
151153

152154
# C# formatting settings - New-line options
153155
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019#new-line-options
154-
csharp_new_line_before_open_brace = types, methods
156+
csharp_new_line_before_open_brace = types, methods, properties
155157
csharp_new_line_before_else = false
156158
csharp_new_line_before_catch = false
157159
csharp_new_line_before_finally = false
@@ -216,16 +218,35 @@ dotnet_naming_style.prefix_underscore.required_prefix = _
216218
# dotnet_naming_rule.<namingRuleTitle>.severity = <value>
217219
dotnet_naming_rule.private_fields_with_underscore.severity = warning
218220

219-
########## name all constant fields using UPPER_CASE ##########
221+
########## name all public constant fields using PascalCase ##########
220222
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019
221223
# dotnet_naming_rule.<namingRuleTitle>.symbols = <symbolTitle>
222-
dotnet_naming_rule.constant_fields_should_be_upper_case.symbols = constant_fields
224+
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
223225

224226
# dotnet_naming_symbols.<symbolTitle>.<property> = <value>
225227
dotnet_naming_symbols.constant_fields.applicable_kinds = field
226-
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
228+
dotnet_naming_symbols.constant_fields.applicable_accessibilities = public
227229
dotnet_naming_symbols.constant_fields.required_modifiers = const
228230

231+
# dotnet_naming_rule.<namingRuleTitle>.style = <styleTitle>
232+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
233+
234+
# dotnet_naming_style.<styleTitle>.<property> = <value>
235+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
236+
237+
# dotnet_naming_rule.<namingRuleTitle>.severity = <value>
238+
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = warning
239+
240+
########## name all other constant fields using UPPER_CASE ##########
241+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019
242+
# dotnet_naming_rule.<namingRuleTitle>.symbols = <symbolTitle>
243+
dotnet_naming_rule.constant_fields_should_be_upper_case.symbols = constant_fields_private
244+
245+
# dotnet_naming_symbols.<symbolTitle>.<property> = <value>
246+
dotnet_naming_symbols.constant_fields_private.applicable_kinds = field
247+
dotnet_naming_symbols.constant_fields_private.applicable_accessibilities = *
248+
dotnet_naming_symbols.constant_fields_private.required_modifiers = const
249+
229250
# dotnet_naming_rule.<namingRuleTitle>.style = <styleTitle>
230251
dotnet_naming_rule.constant_fields_should_be_upper_case.style = upper_case_style
231252

@@ -257,3 +278,18 @@ dotnet_naming_style.end_in_async_style.required_suffix = Async
257278

258279
# dotnet_naming_rule.<namingRuleTitle>.severity = <value>
259280
dotnet_naming_rule.async_methods_end_in_async.severity = warning
281+
282+
# ignore underscores in names
283+
dotnet_diagnostic.CA1707.severity = none
284+
285+
# IDE0005: Remove unnecessary using directives
286+
dotnet_diagnostic.IDE0005.severity = suggestion
287+
288+
# IDE0058: Remove unnecessary expression value
289+
dotnet_diagnostic.IDE0058.severity = none
290+
291+
# IDE0008: Use explicit type
292+
dotnet_diagnostic.IDE0008.severity = none
293+
294+
# IDE0290: Use primary constructor
295+
dotnet_diagnostic.IDE0290.severity = none

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
16-
- name: Use .NET Core 6.0 SDK
16+
- name: Use .NET Core SDK
1717
uses: actions/setup-dotnet@v4
1818
with:
19-
dotnet-version: '6.0.x'
19+
global-json-file: global.json
2020
source-url: https://nuget.pkg.github.com/Shane32/index.json
2121
env:
2222
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/format.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Check formatting
2+
3+
# ==== NOTE: do not rename this yml file or the run_number will be reset ====
4+
5+
on:
6+
pull_request:
7+
8+
jobs:
9+
format:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Use .NET Core SDK
14+
uses: actions/setup-dotnet@v4
15+
with:
16+
global-json-file: global.json
17+
source-url: https://nuget.pkg.github.com/Shane32/index.json
18+
env:
19+
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
20+
- name: Install dependencies
21+
run: dotnet restore
22+
- name: Check formatting
23+
run: |
24+
dotnet format --no-restore --verify-no-changes --severity error || (echo "Run 'dotnet format' to fix issues" && exit 1)

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
version="${github_ref:10}"
2424
echo version=$version
2525
echo "version=$version" >> $GITHUB_ENV
26-
- name: Use .NET Core 6.0 SDK
26+
- name: Use .NET Core SDK
2727
uses: actions/setup-dotnet@v4
2828
with:
29-
dotnet-version: '6.0.x'
29+
global-json-file: global.json
3030
source-url: https://api.nuget.org/v3/index.json
3131
env:
3232
NUGET_AUTH_TOKEN: ${{secrets.NUGET_AUTH_TOKEN}}

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Use .NET Core SDK
2222
uses: actions/setup-dotnet@v4
2323
with:
24-
dotnet-version: 6.x
24+
global-json-file: global.json
2525
source-url: https://nuget.pkg.github.com/Shane32/index.json
2626
env:
2727
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

Directory.Build.props

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
<Nullable>enable</Nullable>
2222
<IsPackable>false</IsPackable>
2323
<PackageReadmeFile>README.md</PackageReadmeFile>
24-
<AnalysisMode>Recommended</AnalysisMode>
24+
<AnalysisLevel>9.0-recommended</AnalysisLevel>
2525
<GraphQLVersion>8.0.0</GraphQLVersion>
26-
<GraphQLAspNetCore3Version>6.0.0</GraphQLAspNetCore3Version>
26+
<GraphQLAspNetCore3Version>7.0.0</GraphQLAspNetCore3Version>
2727
<NuGetAuditMode>direct</NuGetAuditMode>
28+
<NoWarn>$(NoWarn);IDE0057;IDE0290</NoWarn>
2829
</PropertyGroup>
2930

3031
<ItemGroup>

GraphQL.DI.sln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution items", "Solution
1010
.editorconfig = .editorconfig
1111
.gitignore = .gitignore
1212
Directory.Build.props = Directory.Build.props
13+
global.json = global.json
1314
LICENSE = LICENSE
1415
logo.64x64.png = logo.64x64.png
1516
logo.jpg = logo.jpg
@@ -23,6 +24,7 @@ EndProject
2324
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{7432A0AF-9346-41D7-9DA9-D7EFEAF1A401}"
2425
ProjectSection(SolutionItems) = preProject
2526
.github\workflows\build.yml = .github\workflows\build.yml
27+
.github\workflows\format.yml = .github\workflows\format.yml
2628
.github\workflows\publish.yml = .github\workflows\publish.yml
2729
.github\workflows\test.yml = .github\workflows\test.yml
2830
EndProjectSection

Sample/Pages/Index.cshtml.cs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
1-
using Microsoft.AspNetCore.Mvc;
21
using Microsoft.AspNetCore.Mvc.RazorPages;
3-
using Microsoft.Extensions.Logging;
4-
using System;
5-
using System.Collections.Generic;
6-
using System.Linq;
7-
using System.Threading.Tasks;
82

9-
namespace Sample.Pages
3+
namespace Sample.Pages;
4+
5+
public class IndexModel : PageModel
106
{
11-
public class IndexModel : PageModel
7+
public void OnGet()
128
{
13-
private readonly ILogger<IndexModel> _logger;
14-
15-
public IndexModel(ILogger<IndexModel> logger)
16-
{
17-
_logger = logger;
18-
}
19-
20-
public void OnGet()
21-
{
229

23-
}
2410
}
2511
}

Sample/Pages/Privacy.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@page
1+
@page
22
@model PrivacyModel
33
@{
44
ViewData["Title"] = "Privacy Policy";

Sample/Pages/Privacy.cshtml.cs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
1-
using Microsoft.AspNetCore.Mvc;
21
using Microsoft.AspNetCore.Mvc.RazorPages;
3-
using Microsoft.Extensions.Logging;
4-
using System;
5-
using System.Collections.Generic;
6-
using System.Linq;
7-
using System.Threading.Tasks;
82

9-
namespace Sample.Pages
3+
namespace Sample.Pages;
4+
5+
public class PrivacyModel : PageModel
106
{
11-
public class PrivacyModel : PageModel
7+
public void OnGet()
128
{
13-
private readonly ILogger<PrivacyModel> _logger;
14-
15-
public PrivacyModel(ILogger<PrivacyModel> logger)
16-
{
17-
_logger = logger;
18-
}
19-
20-
public void OnGet()
21-
{
22-
}
239
}
2410
}

0 commit comments

Comments
 (0)