From fcda1b634548c8cf4df512ee2ef5ec90d1c3c88a Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Fri, 29 Sep 2023 02:26:31 +0200
Subject: [PATCH 01/16] Multi-target against .NET 6 and .NET 8
---
.github/workflows/build.yml | 18 +++++---
Directory.Build.props | 34 ++-------------
JsonApiDotNetCore.sln | 1 +
README.md | 29 ++++++++-----
benchmarks/Benchmarks.csproj | 4 +-
cleanupcode.ps1 | 6 +--
docs/generate-examples.ps1 | 2 +-
inspectcode.ps1 | 2 +-
package-versions.props | 42 +++++++++++++++++++
.../DapperExample/DapperExample.csproj | 6 ++-
.../Definitions/TodoItemDefinition.cs | 13 +++---
src/Examples/DapperExample/IClock.cs | 6 +++
src/Examples/DapperExample/Program.cs | 3 +-
src/Examples/DapperExample/SystemClock.cs | 6 +++
.../DatabasePerTenantExample.csproj | 6 ++-
.../GettingStarted/GettingStarted.csproj | 4 +-
.../Definitions/TodoItemDefinition.cs | 18 ++++++--
.../JsonApiDotNetCoreExample.csproj | 6 ++-
.../JsonApiDotNetCoreExample/Program.cs | 8 +++-
.../MultiDbContextExample.csproj | 4 +-
.../NoEntityFrameworkExample.csproj | 4 +-
.../ReportsExample/ReportsExample.csproj | 9 ++--
.../JsonApiDotNetCore.Annotations.csproj | 5 ++-
.../JsonApiDotNetCore.SourceGenerators.csproj | 3 +-
.../JsonApiDotNetCore.csproj | 4 +-
.../Response/FingerprintGenerator.cs | 4 ++
test/AnnotationTests/AnnotationTests.csproj | 5 ++-
test/DapperTests/DapperTests.csproj | 4 +-
.../IntegrationTests/DapperTestContext.cs | 7 +++-
.../IntegrationTests/FrozenClock.cs | 11 +++++
test/DiscoveryTests/DiscoveryTests.csproj | 4 +-
.../Creating/AtomicCreateResourceTests.cs | 1 -
...reateResourceWithClientGeneratedIdTests.cs | 1 -
.../DateMustBeInThePastAttribute.cs | 2 +-
.../Meta/AtomicResourceMetaTests.cs | 1 -
.../AtomicModelStateValidationTests.cs | 1 -
.../QueryStrings/AtomicQueryStringTests.cs | 1 -
.../MusicTrackReleaseDefinition.cs | 2 +-
.../Resources/AtomicUpdateResourceTests.cs | 1 -
.../ApiControllerAttributeTests.cs | 6 +--
.../ModelState/ModelStateValidationTests.cs | 6 ++-
.../FilterRewritingResourceDefinition.cs | 2 +-
.../TimeOffset/FilterTimeOffsetRewriter.cs | 2 +-
.../TimeOffset/TimeOffsetTests.cs | 1 -
.../GiftCertificate.cs | 2 +-
.../InjectionDbContext.cs | 1 -
.../PostOffice.cs | 2 +-
.../ResourceInjectionTests.cs | 1 -
.../SoftDeletionAwareResourceService.cs | 2 +-
.../SoftDeletion/SoftDeletionTests.cs | 1 -
.../JsonApiDotNetCoreTests.csproj | 6 ++-
.../MultiDbContextTests.csproj | 4 +-
.../NoEntityFrameworkTests.csproj | 4 +-
.../NullSafeExpressionRewriterTests.cs | 4 ++
.../SourceGeneratorTests.csproj | 4 +-
.../TestBuildingBlocks/DbContextExtensions.cs | 3 ++
test/TestBuildingBlocks/FrozenSystemClock.cs | 1 -
test/TestBuildingBlocks/ISystemClock.cs | 6 +++
.../TestBuildingBlocks.csproj | 6 ++-
test/UnitTests/UnitTests.csproj | 4 +-
60 files changed, 233 insertions(+), 123 deletions(-)
create mode 100644 package-versions.props
create mode 100644 src/Examples/DapperExample/IClock.cs
create mode 100644 src/Examples/DapperExample/SystemClock.cs
create mode 100644 test/DapperTests/IntegrationTests/FrozenClock.cs
create mode 100644 test/TestBuildingBlocks/ISystemClock.cs
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 08df1de510..e907bbbc02 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -47,7 +47,9 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
- dotnet-version: 6.0.x
+ dotnet-version: |
+ 6.0.x
+ 8.0.x
- name: Setup PowerShell (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
@@ -182,7 +184,9 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
- dotnet-version: 6.0.x
+ dotnet-version: |
+ 6.0.x
+ 8.0.x
- name: Git checkout
uses: actions/checkout@v4
- name: Restore tools
@@ -193,7 +197,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 --build --dotnetcoresdk=$(dotnet --version) --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: |
@@ -233,7 +237,9 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
- dotnet-version: 6.0.x
+ dotnet-version: |
+ 6.0.x
+ 8.0.x
- name: Git checkout
uses: actions/checkout@v4
with:
@@ -254,13 +260,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 d780fbefbf..7ce9eb9a00 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -13,43 +13,15 @@
true
-
-
- net6.0
- 4.1.0
- 0.4.1
- 6.0.0
- 2.14.1
-
-
- 6.0.*
- 0.13.*
- 34.0.*
- 3.8.*
- 4.7.*
- 6.0.*
- 2.1.*
- 2.1.*
- 7.0.*
- 6.12.*
- 2.3.*
- 1.3.*
- 2023.3.*
- 7.0.*
- 8.0.*
- 7.0.*
- 17.8.*
- 2.5.*
-
-
-
-
+
+
enable
+ latest
enable
false
false
diff --git a/JsonApiDotNetCore.sln b/JsonApiDotNetCore.sln
index 4f8bd6f8ef..e821d4175d 100644
--- a/JsonApiDotNetCore.sln
+++ b/JsonApiDotNetCore.sln
@@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
CSharpGuidelinesAnalyzer.config = CSharpGuidelinesAnalyzer.config
Directory.Build.props = Directory.Build.props
tests.runsettings = tests.runsettings
+ package-versions.props = package-versions.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{026FBC6C-AF76-4568-9B87-EC73457899FD}"
diff --git a/README.md b/README.md
index fe2658711f..f34dfd1bee 100644
--- a/README.md
+++ b/README.md
@@ -76,17 +76,24 @@ app.MapControllers();
The following chart should help you pick the best version, based on your environment.
See also our [versioning policy](./VERSIONING_POLICY.md).
-| JsonApiDotNetCore | Status | .NET | Entity Framework Core |
-| ----------------- | ----------- | -------- | --------------------- |
-| 3.x | Stable | Core 2.x | 2.x |
-| 4.x | Stable | Core 3.1 | 3.1 |
-| | | Core 3.1 | 5 |
-| | | 5 | 5 |
-| | | 6 | 5 |
-| 5.0.0-5.0.2 | Stable | 6 | 6 |
-| 5.0.3+ | Stable | 6 | 6 |
-| | | 6 | 7 |
-| | | 7 | 7 |
+| JsonApiDotNetCore | Status | .NET | Entity Framework Core |
+| ----------------- | ------------ | -------- | --------------------- |
+| 3.x | Stable | Core 2.x | 2.x |
+| 4.x | Stable | Core 3.1 | 3.1, 5 |
+| | | 5 | 5 |
+| | | 6 | 5 |
+| 5.0.0-5.0.2 | Stable | 6 | 6 |
+| 5.0.3-5.4.0 | Stable | 6 | 6, 7 |
+| | | 7 | 7 |
+| 5.5+ | Stable | 6 | 6, 7 |
+| | | 7 | 7 |
+| | | 8 | 8 |
+| master | Preview | 6 | 6, 7 |
+| | | 7 | 7 |
+| | | 8 | 8 |
+| openapi | Experimental | 6 | 6, 7 |
+| | | 7 | 7 |
+| | | 8 | 8 |
## Contributing
diff --git a/benchmarks/Benchmarks.csproj b/benchmarks/Benchmarks.csproj
index 1e97dd290f..9dbb9ba093 100644
--- a/benchmarks/Benchmarks.csproj
+++ b/benchmarks/Benchmarks.csproj
@@ -1,10 +1,12 @@
Exe
- $(TargetFrameworkName)
+ net8.0
true
+
+
diff --git a/cleanupcode.ps1 b/cleanupcode.ps1
index ba1b0ca4c0..3ab4d620ae 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 --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f staged,modified
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 --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN -f staged,modified,commits -a $headCommitHash -b $baseCommitHash
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 --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --verbosity=WARN
VerifySuccessExitCode
}
diff --git a/docs/generate-examples.ps1 b/docs/generate-examples.ps1
index 4b13408460..ea6b2bd8f2 100644
--- a/docs/generate-examples.ps1
+++ b/docs/generate-examples.ps1
@@ -34,7 +34,7 @@ function Start-WebServer {
Write-Output "Starting web server"
$startTimeUtc = Get-Date -AsUTC
$job = Start-Job -ScriptBlock {
- dotnet run --project ..\src\Examples\GettingStarted\GettingStarted.csproj --configuration Debug --property:TreatWarningsAsErrors=True --urls=http://0.0.0.0:14141
+ dotnet run --project ..\src\Examples\GettingStarted\GettingStarted.csproj --framework net8.0 --configuration Debug --property:TreatWarningsAsErrors=True --urls=http://0.0.0.0:14141
}
$webProcessId = $null
diff --git a/inspectcode.ps1 b/inspectcode.ps1
index b379bce1c6..14c3eb1736 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 --dotnetcoresdk=$(dotnet --version) --build --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal
if ($LastExitCode -ne 0) {
throw "Code inspection failed with exit code $LastExitCode"
diff --git a/package-versions.props b/package-versions.props
new file mode 100644
index 0000000000..dd842f59f6
--- /dev/null
+++ b/package-versions.props
@@ -0,0 +1,42 @@
+
+
+
+ 4.1.0
+ 0.4.1
+ 2.14.1
+
+
+ 0.13.*
+ 34.0.*
+ 4.7.*
+ 6.0.*
+ 2.1.*
+ 6.12.*
+ 2.3.*
+ 1.3.*
+ 8.0.*
+ 17.8.*
+ 2.5.*
+
+
+
+
+ 8.0.0
+
+
+ 8.0.*
+ 8.0.*-*
+ $(AspNetCoreVersion)
+
+
+
+
+ 6.0.0
+
+
+ 6.0.*
+ 2.1.*
+ 7.0.*
+ 7.0.*
+
+
diff --git a/src/Examples/DapperExample/DapperExample.csproj b/src/Examples/DapperExample/DapperExample.csproj
index 4445af8c1e..f49c3e4b40 100644
--- a/src/Examples/DapperExample/DapperExample.csproj
+++ b/src/Examples/DapperExample/DapperExample.csproj
@@ -1,8 +1,10 @@
- $(TargetFrameworkName)
+ net8.0;net6.0
+
+
-
+
diff --git a/src/Examples/DapperExample/Definitions/TodoItemDefinition.cs b/src/Examples/DapperExample/Definitions/TodoItemDefinition.cs
index 77bf6f9548..6fed60fadd 100644
--- a/src/Examples/DapperExample/Definitions/TodoItemDefinition.cs
+++ b/src/Examples/DapperExample/Definitions/TodoItemDefinition.cs
@@ -6,21 +6,20 @@
using JsonApiDotNetCore.Middleware;
using JsonApiDotNetCore.Queries.Expressions;
using JsonApiDotNetCore.Resources;
-using Microsoft.AspNetCore.Authentication;
namespace DapperExample.Definitions;
[UsedImplicitly(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)]
public sealed class TodoItemDefinition : JsonApiResourceDefinition
{
- private readonly ISystemClock _systemClock;
+ private readonly IClock _clock;
- public TodoItemDefinition(IResourceGraph resourceGraph, ISystemClock systemClock)
+ public TodoItemDefinition(IResourceGraph resourceGraph, IClock clock)
: base(resourceGraph)
{
- ArgumentGuard.NotNull(systemClock);
+ ArgumentGuard.NotNull(clock);
- _systemClock = systemClock;
+ _clock = clock;
}
public override SortExpression OnApplySort(SortExpression? existingSort)
@@ -41,11 +40,11 @@ public override Task OnWritingAsync(TodoItem resource, WriteOperationKind writeO
{
if (writeOperation == WriteOperationKind.CreateResource)
{
- resource.CreatedAt = _systemClock.UtcNow;
+ resource.CreatedAt = _clock.UtcNow;
}
else if (writeOperation == WriteOperationKind.UpdateResource)
{
- resource.LastModifiedAt = _systemClock.UtcNow;
+ resource.LastModifiedAt = _clock.UtcNow;
}
return Task.CompletedTask;
diff --git a/src/Examples/DapperExample/IClock.cs b/src/Examples/DapperExample/IClock.cs
new file mode 100644
index 0000000000..0319c42480
--- /dev/null
+++ b/src/Examples/DapperExample/IClock.cs
@@ -0,0 +1,6 @@
+namespace DapperExample;
+
+public interface IClock
+{
+ DateTimeOffset UtcNow { get; }
+}
diff --git a/src/Examples/DapperExample/Program.cs b/src/Examples/DapperExample/Program.cs
index e19e45478f..00ab54ca97 100644
--- a/src/Examples/DapperExample/Program.cs
+++ b/src/Examples/DapperExample/Program.cs
@@ -9,7 +9,6 @@
using JsonApiDotNetCore.AtomicOperations;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Repositories;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.DependencyInjection.Extensions;
@@ -18,7 +17,7 @@
// Add services to the container.
-builder.Services.TryAddSingleton();
+builder.Services.TryAddSingleton();
DatabaseProvider databaseProvider = GetDatabaseProvider(builder.Configuration);
string? connectionString = builder.Configuration.GetConnectionString($"DapperExample{databaseProvider}");
diff --git a/src/Examples/DapperExample/SystemClock.cs b/src/Examples/DapperExample/SystemClock.cs
new file mode 100644
index 0000000000..3fed87c586
--- /dev/null
+++ b/src/Examples/DapperExample/SystemClock.cs
@@ -0,0 +1,6 @@
+namespace DapperExample;
+
+public sealed class SystemClock : IClock
+{
+ public DateTimeOffset UtcNow => DateTimeOffset.UtcNow;
+}
diff --git a/src/Examples/DatabasePerTenantExample/DatabasePerTenantExample.csproj b/src/Examples/DatabasePerTenantExample/DatabasePerTenantExample.csproj
index c219dfd0f5..0ccb4bbc5f 100644
--- a/src/Examples/DatabasePerTenantExample/DatabasePerTenantExample.csproj
+++ b/src/Examples/DatabasePerTenantExample/DatabasePerTenantExample.csproj
@@ -1,8 +1,10 @@
- $(TargetFrameworkName)
+ net8.0;net6.0
+
+
-
+
diff --git a/src/Examples/GettingStarted/GettingStarted.csproj b/src/Examples/GettingStarted/GettingStarted.csproj
index 9e0c80b7f4..1f4645f323 100644
--- a/src/Examples/GettingStarted/GettingStarted.csproj
+++ b/src/Examples/GettingStarted/GettingStarted.csproj
@@ -1,8 +1,10 @@
- $(TargetFrameworkName)
+ net8.0;net6.0
+
+
{
- private readonly ISystemClock _systemClock;
+ private readonly Func _getUtcNow;
+#if NET6_0
public TodoItemDefinition(IResourceGraph resourceGraph, ISystemClock systemClock)
: base(resourceGraph)
{
- _systemClock = systemClock;
+ _getUtcNow = () => systemClock.UtcNow;
}
+#else
+ public TodoItemDefinition(IResourceGraph resourceGraph, TimeProvider timeProvider)
+ : base(resourceGraph)
+ {
+ _getUtcNow = timeProvider.GetUtcNow;
+ }
+#endif
public override SortExpression OnApplySort(SortExpression? existingSort)
{
@@ -38,11 +48,11 @@ public override Task OnWritingAsync(TodoItem resource, WriteOperationKind writeO
{
if (writeOperation == WriteOperationKind.CreateResource)
{
- resource.CreatedAt = _systemClock.UtcNow;
+ resource.CreatedAt = _getUtcNow();
}
else if (writeOperation == WriteOperationKind.UpdateResource)
{
- resource.LastModifiedAt = _systemClock.UtcNow;
+ resource.LastModifiedAt = _getUtcNow();
}
return Task.CompletedTask;
diff --git a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj
index c219dfd0f5..0ccb4bbc5f 100644
--- a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj
+++ b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj
@@ -1,8 +1,10 @@
- $(TargetFrameworkName)
+ net8.0;net6.0
+
+
-
+
diff --git a/src/Examples/JsonApiDotNetCoreExample/Program.cs b/src/Examples/JsonApiDotNetCoreExample/Program.cs
index a65563c681..52b27759e9 100644
--- a/src/Examples/JsonApiDotNetCoreExample/Program.cs
+++ b/src/Examples/JsonApiDotNetCoreExample/Program.cs
@@ -4,10 +4,12 @@
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Diagnostics;
using JsonApiDotNetCoreExample.Data;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.DependencyInjection.Extensions;
+#if NET6_0
+using Microsoft.AspNetCore.Authentication;
+#endif
[assembly: ExcludeFromCodeCoverage]
@@ -45,7 +47,11 @@ static void ConfigureServices(WebApplicationBuilder builder)
{
using IDisposable _ = CodeTimingSessionManager.Current.Measure("Configure services");
+#if NET6_0
builder.Services.TryAddSingleton();
+#else
+ builder.Services.TryAddSingleton(TimeProvider.System);
+#endif
builder.Services.AddDbContext(options =>
{
diff --git a/src/Examples/MultiDbContextExample/MultiDbContextExample.csproj b/src/Examples/MultiDbContextExample/MultiDbContextExample.csproj
index 9e0c80b7f4..1f4645f323 100644
--- a/src/Examples/MultiDbContextExample/MultiDbContextExample.csproj
+++ b/src/Examples/MultiDbContextExample/MultiDbContextExample.csproj
@@ -1,8 +1,10 @@
- $(TargetFrameworkName)
+ net8.0;net6.0
+
+
- $(TargetFrameworkName)
+ net8.0;net6.0
+
+
- $(TargetFrameworkName)
+ net8.0;net6.0
+
+
-
-
-
-
-
diff --git a/src/JsonApiDotNetCore.Annotations/JsonApiDotNetCore.Annotations.csproj b/src/JsonApiDotNetCore.Annotations/JsonApiDotNetCore.Annotations.csproj
index 48ca676b4a..1b93c24975 100644
--- a/src/JsonApiDotNetCore.Annotations/JsonApiDotNetCore.Annotations.csproj
+++ b/src/JsonApiDotNetCore.Annotations/JsonApiDotNetCore.Annotations.csproj
@@ -1,12 +1,13 @@
- $(TargetFrameworkName);netstandard1.0
+ net8.0;net6.0;netstandard1.0
true
true
JsonApiDotNetCore
- latest
+
+
$(JsonApiDotNetCoreVersionPrefix)
jsonapidotnetcore;jsonapi;json:api;dotnet;asp.net;rest;web-api
diff --git a/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj b/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj
index ca6de1a5b7..f784ada6f9 100644
--- a/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj
+++ b/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj
@@ -5,10 +5,11 @@
true
false
$(NoWarn);NU5128
- latest
true
+
+
$(JsonApiDotNetCoreVersionPrefix)
jsonapidotnetcore;jsonapi;json:api;dotnet;asp.net;rest;web-api
diff --git a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj
index 4407edaf1f..1757b54a82 100644
--- a/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj
+++ b/src/JsonApiDotNetCore/JsonApiDotNetCore.csproj
@@ -1,10 +1,12 @@
- $(TargetFrameworkName)
+ net8.0;net6.0
true
true
+
+
$(JsonApiDotNetCoreVersionPrefix)
jsonapidotnetcore;jsonapi;json:api;dotnet;asp.net;rest;web-api
diff --git a/src/JsonApiDotNetCore/Serialization/Response/FingerprintGenerator.cs b/src/JsonApiDotNetCore/Serialization/Response/FingerprintGenerator.cs
index e0b3e56b10..3ecc0b2c5a 100644
--- a/src/JsonApiDotNetCore/Serialization/Response/FingerprintGenerator.cs
+++ b/src/JsonApiDotNetCore/Serialization/Response/FingerprintGenerator.cs
@@ -6,7 +6,11 @@ namespace JsonApiDotNetCore.Serialization.Response;
///
internal sealed class FingerprintGenerator : IFingerprintGenerator
{
+#if NET6_0
private static readonly byte[] Separator = Encoding.UTF8.GetBytes("|");
+#else
+ private static readonly byte[] Separator = "|"u8.ToArray();
+#endif
private static readonly uint[] LookupTable = Enumerable.Range(0, 256).Select(ToLookupEntry).ToArray();
private static uint ToLookupEntry(int index)
diff --git a/test/AnnotationTests/AnnotationTests.csproj b/test/AnnotationTests/AnnotationTests.csproj
index b712b1bb67..081046adb0 100644
--- a/test/AnnotationTests/AnnotationTests.csproj
+++ b/test/AnnotationTests/AnnotationTests.csproj
@@ -1,9 +1,10 @@
- $(TargetFrameworkName);netstandard2.0
- latest
+ net8.0;net6.0;netstandard2.0
+
+
diff --git a/test/DapperTests/DapperTests.csproj b/test/DapperTests/DapperTests.csproj
index c7ce96a37a..45d9c6a88d 100644
--- a/test/DapperTests/DapperTests.csproj
+++ b/test/DapperTests/DapperTests.csproj
@@ -1,8 +1,10 @@
- $(TargetFrameworkName)
+ net8.0;net6.0
+
+
diff --git a/test/DapperTests/IntegrationTests/DapperTestContext.cs b/test/DapperTests/IntegrationTests/DapperTestContext.cs
index 084444e896..0257490065 100644
--- a/test/DapperTests/IntegrationTests/DapperTestContext.cs
+++ b/test/DapperTests/IntegrationTests/DapperTestContext.cs
@@ -8,7 +8,6 @@
using FluentAssertions.Extensions;
using JetBrains.Annotations;
using JsonApiDotNetCore.Configuration;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.EntityFrameworkCore;
@@ -17,6 +16,7 @@
using Microsoft.Extensions.Logging;
using TestBuildingBlocks;
using Xunit.Abstractions;
+using IClock = DapperExample.IClock;
namespace DapperTests.IntegrationTests;
@@ -74,7 +74,7 @@ private WebApplicationFactory CreateFactory()
builder.ConfigureServices(services =>
{
- services.AddSingleton(new FrozenSystemClock
+ services.AddSingleton(new FrozenClock
{
UtcNow = FrozenTime
});
@@ -114,7 +114,10 @@ public async Task ClearAllTablesAsync(DbContext dbContext)
_ => throw new NotSupportedException($"Unsupported database provider '{databaseProvider}'.")
};
+#pragma warning disable EF1002 // Risk of vulnerability to SQL injection.
+ // Justification: Table names cannot be parameterized.
await dbContext.Database.ExecuteSqlRawAsync($"DELETE FROM {escapedTableName}");
+#pragma warning restore EF1002 // Risk of vulnerability to SQL injection.
}
}
}
diff --git a/test/DapperTests/IntegrationTests/FrozenClock.cs b/test/DapperTests/IntegrationTests/FrozenClock.cs
new file mode 100644
index 0000000000..0de2390b71
--- /dev/null
+++ b/test/DapperTests/IntegrationTests/FrozenClock.cs
@@ -0,0 +1,11 @@
+using DapperExample;
+using FluentAssertions.Extensions;
+
+namespace DapperTests.IntegrationTests;
+
+internal sealed class FrozenClock : IClock
+{
+ private static readonly DateTimeOffset DefaultTime = 1.January(2020).At(1, 1, 1).AsUtc();
+
+ public DateTimeOffset UtcNow { get; set; } = DefaultTime;
+}
diff --git a/test/DiscoveryTests/DiscoveryTests.csproj b/test/DiscoveryTests/DiscoveryTests.csproj
index a09e322203..a64d3be689 100644
--- a/test/DiscoveryTests/DiscoveryTests.csproj
+++ b/test/DiscoveryTests/DiscoveryTests.csproj
@@ -1,8 +1,10 @@
- $(TargetFrameworkName)
+ net8.0;net6.0
+
+
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs
index 99b3b3bc5b..5639d44f40 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs
@@ -3,7 +3,6 @@
using FluentAssertions.Extensions;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Serialization.Objects;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using TestBuildingBlocks;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs
index 5bd4acb39e..62013322e5 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs
@@ -2,7 +2,6 @@
using FluentAssertions;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Serialization.Objects;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
using TestBuildingBlocks;
using Xunit;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/DateMustBeInThePastAttribute.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/DateMustBeInThePastAttribute.cs
index 0421f2e396..b273eca898 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/DateMustBeInThePastAttribute.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/DateMustBeInThePastAttribute.cs
@@ -1,8 +1,8 @@
using System.ComponentModel.DataAnnotations;
using System.Reflection;
using JsonApiDotNetCore.Resources;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
+using TestBuildingBlocks;
namespace JsonApiDotNetCoreTests.IntegrationTests.AtomicOperations;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Meta/AtomicResourceMetaTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Meta/AtomicResourceMetaTests.cs
index 3edb88b14a..f98bc1b49d 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Meta/AtomicResourceMetaTests.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Meta/AtomicResourceMetaTests.cs
@@ -4,7 +4,6 @@
using FluentAssertions.Extensions;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Serialization.Objects;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
using TestBuildingBlocks;
using Xunit;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ModelStateValidation/AtomicModelStateValidationTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ModelStateValidation/AtomicModelStateValidationTests.cs
index 4a8b7d9e52..98564f3a57 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ModelStateValidation/AtomicModelStateValidationTests.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ModelStateValidation/AtomicModelStateValidationTests.cs
@@ -1,7 +1,6 @@
using System.Net;
using FluentAssertions;
using JsonApiDotNetCore.Serialization.Objects;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using TestBuildingBlocks;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/QueryStrings/AtomicQueryStringTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/QueryStrings/AtomicQueryStringTests.cs
index a9d0fbd44b..6db0926773 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/QueryStrings/AtomicQueryStringTests.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/QueryStrings/AtomicQueryStringTests.cs
@@ -2,7 +2,6 @@
using FluentAssertions;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Serialization.Objects;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
using TestBuildingBlocks;
using Xunit;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/QueryStrings/MusicTrackReleaseDefinition.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/QueryStrings/MusicTrackReleaseDefinition.cs
index 65ab4a4344..84827322ad 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/QueryStrings/MusicTrackReleaseDefinition.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/QueryStrings/MusicTrackReleaseDefinition.cs
@@ -2,8 +2,8 @@
using JsonApiDotNetCore;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Resources;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Primitives;
+using TestBuildingBlocks;
namespace JsonApiDotNetCoreTests.IntegrationTests.AtomicOperations.QueryStrings;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs
index 0af67d4c20..943d2d9bb4 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs
@@ -3,7 +3,6 @@
using FluentAssertions.Extensions;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Serialization.Objects;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using TestBuildingBlocks;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/ApiControllerAttributeTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/ApiControllerAttributeTests.cs
index 28e6ba2439..a27ef77329 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().StartWith("https://tools.ietf.org/html/rfc");
}
[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().StartWith("https://tools.ietf.org/html/rfc");
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().StartWith("https://tools.ietf.org/html/rfc");
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();
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/ModelStateValidationTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/ModelStateValidationTests.cs
index 55e293aab1..e6e83fa7c3 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/ModelStateValidationTests.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/ModelStateValidationTests.cs
@@ -1,9 +1,11 @@
using System.Net;
using FluentAssertions;
using JsonApiDotNetCore.Serialization.Objects;
-using Microsoft.Extensions.DependencyInjection;
using TestBuildingBlocks;
using Xunit;
+#if NET6_0
+using Microsoft.Extensions.DependencyInjection;
+#endif
namespace JsonApiDotNetCoreTests.IntegrationTests.InputValidation.ModelState;
@@ -19,11 +21,13 @@ public ModelStateValidationTests(IntegrationTestContext();
testContext.UseController();
+#if NET6_0
testContext.ConfigureServices(services =>
{
// Polyfill for missing DateOnly/TimeOnly support in .NET 6 ModelState validation.
services.AddDateOnlyTimeOnlyStringConverters();
});
+#endif
}
[Fact]
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/FilterRewritingResourceDefinition.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/FilterRewritingResourceDefinition.cs
index 138ccdeafd..c3e5941a19 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/FilterRewritingResourceDefinition.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/FilterRewritingResourceDefinition.cs
@@ -2,7 +2,7 @@
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Queries.Expressions;
using JsonApiDotNetCore.Resources;
-using Microsoft.AspNetCore.Authentication;
+using TestBuildingBlocks;
namespace JsonApiDotNetCoreTests.IntegrationTests.QueryStrings.CustomFunctions.TimeOffset;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/FilterTimeOffsetRewriter.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/FilterTimeOffsetRewriter.cs
index 8adc07fdf0..2d2ee4da89 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/FilterTimeOffsetRewriter.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/FilterTimeOffsetRewriter.cs
@@ -1,5 +1,5 @@
using JsonApiDotNetCore.Queries.Expressions;
-using Microsoft.AspNetCore.Authentication;
+using TestBuildingBlocks;
namespace JsonApiDotNetCoreTests.IntegrationTests.QueryStrings.CustomFunctions.TimeOffset;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/TimeOffsetTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/TimeOffsetTests.cs
index baec74602b..8b8062674c 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/TimeOffsetTests.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/TimeOffsetTests.cs
@@ -6,7 +6,6 @@
using JsonApiDotNetCore.Queries.Parsing;
using JsonApiDotNetCore.Resources;
using JsonApiDotNetCore.Serialization.Objects;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
using TestBuildingBlocks;
using Xunit;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/GiftCertificate.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/GiftCertificate.cs
index 2cd1ff91d8..6da63a30cb 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/GiftCertificate.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/GiftCertificate.cs
@@ -2,7 +2,7 @@
using JetBrains.Annotations;
using JsonApiDotNetCore.Resources;
using JsonApiDotNetCore.Resources.Annotations;
-using Microsoft.AspNetCore.Authentication;
+using TestBuildingBlocks;
namespace JsonApiDotNetCoreTests.IntegrationTests.ResourceConstructorInjection;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/InjectionDbContext.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/InjectionDbContext.cs
index bb3bbfd85b..57ec534cae 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/InjectionDbContext.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/InjectionDbContext.cs
@@ -1,6 +1,5 @@
using JetBrains.Annotations;
using JsonApiDotNetCore;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
using TestBuildingBlocks;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/PostOffice.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/PostOffice.cs
index da163d9cee..f7bd504cd8 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/PostOffice.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/PostOffice.cs
@@ -2,7 +2,7 @@
using JetBrains.Annotations;
using JsonApiDotNetCore.Resources;
using JsonApiDotNetCore.Resources.Annotations;
-using Microsoft.AspNetCore.Authentication;
+using TestBuildingBlocks;
namespace JsonApiDotNetCoreTests.IntegrationTests.ResourceConstructorInjection;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/ResourceInjectionTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/ResourceInjectionTests.cs
index 403f86757b..7dd8c92726 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/ResourceInjectionTests.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/ResourceInjectionTests.cs
@@ -2,7 +2,6 @@
using FluentAssertions;
using FluentAssertions.Extensions;
using JsonApiDotNetCore.Serialization.Objects;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using TestBuildingBlocks;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/SoftDeletion/SoftDeletionAwareResourceService.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/SoftDeletion/SoftDeletionAwareResourceService.cs
index 299a40bad8..2b6e3be294 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/SoftDeletion/SoftDeletionAwareResourceService.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/SoftDeletion/SoftDeletionAwareResourceService.cs
@@ -5,8 +5,8 @@
using JsonApiDotNetCore.Repositories;
using JsonApiDotNetCore.Resources;
using JsonApiDotNetCore.Services;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Logging;
+using TestBuildingBlocks;
namespace JsonApiDotNetCoreTests.IntegrationTests.SoftDeletion;
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/SoftDeletion/SoftDeletionTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/SoftDeletion/SoftDeletionTests.cs
index f750826f8c..7bd7fe66f1 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/SoftDeletion/SoftDeletionTests.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/SoftDeletion/SoftDeletionTests.cs
@@ -3,7 +3,6 @@
using FluentAssertions.Extensions;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Serialization.Objects;
-using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using TestBuildingBlocks;
diff --git a/test/JsonApiDotNetCoreTests/JsonApiDotNetCoreTests.csproj b/test/JsonApiDotNetCoreTests/JsonApiDotNetCoreTests.csproj
index 7a3fa8ddf8..38d665aa5b 100644
--- a/test/JsonApiDotNetCoreTests/JsonApiDotNetCoreTests.csproj
+++ b/test/JsonApiDotNetCoreTests/JsonApiDotNetCoreTests.csproj
@@ -1,8 +1,10 @@
- $(TargetFrameworkName)
+ net8.0;net6.0
+
+
-
+
diff --git a/test/MultiDbContextTests/MultiDbContextTests.csproj b/test/MultiDbContextTests/MultiDbContextTests.csproj
index 394d72e2d2..54497bfada 100644
--- a/test/MultiDbContextTests/MultiDbContextTests.csproj
+++ b/test/MultiDbContextTests/MultiDbContextTests.csproj
@@ -1,8 +1,10 @@
- $(TargetFrameworkName)
+ net8.0;net6.0
+
+
diff --git a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj
index 84a36dcbb1..080666d491 100644
--- a/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj
+++ b/test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj
@@ -1,8 +1,10 @@
- $(TargetFrameworkName)
+ net8.0;net6.0
+
+
diff --git a/test/NoEntityFrameworkTests/NullSafeExpressionRewriterTests.cs b/test/NoEntityFrameworkTests/NullSafeExpressionRewriterTests.cs
index 57da032819..e8fe1585ca 100644
--- a/test/NoEntityFrameworkTests/NullSafeExpressionRewriterTests.cs
+++ b/test/NoEntityFrameworkTests/NullSafeExpressionRewriterTests.cs
@@ -498,7 +498,11 @@ public void Can_rewrite_order_by_clause_with_IntPtr()
Parent = new TestResource
{
Id = generator.GetNext(),
+#if NET6_0
Pointer = (IntPtr)1
+#else
+ Pointer = 1
+#endif
}
}
};
diff --git a/test/SourceGeneratorTests/SourceGeneratorTests.csproj b/test/SourceGeneratorTests/SourceGeneratorTests.csproj
index d361de38e5..e28bdc20d1 100644
--- a/test/SourceGeneratorTests/SourceGeneratorTests.csproj
+++ b/test/SourceGeneratorTests/SourceGeneratorTests.csproj
@@ -1,8 +1,10 @@
- $(TargetFrameworkName)
+ net8.0;net6.0
+
+
diff --git a/test/TestBuildingBlocks/DbContextExtensions.cs b/test/TestBuildingBlocks/DbContextExtensions.cs
index 7f32073874..d3a8a0e8ad 100644
--- a/test/TestBuildingBlocks/DbContextExtensions.cs
+++ b/test/TestBuildingBlocks/DbContextExtensions.cs
@@ -44,7 +44,10 @@ private static async Task ClearTablesAsync(this DbContext dbContext, params Type
}
else
{
+#pragma warning disable EF1002 // Risk of vulnerability to SQL injection.
+ // Justification: Table names cannot be parameterized.
await dbContext.Database.ExecuteSqlRawAsync($"DELETE FROM \"{tableName}\"");
+#pragma warning restore EF1002 // Risk of vulnerability to SQL injection.
}
}
}
diff --git a/test/TestBuildingBlocks/FrozenSystemClock.cs b/test/TestBuildingBlocks/FrozenSystemClock.cs
index a1d85e1fcc..6ffe8feaaf 100644
--- a/test/TestBuildingBlocks/FrozenSystemClock.cs
+++ b/test/TestBuildingBlocks/FrozenSystemClock.cs
@@ -1,5 +1,4 @@
using FluentAssertions.Extensions;
-using Microsoft.AspNetCore.Authentication;
namespace TestBuildingBlocks;
diff --git a/test/TestBuildingBlocks/ISystemClock.cs b/test/TestBuildingBlocks/ISystemClock.cs
new file mode 100644
index 0000000000..eb1c8628a3
--- /dev/null
+++ b/test/TestBuildingBlocks/ISystemClock.cs
@@ -0,0 +1,6 @@
+namespace TestBuildingBlocks;
+
+public interface ISystemClock
+{
+ DateTimeOffset UtcNow { get; }
+}
diff --git a/test/TestBuildingBlocks/TestBuildingBlocks.csproj b/test/TestBuildingBlocks/TestBuildingBlocks.csproj
index ba9a2f5da3..ae6cf32ff6 100644
--- a/test/TestBuildingBlocks/TestBuildingBlocks.csproj
+++ b/test/TestBuildingBlocks/TestBuildingBlocks.csproj
@@ -1,8 +1,10 @@
- $(TargetFrameworkName)
+ net8.0;net6.0
+
+
@@ -15,7 +17,7 @@
-
+
diff --git a/test/UnitTests/UnitTests.csproj b/test/UnitTests/UnitTests.csproj
index f8dcbce984..99fc7ce781 100644
--- a/test/UnitTests/UnitTests.csproj
+++ b/test/UnitTests/UnitTests.csproj
@@ -1,8 +1,10 @@
- $(TargetFrameworkName)
+ net8.0;net6.0
+
+
From d1a36649743a0a420a1e806079a61e5339510796 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Fri, 17 Nov 2023 15:14:56 +0100
Subject: [PATCH 02/16] Create codeql.yml
---
.github/workflows/codeql.yml | 43 ++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 .github/workflows/codeql.yml
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
new file mode 100644
index 0000000000..5b1868eae5
--- /dev/null
+++ b/.github/workflows/codeql.yml
@@ -0,0 +1,43 @@
+name: "CodeQL"
+
+on:
+ push:
+ branches: [ 'master', 'release/**' ]
+ pull_request:
+ # The branches below must be a subset of the branches above
+ branches: [ 'master', 'release/**' ]
+ schedule:
+ - cron: '0 0 * * 5'
+
+jobs:
+ analyze:
+ name: Analyze
+ runs-on: 'ubuntu-latest'
+ timeout-minutes: 60
+ permissions:
+ actions: read
+ contents: read
+ security-events: write
+ strategy:
+ fail-fast: false
+ matrix:
+ language: [ 'csharp' ]
+ steps:
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: |
+ 6.0.x
+ 8.0.x
+ - name: Git checkout
+ uses: actions/checkout@v4
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v2
+ with:
+ languages: ${{ matrix.language }}
+ - name: Autobuild
+ uses: github/codeql-action/autobuild@v2
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v2
+ with:
+ category: "/language:${{matrix.language}}"
From f3f382a9ac74481dab2e11e11e38c88dc11ea6a7 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Fri, 17 Nov 2023 15:50:10 +0100
Subject: [PATCH 03/16] Revert "Workaround failure while installing latest
PowerShell that requires .NET 8"
This reverts commit 4d2ffd893b4c33d0a5503ae755941bbb5279326b.
---
.github/workflows/build.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e907bbbc02..ca7042c976 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -53,8 +53,7 @@ jobs:
- name: Setup PowerShell (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
- # Temporary version downgrade because .NET 8 is not installed on runner.
- dotnet tool install --global PowerShell --version 7.3.10
+ dotnet tool install --global PowerShell
- name: Find latest PowerShell version (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
From 875ac5484acf49cde842e75d43a482a801c22a53 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Sat, 18 Nov 2023 19:05:43 +0100
Subject: [PATCH 04/16] Resharper: Use collection expression
---
JsonApiDotNetCore.sln.DotSettings | 3 +
WarningSeverities.DotSettings | 2 +
.../DapperExample/Data/RotatingList.cs | 2 +-
.../Definitions/TodoItemDefinition.cs | 5 +-
.../Repositories/DapperFacade.cs | 4 +-
.../Repositories/ResourceChangeDetector.cs | 22 +++---
.../Repositories/ResultSetMapper.cs | 12 +--
.../Repositories/SqlCaptureStore.cs | 2 +-
.../Builders/InsertStatementBuilder.cs | 2 +-
.../Builders/SelectStatementBuilder.cs | 36 ++++-----
.../Builders/SqlQueryBuilder.cs | 10 +--
.../UpdateResourceStatementBuilder.cs | 2 +-
.../DataModel/BaseDataModelService.cs | 4 +-
.../DataModel/FromEntitiesDataModelService.cs | 4 +-
.../TranslationToSql/ParameterFormatter.cs | 6 +-
.../ColumnSelectorUsageCollector.cs | 2 +-
.../StaleColumnReferenceRewriter.cs | 4 +-
.../UnusedSelectorsRewriter.cs | 4 +-
.../TranslationToSql/TreeNodes/SelectNode.cs | 2 +-
.../TranslationToSql/TreeNodes/TableNode.cs | 2 +-
.../Controllers/NonJsonApiController.cs | 5 +-
.../Data/RotatingList.cs | 2 +-
.../Definitions/TodoItemDefinition.cs | 5 +-
.../NoEntityFrameworkExample/Data/Database.cs | 26 +++----
.../NullSafeExpressionRewriter.cs | 4 +-
.../Configuration/ResourceType.cs | 8 +-
.../ObjectExtensions.cs | 15 +---
.../ResourceDescriptorAssemblyCache.cs | 2 +-
.../Configuration/ResourceGraph.cs | 4 +-
.../Configuration/ResourceGraphBuilder.cs | 8 +-
.../Configuration/ServiceDiscoveryFacade.cs | 17 ++--
.../Diagnostics/CascadingCodeTimer.cs | 2 +-
.../Errors/InvalidModelStateException.cs | 2 +-
.../Middleware/JsonApiRoutingConvention.cs | 6 +-
.../Expressions/IncludeChainConverter.cs | 2 +-
.../Queries/Parsing/FilterParser.cs | 6 +-
.../Queries/Parsing/IncludeParser.cs | 4 +-
.../QueryableBuilding/IncludeClauseBuilder.cs | 2 +-
.../QueryableBuilding/LambdaScopeFactory.cs | 2 +-
.../QueryStrings/FieldChains/MatchState.cs | 2 +-
.../FieldChains/MatchTraceScope.cs | 2 +-
.../FieldChains/PatternMatcher.cs | 2 +-
.../QueryStrings/FieldChains/PatternParser.cs | 6 +-
.../FilterQueryStringParameterReader.cs | 2 +-
.../PaginationQueryStringParameterReader.cs | 2 +-
...ourceDefinitionQueryableParameterReader.cs | 2 +-
.../SortQueryStringParameterReader.cs | 2 +-
.../Resources/TargetedFields.cs | 4 +-
.../Serialization/Response/MetaBuilder.cs | 2 +-
.../Response/ResourceObjectTreeNode.cs | 8 +-
.../UnitTests/SqlTreeNodeVisitorTests.cs | 4 +-
.../ServiceDiscoveryFacadeTests.cs | 2 +-
.../AtomicAddToToManyRelationshipTests.cs | 4 +-
...AtomicRemoveFromToManyRelationshipTests.cs | 4 +-
.../AtomicReplaceToManyRelationshipTests.cs | 4 +-
.../AtomicReplaceToManyRelationshipTests.cs | 4 +-
.../Authorization/Scopes/AuthScopeSet.cs | 2 +-
.../IdObfuscation/HexadecimalCodec.cs | 2 +-
.../Microservices/MessagingGroupDefinition.cs | 2 +-
.../Microservices/MessagingUserDefinition.cs | 2 +-
.../NonJsonApiController.cs | 6 +-
.../CustomFunctions/Sum/SumFilterParser.cs | 6 +-
.../SparseFieldSets/ResourceCaptureStore.cs | 2 +-
.../Reading/StarDefinition.cs | 5 +-
.../WheelSortDefinition.cs | 5 +-
.../Serialization/SerializationFakers.cs | 4 +-
.../Serialization/SerializationTests.cs | 2 +-
.../TestableQueryExpressionRewriter.cs | 2 +-
.../CreateSortExpressionFromLambdaTests.cs | 78 ++++++-------------
.../CompilationBuilder.cs | 4 +-
.../SourceGeneratorTests/SourceCodeBuilder.cs | 2 +-
test/TestBuildingBlocks/FakeLoggerFactory.cs | 2 +-
.../IgnoreLineEndingsComparer.cs | 4 +-
73 files changed, 193 insertions(+), 245 deletions(-)
diff --git a/JsonApiDotNetCore.sln.DotSettings b/JsonApiDotNetCore.sln.DotSettings
index bf7a5182f0..64125e085d 100644
--- a/JsonApiDotNetCore.sln.DotSettings
+++ b/JsonApiDotNetCore.sln.DotSettings
@@ -93,6 +93,7 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$);
SUGGESTION
SUGGESTION
WARNING
+ SUGGESTION
<?xml version="1.0" encoding="utf-16"?><Profile name="JADNC Full Cleanup"><XMLReformatCode>True</XMLReformatCode><CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="True" AddMissingParentheses="True" ArrangeBraces="True" ArrangeAttributes="True" ArrangeArgumentsStyle="True" ArrangeCodeBodyStyle="True" ArrangeVarStyle="True" ArrangeTrailingCommas="True" ArrangeObjectCreation="True" ArrangeDefaultValue="True" ArrangeNamespaces="True" ArrangeNullCheckingPattern="True" /><CssAlphabetizeProperties>True</CssAlphabetizeProperties><JsInsertSemicolon>True</JsInsertSemicolon><FormatAttributeQuoteDescriptor>True</FormatAttributeQuoteDescriptor><CorrectVariableKindsDescriptor>True</CorrectVariableKindsDescriptor><VariablesToInnerScopesDescriptor>True</VariablesToInnerScopesDescriptor><StringToTemplatesDescriptor>True</StringToTemplatesDescriptor><JsReformatCode>True</JsReformatCode><JsFormatDocComments>True</JsFormatDocComments><RemoveRedundantQualifiersTs>True</RemoveRedundantQualifiersTs><OptimizeImportsTs>True</OptimizeImportsTs><OptimizeReferenceCommentsTs>True</OptimizeReferenceCommentsTs><PublicModifierStyleTs>True</PublicModifierStyleTs><ExplicitAnyTs>True</ExplicitAnyTs><TypeAnnotationStyleTs>True</TypeAnnotationStyleTs><RelativePathStyleTs>True</RelativePathStyleTs><AsInsteadOfCastTs>True</AsInsteadOfCastTs><HtmlReformatCode>True</HtmlReformatCode><AspOptimizeRegisterDirectives>True</AspOptimizeRegisterDirectives><RemoveCodeRedundancies>True</RemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSMakeAutoPropertyGetOnly>True</CSMakeAutoPropertyGetOnly><CSArrangeQualifiers>True</CSArrangeQualifiers><CSFixBuiltinTypeReferences>True</CSFixBuiltinTypeReferences><CssReformatCode>True</CssReformatCode><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><CSReformatCode>True</CSReformatCode><CSharpFormatDocComments>True</CSharpFormatDocComments><CSReorderTypeMembers>True</CSReorderTypeMembers><XAMLCollapseEmptyTags>False</XAMLCollapseEmptyTags><CSReformatInactiveBranches>True</CSReformatInactiveBranches></Profile>
JADNC Full Cleanup
Required
@@ -125,6 +126,7 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$);
False
False
True
+ 1
NEVER
NEVER
False
@@ -145,6 +147,7 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$);
True
WRAP_IF_LONG
160
+ CHOP_IF_LONG
WRAP_IF_LONG
CHOP_ALWAYS
CHOP_ALWAYS
diff --git a/WarningSeverities.DotSettings b/WarningSeverities.DotSettings
index 96f358da23..b5e5ca9c42 100644
--- a/WarningSeverities.DotSettings
+++ b/WarningSeverities.DotSettings
@@ -240,6 +240,7 @@
WARNING
WARNING
WARNING
+ WARNING
WARNING
WARNING
WARNING
@@ -264,4 +265,5 @@
WARNING
WARNING
WARNING
+ WARNING
\ No newline at end of file
diff --git a/src/Examples/DapperExample/Data/RotatingList.cs b/src/Examples/DapperExample/Data/RotatingList.cs
index 3fa04762a3..67c19bea4a 100644
--- a/src/Examples/DapperExample/Data/RotatingList.cs
+++ b/src/Examples/DapperExample/Data/RotatingList.cs
@@ -4,7 +4,7 @@ internal abstract class RotatingList
{
public static RotatingList Create(int count, Func createElement)
{
- List elements = new();
+ List elements = [];
for (int index = 0; index < count; index++)
{
diff --git a/src/Examples/DapperExample/Definitions/TodoItemDefinition.cs b/src/Examples/DapperExample/Definitions/TodoItemDefinition.cs
index 6fed60fadd..dc7c1802c8 100644
--- a/src/Examples/DapperExample/Definitions/TodoItemDefinition.cs
+++ b/src/Examples/DapperExample/Definitions/TodoItemDefinition.cs
@@ -29,11 +29,10 @@ public override SortExpression OnApplySort(SortExpression? existingSort)
private SortExpression GetDefaultSortOrder()
{
- return CreateSortExpressionFromLambda(new PropertySortOrder
- {
+ return CreateSortExpressionFromLambda([
(todoItem => todoItem.Priority, ListSortDirection.Ascending),
(todoItem => todoItem.LastModifiedAt, ListSortDirection.Descending)
- });
+ ]);
}
public override Task OnWritingAsync(TodoItem resource, WriteOperationKind writeOperation, CancellationToken cancellationToken)
diff --git a/src/Examples/DapperExample/Repositories/DapperFacade.cs b/src/Examples/DapperExample/Repositories/DapperFacade.cs
index d3247967f9..4d30e430c7 100644
--- a/src/Examples/DapperExample/Repositories/DapperFacade.cs
+++ b/src/Examples/DapperExample/Repositories/DapperFacade.cs
@@ -38,7 +38,7 @@ public IReadOnlyCollection BuildSqlCommandsForOneToOneRelatio
{
ArgumentGuard.NotNull(changeDetector);
- List sqlCommands = new();
+ List sqlCommands = [];
foreach ((HasOneAttribute relationship, (object? currentRightId, object newRightId)) in changeDetector.GetOneToOneRelationshipsChangedToNotNull())
{
@@ -81,7 +81,7 @@ public IReadOnlyCollection BuildSqlCommandsForChangedRelation
{
ArgumentGuard.NotNull(changeDetector);
- List sqlCommands = new();
+ List sqlCommands = [];
foreach ((HasOneAttribute hasOneRelationship, (object? currentRightId, object? newRightId)) in changeDetector
.GetChangedToOneRelationshipsWithForeignKeyAtRightSide())
diff --git a/src/Examples/DapperExample/Repositories/ResourceChangeDetector.cs b/src/Examples/DapperExample/Repositories/ResourceChangeDetector.cs
index bd6537b547..1d9b998340 100644
--- a/src/Examples/DapperExample/Repositories/ResourceChangeDetector.cs
+++ b/src/Examples/DapperExample/Repositories/ResourceChangeDetector.cs
@@ -15,11 +15,11 @@ internal sealed class ResourceChangeDetector
private readonly CollectionConverter _collectionConverter = new();
private readonly IDataModelService _dataModelService;
- private Dictionary _currentColumnValues = new();
- private Dictionary _newColumnValues = new();
+ private Dictionary _currentColumnValues = [];
+ private Dictionary _newColumnValues = [];
- private Dictionary> _currentRightResourcesByRelationship = new();
- private Dictionary> _newRightResourcesByRelationship = new();
+ private Dictionary> _currentRightResourcesByRelationship = [];
+ private Dictionary> _newRightResourcesByRelationship = [];
public ResourceType ResourceType { get; }
@@ -52,7 +52,7 @@ public void CaptureNewValues(IIdentifiable resource)
private Dictionary CaptureColumnValues(IIdentifiable resource)
{
- Dictionary columnValues = new();
+ Dictionary columnValues = [];
foreach ((string columnName, ResourceFieldAttribute? _) in _dataModelService.GetColumnMappings(ResourceType))
{
@@ -64,7 +64,7 @@ public void CaptureNewValues(IIdentifiable resource)
private Dictionary> CaptureRightResourcesByRelationship(IIdentifiable resource)
{
- Dictionary> relationshipValues = new();
+ Dictionary> relationshipValues = [];
foreach (RelationshipAttribute relationship in ResourceType.Relationships)
{
@@ -107,7 +107,7 @@ public void AssertIsNotClearingAnyRequiredToOneRelationships(string resourceName
public IReadOnlyDictionary GetOneToOneRelationshipsChangedToNotNull()
{
- Dictionary changes = new();
+ Dictionary changes = [];
foreach ((RelationshipAttribute relationship, ISet newRightResources) in _newRightResourcesByRelationship)
{
@@ -135,7 +135,7 @@ public void AssertIsNotClearingAnyRequiredToOneRelationships(string resourceName
public IReadOnlyDictionary GetChangedColumnValues()
{
- Dictionary changes = new();
+ Dictionary changes = [];
foreach ((string columnName, object? newColumnValue) in _newColumnValues)
{
@@ -152,7 +152,7 @@ public void AssertIsNotClearingAnyRequiredToOneRelationships(string resourceName
public IReadOnlyDictionary GetChangedToOneRelationshipsWithForeignKeyAtRightSide()
{
- Dictionary changes = new();
+ Dictionary changes = [];
foreach ((RelationshipAttribute relationship, ISet newRightResources) in _newRightResourcesByRelationship)
{
@@ -183,7 +183,7 @@ public void AssertIsNotClearingAnyRequiredToOneRelationships(string resourceName
public IReadOnlyDictionary currentRightIds, ISet