diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index 18b3998447..9271d4ee81 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
- "version": "2024.2.7",
+ "version": "2024.3.3",
"commands": [
"jb"
],
@@ -17,21 +17,21 @@
"rollForward": false
},
"dotnet-reportgenerator-globaltool": {
- "version": "5.3.11",
+ "version": "5.4.2",
"commands": [
"reportgenerator"
],
"rollForward": false
},
"docfx": {
- "version": "2.77.0",
+ "version": "2.78.2",
"commands": [
"docfx"
],
"rollForward": false
},
"microsoft.openapi.kiota": {
- "version": "1.19.1",
+ "version": "1.21.0",
"commands": [
"kiota"
],
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 8f8e5d2437..318240aed7 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -46,8 +46,8 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
- 6.0.x
8.0.x
+ 9.0.x
- name: Show installed versions
shell: pwsh
run: |
@@ -164,8 +164,8 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
- 6.0.x
8.0.x
+ 9.0.x
- name: Git checkout
uses: actions/checkout@v4
- name: Restore tools
@@ -219,8 +219,8 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
- 6.0.x
8.0.x
+ 9.0.x
- name: Git checkout
uses: actions/checkout@v4
with:
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
index 55d430a67c..3bdc622297 100644
--- a/.github/workflows/codeql.yml
+++ b/.github/workflows/codeql.yml
@@ -27,8 +27,8 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
- 6.0.x
8.0.x
+ 9.0.x
- name: Git checkout
uses: actions/checkout@v4
- name: Initialize CodeQL
diff --git a/Build.ps1 b/Build.ps1
index 3abc926e6a..0b2bbb40f1 100644
--- a/Build.ps1
+++ b/Build.ps1
@@ -19,7 +19,7 @@ VerifySuccessExitCode
dotnet build --configuration Release /p:VersionSuffix=$versionSuffix
VerifySuccessExitCode
-dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage"
+dotnet test --no-build --configuration Release --verbosity quiet --collect:"XPlat Code Coverage"
VerifySuccessExitCode
dotnet reportgenerator -reports:**\coverage.cobertura.xml -targetdir:artifacts\coverage -filefilters:-*.g.cs
diff --git a/Directory.Build.props b/Directory.Build.props
index dc48433409..eeaaba8d16 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -24,6 +24,9 @@
-->
IDE0028;IDE0300;IDE0301;IDE0302;IDE0303;IDE0304;IDE0305
$(NoWarn);$(UseCollectionExpressionRules)
+
+
+ $(NoWarn);NETSDK1215
@@ -49,13 +52,8 @@
$(NoWarn);CA1062
-
-
- $(NoWarn);SYSLIB1006
-
-
-
+
diff --git a/JsonApiDotNetCore.sln.DotSettings b/JsonApiDotNetCore.sln.DotSettings
index 7cbbf82351..0d32615a65 100644
--- a/JsonApiDotNetCore.sln.DotSettings
+++ b/JsonApiDotNetCore.sln.DotSettings
@@ -1,21 +1,11 @@
- // Use the following placeholders:
-// $EXPR$ -- source expression
-// $NAME$ -- source name (string literal or 'nameof' expression)
-// $MESSAGE$ -- string literal in the form of "$NAME$ != null"
-JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$);
- 199
- 5000
- 99
- 100
- 200
- 1000
- 500
+ 5000
+ 2000
3000
- 50
False
True
71287D6F-6C3B-44B4-9FCA-E78FE3F02289/f:SchemaGenerator.cs
+ 83FF097C-C8C6-477B-9FAB-DF99B84978B5/f:ReadOnlySet.cs
swagger.g.json
swagger.json
SOLUTION
@@ -607,7 +597,7 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$);
True
True
True
- Replace argument null check using throw expression with Guard clause
+ Replace argument null check using throw expression with ArgumentNullException.ThrowIfNull
True
True
False
@@ -626,13 +616,12 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$);
True
CSHARP
False
- Replace argument null check with Guard clause
- JsonApiDotNetCore.ArgumentGuard.NotNull($argument$);
+ System.ArgumentNullException.ThrowIfNull($argument$);
$left$ = $right$;
$left$ = $right$ ?? throw new ArgumentNullException(nameof($argument$));
WARNING
True
- Replace argument == null check with Guard clause
+ Replace argument == null check with ArgumentNullException.ThrowIfNull
True
True
False
@@ -641,8 +630,7 @@ $left$ = $right$;
True
CSHARP
False
- Replace argument null check with Guard clause
- JsonApiDotNetCore.ArgumentGuard.NotNull($argument$);
+ System.ArgumentNullException.ThrowIfNull($argument$);
if ($argument$ == null) throw new ArgumentNullException(nameof($argument$));
WARNING
True
@@ -654,12 +642,11 @@ $left$ = $right$;
True
CSHARP
False
- Replace collection null/empty check with extension method
$collection$.IsNullOrEmpty()
$collection$ == null || !$collection$.Any()
WARNING
True
- Replace argument is null check with Guard clause
+ Replace argument is null check with ArgumentNullException.ThrowIfNull
True
True
False
@@ -668,7 +655,7 @@ $left$ = $right$;
True
CSHARP
False
- JsonApiDotNetCore.ArgumentGuard.NotNull($argument$);
+ System.ArgumentNullException.ThrowIfNull($argument$);
if ($argument$ is null) throw new ArgumentNullException(nameof($argument$));
WARNING
True
diff --git a/README.md b/README.md
index 3354eac45b..8bd84b3d9c 100644
--- a/README.md
+++ b/README.md
@@ -87,13 +87,9 @@ See also our [versioning policy](./VERSIONING_POLICY.md).
| | | 7 | 7 |
| | | 8 | 8, 9 |
| | | 9 | 9 |
-| master | Preview | 6 | 6, 7 |
-| | | 7 | 7 |
-| | | 8 | 8, 9 |
+| master | Preview | 8 | 8, 9 |
| | | 9 | 9 |
-| openapi | Experimental | 6 | 6, 7 |
-| | | 7 | 7 |
-| | | 8 | 8, 9 |
+| openapi | Experimental | 8 | 8, 9 |
| | | 9 | 9 |
## Contributing
diff --git a/benchmarks/Benchmarks.csproj b/benchmarks/Benchmarks.csproj
index 9dbb9ba093..90d53461d2 100644
--- a/benchmarks/Benchmarks.csproj
+++ b/benchmarks/Benchmarks.csproj
@@ -1,7 +1,7 @@
Exe
- net8.0
+ net9.0
true
diff --git a/package-versions.props b/package-versions.props
index a6eb42633a..1700f2b66d 100644
--- a/package-versions.props
+++ b/package-versions.props
@@ -4,49 +4,49 @@
4.1.0
0.4.1
2.14.1
- 6.8.1
+ 7.2.0
13.0.3
- 8.0.*
0.14.*
1.0.*
35.6.*
- 4.11.*
+ 4.12.*
6.0.*
2.1.*
- 6.12.*
+ 7.0.*
2.4.*
2.0.*
1.*
- 8.0.*
- 14.1.*
+ 9.0.*
+ 9.0.*
+ 14.2.*
13.0.*
8.0.*
- 6.*-*
- 17.11.*
+ 7.*-*
+ 9.0.*
+ 17.12.*
2.9.*
2.8.*
-
+
- 8.0.0
+ N/A
- 8.0.*
- 8.0.*
- $(AspNetCoreVersion)
+ 9.0.*
+ 9.0.*
+ 9.0.0-*
-
+
- 6.0.0
+ 8.0.0
- 6.0.*
- 2.1.*
- 7.0.*
- 8.0.*
+ 8.0.*
+ 8.0.*
+ $(EntityFrameworkCoreVersion)
diff --git a/src/Examples/DapperExample/AtomicOperations/AmbientTransaction.cs b/src/Examples/DapperExample/AtomicOperations/AmbientTransaction.cs
index c442861bc4..11d052da66 100644
--- a/src/Examples/DapperExample/AtomicOperations/AmbientTransaction.cs
+++ b/src/Examples/DapperExample/AtomicOperations/AmbientTransaction.cs
@@ -1,5 +1,4 @@
using System.Data.Common;
-using JsonApiDotNetCore;
using JsonApiDotNetCore.AtomicOperations;
namespace DapperExample.AtomicOperations;
@@ -18,8 +17,8 @@ internal sealed class AmbientTransaction : IOperationsTransaction
public AmbientTransaction(AmbientTransactionFactory owner, DbTransaction current, Guid transactionId)
{
- ArgumentGuard.NotNull(owner);
- ArgumentGuard.NotNull(current);
+ ArgumentNullException.ThrowIfNull(owner);
+ ArgumentNullException.ThrowIfNull(current);
_owner = owner;
Current = current;
diff --git a/src/Examples/DapperExample/AtomicOperations/AmbientTransactionFactory.cs b/src/Examples/DapperExample/AtomicOperations/AmbientTransactionFactory.cs
index d10959b79a..82790819fe 100644
--- a/src/Examples/DapperExample/AtomicOperations/AmbientTransactionFactory.cs
+++ b/src/Examples/DapperExample/AtomicOperations/AmbientTransactionFactory.cs
@@ -1,6 +1,5 @@
using System.Data.Common;
using DapperExample.TranslationToSql.DataModel;
-using JsonApiDotNetCore;
using JsonApiDotNetCore.AtomicOperations;
using JsonApiDotNetCore.Configuration;
@@ -18,8 +17,8 @@ public sealed class AmbientTransactionFactory : IOperationsTransactionFactory
public AmbientTransactionFactory(IJsonApiOptions options, IDataModelService dataModelService)
{
- ArgumentGuard.NotNull(options);
- ArgumentGuard.NotNull(dataModelService);
+ ArgumentNullException.ThrowIfNull(options);
+ ArgumentNullException.ThrowIfNull(dataModelService);
_options = options;
_dataModelService = dataModelService;
@@ -64,7 +63,7 @@ async Task IOperationsTransactionFactory.BeginTransactio
internal void Detach(AmbientTransaction ambientTransaction)
{
- ArgumentGuard.NotNull(ambientTransaction);
+ ArgumentNullException.ThrowIfNull(ambientTransaction);
if (AmbientTransaction != null && AmbientTransaction == ambientTransaction)
{
diff --git a/src/Examples/DapperExample/DapperExample.csproj b/src/Examples/DapperExample/DapperExample.csproj
index f49c3e4b40..ed7bd358eb 100644
--- a/src/Examples/DapperExample/DapperExample.csproj
+++ b/src/Examples/DapperExample/DapperExample.csproj
@@ -1,6 +1,6 @@
- net8.0;net6.0
+ net9.0;net8.0
@@ -16,6 +16,6 @@
-
+
diff --git a/src/Examples/DapperExample/Data/AppDbContext.cs b/src/Examples/DapperExample/Data/AppDbContext.cs
index ee18bab08e..31f09b277c 100644
--- a/src/Examples/DapperExample/Data/AppDbContext.cs
+++ b/src/Examples/DapperExample/Data/AppDbContext.cs
@@ -1,6 +1,5 @@
using DapperExample.Models;
using JetBrains.Annotations;
-using JsonApiDotNetCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
@@ -23,7 +22,7 @@ public sealed class AppDbContext : DbContext
public AppDbContext(DbContextOptions options, IConfiguration configuration)
: base(options)
{
- ArgumentGuard.NotNull(configuration);
+ ArgumentNullException.ThrowIfNull(configuration);
_configuration = configuration;
}
diff --git a/src/Examples/DapperExample/Definitions/TodoItemDefinition.cs b/src/Examples/DapperExample/Definitions/TodoItemDefinition.cs
index dc7c1802c8..f20268fb7d 100644
--- a/src/Examples/DapperExample/Definitions/TodoItemDefinition.cs
+++ b/src/Examples/DapperExample/Definitions/TodoItemDefinition.cs
@@ -1,7 +1,6 @@
using System.ComponentModel;
using DapperExample.Models;
using JetBrains.Annotations;
-using JsonApiDotNetCore;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Middleware;
using JsonApiDotNetCore.Queries.Expressions;
@@ -12,14 +11,14 @@ namespace DapperExample.Definitions;
[UsedImplicitly(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)]
public sealed class TodoItemDefinition : JsonApiResourceDefinition
{
- private readonly IClock _clock;
+ private readonly TimeProvider _timeProvider;
- public TodoItemDefinition(IResourceGraph resourceGraph, IClock clock)
+ public TodoItemDefinition(IResourceGraph resourceGraph, TimeProvider timeProvider)
: base(resourceGraph)
{
- ArgumentGuard.NotNull(clock);
+ ArgumentNullException.ThrowIfNull(timeProvider);
- _clock = clock;
+ _timeProvider = timeProvider;
}
public override SortExpression OnApplySort(SortExpression? existingSort)
@@ -39,11 +38,11 @@ public override Task OnWritingAsync(TodoItem resource, WriteOperationKind writeO
{
if (writeOperation == WriteOperationKind.CreateResource)
{
- resource.CreatedAt = _clock.UtcNow;
+ resource.CreatedAt = _timeProvider.GetUtcNow();
}
else if (writeOperation == WriteOperationKind.UpdateResource)
{
- resource.LastModifiedAt = _clock.UtcNow;
+ resource.LastModifiedAt = _timeProvider.GetUtcNow();
}
return Task.CompletedTask;
diff --git a/src/Examples/DapperExample/FromEntitiesNavigationResolver.cs b/src/Examples/DapperExample/FromEntitiesNavigationResolver.cs
index 8ab88473c1..4ae5f05dcc 100644
--- a/src/Examples/DapperExample/FromEntitiesNavigationResolver.cs
+++ b/src/Examples/DapperExample/FromEntitiesNavigationResolver.cs
@@ -1,6 +1,5 @@
using DapperExample.Data;
using DapperExample.TranslationToSql.DataModel;
-using JsonApiDotNetCore;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Repositories;
using Microsoft.EntityFrameworkCore;
@@ -18,9 +17,9 @@ internal sealed class FromEntitiesNavigationResolver : IInverseNavigationResolve
public FromEntitiesNavigationResolver(IResourceGraph resourceGraph, FromEntitiesDataModelService dataModelService, AppDbContext appDbContext)
{
- ArgumentGuard.NotNull(resourceGraph);
- ArgumentGuard.NotNull(dataModelService);
- ArgumentGuard.NotNull(appDbContext);
+ ArgumentNullException.ThrowIfNull(resourceGraph);
+ ArgumentNullException.ThrowIfNull(dataModelService);
+ ArgumentNullException.ThrowIfNull(appDbContext);
_defaultResolver = new InverseNavigationResolver(resourceGraph, new[]
{
diff --git a/src/Examples/DapperExample/IClock.cs b/src/Examples/DapperExample/IClock.cs
deleted file mode 100644
index 0319c42480..0000000000
--- a/src/Examples/DapperExample/IClock.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace DapperExample;
-
-public interface IClock
-{
- DateTimeOffset UtcNow { get; }
-}
diff --git a/src/Examples/DapperExample/Program.cs b/src/Examples/DapperExample/Program.cs
index f7bf198af9..6e84497d02 100644
--- a/src/Examples/DapperExample/Program.cs
+++ b/src/Examples/DapperExample/Program.cs
@@ -11,13 +11,12 @@
using JsonApiDotNetCore.Repositories;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
-using Microsoft.Extensions.DependencyInjection.Extensions;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
// Add services to the container.
-builder.Services.TryAddSingleton();
+builder.Services.AddSingleton();
DatabaseProvider databaseProvider = GetDatabaseProvider(builder.Configuration);
string? connectionString = builder.Configuration.GetConnectionString($"DapperExample{databaseProvider}");
@@ -31,8 +30,13 @@
}
case DatabaseProvider.MySql:
{
- builder.Services.AddMySql(connectionString, ServerVersion.AutoDetect(connectionString),
- optionsAction: options => SetDbContextDebugOptions(options));
+#if NET8_0
+ ServerVersion serverVersion = ServerVersion.AutoDetect(connectionString);
+#else
+ ServerVersion serverVersion = await ServerVersion.AutoDetectAsync(connectionString);
+#endif
+
+ builder.Services.AddMySql(connectionString, serverVersion, optionsAction: options => SetDbContextDebugOptions(options));
break;
}
diff --git a/src/Examples/DapperExample/Repositories/DapperFacade.cs b/src/Examples/DapperExample/Repositories/DapperFacade.cs
index feb0a88e06..e7190ec0de 100644
--- a/src/Examples/DapperExample/Repositories/DapperFacade.cs
+++ b/src/Examples/DapperExample/Repositories/DapperFacade.cs
@@ -17,14 +17,14 @@ internal sealed class DapperFacade
public DapperFacade(IDataModelService dataModelService)
{
- ArgumentGuard.NotNull(dataModelService);
+ ArgumentNullException.ThrowIfNull(dataModelService);
_dataModelService = dataModelService;
}
public CommandDefinition GetSqlCommand(SqlTreeNode node, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(node);
+ ArgumentNullException.ThrowIfNull(node);
var queryBuilder = new SqlQueryBuilder(_dataModelService.DatabaseProvider);
string statement = queryBuilder.GetCommand(node);
@@ -36,7 +36,7 @@ public CommandDefinition GetSqlCommand(SqlTreeNode node, CancellationToken cance
public IReadOnlyCollection BuildSqlCommandsForOneToOneRelationshipsChangedToNotNull(ResourceChangeDetector changeDetector,
CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(changeDetector);
+ ArgumentNullException.ThrowIfNull(changeDetector);
List sqlCommands = [];
@@ -79,7 +79,7 @@ public IReadOnlyCollection BuildSqlCommandsForOneToOneRelatio
public IReadOnlyCollection BuildSqlCommandsForChangedRelationshipsHavingForeignKeyAtRightSide(ResourceChangeDetector changeDetector,
TId leftId, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(changeDetector);
+ ArgumentNullException.ThrowIfNull(changeDetector);
List sqlCommands = [];
@@ -126,7 +126,7 @@ public IReadOnlyCollection BuildSqlCommandsForChangedRelation
public CommandDefinition BuildSqlCommandForRemoveFromToMany(RelationshipForeignKey foreignKey, object[] rightResourceIdValues,
CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(foreignKey);
+ ArgumentNullException.ThrowIfNull(foreignKey);
ArgumentGuard.NotNullNorEmpty(rightResourceIdValues);
if (!foreignKey.IsNullable)
@@ -149,8 +149,8 @@ public CommandDefinition BuildSqlCommandForRemoveFromToMany(RelationshipForeignK
public CommandDefinition BuildSqlCommandForAddToToMany(RelationshipForeignKey foreignKey, object leftId, object[] rightResourceIdValues,
CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(foreignKey);
- ArgumentGuard.NotNull(leftId);
+ ArgumentNullException.ThrowIfNull(foreignKey);
+ ArgumentNullException.ThrowIfNull(leftId);
ArgumentGuard.NotNullNorEmpty(rightResourceIdValues);
var columnsToUpdate = new Dictionary
@@ -165,7 +165,7 @@ public CommandDefinition BuildSqlCommandForAddToToMany(RelationshipForeignKey fo
public CommandDefinition BuildSqlCommandForCreate(ResourceChangeDetector changeDetector, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(changeDetector);
+ ArgumentNullException.ThrowIfNull(changeDetector);
IReadOnlyDictionary columnsToSet = changeDetector.GetChangedColumnValues();
@@ -176,7 +176,7 @@ public CommandDefinition BuildSqlCommandForCreate(ResourceChangeDetector changeD
public CommandDefinition? BuildSqlCommandForUpdate(ResourceChangeDetector changeDetector, TId leftId, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(changeDetector);
+ ArgumentNullException.ThrowIfNull(changeDetector);
IReadOnlyDictionary columnsToUpdate = changeDetector.GetChangedColumnValues();
diff --git a/src/Examples/DapperExample/Repositories/DapperRepository.cs b/src/Examples/DapperExample/Repositories/DapperRepository.cs
index 7a46e69a53..716db19519 100644
--- a/src/Examples/DapperExample/Repositories/DapperRepository.cs
+++ b/src/Examples/DapperExample/Repositories/DapperRepository.cs
@@ -114,14 +114,14 @@ public DapperRepository(ITargetedFields targetedFields, IResourceGraph resourceG
IResourceDefinitionAccessor resourceDefinitionAccessor, AmbientTransactionFactory transactionFactory, IDataModelService dataModelService,
SqlCaptureStore captureStore, ILoggerFactory loggerFactory)
{
- ArgumentGuard.NotNull(targetedFields);
- ArgumentGuard.NotNull(resourceGraph);
- ArgumentGuard.NotNull(resourceFactory);
- ArgumentGuard.NotNull(resourceDefinitionAccessor);
- ArgumentGuard.NotNull(transactionFactory);
- ArgumentGuard.NotNull(dataModelService);
- ArgumentGuard.NotNull(captureStore);
- ArgumentGuard.NotNull(loggerFactory);
+ ArgumentNullException.ThrowIfNull(targetedFields);
+ ArgumentNullException.ThrowIfNull(resourceGraph);
+ ArgumentNullException.ThrowIfNull(resourceFactory);
+ ArgumentNullException.ThrowIfNull(resourceDefinitionAccessor);
+ ArgumentNullException.ThrowIfNull(transactionFactory);
+ ArgumentNullException.ThrowIfNull(dataModelService);
+ ArgumentNullException.ThrowIfNull(captureStore);
+ ArgumentNullException.ThrowIfNull(loggerFactory);
_targetedFields = targetedFields;
_resourceGraph = resourceGraph;
@@ -138,7 +138,7 @@ public DapperRepository(ITargetedFields targetedFields, IResourceGraph resourceG
///
public async Task> GetAsync(QueryLayer queryLayer, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(queryLayer);
+ ArgumentNullException.ThrowIfNull(queryLayer);
var mapper = new ResultSetMapper(queryLayer.Include);
@@ -180,7 +180,7 @@ public async Task CountAsync(FilterExpression? filter, CancellationToken ca
///
public Task GetForCreateAsync(Type resourceClrType, [DisallowNull] TId id, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(resourceClrType);
+ ArgumentNullException.ThrowIfNull(resourceClrType);
var resource = (TResource)_resourceFactory.CreateInstance(resourceClrType);
resource.Id = id;
@@ -191,8 +191,8 @@ public Task GetForCreateAsync(Type resourceClrType, [DisallowNull] TI
///
public async Task CreateAsync(TResource resourceFromRequest, TResource resourceForDatabase, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(resourceFromRequest);
- ArgumentGuard.NotNull(resourceForDatabase);
+ ArgumentNullException.ThrowIfNull(resourceFromRequest);
+ ArgumentNullException.ThrowIfNull(resourceForDatabase);
var changeDetector = new ResourceChangeDetector(ResourceType, _dataModelService);
@@ -283,7 +283,7 @@ await _resourceDefinitionAccessor.OnSetToManyRelationshipAsync(leftResource, has
///
public async Task GetForUpdateAsync(QueryLayer queryLayer, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(queryLayer);
+ ArgumentNullException.ThrowIfNull(queryLayer);
IReadOnlyCollection resources = await GetAsync(queryLayer, cancellationToken);
return resources.FirstOrDefault();
@@ -292,8 +292,8 @@ await _resourceDefinitionAccessor.OnSetToManyRelationshipAsync(leftResource, has
///
public async Task UpdateAsync(TResource resourceFromRequest, TResource resourceFromDatabase, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(resourceFromRequest);
- ArgumentGuard.NotNull(resourceFromDatabase);
+ ArgumentNullException.ThrowIfNull(resourceFromRequest);
+ ArgumentNullException.ThrowIfNull(resourceFromDatabase);
var changeDetector = new ResourceChangeDetector(ResourceType, _dataModelService);
changeDetector.CaptureCurrentValues(resourceFromDatabase);
@@ -384,7 +384,7 @@ await ExecuteInTransactionAsync(async transaction =>
///
public async Task SetRelationshipAsync(TResource leftResource, object? rightValue, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(leftResource);
+ ArgumentNullException.ThrowIfNull(leftResource);
RelationshipAttribute relationship = _targetedFields.Relationships.Single();
@@ -455,7 +455,7 @@ await ExecuteInTransactionAsync(async transaction =>
public async Task AddToToManyRelationshipAsync(TResource? leftResource, [DisallowNull] TId leftId, ISet rightResourceIds,
CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(rightResourceIds);
+ ArgumentNullException.ThrowIfNull(rightResourceIds);
var relationship = (HasManyAttribute)_targetedFields.Relationships.Single();
@@ -495,8 +495,8 @@ await ExecuteInTransactionAsync(async transaction =>
///
public async Task RemoveFromToManyRelationshipAsync(TResource leftResource, ISet rightResourceIds, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(leftResource);
- ArgumentGuard.NotNull(rightResourceIds);
+ ArgumentNullException.ThrowIfNull(leftResource);
+ ArgumentNullException.ThrowIfNull(rightResourceIds);
var relationship = (HasManyAttribute)_targetedFields.Relationships.Single();
diff --git a/src/Examples/DapperExample/Repositories/ResourceChangeDetector.cs b/src/Examples/DapperExample/Repositories/ResourceChangeDetector.cs
index 73213445e2..58f7579254 100644
--- a/src/Examples/DapperExample/Repositories/ResourceChangeDetector.cs
+++ b/src/Examples/DapperExample/Repositories/ResourceChangeDetector.cs
@@ -24,8 +24,8 @@ internal sealed class ResourceChangeDetector
public ResourceChangeDetector(ResourceType resourceType, IDataModelService dataModelService)
{
- ArgumentGuard.NotNull(resourceType);
- ArgumentGuard.NotNull(dataModelService);
+ ArgumentNullException.ThrowIfNull(resourceType);
+ ArgumentNullException.ThrowIfNull(dataModelService);
ResourceType = resourceType;
_dataModelService = dataModelService;
@@ -33,7 +33,7 @@ public ResourceChangeDetector(ResourceType resourceType, IDataModelService dataM
public void CaptureCurrentValues(IIdentifiable resource)
{
- ArgumentGuard.NotNull(resource);
+ ArgumentNullException.ThrowIfNull(resource);
AssertSameType(ResourceType, resource);
_currentColumnValues = CaptureColumnValues(resource);
@@ -42,7 +42,7 @@ public void CaptureCurrentValues(IIdentifiable resource)
public void CaptureNewValues(IIdentifiable resource)
{
- ArgumentGuard.NotNull(resource);
+ ArgumentNullException.ThrowIfNull(resource);
AssertSameType(ResourceType, resource);
_newColumnValues = CaptureColumnValues(resource);
diff --git a/src/Examples/DapperExample/Repositories/ResultSetMapper.cs b/src/Examples/DapperExample/Repositories/ResultSetMapper.cs
index 1b20f74dd9..89a7890fd0 100644
--- a/src/Examples/DapperExample/Repositories/ResultSetMapper.cs
+++ b/src/Examples/DapperExample/Repositories/ResultSetMapper.cs
@@ -3,9 +3,6 @@
using JsonApiDotNetCore.Queries.Expressions;
using JsonApiDotNetCore.Resources;
using JsonApiDotNetCore.Resources.Annotations;
-#if NET6_0
-using JsonApiDotNetCore;
-#endif
namespace DapperExample.Repositories;
diff --git a/src/Examples/DapperExample/SystemClock.cs b/src/Examples/DapperExample/SystemClock.cs
deleted file mode 100644
index 3fed87c586..0000000000
--- a/src/Examples/DapperExample/SystemClock.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace DapperExample;
-
-public sealed class SystemClock : IClock
-{
- public DateTimeOffset UtcNow => DateTimeOffset.UtcNow;
-}
diff --git a/src/Examples/DapperExample/TranslationToSql/Builders/DeleteOneToOneStatementBuilder.cs b/src/Examples/DapperExample/TranslationToSql/Builders/DeleteOneToOneStatementBuilder.cs
index 24be003a0a..afd955dc62 100644
--- a/src/Examples/DapperExample/TranslationToSql/Builders/DeleteOneToOneStatementBuilder.cs
+++ b/src/Examples/DapperExample/TranslationToSql/Builders/DeleteOneToOneStatementBuilder.cs
@@ -1,6 +1,5 @@
using DapperExample.TranslationToSql.DataModel;
using DapperExample.TranslationToSql.TreeNodes;
-using JsonApiDotNetCore;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Queries.Expressions;
@@ -11,8 +10,8 @@ internal sealed class DeleteOneToOneStatementBuilder(IDataModelService dataModel
{
public DeleteNode Build(ResourceType resourceType, string whereColumnName, object? whereValue)
{
- ArgumentGuard.NotNull(resourceType);
- ArgumentGuard.NotNullNorEmpty(whereColumnName);
+ ArgumentNullException.ThrowIfNull(resourceType);
+ ArgumentException.ThrowIfNullOrEmpty(whereColumnName);
ResetState();
diff --git a/src/Examples/DapperExample/TranslationToSql/Builders/DeleteResourceStatementBuilder.cs b/src/Examples/DapperExample/TranslationToSql/Builders/DeleteResourceStatementBuilder.cs
index 2e4779e334..b3afe4a2a4 100644
--- a/src/Examples/DapperExample/TranslationToSql/Builders/DeleteResourceStatementBuilder.cs
+++ b/src/Examples/DapperExample/TranslationToSql/Builders/DeleteResourceStatementBuilder.cs
@@ -12,7 +12,7 @@ internal sealed class DeleteResourceStatementBuilder(IDataModelService dataModel
{
public DeleteNode Build(ResourceType resourceType, params object[] idValues)
{
- ArgumentGuard.NotNull(resourceType);
+ ArgumentNullException.ThrowIfNull(resourceType);
ArgumentGuard.NotNullNorEmpty(idValues);
ResetState();
diff --git a/src/Examples/DapperExample/TranslationToSql/Builders/InsertStatementBuilder.cs b/src/Examples/DapperExample/TranslationToSql/Builders/InsertStatementBuilder.cs
index 7a12ec5acd..2f71cee112 100644
--- a/src/Examples/DapperExample/TranslationToSql/Builders/InsertStatementBuilder.cs
+++ b/src/Examples/DapperExample/TranslationToSql/Builders/InsertStatementBuilder.cs
@@ -1,7 +1,6 @@
using System.Collections.ObjectModel;
using DapperExample.TranslationToSql.DataModel;
using DapperExample.TranslationToSql.TreeNodes;
-using JsonApiDotNetCore;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Resources;
@@ -12,8 +11,8 @@ internal sealed class InsertStatementBuilder(IDataModelService dataModelService)
{
public InsertNode Build(ResourceType resourceType, IReadOnlyDictionary columnsToSet)
{
- ArgumentGuard.NotNull(resourceType);
- ArgumentGuard.NotNull(columnsToSet);
+ ArgumentNullException.ThrowIfNull(resourceType);
+ ArgumentNullException.ThrowIfNull(columnsToSet);
ResetState();
diff --git a/src/Examples/DapperExample/TranslationToSql/Builders/SelectStatementBuilder.cs b/src/Examples/DapperExample/TranslationToSql/Builders/SelectStatementBuilder.cs
index 95a2681a80..23a2b7d2d0 100644
--- a/src/Examples/DapperExample/TranslationToSql/Builders/SelectStatementBuilder.cs
+++ b/src/Examples/DapperExample/TranslationToSql/Builders/SelectStatementBuilder.cs
@@ -4,7 +4,6 @@
using DapperExample.TranslationToSql.Generators;
using DapperExample.TranslationToSql.Transformations;
using DapperExample.TranslationToSql.TreeNodes;
-using JsonApiDotNetCore;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Errors;
using JsonApiDotNetCore.Queries;
@@ -50,7 +49,7 @@ private SelectStatementBuilder(QueryState queryState)
public SelectNode Build(QueryLayer queryLayer, SelectShape selectShape)
{
- ArgumentGuard.NotNull(queryLayer);
+ ArgumentNullException.ThrowIfNull(queryLayer);
// Convert queryLayer.Include into multiple levels of queryLayer.Selection.
var includeConverter = new QueryLayerIncludeConverter(queryLayer);
@@ -701,7 +700,7 @@ private sealed class NullableAttributeFinder : QueryExpressionRewriter