Skip to content

Commit

Permalink
Update to .NET 8.0 (#225)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
brminnick committed May 26, 2024
1 parent 3cc566e commit b0a780b
Show file tree
Hide file tree
Showing 55 changed files with 358 additions and 343 deletions.
17 changes: 13 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ indent_size = 2
# Organize usings
dotnet_sort_system_directives_first = true

# IDE0160: Use file scoped namespace
csharp_style_namespace_declarations = file_scoped:error

# CS4014: Because this call is not awaited, execution of the current method continues before the call is completed
dotnet_diagnostic.CS4014.severity = error

# 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.
dotnet_diagnostic.CS2012.severity = error

# 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.
dotnet_diagnostic.CS1998.severity = error

# Remove explicit default access modifiers
dotnet_style_require_accessibility_modifiers = omit_if_default:error

Expand All @@ -67,7 +70,10 @@ csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestions
csharp_style_conditional_delegate_call = true:suggestion

# Collection Expressions
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion

# Naming rules

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

# CA1068: CancellationToken parameters must come last
dotnet_diagnostic.CA1068.severity = error

# 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.
dotnet_diagnostic.CA2208.severity = error

Expand Down
40 changes: 20 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup .NET v7.0
- name: Setup .NET v8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.0.x"
dotnet-version: "8.0.x"

- name: Install .NET MAUI Workload
run: |
Expand All @@ -32,18 +32,18 @@ jobs:
MobileProjectDirectory=`dirname $MobileProject`
echo $MobileProjectDirectory
dotnet build $MobileProjectDirectory -f:net7.0-android -c Release
dotnet build $MobileProjectDirectory -f:net8.0-android -c Release
iOS:
runs-on: macos-13

steps:
- uses: actions/checkout@v3

- name: Setup .NET v7.0
- name: Setup .NET v8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.0.x"
dotnet-version: "8.0.x"

- name: Install .NET MAUI Workload
run: |
Expand All @@ -62,18 +62,18 @@ jobs:
MobileProjectDirectory=`dirname $MobileProject`
echo $MobileProjectDirectory
dotnet build $MobileProjectDirectory -f:net7.0-ios -c Release
dotnet build $MobileProjectDirectory -f:net8.0-ios -c Release
MacCatalyst:
runs-on: macos-13

steps:
- uses: actions/checkout@v3

- name: Setup .NET v7.0
- name: Setup .NET v8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.0.x"
dotnet-version: "8.0.x"

- name: Install .NET MAUI Workload
run: |
Expand All @@ -92,7 +92,7 @@ jobs:
MobileProjectDirectory=`dirname $MobileProject`
echo $MobileProjectDirectory
dotnet build $MobileProjectDirectory -f:net7.0-maccatalyst -c Release
dotnet build $MobileProjectDirectory -f:net8.0-maccatalyst -c Release
Windows:
runs-on: windows-latest
Expand All @@ -105,29 +105,29 @@ jobs:
distribution: 'microsoft'
java-version: '11'

- name: Setup .NET v7.0
- name: Setup .NET v8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.0.x"
dotnet-version: "8.0.x"

- name: Install .NET MAUI Workload
run: |
dotnet workload install maui
- name: Build Windows App
run: |
dotnet build ./samples/GitStatus.Mobile/ -c Release -f net7.0-windows10.0.19041.0
dotnet build ./samples/GitStatus.Mobile/ -c Release -f net8.0-windows10.0.19041.0
API:
runs-on: macos-latest

steps:
- uses: actions/checkout@v3

- name: Setup .NET v7.0
- name: Setup .NET v8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Build API App
run: |
Expand All @@ -145,10 +145,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup .NET v7.0
- name: Setup .NET v8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Build Console App
run: |
Expand All @@ -166,10 +166,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup .NET v7.0
- name: Setup .NET v8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Build Web App
run: |
Expand All @@ -187,10 +187,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup .NET v7.0
- name: Setup .NET v8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Build Web App
run: |
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ jobs:
GitHubPersonalAccessToken: ${{ secrets.GitHubPersonalAccessToken }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
7.0.x
6.0.x
3.1.x
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ obj/

### VisualStudioCode ###
.vscode/*
**/.meteor/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
Expand Down
59 changes: 40 additions & 19 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,21 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<!--CS1570: XML comment has badly formed XML 'Expected an end tag for element [parameter] -->
<!--CS1571: XML comment on [construct] has a duplicate param tag for [parameter] -->
<!--CS1572: XML comment has a param tag for '[parameter]', but there is no parameter by that name -->
<!--CS1573: Parameter has no matching param tag in the XML comment -->
<!--CS1574: XML comment has cref attribute that could not be resolved-->
<!--CS1734: XML comment has a paramref tag, but there is no parameter by that name-->
<WarningsAsErrors>nullable,CS1570,CS1571,CS1572,CS1573,CS1574,CS1734</WarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<Optimize>true</Optimize>
</PropertyGroup>
</Project>
<PropertyGroup>
<Nullable>enable</Nullable>
<NoWarn>NETSDK1023</NoWarn>
<IsTrimmable>false</IsTrimmable>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<LatestSupportedNetVersion>net8.0</LatestSupportedNetVersion>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
<SkipValidateMauiImplicitPackageReferences>true</SkipValidateMauiImplicitPackageReferences>

<!-- WarningsAsErrors
CS0419: Ambiguous reference in cref attribute
CS1570: XML comment has badly formed XML 'Expected an end tag for element [parameter]
CS1571: XML comment on [construct] has a duplicate param tag for [parameter]
CS1572: XML comment has a param tag for '[parameter]', but there is no parameter by that name
CS1573: Parameter has no matching param tag in the XML comment
CS1574: XML comment has cref attribute that could not be resolved
CS1580: Invalid type for parameter 'parameter number' in XML comment cref attribute
CS1581: Invalid return type in XML comment cref attribute
CS1584: XML comment has syntactically incorrect cref attribute
CS1587: XML comment is not placed on a valid language element
CS1589: The syntax of a tag which referenced a file was incorrect
CS1590: Invalid XML include element Missing file attribute
CS1591: Missing XML comment for publicly visible type or member
CS1592: Badly formed XML in included comments file
CS1598: XML parser could not be loaded. The XML documentation file will not be generated.
CS1658: Identifier expected; 'true' is a keyword
CS1710: XML comment on 'type' has a duplicate typeparam tag for 'parameter'
CS1711: XML comment has a typeparam tag, but there is no type parameter by that name
CS1712: Type parameter has no matching typeparam tag in the XML comment
CS1723: XML comment has cref attribute that refers to a type parameter
CS1734: XML comment has a paramref tag, but there is no parameter by that name
xUnit1012: Null should not be used for type parameter
xUnit2021: Assert.ThrowsAsync is async. The resulting task should be awaited -->
<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>
</PropertyGroup>
</Project>
45 changes: 45 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project>
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.EndsWith('-ios')) != true">
<Compile Remove="**\**\*.ios.cs" />
<None Include="**\**\*.ios.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
<Compile Remove="**\ios\**\*.cs" />
<None Include="**\ios\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac')) != true AND $(TargetFramework.EndsWith('-maccatalyst')) != true">
<Compile Remove="**\*.macos.cs" />
<None Include="**\*.macos.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
<Compile Remove="**\macos\**\*.cs" />
<None Include="**\macos\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac')) != true AND $(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.EndsWith('-ios')) != true AND $(TargetFramework.EndsWith('-maccatalyst')) != true">
<Compile Remove="**\*.macios.cs" />
<None Include="**\*.macios.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
<Compile Remove="**\macios\**\*.cs" />
<None Include="**\macios\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('MonoAndroid')) != true AND $(TargetFramework.EndsWith('-android')) != true ">
<Compile Remove="**\**\*.android.cs" />
<None Include="**\**\*.android.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
<Compile Remove="**\android\**\*.cs" />
<None Include="**\android\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.Contains('-windows')) != true ">
<Compile Remove="**\*.windows.cs" />
<None Include="**\*.windows.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
<Compile Remove="**\windows\**\*.cs" />
<None Include="**\windows\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.Contains('-tizen')) != true ">
<Compile Remove="**\*.tizen.cs" />
<None Include="**\*.tizen.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
<Compile Remove="**\tizen\**\*.cs" />
<None Include="**\tizen\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>
<ItemGroup Condition="!($(TargetFramework.StartsWith('net')) == true AND $(TargetFramework.EndsWith('.0')) == true AND $(TargetFramework.Contains('-')) != true)"> <!-- e.g net6.0 or net7.0 -->
<Compile Remove="**\*.net.cs" />
<None Include="**\*.net.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
<Compile Remove="**\net\**\*.cs" />
<None Include="**\net\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions GitHubApiStatus.sln
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
global.json = global.json
EndProjectSection
EndProject
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public int GetRemainingRequestCount(HttpResponseHeaders httpResponseHeaders)
- Get the number of GitHub API Requests remaining
- Parses the `X-RateLimit-Remaining` header and return its `int` value

#### HasReachedMaximimApiCallLimit
#### HasReachedMaximumApiCallLimit

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

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

bool hasReachedMaximumApiLimit = gitHubApiStatusService.HasReachedMaximimApiCallLimit(restApiResponse.Headers);
bool hasReachedMaximumApiLimit = gitHubApiStatusService.HasReachedMaximumApiCallLimit(restApiResponse.Headers);

Console.WriteLine($"What is the GitHub REST API Rate Limit? {rateLimit}"); // What is the GitHub REST API Rate Limit? 60
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.100",
"rollForward": "latestMajor"
"version": "8.0.300",
"rollForward": "latestFeature"
}
}
2 changes: 0 additions & 2 deletions samples/GitStatus.API/GetRateLimits.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using GitHubApiStatus;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
Expand Down
2 changes: 1 addition & 1 deletion samples/GitStatus.API/GitStatus.API.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>$(LatestSupportedNetVersion)</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
Expand Down
4 changes: 1 addition & 3 deletions samples/GitStatus.API/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Net.Http.Headers;
using GitHubApiStatus.Extensions;
using GitStatus.Shared;
using Microsoft.Extensions.Configuration;
Expand Down
2 changes: 1 addition & 1 deletion samples/GitStatus.ConsoleApp/GitStatus.ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>$(LatestSupportedNetVersion)</TargetFramework>
<AssemblyName>GitStatus.ConsoleApp</AssemblyName>
</PropertyGroup>
<ItemGroup>
Expand Down
Loading

0 comments on commit b0a780b

Please sign in to comment.