Skip to content

Commit b0a780b

Browse files
Update to .NET 8.0 (#225)
* Update to .NET 8.0 * Update GitStatus.Mobile.csproj * Update GitStatus.Mobile.csproj * Update GitStatus.Mobile.csproj * Add `System.Diagnostics.CodeAnalysis` Support * Update ProductHeaderValueTests.cs * `dotnet format` * Remove `net7.0` support * Update to .NET 8.0 * Add .NET 7.0 to Unit Test * Update unittests.yml * Update unittests.yml * Update unittests.yml * Update unittests.yml * Update unittests.yml * Update unittests.yml * Fix Failing Tests * Remove Unused Usings * Fix Failing Unit Tests * Update Failing tests * Update GitHubApiStatus.UnitTests.csproj * Update Target Frameworks * Remove Unused Code, Increase to v3.0.0
1 parent 3cc566e commit b0a780b

File tree

55 files changed

+358
-343
lines changed

Some content is hidden

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

55 files changed

+358
-343
lines changed

.editorconfig

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ indent_size = 2
4040
# Organize usings
4141
dotnet_sort_system_directives_first = true
4242

43-
# IDE0160: Use file scoped namespace
44-
csharp_style_namespace_declarations = file_scoped:error
45-
4643
# CS4014: Because this call is not awaited, execution of the current method continues before the call is completed
4744
dotnet_diagnostic.CS4014.severity = error
4845

46+
# CS2012: ValueTask instances returned from member invocations are intended to be directly awaited. Attempts to consume a ValueTask multiple times or to directly access one's result before it's known to be completed may result in an exception or corruption. Ignoring such a ValueTask is likely an indication of a functional bug and may degrade performance.
47+
dotnet_diagnostic.CS2012.severity = error
48+
49+
# CS1998 : This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
50+
dotnet_diagnostic.CS1998.severity = error
51+
4952
# Remove explicit default access modifiers
5053
dotnet_style_require_accessibility_modifiers = omit_if_default:error
5154

@@ -67,7 +70,10 @@ csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
6770
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
6871
csharp_style_inlined_variable_declaration = true:suggestion
6972
csharp_style_throw_expression = true:suggestion
70-
csharp_style_conditional_delegate_call = true:suggestions
73+
csharp_style_conditional_delegate_call = true:suggestion
74+
75+
# Collection Expressions
76+
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
7177

7278
# Naming rules
7379

@@ -118,6 +124,9 @@ dotnet_diagnostic.CA1050.severity = error
118124
# CA2016: Forward the 'cancellationToken' parameter methods that take one
119125
dotnet_diagnostic.CA2016.severity = error
120126

127+
# CA1068: CancellationToken parameters must come last
128+
dotnet_diagnostic.CA1068.severity = error
129+
121130
# CA2208: Method passes parameter as the paramName argument to a ArgumentNullException constructor. Replace this argument with one of the method's parameter names. Note that the provided parameter name should have the exact casing as declared on the method.
122131
dotnet_diagnostic.CA2208.severity = error
123132

.github/workflows/build.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v3
1717

18-
- name: Setup .NET v7.0
18+
- name: Setup .NET v8.0
1919
uses: actions/setup-dotnet@v3
2020
with:
21-
dotnet-version: "7.0.x"
21+
dotnet-version: "8.0.x"
2222

2323
- name: Install .NET MAUI Workload
2424
run: |
@@ -32,18 +32,18 @@ jobs:
3232
MobileProjectDirectory=`dirname $MobileProject`
3333
echo $MobileProjectDirectory
3434
35-
dotnet build $MobileProjectDirectory -f:net7.0-android -c Release
35+
dotnet build $MobileProjectDirectory -f:net8.0-android -c Release
3636
3737
iOS:
3838
runs-on: macos-13
3939

4040
steps:
4141
- uses: actions/checkout@v3
4242

43-
- name: Setup .NET v7.0
43+
- name: Setup .NET v8.0
4444
uses: actions/setup-dotnet@v3
4545
with:
46-
dotnet-version: "7.0.x"
46+
dotnet-version: "8.0.x"
4747

4848
- name: Install .NET MAUI Workload
4949
run: |
@@ -62,18 +62,18 @@ jobs:
6262
MobileProjectDirectory=`dirname $MobileProject`
6363
echo $MobileProjectDirectory
6464
65-
dotnet build $MobileProjectDirectory -f:net7.0-ios -c Release
65+
dotnet build $MobileProjectDirectory -f:net8.0-ios -c Release
6666
6767
MacCatalyst:
6868
runs-on: macos-13
6969

7070
steps:
7171
- uses: actions/checkout@v3
7272

73-
- name: Setup .NET v7.0
73+
- name: Setup .NET v8.0
7474
uses: actions/setup-dotnet@v3
7575
with:
76-
dotnet-version: "7.0.x"
76+
dotnet-version: "8.0.x"
7777

7878
- name: Install .NET MAUI Workload
7979
run: |
@@ -92,7 +92,7 @@ jobs:
9292
MobileProjectDirectory=`dirname $MobileProject`
9393
echo $MobileProjectDirectory
9494
95-
dotnet build $MobileProjectDirectory -f:net7.0-maccatalyst -c Release
95+
dotnet build $MobileProjectDirectory -f:net8.0-maccatalyst -c Release
9696
9797
Windows:
9898
runs-on: windows-latest
@@ -105,29 +105,29 @@ jobs:
105105
distribution: 'microsoft'
106106
java-version: '11'
107107

108-
- name: Setup .NET v7.0
108+
- name: Setup .NET v8.0
109109
uses: actions/setup-dotnet@v3
110110
with:
111-
dotnet-version: "7.0.x"
111+
dotnet-version: "8.0.x"
112112

113113
- name: Install .NET MAUI Workload
114114
run: |
115115
dotnet workload install maui
116116
117117
- name: Build Windows App
118118
run: |
119-
dotnet build ./samples/GitStatus.Mobile/ -c Release -f net7.0-windows10.0.19041.0
119+
dotnet build ./samples/GitStatus.Mobile/ -c Release -f net8.0-windows10.0.19041.0
120120
121121
API:
122122
runs-on: macos-latest
123123

124124
steps:
125125
- uses: actions/checkout@v3
126126

127-
- name: Setup .NET v7.0
127+
- name: Setup .NET v8.0
128128
uses: actions/setup-dotnet@v3
129129
with:
130-
dotnet-version: '7.0.x'
130+
dotnet-version: '8.0.x'
131131

132132
- name: Build API App
133133
run: |
@@ -145,10 +145,10 @@ jobs:
145145
steps:
146146
- uses: actions/checkout@v3
147147

148-
- name: Setup .NET v7.0
148+
- name: Setup .NET v8.0
149149
uses: actions/setup-dotnet@v3
150150
with:
151-
dotnet-version: '7.0.x'
151+
dotnet-version: '8.0.x'
152152

153153
- name: Build Console App
154154
run: |
@@ -166,10 +166,10 @@ jobs:
166166
steps:
167167
- uses: actions/checkout@v3
168168

169-
- name: Setup .NET v7.0
169+
- name: Setup .NET v8.0
170170
uses: actions/setup-dotnet@v3
171171
with:
172-
dotnet-version: '7.0.x'
172+
dotnet-version: '8.0.x'
173173

174174
- name: Build Web App
175175
run: |
@@ -187,10 +187,10 @@ jobs:
187187
steps:
188188
- uses: actions/checkout@v3
189189

190-
- name: Setup .NET v7.0
190+
- name: Setup .NET v8.0
191191
uses: actions/setup-dotnet@v3
192192
with:
193-
dotnet-version: '7.0.x'
193+
dotnet-version: '8.0.x'
194194

195195
- name: Build Web App
196196
run: |

.github/workflows/unittests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ jobs:
1616
GitHubPersonalAccessToken: ${{ secrets.GitHubPersonalAccessToken }}
1717

1818
steps:
19-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
2020

2121
- name: Install .NET
22-
uses: actions/setup-dotnet@v3
22+
uses: actions/setup-dotnet@v4
2323
with:
2424
dotnet-version: |
25+
8.0.x
2526
7.0.x
2627
6.0.x
2728
3.1.x

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ obj/
2626

2727
### VisualStudioCode ###
2828
.vscode/*
29+
**/.meteor/*
2930
!.vscode/settings.json
3031
!.vscode/tasks.json
3132
!.vscode/launch.json

Directory.Build.props

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,42 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Project>
3-
<PropertyGroup>
4-
<LangVersion>latest</LangVersion>
5-
<Nullable>enable</Nullable>
6-
<WarningsAsErrors>nullable</WarningsAsErrors>
7-
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>
8-
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
9-
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
10-
<!--CS1570: XML comment has badly formed XML 'Expected an end tag for element [parameter] -->
11-
<!--CS1571: XML comment on [construct] has a duplicate param tag for [parameter] -->
12-
<!--CS1572: XML comment has a param tag for '[parameter]', but there is no parameter by that name -->
13-
<!--CS1573: Parameter has no matching param tag in the XML comment -->
14-
<!--CS1574: XML comment has cref attribute that could not be resolved-->
15-
<!--CS1734: XML comment has a paramref tag, but there is no parameter by that name-->
16-
<WarningsAsErrors>nullable,CS1570,CS1571,CS1572,CS1573,CS1574,CS1734</WarningsAsErrors>
17-
</PropertyGroup>
18-
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
19-
<Optimize>true</Optimize>
20-
</PropertyGroup>
21-
</Project>
3+
<PropertyGroup>
4+
<Nullable>enable</Nullable>
5+
<NoWarn>NETSDK1023</NoWarn>
6+
<IsTrimmable>false</IsTrimmable>
7+
<LangVersion>latest</LangVersion>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
10+
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
11+
<LatestSupportedNetVersion>net8.0</LatestSupportedNetVersion>
12+
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
13+
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
14+
<SkipValidateMauiImplicitPackageReferences>true</SkipValidateMauiImplicitPackageReferences>
15+
16+
<!-- WarningsAsErrors
17+
CS0419: Ambiguous reference in cref attribute
18+
CS1570: XML comment has badly formed XML 'Expected an end tag for element [parameter]
19+
CS1571: XML comment on [construct] has a duplicate param tag for [parameter]
20+
CS1572: XML comment has a param tag for '[parameter]', but there is no parameter by that name
21+
CS1573: Parameter has no matching param tag in the XML comment
22+
CS1574: XML comment has cref attribute that could not be resolved
23+
CS1580: Invalid type for parameter 'parameter number' in XML comment cref attribute
24+
CS1581: Invalid return type in XML comment cref attribute
25+
CS1584: XML comment has syntactically incorrect cref attribute
26+
CS1587: XML comment is not placed on a valid language element
27+
CS1589: The syntax of a tag which referenced a file was incorrect
28+
CS1590: Invalid XML include element Missing file attribute
29+
CS1591: Missing XML comment for publicly visible type or member
30+
CS1592: Badly formed XML in included comments file
31+
CS1598: XML parser could not be loaded. The XML documentation file will not be generated.
32+
CS1658: Identifier expected; 'true' is a keyword
33+
CS1710: XML comment on 'type' has a duplicate typeparam tag for 'parameter'
34+
CS1711: XML comment has a typeparam tag, but there is no type parameter by that name
35+
CS1712: Type parameter has no matching typeparam tag in the XML comment
36+
CS1723: XML comment has cref attribute that refers to a type parameter
37+
CS1734: XML comment has a paramref tag, but there is no parameter by that name
38+
xUnit1012: Null should not be used for type parameter
39+
xUnit2021: Assert.ThrowsAsync is async. The resulting task should be awaited -->
40+
<WarningsAsErrors>nullable,CS0419,CS1570,CS1571,CS1572,CS1573,CS1574,CS1580,CS1581,CS1584,CS1587,CS1589,CS1590,CS1591,CS1592,CS1598,CS1658,CS1710,CS1711,CS1712,CS1723,CS1734,xUnit1012,xUnit2021</WarningsAsErrors>
41+
</PropertyGroup>
42+
</Project>

Directory.Build.targets

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Project>
3+
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.EndsWith('-ios')) != true">
4+
<Compile Remove="**\**\*.ios.cs" />
5+
<None Include="**\**\*.ios.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
6+
<Compile Remove="**\ios\**\*.cs" />
7+
<None Include="**\ios\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
8+
</ItemGroup>
9+
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac')) != true AND $(TargetFramework.EndsWith('-maccatalyst')) != true">
10+
<Compile Remove="**\*.macos.cs" />
11+
<None Include="**\*.macos.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
12+
<Compile Remove="**\macos\**\*.cs" />
13+
<None Include="**\macos\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
14+
</ItemGroup>
15+
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac')) != true AND $(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.EndsWith('-ios')) != true AND $(TargetFramework.EndsWith('-maccatalyst')) != true">
16+
<Compile Remove="**\*.macios.cs" />
17+
<None Include="**\*.macios.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
18+
<Compile Remove="**\macios\**\*.cs" />
19+
<None Include="**\macios\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
20+
</ItemGroup>
21+
<ItemGroup Condition="$(TargetFramework.StartsWith('MonoAndroid')) != true AND $(TargetFramework.EndsWith('-android')) != true ">
22+
<Compile Remove="**\**\*.android.cs" />
23+
<None Include="**\**\*.android.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
24+
<Compile Remove="**\android\**\*.cs" />
25+
<None Include="**\android\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
26+
</ItemGroup>
27+
<ItemGroup Condition="$(TargetFramework.Contains('-windows')) != true ">
28+
<Compile Remove="**\*.windows.cs" />
29+
<None Include="**\*.windows.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
30+
<Compile Remove="**\windows\**\*.cs" />
31+
<None Include="**\windows\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
32+
</ItemGroup>
33+
<ItemGroup Condition="$(TargetFramework.Contains('-tizen')) != true ">
34+
<Compile Remove="**\*.tizen.cs" />
35+
<None Include="**\*.tizen.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
36+
<Compile Remove="**\tizen\**\*.cs" />
37+
<None Include="**\tizen\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
38+
</ItemGroup>
39+
<ItemGroup Condition="!($(TargetFramework.StartsWith('net')) == true AND $(TargetFramework.EndsWith('.0')) == true AND $(TargetFramework.Contains('-')) != true)"> <!-- e.g net6.0 or net7.0 -->
40+
<Compile Remove="**\*.net.cs" />
41+
<None Include="**\*.net.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
42+
<Compile Remove="**\net\**\*.cs" />
43+
<None Include="**\net\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
44+
</ItemGroup>
45+
</Project>

GitHubApiStatus.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
3232
ProjectSection(SolutionItems) = preProject
3333
.editorconfig = .editorconfig
3434
Directory.Build.props = Directory.Build.props
35+
Directory.Build.targets = Directory.Build.targets
3536
global.json = global.json
3637
EndProjectSection
3738
EndProject

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ public int GetRemainingRequestCount(HttpResponseHeaders httpResponseHeaders)
8484
- Get the number of GitHub API Requests remaining
8585
- Parses the `X-RateLimit-Remaining` header and return its `int` value
8686

87-
#### HasReachedMaximimApiCallLimit
87+
#### HasReachedMaximumApiCallLimit
8888

8989
```csharp
90-
public bool HasReachedMaximimApiCallLimit(HttpResponseHeaders httpResponseHeaders)
90+
public bool HasReachedMaximumApiCallLimit(HttpResponseHeaders httpResponseHeaders)
9191
```
9292
- Determines whether the maximum number of requests
9393
- Parses the `X-RateLimit-Remaining` header and returns wether or not it is greater than 0
@@ -253,7 +253,7 @@ static async Task Main(string[] args)
253253

254254
bool isAuthenticated = gitHubApiStatusService.IsResponseFromAuthenticatedRequest(restApiResponse.Headers);
255255

256-
bool hasReachedMaximumApiLimit = gitHubApiStatusService.HasReachedMaximimApiCallLimit(restApiResponse.Headers);
256+
bool hasReachedMaximumApiLimit = gitHubApiStatusService.HasReachedMaximumApiCallLimit(restApiResponse.Headers);
257257

258258
Console.WriteLine($"What is the GitHub REST API Rate Limit? {rateLimit}"); // What is the GitHub REST API Rate Limit? 60
259259

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "7.0.100",
4-
"rollForward": "latestMajor"
3+
"version": "8.0.300",
4+
"rollForward": "latestFeature"
55
}
66
}

samples/GitStatus.API/GetRateLimits.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System.Net;
2-
using System.Threading;
3-
using System.Threading.Tasks;
42
using GitHubApiStatus;
53
using Microsoft.Azure.Functions.Worker;
64
using Microsoft.Azure.Functions.Worker.Http;

0 commit comments

Comments
 (0)