From 9786451f10a5afddf207f593aa3723d02e7ac44a Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Thu, 18 May 2023 12:10:09 +0200 Subject: [PATCH 1/7] Update to .NET 8 and EF Core 8 RC1 --- .config/dotnet-tools.json | 2 +- .github/workflows/build.yml | 19 +++++++++++-------- Directory.Build.props | 15 +++++++++------ cleanupcode.ps1 | 6 +++--- inspectcode.ps1 | 2 +- .../JsonApiDotNetCore.SourceGenerators.csproj | 1 + .../Response/FingerprintGenerator.cs | 2 +- .../ApiControllerAttributeTests.cs | 6 +++--- 8 files changed, 30 insertions(+), 23 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 3919f2223e..369dfb58c2 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "jetbrains.resharper.globaltools": { - "version": "2023.2.1", + "version": "2023.2.2", "commands": [ "jb" ] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8b4ccab00..6226907336 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,9 +10,9 @@ name: Build on: push: - branches: [ 'master', 'release/**' ] + branches: [ 'master', 'release/**', 'update-to-net7-ef7' ] pull_request: - branches: [ 'master', 'release/**' ] + branches: [ 'master', 'release/**', 'update-to-net7-ef7' ] release: types: [published] @@ -47,7 +47,8 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x + dotnet-quality: 'preview' - name: Setup PowerShell (Ubuntu) if: matrix.os == 'ubuntu-latest' run: | @@ -178,7 +179,8 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x + dotnet-quality: 'preview' - name: Git checkout uses: actions/checkout@v4 - name: Restore tools @@ -189,7 +191,7 @@ jobs: run: | $inspectCodeOutputPath = Join-Path $env:RUNNER_TEMP 'jetbrains-inspectcode-results.xml' Write-Output "INSPECT_CODE_OUTPUT_PATH=$inspectCodeOutputPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - dotnet jb inspectcode JsonApiDotNetCore.sln --build --output="$inspectCodeOutputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --properties:ContinuousIntegrationBuild=false --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal + dotnet jb inspectcode JsonApiDotNetCore.sln --dotnetcoresdk=$(dotnet --version) --build --output="$inspectCodeOutputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --properties:ContinuousIntegrationBuild=false --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal - name: Verify outcome shell: pwsh run: | @@ -229,7 +231,8 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x + dotnet-quality: 'preview' - name: Git checkout uses: actions/checkout@v4 with: @@ -250,13 +253,13 @@ jobs: $baseCommitHash = git rev-parse HEAD~1 Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request." - dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --max-runs=5 --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff + dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff - name: CleanupCode (on branch) if: github.event_name == 'push' || github.event_name == 'release' shell: pwsh run: | Write-Output "Running code cleanup on all files." - dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN --fail-on-diff --print-diff + dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN --fail-on-diff --print-diff publish: timeout-minutes: 60 diff --git a/Directory.Build.props b/Directory.Build.props index 23a0793d7d..c0024b60e3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -15,26 +15,26 @@ - net7.0 + net8.0 4.1.0 0.4.1 - 7.0.0 + 8.0.0-rc.1.* 2.14.1 - 7.0.* + 8.0.0-rc.1.* 0.13.* 34.0.* 3.8.* 4.7.* 6.0.* 2.1.* - 7.0.* + 8.0.0-rc.1.* 6.12.* 2.3.* 1.3.* 2023.2.* - 7.0.* + 8.0.0-rc.1 1.1.* $(AspNetCoreVersion) 17.7.* @@ -53,6 +53,9 @@ false false $(MSBuildThisFileDirectory)CodingGuidelines.ruleset - 5.4.1 + + + 5.4.1-net80 + true diff --git a/cleanupcode.ps1 b/cleanupcode.ps1 index ba1b0ca4c0..cb4b42419d 100644 --- a/cleanupcode.ps1 +++ b/cleanupcode.ps1 @@ -28,17 +28,17 @@ if ($revision) { if ($baseCommitHash -eq $headCommitHash) { Write-Output "Running code cleanup on staged/unstaged files." - dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --max-runs=5 --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f staged,modified + dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --max-runs=5 --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f staged,modified --jb --dotnetcoresdk=$(dotnet --version) VerifySuccessExitCode } else { Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash, including staged/unstaged files." - dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --max-runs=5 --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f staged,modified,commits -a $headCommitHash -b $baseCommitHash + dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --max-runs=5 --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f staged,modified,commits -a $headCommitHash -b $baseCommitHash --jb --dotnetcoresdk=$(dotnet --version) VerifySuccessExitCode } } else { Write-Output "Running code cleanup on all files." - dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN + dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN --jb --dotnetcoresdk=$(dotnet --version) VerifySuccessExitCode } diff --git a/inspectcode.ps1 b/inspectcode.ps1 index b379bce1c6..dc8114cc4b 100644 --- a/inspectcode.ps1 +++ b/inspectcode.ps1 @@ -10,7 +10,7 @@ if ($LastExitCode -ne 0) { $outputPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.xml') $resultPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.html') -dotnet jb inspectcode JsonApiDotNetCore.sln --build --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal +dotnet jb inspectcode JsonApiDotNetCore.sln --build --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal --dotnetcoresdk=$(dotnet --version) if ($LastExitCode -ne 0) { throw "Code inspection failed with exit code $LastExitCode" diff --git a/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj b/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj index ca6de1a5b7..89c3b81920 100644 --- a/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj +++ b/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj @@ -7,6 +7,7 @@ $(NoWarn);NU5128 latest true + true diff --git a/src/JsonApiDotNetCore/Serialization/Response/FingerprintGenerator.cs b/src/JsonApiDotNetCore/Serialization/Response/FingerprintGenerator.cs index e0b3e56b10..5baef6c086 100644 --- a/src/JsonApiDotNetCore/Serialization/Response/FingerprintGenerator.cs +++ b/src/JsonApiDotNetCore/Serialization/Response/FingerprintGenerator.cs @@ -6,7 +6,7 @@ namespace JsonApiDotNetCore.Serialization.Response; /// internal sealed class FingerprintGenerator : IFingerprintGenerator { - private static readonly byte[] Separator = Encoding.UTF8.GetBytes("|"); + private static readonly byte[] Separator = "|"u8.ToArray(); private static readonly uint[] LookupTable = Enumerable.Range(0, 256).Select(ToLookupEntry).ToArray(); private static uint ToLookupEntry(int index) diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/ApiControllerAttributeTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/ApiControllerAttributeTests.cs index 28e6ba2439..8e9122d74b 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/ApiControllerAttributeTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/ApiControllerAttributeTests.cs @@ -33,7 +33,7 @@ public async Task ApiController_attribute_transforms_NotFound_action_result_with ErrorObject error = responseDocument.Errors[0]; error.Links.ShouldNotBeNull(); - error.Links.About.Should().Be("https://tools.ietf.org/html/rfc7231#section-6.5.4"); + error.Links.About.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.5"); } [Fact] @@ -66,7 +66,7 @@ public async Task ProblemDetails_from_invalid_ModelState_is_translated_into_erro ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.BadRequest); error1.Links.ShouldNotBeNull(); - error1.Links.About.Should().Be("https://tools.ietf.org/html/rfc7231#section-6.5.1"); + error1.Links.About.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.1"); error1.Title.Should().Be("One or more validation errors occurred."); error1.Detail.Should().Be("The Name field is required."); error1.Source.Should().BeNull(); @@ -74,7 +74,7 @@ public async Task ProblemDetails_from_invalid_ModelState_is_translated_into_erro ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.BadRequest); error2.Links.ShouldNotBeNull(); - error2.Links.About.Should().Be("https://tools.ietf.org/html/rfc7231#section-6.5.1"); + error2.Links.About.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.1"); error2.Title.Should().Be("One or more validation errors occurred."); error2.Detail.Should().Be("The field YearOfBirth must be between 1900 and 2050."); error2.Source.Should().BeNull(); From 3bdceb36d7303af1fbe27afed4753e0ac96504e6 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Mon, 18 Sep 2023 14:38:58 +0200 Subject: [PATCH 2/7] Suppress warning about obsolete ISystemClock --- Directory.Build.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index c0024b60e3..c2235c55a0 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,10 +1,10 @@ - $(NoWarn);AV2210 + $(NoWarn);AV2210;CS0618 - $(NoWarn);1591 + $(NoWarn);1591;CS0618 true true From f49665f4c652fa5179f001e2c75fa02fecaaa6f5 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Mon, 18 Sep 2023 14:42:34 +0200 Subject: [PATCH 3/7] Suppress warning about non-parameterized SQL because table names cannot be parameterized --- test/TestBuildingBlocks/DbContextExtensions.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/TestBuildingBlocks/DbContextExtensions.cs b/test/TestBuildingBlocks/DbContextExtensions.cs index 7f32073874..757ea2491d 100644 --- a/test/TestBuildingBlocks/DbContextExtensions.cs +++ b/test/TestBuildingBlocks/DbContextExtensions.cs @@ -44,7 +44,9 @@ private static async Task ClearTablesAsync(this DbContext dbContext, params Type } else { +#pragma warning disable EF1002 // Risk of vulnerability to SQL injection. await dbContext.Database.ExecuteSqlRawAsync($"DELETE FROM \"{tableName}\""); +#pragma warning restore EF1002 // Risk of vulnerability to SQL injection. } } } From 5c6fbdf76615fdb8f21032cafe9e825422dbfa36 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Mon, 18 Sep 2023 14:56:32 +0200 Subject: [PATCH 4/7] Adapt for breaking change in Entity Framework Core Fix broken tests --- src/Examples/NoEntityFrameworkExample/Data/InMemoryModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Examples/NoEntityFrameworkExample/Data/InMemoryModel.cs b/src/Examples/NoEntityFrameworkExample/Data/InMemoryModel.cs index c81aa07b8f..916bdc78b1 100644 --- a/src/Examples/NoEntityFrameworkExample/Data/InMemoryModel.cs +++ b/src/Examples/NoEntityFrameworkExample/Data/InMemoryModel.cs @@ -19,7 +19,7 @@ private static void SetEntityProperties(RuntimeEntityType entityType, ResourceTy { foreach (PropertyInfo property in resourceType.ClrType.GetProperties()) { - entityType.AddProperty(property.Name, property.PropertyType, property); + entityType.AddProperty(property.Name, property.PropertyType, propertyInfo: property); } } } From 62b4d0977d070a817ff085725fb5cdd335e65a2d Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Wed, 27 Sep 2023 00:31:29 +0200 Subject: [PATCH 5/7] Suppress new Resharper warning on redundant bodies in empty types --- JsonApiDotNetCore.sln.DotSettings | 1 + 1 file changed, 1 insertion(+) diff --git a/JsonApiDotNetCore.sln.DotSettings b/JsonApiDotNetCore.sln.DotSettings index 2602272e97..33c2abd10e 100644 --- a/JsonApiDotNetCore.sln.DotSettings +++ b/JsonApiDotNetCore.sln.DotSettings @@ -76,6 +76,7 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$); WARNING SUGGESTION SUGGESTION + DO_NOT_SHOW SUGGESTION WARNING WARNING From 9a4f2f413c18f8e116161b8f6afa001dda4681eb Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Wed, 20 Sep 2023 02:35:35 +0200 Subject: [PATCH 6/7] Capture InspectCode logs --- .github/workflows/build.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6226907336..e67b37270c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -191,7 +191,12 @@ jobs: run: | $inspectCodeOutputPath = Join-Path $env:RUNNER_TEMP 'jetbrains-inspectcode-results.xml' Write-Output "INSPECT_CODE_OUTPUT_PATH=$inspectCodeOutputPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - dotnet jb inspectcode JsonApiDotNetCore.sln --dotnetcoresdk=$(dotnet --version) --build --output="$inspectCodeOutputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --properties:ContinuousIntegrationBuild=false --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal + dotnet jb inspectcode JsonApiDotNetCore.sln --dotnetcoresdk=$(dotnet --version) --build --output="$inspectCodeOutputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --properties:ContinuousIntegrationBuild=false --severity=WARNING --verbosity=TRACE --LogFolder=$env:RUNNER_TEMP/inspect-code-logs --debug -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal + - name: Upload logs to artifacts + uses: actions/upload-artifact@v3 + with: + name: inspect-code-logs-${{ matrix.os }} + path: ${{ runner.temp }}/inspect-code-logs - name: Verify outcome shell: pwsh run: | From a1e9d08bb5ef0dc0f50f9336a537a3a67b249caf Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Tue, 26 Sep 2023 03:40:09 +0200 Subject: [PATCH 7/7] Revert "Capture InspectCode logs" This reverts commit 96b1e1aef512eb119bb9146ce5356b3d42d6d4de. --- .github/workflows/build.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e67b37270c..6226907336 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -191,12 +191,7 @@ jobs: run: | $inspectCodeOutputPath = Join-Path $env:RUNNER_TEMP 'jetbrains-inspectcode-results.xml' Write-Output "INSPECT_CODE_OUTPUT_PATH=$inspectCodeOutputPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - dotnet jb inspectcode JsonApiDotNetCore.sln --dotnetcoresdk=$(dotnet --version) --build --output="$inspectCodeOutputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --properties:ContinuousIntegrationBuild=false --severity=WARNING --verbosity=TRACE --LogFolder=$env:RUNNER_TEMP/inspect-code-logs --debug -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal - - name: Upload logs to artifacts - uses: actions/upload-artifact@v3 - with: - name: inspect-code-logs-${{ matrix.os }} - path: ${{ runner.temp }}/inspect-code-logs + dotnet jb inspectcode JsonApiDotNetCore.sln --dotnetcoresdk=$(dotnet --version) --build --output="$inspectCodeOutputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --properties:ContinuousIntegrationBuild=false --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal - name: Verify outcome shell: pwsh run: |