Skip to content

Update to .NET 8 and EF Core 8 (preview) #1282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
"version": "2023.2.1",
"version": "2023.2.2",
"commands": [
"jb"
]
Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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: |
Expand Down Expand Up @@ -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
Expand All @@ -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: |
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
19 changes: 11 additions & 8 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<NoWarn>$(NoWarn);AV2210</NoWarn>
<NoWarn>$(NoWarn);AV2210;CS0618</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<NoWarn>$(NoWarn);1591</NoWarn>
<NoWarn>$(NoWarn);1591;CS0618</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
Expand All @@ -15,26 +15,26 @@

<PropertyGroup>
<!-- Published dependencies (only update on major version change) -->
<TargetFrameworkName>net7.0</TargetFrameworkName>
<TargetFrameworkName>net8.0</TargetFrameworkName>
<CodeAnalysisFrozenVersion>4.1.0</CodeAnalysisFrozenVersion>
<DemystifierFrozenVersion>0.4.1</DemystifierFrozenVersion>
<EntityFrameworkCoreFrozenVersion>7.0.0</EntityFrameworkCoreFrozenVersion>
<EntityFrameworkCoreFrozenVersion>8.0.0-rc.1.*</EntityFrameworkCoreFrozenVersion>
<HumanizerFrozenVersion>2.14.1</HumanizerFrozenVersion>

<!-- Non-published dependencies (these are safe to update, won't cause a breaking change) -->
<AspNetCoreVersion>7.0.*</AspNetCoreVersion>
<AspNetCoreVersion>8.0.0-rc.1.*</AspNetCoreVersion>
<BenchmarkDotNetVersion>0.13.*</BenchmarkDotNetVersion>
<BogusVersion>34.0.*</BogusVersion>
<CSharpGuidelinesAnalyzerVersion>3.8.*</CSharpGuidelinesAnalyzerVersion>
<CodeAnalysisVersion>4.7.*</CodeAnalysisVersion>
<CoverletVersion>6.0.*</CoverletVersion>
<DateOnlyTimeOnlyVersion>2.1.*</DateOnlyTimeOnlyVersion>
<EntityFrameworkCoreVersion>7.0.*</EntityFrameworkCoreVersion>
<EntityFrameworkCoreVersion>8.0.0-rc.1.*</EntityFrameworkCoreVersion>
<FluentAssertionsVersion>6.12.*</FluentAssertionsVersion>
<GitHubActionsTestLoggerVersion>2.3.*</GitHubActionsTestLoggerVersion>
<InheritDocVersion>1.3.*</InheritDocVersion>
<JetBrainsAnnotationsVersion>2023.2.*</JetBrainsAnnotationsVersion>
<NpgsqlVersion>7.0.*</NpgsqlVersion>
<NpgsqlVersion>8.0.0-rc.1</NpgsqlVersion>
<SourceLinkVersion>1.1.*</SourceLinkVersion>
<SystemTextJsonVersion>$(AspNetCoreVersion)</SystemTextJsonVersion>
<TestSdkVersion>17.7.*</TestSdkVersion>
Expand All @@ -53,6 +53,9 @@
<IsPackable>false</IsPackable>
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodingGuidelines.ruleset</CodeAnalysisRuleSet>
<JsonApiDotNetCoreVersionPrefix>5.4.1</JsonApiDotNetCoreVersionPrefix>

<!-- workaround for "NU5104: A stable release of a package should not have a prerelease dependency." -->
<JsonApiDotNetCoreVersionPrefix>5.4.1-net80</JsonApiDotNetCoreVersionPrefix>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions JsonApiDotNetCore.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$);</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantOverload_002ELocal/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantQueryOrderByAscendingKeyword/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantToStringCallForValueType/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantTypeDeclarationBody/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RemoveConstructorInvocation/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ReplaceSequenceEqualWithConstantPattern/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SimplifyStringInterpolation/@EntryIndexedValue">WARNING</s:String>
Expand Down
6 changes: 3 additions & 3 deletions cleanupcode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion inspectcode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<NoWarn>$(NoWarn);NU5128</NoWarn>
<LangVersion>latest</LangVersion>
<IsRoslynComponent>true</IsRoslynComponent>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace JsonApiDotNetCore.Serialization.Response;
/// <inheritdoc cref="IFingerprintGenerator" />
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -66,15 +66,15 @@ 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();

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();
Expand Down
2 changes: 2 additions & 0 deletions test/TestBuildingBlocks/DbContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
}
}
Expand Down