From 71e53981ae74b33db338635ea5de5c90f3f80cce Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Wed, 6 Apr 2022 20:05:01 +0200
Subject: [PATCH 01/50] Increment version number (used for pre-release builds
from ci)
---
Directory.Build.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index 5b311343c7..403d433302 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -6,7 +6,7 @@
6.0.*
4.1.*
2.14.1
- 5.0.1
+ 5.0.2
$(MSBuildThisFileDirectory)CodingGuidelines.ruleset
9999
enable
From 59f319f3c29c64e55f3aa5dc310ef57200f41d46 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Fri, 29 Apr 2022 22:30:45 +0200
Subject: [PATCH 02/50] Package updates
---
Directory.Build.props | 4 ++--
.../Configuration/ServiceCollectionExtensions.cs | 2 --
.../Queries/Expressions/QueryableHandlerExpression.cs | 2 --
.../Repositories/EntityFrameworkCoreRepository.cs | 4 ----
test/TestBuildingBlocks/TestBuildingBlocks.csproj | 2 +-
5 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index 403d433302..55df28cab3 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -16,8 +16,8 @@
-
-
+
+
diff --git a/src/JsonApiDotNetCore/Configuration/ServiceCollectionExtensions.cs b/src/JsonApiDotNetCore/Configuration/ServiceCollectionExtensions.cs
index 8e5d15a7c4..8b5356fdef 100644
--- a/src/JsonApiDotNetCore/Configuration/ServiceCollectionExtensions.cs
+++ b/src/JsonApiDotNetCore/Configuration/ServiceCollectionExtensions.cs
@@ -6,8 +6,6 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
-#pragma warning disable AV1130 // Return type in method signature should be an interface to an unchangeable collection
-
namespace JsonApiDotNetCore.Configuration;
[PublicAPI]
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/QueryableHandlerExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/QueryableHandlerExpression.cs
index 4cd035ba2d..1d9c910955 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/QueryableHandlerExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/QueryableHandlerExpression.cs
@@ -21,10 +21,8 @@ public QueryableHandlerExpression(object queryableHandler, StringValues paramete
_parameterValue = parameterValue;
}
-#pragma warning disable AV1130 // Return type in method signature should be an interface to an unchangeable collection
public IQueryable Apply(IQueryable query)
where TResource : class, IIdentifiable
-#pragma warning restore AV1130 // Return type in method signature should be an interface to an unchangeable collection
{
var handler = (Func, StringValues, IQueryable>)_queryableHandler;
return handler(query, _parameterValue);
diff --git a/src/JsonApiDotNetCore/Repositories/EntityFrameworkCoreRepository.cs b/src/JsonApiDotNetCore/Repositories/EntityFrameworkCoreRepository.cs
index 7384cec693..358f63a2cd 100644
--- a/src/JsonApiDotNetCore/Repositories/EntityFrameworkCoreRepository.cs
+++ b/src/JsonApiDotNetCore/Repositories/EntityFrameworkCoreRepository.cs
@@ -105,9 +105,7 @@ public virtual async Task CountAsync(FilterExpression? filter, Cancellation
}
}
-#pragma warning disable AV1130 // Return type in method signature should be an interface to an unchangeable collection
protected virtual IQueryable ApplyQueryLayer(QueryLayer queryLayer)
-#pragma warning restore AV1130 // Return type in method signature should be an interface to an unchangeable collection
{
_traceWriter.LogMethodStart(new
{
@@ -151,9 +149,7 @@ protected virtual IQueryable ApplyQueryLayer(QueryLayer queryLayer)
}
}
-#pragma warning disable AV1130 // Return type in method signature should be an interface to an unchangeable collection
protected virtual IQueryable GetAll()
-#pragma warning restore AV1130 // Return type in method signature should be an interface to an unchangeable collection
{
return _dbContext.Set();
}
diff --git a/test/TestBuildingBlocks/TestBuildingBlocks.csproj b/test/TestBuildingBlocks/TestBuildingBlocks.csproj
index 3a8655508c..68db5c994c 100644
--- a/test/TestBuildingBlocks/TestBuildingBlocks.csproj
+++ b/test/TestBuildingBlocks/TestBuildingBlocks.csproj
@@ -10,7 +10,7 @@
-
+
From bba90e55feaa197e8b51c603b56e5b75a5876a15 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Wed, 11 May 2022 21:16:06 +0200
Subject: [PATCH 03/50] Fixed broken link
---
.github/PULL_REQUEST_TEMPLATE.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 3e23a87e27..1a1c618dd7 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -4,6 +4,6 @@ Closes #{ISSUE_NUMBER}
#### QUALITY CHECKLIST
- [ ] Changes implemented in code
-- [ ] Complies with our [contributing guidelines](./.github/CONTRIBUTING.md)
+- [ ] Complies with our [contributing guidelines](https://github.com/json-api-dotnet/JsonApiDotNetCore/blob/master/.github/CONTRIBUTING.md)
- [ ] Adapted tests
- [ ] Documentation updated
From 9e0fed89f5878c9e6629b7ebb5a8d4f2a53738f1 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Sat, 21 May 2022 15:24:18 +0200
Subject: [PATCH 04/50] Removed workaround for debugging source generators
(#1155)
* Removed workaround for https://github.com/dotnet/roslyn/issues/55802. The bug has been fixed in VS 2022 v17.2.
* Package updates (in non-breaking fashion)
---
Directory.Build.props | 6 +-
JsonApiDotNetCore.sln | 15 -----
.../Annotations/ResourceAttribute.cs | 3 -
.../ControllerSourceGenerator.cs | 6 ++
.../JsonApiDotNetCore.SourceGenerators.csproj | 2 +-
.../Properties/launchSettings.json | 2 +-
.../Controllers/ArticlesController.cs | 16 -----
.../Controllers/CustomersController.cs | 18 ------
.../JsonApiDotNetCore/ArgumentGuard.cs | 19 ------
.../JsonApiDotNetCore/AttrAttribute.cs | 15 -----
.../BaseJsonApiController.cs | 41 -------------
.../IAddToRelationshipService.cs | 18 ------
.../JsonApiDotNetCore/ICreateService.cs | 18 ------
.../JsonApiDotNetCore/IDeleteService.cs | 18 ------
.../JsonApiDotNetCore/IGetAllService.cs | 18 ------
.../JsonApiDotNetCore/IGetByIdService.cs | 18 ------
.../IGetRelationshipService.cs | 18 ------
.../JsonApiDotNetCore/IGetSecondaryService.cs | 18 ------
.../JsonApiDotNetCore/IIdentifiable.cs | 23 --------
.../JsonApiDotNetCore/IJsonApiOptions.cs | 15 -----
.../IRemoveFromRelationshipService.cs | 18 ------
.../IResourceCommandService.cs | 19 ------
.../JsonApiDotNetCore/IResourceGraph.cs | 15 -----
.../IResourceQueryService.cs | 18 ------
.../ISetRelationshipService.cs | 18 ------
.../JsonApiDotNetCore/IUpdateService.cs | 18 ------
.../JsonApiDotNetCore/Identifiable.cs | 19 ------
.../JsonApiCommandController.cs | 25 --------
.../JsonApiDotNetCore/JsonApiController.cs | 36 ------------
.../JsonApiDotNetCore/JsonApiOptions.cs | 16 -----
.../JsonApiQueryController.cs | 25 --------
.../JsonApiResourceService.cs | 17 ------
.../JsonApiDotNetCore/ResourceGraph.cs | 15 -----
.../ResourceServiceInterfaces.cs | 17 ------
.../SourceGeneratorDebugger/Models/Account.cs | 14 -----
.../SourceGeneratorDebugger/Models/Article.cs | 14 -----
.../Models/Customer.cs | 12 ----
test/SourceGeneratorDebugger/Models/Global.cs | 14 -----
test/SourceGeneratorDebugger/Models/Login.cs | 28 ---------
test/SourceGeneratorDebugger/Models/Order.cs | 14 -----
.../Models/SimpleNamespace.cs | 15 -----
test/SourceGeneratorDebugger/Program.cs | 58 -------------------
.../SourceGeneratorDebugger.csproj | 28 ---------
.../TestBuildingBlocks.csproj | 4 +-
44 files changed, 13 insertions(+), 771 deletions(-)
delete mode 100644 test/SourceGeneratorDebugger/Controllers/ArticlesController.cs
delete mode 100644 test/SourceGeneratorDebugger/Controllers/CustomersController.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/ArgumentGuard.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/AttrAttribute.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/BaseJsonApiController.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/IAddToRelationshipService.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/ICreateService.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/IDeleteService.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetAllService.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetByIdService.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetRelationshipService.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetSecondaryService.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/IIdentifiable.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/IJsonApiOptions.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/IRemoveFromRelationshipService.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceCommandService.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceGraph.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceQueryService.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/ISetRelationshipService.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/IUpdateService.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/Identifiable.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiCommandController.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiController.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiOptions.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiQueryController.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiResourceService.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/ResourceGraph.cs
delete mode 100644 test/SourceGeneratorDebugger/JsonApiDotNetCore/ResourceServiceInterfaces.cs
delete mode 100644 test/SourceGeneratorDebugger/Models/Account.cs
delete mode 100644 test/SourceGeneratorDebugger/Models/Article.cs
delete mode 100644 test/SourceGeneratorDebugger/Models/Customer.cs
delete mode 100644 test/SourceGeneratorDebugger/Models/Global.cs
delete mode 100644 test/SourceGeneratorDebugger/Models/Login.cs
delete mode 100644 test/SourceGeneratorDebugger/Models/Order.cs
delete mode 100644 test/SourceGeneratorDebugger/Models/SimpleNamespace.cs
delete mode 100644 test/SourceGeneratorDebugger/Program.cs
delete mode 100644 test/SourceGeneratorDebugger/SourceGeneratorDebugger.csproj
diff --git a/Directory.Build.props b/Directory.Build.props
index 55df28cab3..26ff3e7175 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -4,7 +4,7 @@
6.0.*
6.0.*
6.0.*
- 4.1.*
+ 4.2.*
2.14.1
5.0.2
$(MSBuildThisFileDirectory)CodingGuidelines.ruleset
@@ -34,7 +34,7 @@
3.1.2
- 4.17.2
- 17.1.0
+ 4.18.1
+ 17.2.0
diff --git a/JsonApiDotNetCore.sln b/JsonApiDotNetCore.sln
index 0a8ed12d2a..21b1cca7ce 100644
--- a/JsonApiDotNetCore.sln
+++ b/JsonApiDotNetCore.sln
@@ -46,8 +46,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestBuildingBlocks", "test\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCore.SourceGenerators", "src\JsonApiDotNetCore.SourceGenerators\JsonApiDotNetCore.SourceGenerators.csproj", "{952C0FDE-AFC8-455C-986F-6CC882ED8953}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceGeneratorDebugger", "test\SourceGeneratorDebugger\SourceGeneratorDebugger.csproj", "{87D066F9-3540-4AC7-A748-134900969EE5}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceGeneratorTests", "test\SourceGeneratorTests\SourceGeneratorTests.csproj", "{0E0B5C51-F7E2-4F40-A4E4-DED0E9731DC9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCore.Annotations", "src\JsonApiDotNetCore.Annotations\JsonApiDotNetCore.Annotations.csproj", "{83FF097C-C8C6-477B-9FAB-DF99B84978B5}"
@@ -232,18 +230,6 @@ Global
{952C0FDE-AFC8-455C-986F-6CC882ED8953}.Release|x64.Build.0 = Release|Any CPU
{952C0FDE-AFC8-455C-986F-6CC882ED8953}.Release|x86.ActiveCfg = Release|Any CPU
{952C0FDE-AFC8-455C-986F-6CC882ED8953}.Release|x86.Build.0 = Release|Any CPU
- {87D066F9-3540-4AC7-A748-134900969EE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {87D066F9-3540-4AC7-A748-134900969EE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {87D066F9-3540-4AC7-A748-134900969EE5}.Debug|x64.ActiveCfg = Debug|Any CPU
- {87D066F9-3540-4AC7-A748-134900969EE5}.Debug|x64.Build.0 = Debug|Any CPU
- {87D066F9-3540-4AC7-A748-134900969EE5}.Debug|x86.ActiveCfg = Debug|Any CPU
- {87D066F9-3540-4AC7-A748-134900969EE5}.Debug|x86.Build.0 = Debug|Any CPU
- {87D066F9-3540-4AC7-A748-134900969EE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {87D066F9-3540-4AC7-A748-134900969EE5}.Release|Any CPU.Build.0 = Release|Any CPU
- {87D066F9-3540-4AC7-A748-134900969EE5}.Release|x64.ActiveCfg = Release|Any CPU
- {87D066F9-3540-4AC7-A748-134900969EE5}.Release|x64.Build.0 = Release|Any CPU
- {87D066F9-3540-4AC7-A748-134900969EE5}.Release|x86.ActiveCfg = Release|Any CPU
- {87D066F9-3540-4AC7-A748-134900969EE5}.Release|x86.Build.0 = Release|Any CPU
{0E0B5C51-F7E2-4F40-A4E4-DED0E9731DC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0E0B5C51-F7E2-4F40-A4E4-DED0E9731DC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E0B5C51-F7E2-4F40-A4E4-DED0E9731DC9}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -299,7 +285,6 @@ Global
{EC3202C6-1D4C-4B14-A599-B9D3F27FE3BA} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}
{210FD61E-FF5D-4CEE-8E0D-C739ECCCBA21} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}
{952C0FDE-AFC8-455C-986F-6CC882ED8953} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF}
- {87D066F9-3540-4AC7-A748-134900969EE5} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}
{0E0B5C51-F7E2-4F40-A4E4-DED0E9731DC9} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}
{83FF097C-C8C6-477B-9FAB-DF99B84978B5} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF}
{60334658-BE51-43B3-9C4D-F2BBF56C89CE} = {026FBC6C-AF76-4568-9B87-EC73457899FD}
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceAttribute.cs b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceAttribute.cs
index ca517e3e99..72669de585 100644
--- a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceAttribute.cs
+++ b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceAttribute.cs
@@ -1,9 +1,6 @@
using JetBrains.Annotations;
using JsonApiDotNetCore.Controllers;
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
namespace JsonApiDotNetCore.Resources.Annotations;
///
diff --git a/src/JsonApiDotNetCore.SourceGenerators/ControllerSourceGenerator.cs b/src/JsonApiDotNetCore.SourceGenerators/ControllerSourceGenerator.cs
index 6728fd537c..65800bba82 100644
--- a/src/JsonApiDotNetCore.SourceGenerators/ControllerSourceGenerator.cs
+++ b/src/JsonApiDotNetCore.SourceGenerators/ControllerSourceGenerator.cs
@@ -13,6 +13,12 @@
namespace JsonApiDotNetCore.SourceGenerators
{
+ // To debug in Visual Studio (requires v17.2 or higher):
+ // - Set JsonApiDotNetCore.SourceGenerators as startup project
+ // - Add a breakpoint at the start of the Initialize or Execute method
+ // - Optional: change targetProject in Properties\launchSettings.json
+ // - Press F5
+
[Generator(LanguageNames.CSharp)]
public sealed class ControllerSourceGenerator : ISourceGenerator
{
diff --git a/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj b/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj
index 9f7c0b85dd..bcd8c06b0a 100644
--- a/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj
+++ b/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj
@@ -48,6 +48,6 @@
-
+
diff --git a/src/JsonApiDotNetCore.SourceGenerators/Properties/launchSettings.json b/src/JsonApiDotNetCore.SourceGenerators/Properties/launchSettings.json
index 2679b059a9..03635841ec 100644
--- a/src/JsonApiDotNetCore.SourceGenerators/Properties/launchSettings.json
+++ b/src/JsonApiDotNetCore.SourceGenerators/Properties/launchSettings.json
@@ -2,7 +2,7 @@
"profiles": {
"JsonApiDotNetCore.SourceGenerators": {
"commandName": "DebugRoslynComponent",
- "targetProject": "..\\..\\test\\SourceGeneratorDebugger\\SourceGeneratorDebugger.csproj"
+ "targetProject": "..\\Examples\\JsonApiDotNetCoreExample\\JsonApiDotNetCoreExample.csproj"
}
}
}
diff --git a/test/SourceGeneratorDebugger/Controllers/ArticlesController.cs b/test/SourceGeneratorDebugger/Controllers/ArticlesController.cs
deleted file mode 100644
index 1ceafa5d02..0000000000
--- a/test/SourceGeneratorDebugger/Controllers/ArticlesController.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using JetBrains.Annotations;
-
-namespace SourceGeneratorDebugger.Controllers;
-
-// Workaround for https://youtrack.jetbrains.com/issue/RSRP-487028
-public partial class ArticlesController
-{
-}
-
-[PublicAPI]
-partial class ArticlesController
-{
- public void ExtraMethod()
- {
- }
-}
diff --git a/test/SourceGeneratorDebugger/Controllers/CustomersController.cs b/test/SourceGeneratorDebugger/Controllers/CustomersController.cs
deleted file mode 100644
index a10de41483..0000000000
--- a/test/SourceGeneratorDebugger/Controllers/CustomersController.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Configuration;
-using JsonApiDotNetCore.Controllers;
-using JsonApiDotNetCore.Services;
-using Microsoft.Extensions.Logging;
-using SourceGeneratorDebugger.Models;
-
-namespace SourceGeneratorDebugger.Controllers;
-
-[PublicAPI]
-public sealed class CustomersController : JsonApiController
-{
- public CustomersController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory,
- IResourceService resourceService)
- : base(options, resourceGraph, loggerFactory, resourceService)
- {
- }
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ArgumentGuard.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/ArgumentGuard.cs
deleted file mode 100644
index e806a3caa1..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ArgumentGuard.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using JetBrains.Annotations;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-#pragma warning disable AV1008 // Class should not be static
-
-namespace JsonApiDotNetCore;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-internal static class ArgumentGuard
-{
- public static void NotNullNorEmpty(string? value, string name)
- {
- }
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/AttrAttribute.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/AttrAttribute.cs
deleted file mode 100644
index d8201a0a59..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/AttrAttribute.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using JetBrains.Annotations;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Resources.Annotations;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public sealed class AttrAttribute : Attribute
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/BaseJsonApiController.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/BaseJsonApiController.cs
deleted file mode 100644
index 2cd3fd0cd6..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/BaseJsonApiController.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Configuration;
-using JsonApiDotNetCore.Resources;
-using JsonApiDotNetCore.Services;
-using Microsoft.Extensions.Logging;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Controllers;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public abstract class BaseJsonApiController
- where TResource : class, IIdentifiable
-{
- protected BaseJsonApiController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory,
- IResourceService resourceService)
- : this(options, resourceGraph, loggerFactory, resourceService, resourceService)
- {
- }
-
- protected BaseJsonApiController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory,
- IResourceQueryService? queryService = null, IResourceCommandService? commandService = null)
- : this(options, resourceGraph, loggerFactory, queryService, queryService, queryService, queryService, commandService, commandService, commandService,
- commandService, commandService, commandService)
- {
- }
-
- protected BaseJsonApiController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory,
- IGetAllService? getAll = null, IGetByIdService? getById = null,
- IGetSecondaryService? getSecondary = null, IGetRelationshipService? getRelationship = null,
- ICreateService? create = null, IAddToRelationshipService? addToRelationship = null,
- IUpdateService? update = null, ISetRelationshipService? setRelationship = null,
- IDeleteService? delete = null, IRemoveFromRelationshipService? removeFromRelationship = null)
- {
- }
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IAddToRelationshipService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IAddToRelationshipService.cs
deleted file mode 100644
index 4bdfbe99ab..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IAddToRelationshipService.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-
-// ReSharper disable UnusedTypeParameter
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Services;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface IAddToRelationshipService
- where TResource : class, IIdentifiable
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ICreateService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/ICreateService.cs
deleted file mode 100644
index 3e1d7525a3..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ICreateService.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-
-// ReSharper disable UnusedTypeParameter
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Services;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface ICreateService
- where TResource : class, IIdentifiable
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IDeleteService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IDeleteService.cs
deleted file mode 100644
index 10a1092bd9..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IDeleteService.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-
-// ReSharper disable UnusedTypeParameter
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Services;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface IDeleteService
- where TResource : class, IIdentifiable
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetAllService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetAllService.cs
deleted file mode 100644
index 9a6644e428..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetAllService.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-
-// ReSharper disable UnusedTypeParameter
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Services;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface IGetAllService
- where TResource : class, IIdentifiable
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetByIdService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetByIdService.cs
deleted file mode 100644
index f59885af15..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetByIdService.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-
-// ReSharper disable UnusedTypeParameter
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Services;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface IGetByIdService
- where TResource : class, IIdentifiable
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetRelationshipService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetRelationshipService.cs
deleted file mode 100644
index 7e28fe1cb1..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetRelationshipService.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-
-// ReSharper disable UnusedTypeParameter
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Services;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface IGetRelationshipService
- where TResource : class, IIdentifiable
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetSecondaryService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetSecondaryService.cs
deleted file mode 100644
index 3d2d0fd381..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IGetSecondaryService.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-
-// ReSharper disable UnusedTypeParameter
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Services;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface IGetSecondaryService
- where TResource : class, IIdentifiable
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IIdentifiable.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IIdentifiable.cs
deleted file mode 100644
index a5a857cf3e..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IIdentifiable.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using JetBrains.Annotations;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Resources;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface IIdentifiable
-{
- string? StringId { get; set; }
- string? LocalId { get; set; }
-}
-
-[PublicAPI]
-public interface IIdentifiable : IIdentifiable
-{
- TId Id { get; set; }
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IJsonApiOptions.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IJsonApiOptions.cs
deleted file mode 100644
index 5d076dd4ca..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IJsonApiOptions.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using JetBrains.Annotations;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Configuration;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface IJsonApiOptions
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IRemoveFromRelationshipService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IRemoveFromRelationshipService.cs
deleted file mode 100644
index dd071fdc6e..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IRemoveFromRelationshipService.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-
-// ReSharper disable UnusedTypeParameter
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Services;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface IRemoveFromRelationshipService
- where TResource : class, IIdentifiable
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceCommandService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceCommandService.cs
deleted file mode 100644
index e7fcebc608..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceCommandService.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Services;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface IResourceCommandService
- : ICreateService, IAddToRelationshipService, IUpdateService, ISetRelationshipService,
- IDeleteService, IRemoveFromRelationshipService
- where TResource : class, IIdentifiable
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceGraph.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceGraph.cs
deleted file mode 100644
index 7d1f1562ba..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceGraph.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using JetBrains.Annotations;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Configuration;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface IResourceGraph
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceQueryService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceQueryService.cs
deleted file mode 100644
index b734963ad3..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IResourceQueryService.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Services;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface IResourceQueryService
- : IGetAllService, IGetByIdService, IGetRelationshipService, IGetSecondaryService
- where TResource : class, IIdentifiable
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ISetRelationshipService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/ISetRelationshipService.cs
deleted file mode 100644
index 2cd43448bd..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ISetRelationshipService.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-
-// ReSharper disable UnusedTypeParameter
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Services;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface ISetRelationshipService
- where TResource : class, IIdentifiable
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IUpdateService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/IUpdateService.cs
deleted file mode 100644
index 974335097c..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/IUpdateService.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-
-// ReSharper disable UnusedTypeParameter
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Services;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface IUpdateService
- where TResource : class, IIdentifiable
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/Identifiable.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/Identifiable.cs
deleted file mode 100644
index 6e78d67867..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/Identifiable.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using JetBrains.Annotations;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Resources;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public abstract class Identifiable : IIdentifiable
-{
- public virtual TId Id { get; set; } = default!;
-
- public string? StringId { get; set; }
- public string? LocalId { get; set; }
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiCommandController.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiCommandController.cs
deleted file mode 100644
index 31736e8088..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiCommandController.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Configuration;
-using JsonApiDotNetCore.Resources;
-using JsonApiDotNetCore.Services;
-using Microsoft.Extensions.Logging;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Controllers;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public abstract class JsonApiCommandController : BaseJsonApiController
- where TResource : class, IIdentifiable
-{
- protected JsonApiCommandController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory,
- IResourceCommandService commandService)
- : base(options, resourceGraph, loggerFactory, null, commandService)
- {
- }
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiController.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiController.cs
deleted file mode 100644
index 9d7d1d6e9c..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiController.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Configuration;
-using JsonApiDotNetCore.Resources;
-using JsonApiDotNetCore.Services;
-using Microsoft.Extensions.Logging;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Controllers;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public abstract class JsonApiController : BaseJsonApiController
- where TResource : class, IIdentifiable
-{
- protected JsonApiController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory,
- IResourceService resourceService)
- : base(options, resourceGraph, loggerFactory, resourceService)
- {
- }
-
- protected JsonApiController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory,
- IGetAllService? getAll = null, IGetByIdService? getById = null,
- IGetSecondaryService? getSecondary = null, IGetRelationshipService? getRelationship = null,
- ICreateService? create = null, IAddToRelationshipService? addToRelationship = null,
- IUpdateService? update = null, ISetRelationshipService? setRelationship = null,
- IDeleteService? delete = null, IRemoveFromRelationshipService? removeFromRelationship = null)
- : base(options, resourceGraph, loggerFactory, getAll, getById, getSecondary, getRelationship, create, addToRelationship, update, setRelationship,
- delete, removeFromRelationship)
- {
- }
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiOptions.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiOptions.cs
deleted file mode 100644
index bad4ca2a28..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiOptions.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-// ReSharper disable CheckNamespace
-
-using JetBrains.Annotations;
-
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Configuration;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public sealed class JsonApiOptions : IJsonApiOptions
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiQueryController.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiQueryController.cs
deleted file mode 100644
index cebb57e7bc..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiQueryController.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Configuration;
-using JsonApiDotNetCore.Resources;
-using JsonApiDotNetCore.Services;
-using Microsoft.Extensions.Logging;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Controllers;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public abstract class JsonApiQueryController : BaseJsonApiController
- where TResource : class, IIdentifiable
-{
- protected JsonApiQueryController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory,
- IResourceQueryService queryService)
- : base(options, resourceGraph, loggerFactory, queryService)
- {
- }
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiResourceService.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiResourceService.cs
deleted file mode 100644
index 118f5d315d..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/JsonApiResourceService.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Services;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public sealed class JsonApiResourceService : IResourceService
- where TResource : class, IIdentifiable
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ResourceGraph.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/ResourceGraph.cs
deleted file mode 100644
index 5be951c9f4..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ResourceGraph.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using JetBrains.Annotations;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Configuration;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public sealed class ResourceGraph : IResourceGraph
-{
-}
diff --git a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ResourceServiceInterfaces.cs b/test/SourceGeneratorDebugger/JsonApiDotNetCore/ResourceServiceInterfaces.cs
deleted file mode 100644
index 72cd018d77..0000000000
--- a/test/SourceGeneratorDebugger/JsonApiDotNetCore/ResourceServiceInterfaces.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace JsonApiDotNetCore.Services;
-
-///
-/// Represents a stripped-down copy of this type in the JsonApiDotNetCore project. It exists solely to fulfill the dependency needs for successfully
-/// compiling the source-generated controllers in this project.
-///
-[PublicAPI]
-public interface IResourceService : IResourceCommandService, IResourceQueryService
- where TResource : class, IIdentifiable
-{
-}
diff --git a/test/SourceGeneratorDebugger/Models/Account.cs b/test/SourceGeneratorDebugger/Models/Account.cs
deleted file mode 100644
index 360f6f837f..0000000000
--- a/test/SourceGeneratorDebugger/Models/Account.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Controllers;
-using JsonApiDotNetCore.Resources;
-using JsonApiDotNetCore.Resources.Annotations;
-
-namespace SourceGeneratorDebugger.Models;
-
-[UsedImplicitly(ImplicitUseTargetFlags.Members)]
-[Resource(GenerateControllerEndpoints = JsonApiEndpoints.Query, ControllerNamespace = "Some.Namespace.To.Place.Controllers")]
-public sealed class Account : Identifiable
-{
- [Attr]
- public string? DisplayName { get; set; }
-}
diff --git a/test/SourceGeneratorDebugger/Models/Article.cs b/test/SourceGeneratorDebugger/Models/Article.cs
deleted file mode 100644
index fd28b80494..0000000000
--- a/test/SourceGeneratorDebugger/Models/Article.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Controllers;
-using JsonApiDotNetCore.Resources;
-using JsonApiDotNetCore.Resources.Annotations;
-
-namespace SourceGeneratorDebugger.Models;
-
-[UsedImplicitly(ImplicitUseTargetFlags.Members)]
-[Resource(GenerateControllerEndpoints = JsonApiEndpoints.GetCollection | JsonApiEndpoints.GetSingle | JsonApiEndpoints.GetSecondary)]
-public sealed class Article : Identifiable
-{
- [Attr]
- public string? DisplayName { get; set; }
-}
diff --git a/test/SourceGeneratorDebugger/Models/Customer.cs b/test/SourceGeneratorDebugger/Models/Customer.cs
deleted file mode 100644
index 26d869c550..0000000000
--- a/test/SourceGeneratorDebugger/Models/Customer.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-using JsonApiDotNetCore.Resources.Annotations;
-
-namespace SourceGeneratorDebugger.Models;
-
-[UsedImplicitly(ImplicitUseTargetFlags.Members)]
-public sealed class Customer : Identifiable
-{
- [Attr]
- public string Name { get; set; } = null!;
-}
diff --git a/test/SourceGeneratorDebugger/Models/Global.cs b/test/SourceGeneratorDebugger/Models/Global.cs
deleted file mode 100644
index ef62b974ca..0000000000
--- a/test/SourceGeneratorDebugger/Models/Global.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-using JsonApiDotNetCore.Resources.Annotations;
-
-// ReSharper disable CheckNamespace
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-[UsedImplicitly(ImplicitUseTargetFlags.Members)]
-[Resource]
-public sealed class Global : Identifiable
-{
- [Attr]
- public string? Value { get; set; }
-}
diff --git a/test/SourceGeneratorDebugger/Models/Login.cs b/test/SourceGeneratorDebugger/Models/Login.cs
deleted file mode 100644
index 334a395a21..0000000000
--- a/test/SourceGeneratorDebugger/Models/Login.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Controllers;
-using JsonApiDotNetCore.Resources;
-using JsonApiDotNetCore.Resources.Annotations;
-
-#pragma warning disable AV1505 // Namespace should match with assembly name
-
-namespace SourceGeneratorDebugger.Models
-{
- [UsedImplicitly(ImplicitUseTargetFlags.Members)]
- [Resource(GenerateControllerEndpoints = JsonApiEndpoints.Command)]
- public sealed class Login : Identifiable
- {
- [Attr]
- public DateTimeOffset Time { get; set; }
- }
-}
-
-namespace Some.Other.Path
-{
- [UsedImplicitly(ImplicitUseTargetFlags.Members)]
- [Resource(GenerateControllerEndpoints = JsonApiEndpoints.Command)]
- public sealed class Login : Identifiable
- {
- [Attr]
- public DateTimeOffset Time { get; set; }
- }
-}
diff --git a/test/SourceGeneratorDebugger/Models/Order.cs b/test/SourceGeneratorDebugger/Models/Order.cs
deleted file mode 100644
index 40d5582ff1..0000000000
--- a/test/SourceGeneratorDebugger/Models/Order.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Controllers;
-using JsonApiDotNetCore.Resources;
-using JsonApiDotNetCore.Resources.Annotations;
-
-namespace SourceGeneratorDebugger.Models;
-
-[UsedImplicitly(ImplicitUseTargetFlags.Members)]
-[Resource(GenerateControllerEndpoints = JsonApiEndpoints.All)]
-public sealed class Order : Identifiable
-{
- [Attr]
- public decimal TotalAmount { get; set; }
-}
diff --git a/test/SourceGeneratorDebugger/Models/SimpleNamespace.cs b/test/SourceGeneratorDebugger/Models/SimpleNamespace.cs
deleted file mode 100644
index ea02d20413..0000000000
--- a/test/SourceGeneratorDebugger/Models/SimpleNamespace.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using JetBrains.Annotations;
-using JsonApiDotNetCore.Resources;
-using JsonApiDotNetCore.Resources.Annotations;
-
-// ReSharper disable CheckNamespace
-
-namespace SourceGeneratorDebugger;
-
-[UsedImplicitly(ImplicitUseTargetFlags.Members)]
-[Resource]
-public sealed class SimpleNamespace : Identifiable
-{
- [Attr]
- public string? Value { get; set; }
-}
diff --git a/test/SourceGeneratorDebugger/Program.cs b/test/SourceGeneratorDebugger/Program.cs
deleted file mode 100644
index b237a86f68..0000000000
--- a/test/SourceGeneratorDebugger/Program.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using JsonApiDotNetCore.Configuration;
-using JsonApiDotNetCore.Services;
-using Microsoft.Extensions.Logging.Abstractions;
-using SourceGeneratorDebugger.Controllers;
-using SourceGeneratorDebugger.Models;
-
-namespace SourceGeneratorDebugger;
-
-// Until https://github.com/dotnet/roslyn/issues/55802 is fixed, this project enables us to debug the ASP.NET Controller source generator.
-// In Visual Studio, set JsonApiDotNetCore.SourceGenerators as startup project, add a breakpoint at the start of ControllerSourceGenerator and press F5.
-internal static class Program
-{
- public static void Main()
- {
- JsonApiOptions options = new();
- ResourceGraph resourceGraph = new();
-
- // Built-in
- IResourceService customerResourceService = new JsonApiResourceService();
- CustomersController customersController = new(options, resourceGraph, NullLoggerFactory.Instance, customerResourceService);
- GC.KeepAlive(customersController);
-
- // Generated
- IResourceService orderResourceService = new JsonApiResourceService();
- OrdersController ordersController = new(options, resourceGraph, NullLoggerFactory.Instance, orderResourceService);
- GC.KeepAlive(ordersController);
-
- // Generated Query
- IResourceQueryService accountQueryService = new JsonApiResourceService();
- AccountsController accountsController = new(options, resourceGraph, NullLoggerFactory.Instance, accountQueryService);
- GC.KeepAlive(accountsController);
-
- // Generated Command
- IResourceCommandService loginCommandService = new JsonApiResourceService();
- LoginsController loginsController = new(options, resourceGraph, NullLoggerFactory.Instance, loginCommandService);
- GC.KeepAlive(loginsController);
-
- // Generated mix
- IGetAllService articleGetAllResourceService = new JsonApiResourceService();
- IGetByIdService articleGetByIdResourceService = new JsonApiResourceService();
- IGetSecondaryService articleGetSecondaryResourceService = new JsonApiResourceService();
-
- ArticlesController articlesController = new(options, resourceGraph, NullLoggerFactory.Instance, articleGetAllResourceService,
- articleGetByIdResourceService, articleGetSecondaryResourceService);
-
- articlesController.ExtraMethod();
-
- // Generated in global namespace
- IResourceService globalResourceService = new JsonApiResourceService();
- GlobalsController globalsController = new(options, resourceGraph, NullLoggerFactory.Instance, globalResourceService);
- GC.KeepAlive(globalsController);
-
- // Generated in non-nested namespace
- IResourceService singleNamespaceResourceService = new JsonApiResourceService();
- SimpleNamespacesController singleNamespacesController = new(options, resourceGraph, NullLoggerFactory.Instance, singleNamespaceResourceService);
- GC.KeepAlive(singleNamespacesController);
- }
-}
diff --git a/test/SourceGeneratorDebugger/SourceGeneratorDebugger.csproj b/test/SourceGeneratorDebugger/SourceGeneratorDebugger.csproj
deleted file mode 100644
index 2909905e2b..0000000000
--- a/test/SourceGeneratorDebugger/SourceGeneratorDebugger.csproj
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- $(TargetFrameworkName)
- Exe
- true
- $(BaseIntermediateOutputPath)\GeneratedFiles
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/test/TestBuildingBlocks/TestBuildingBlocks.csproj b/test/TestBuildingBlocks/TestBuildingBlocks.csproj
index 68db5c994c..2f383d72e9 100644
--- a/test/TestBuildingBlocks/TestBuildingBlocks.csproj
+++ b/test/TestBuildingBlocks/TestBuildingBlocks.csproj
@@ -10,13 +10,13 @@
-
+
-
+
From 7246d1344c59f6f4c17bd856532979b560ee3d4b Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Thu, 26 May 2022 23:17:06 +0200
Subject: [PATCH 05/50] Updated issue templates
---
.github/CONTRIBUTING.md | 4 +--
.github/ISSUE_TEMPLATE/bug_report.md | 13 ++++----
.github/ISSUE_TEMPLATE/feature_request.md | 12 +++----
.github/ISSUE_TEMPLATE/question.md | 38 +++++++++++++++++++++++
4 files changed, 52 insertions(+), 15 deletions(-)
create mode 100644 .github/ISSUE_TEMPLATE/question.md
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 150c8b45df..5e87f135f0 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -1,8 +1,6 @@
# I don't want to read this whole thing I just have a question!!!
-> Note: Please don't file an issue to ask a question.
-
-You'll get faster results by using our official [Gitter channel](https://gitter.im/json-api-dotnet-core/Lobby) or [StackOverflow](https://stackoverflow.com/search?q=jsonapidotnetcore) where the community chimes in with helpful advice if you have questions.
+> You can file an issue to ask a question, but you'll get faster results by using our official [Gitter channel](https://gitter.im/json-api-dotnet-core/Lobby) or [StackOverflow](https://stackoverflow.com/search?q=jsonapidotnetcore) where the community chimes in with helpful advice if you have questions.
# How can I contribute?
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index e0c2388a38..c59acf46d6 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -2,18 +2,18 @@
name: Bug report
about: Create a report to help us improve
title: ''
-labels: ''
+labels: 'bug'
assignees: ''
---
-_Please read our [Contributing Guides](https://github.com/json-api-dotnet/JsonApiDotNetCore/blob/master/.github/CONTRIBUTING.md) before submitting a bug._
+
#### DESCRIPTION
-_A clear and concise description of what the bug is._
+
#### STEPS TO REPRODUCE
-_Consider to include your code here, such as models, DbContext, controllers, resource services, repositories, resource definitions etc. Please also include the request URL with body (if applicable) and the full exception stack trace (set `options.IncludeExceptionStackTraceInErrors` to `true`) in case of errors._ It may also be helpful to include the produced SQL, which can be made visible in logs by adding this to appsettings.json:
+
1.
2.
3.
#### EXPECTED BEHAVIOR
-_A clear and concise description of what you expected to happen._
+
#### ACTUAL BEHAVIOR
-_A clear and concise description of what happens instead._
+
#### VERSIONS USED
- JsonApiDotNetCore version:
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index f7b806fe50..f629ca472d 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -2,21 +2,21 @@
name: Feature request
about: Suggest an idea for this project
title: ''
-labels: ''
+labels: 'enhancement'
assignees: ''
---
-_Please read our [Contributing Guides](https://github.com/json-api-dotnet/JsonApiDotNetCore/blob/master/.github/CONTRIBUTING.md) before suggesting an idea._
+
**Is your feature request related to a problem? Please describe.**
-_A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]_
+
**Describe the solution you'd like**
-_A clear and concise description of what you want to happen._
+
**Describe alternatives you've considered**
-_A clear and concise description of any alternative solutions or features you've considered._
+
**Additional context**
-_Add any other context or screenshots about the feature request here._
+
diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md
new file mode 100644
index 0000000000..689f2daa01
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/question.md
@@ -0,0 +1,38 @@
+---
+name: Question
+about: Ask a question
+title: ''
+labels: 'question'
+assignees: ''
+
+---
+
+#### SUMMARY
+
+
+#### DETAILS
+
+
+#### STEPS TO REPRODUCE
+
+
+1.
+2.
+3.
+
+#### VERSIONS USED
+- JsonApiDotNetCore version:
+- ASP.NET Core version:
+- Entity Framework Core version:
+- Database provider:
From 9af5eda9f6c01190414d07b5ca50ed9adbccd966 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Sat, 18 Jun 2022 10:29:20 +0200
Subject: [PATCH 06/50] Fixed spelling error
---
src/JsonApiDotNetCore/Diagnostics/CascadingCodeTimer.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/JsonApiDotNetCore/Diagnostics/CascadingCodeTimer.cs b/src/JsonApiDotNetCore/Diagnostics/CascadingCodeTimer.cs
index 44cc2955d9..a2aa7a379b 100644
--- a/src/JsonApiDotNetCore/Diagnostics/CascadingCodeTimer.cs
+++ b/src/JsonApiDotNetCore/Diagnostics/CascadingCodeTimer.cs
@@ -18,7 +18,7 @@ static CascadingCodeTimer()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- // Be default, measurements using Stopwatch can differ 25%-30% on the same function on the same computer.
+ // By default, measurements using Stopwatch can differ 25%-30% on the same function on the same computer.
// The steps below ensure to get an accuracy of 0.1%-0.2%. With this accuracy, algorithms can be tested and compared.
// https://www.codeproject.com/Articles/61964/Performance-Tests-Precise-Run-Time-Measurements-wi
From 174a599a169c343f9c1ec9ba8ced088cd5a6a5ea Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Thu, 23 Jun 2022 00:25:10 +0200
Subject: [PATCH 07/50] Fixed crash when a generic resource definition
references an interface field from its OnApplySort lambda. Where we used to
special-case for Identifiable.Id, we now always use the expression type for
resource graph lookups. This is safe because its not possible in C# to remove
base members. The value of memberExpression.Expression is null on static
member access, which is unlikely to occur in sort lambdas.
---
.../Resources/SortExpressionLambdaConverter.cs | 7 ++-----
.../CreateSortExpressionFromLambdaTests.cs | 4 ++--
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/JsonApiDotNetCore/Resources/SortExpressionLambdaConverter.cs b/src/JsonApiDotNetCore/Resources/SortExpressionLambdaConverter.cs
index a2371419b6..36a6d97aec 100644
--- a/src/JsonApiDotNetCore/Resources/SortExpressionLambdaConverter.cs
+++ b/src/JsonApiDotNetCore/Resources/SortExpressionLambdaConverter.cs
@@ -114,12 +114,9 @@ private static (Expression? innerExpression, bool isCount) TryReadCount(Expressi
private Expression? ReadAttribute(Expression expression)
{
- if (expression is MemberExpression memberExpression)
+ if (expression is MemberExpression { Expression: { } } memberExpression)
{
- ResourceType resourceType = memberExpression.Member.Name == nameof(Identifiable
[PublicAPI]
-public sealed class AtomicReference : IResourceIdentity
+public sealed class AtomicReference : ResourceIdentity
{
- [JsonPropertyName("type")]
- [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
- public string? Type { get; set; }
-
- [JsonPropertyName("id")]
- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
- public string? Id { get; set; }
-
- [JsonPropertyName("lid")]
- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
- public string? Lid { get; set; }
-
[JsonPropertyName("relationship")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Relationship { get; set; }
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/IResourceIdentity.cs b/src/JsonApiDotNetCore/Serialization/Objects/IResourceIdentity.cs
deleted file mode 100644
index c4b57f535f..0000000000
--- a/src/JsonApiDotNetCore/Serialization/Objects/IResourceIdentity.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace JsonApiDotNetCore.Serialization.Objects;
-
-public interface IResourceIdentity
-{
- public string? Type { get; }
- public string? Id { get; }
- public string? Lid { get; }
-}
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/ResourceIdentifierObject.cs b/src/JsonApiDotNetCore/Serialization/Objects/ResourceIdentifierObject.cs
index a1b8271cf7..20c30909ed 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/ResourceIdentifierObject.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/ResourceIdentifierObject.cs
@@ -7,21 +7,10 @@ namespace JsonApiDotNetCore.Serialization.Objects;
/// See https://jsonapi.org/format/1.1/#document-resource-identifier-objects.
///
[PublicAPI]
-public sealed class ResourceIdentifierObject : IResourceIdentity
+public class ResourceIdentifierObject : ResourceIdentity
{
- [JsonPropertyName("type")]
- [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
- public string? Type { get; set; }
-
- [JsonPropertyName("id")]
- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
- public string? Id { get; set; }
-
- [JsonPropertyName("lid")]
- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
- public string? Lid { get; set; }
-
[JsonPropertyName("meta")]
+ [JsonPropertyOrder(100)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IDictionary? Meta { get; set; }
}
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/ResourceIdentity.cs b/src/JsonApiDotNetCore/Serialization/Objects/ResourceIdentity.cs
new file mode 100644
index 0000000000..41a3d951e6
--- /dev/null
+++ b/src/JsonApiDotNetCore/Serialization/Objects/ResourceIdentity.cs
@@ -0,0 +1,26 @@
+using System.Text.Json.Serialization;
+using JetBrains.Annotations;
+
+namespace JsonApiDotNetCore.Serialization.Objects;
+
+///
+/// Shared identity information for various JSON:API objects.
+///
+[PublicAPI]
+public abstract class ResourceIdentity
+{
+ [JsonPropertyName("type")]
+ [JsonPropertyOrder(-3)]
+ [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
+ public string? Type { get; set; }
+
+ [JsonPropertyName("id")]
+ [JsonPropertyOrder(-2)]
+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
+ public string? Id { get; set; }
+
+ [JsonPropertyName("lid")]
+ [JsonPropertyOrder(-1)]
+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
+ public string? Lid { get; set; }
+}
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/ResourceObject.cs b/src/JsonApiDotNetCore/Serialization/Objects/ResourceObject.cs
index 43b3b9616a..ed38a40f9a 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/ResourceObject.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/ResourceObject.cs
@@ -7,33 +7,20 @@ namespace JsonApiDotNetCore.Serialization.Objects;
/// See https://jsonapi.org/format/1.1/#document-resource-objects.
///
[PublicAPI]
-public sealed class ResourceObject : IResourceIdentity
+public sealed class ResourceObject : ResourceIdentifierObject
{
- [JsonPropertyName("type")]
- [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
- public string? Type { get; set; }
-
- [JsonPropertyName("id")]
- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
- public string? Id { get; set; }
-
- [JsonPropertyName("lid")]
- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
- public string? Lid { get; set; }
-
[JsonPropertyName("attributes")]
+ [JsonPropertyOrder(1)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IDictionary? Attributes { get; set; }
[JsonPropertyName("relationships")]
+ [JsonPropertyOrder(2)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IDictionary? Relationships { get; set; }
[JsonPropertyName("links")]
+ [JsonPropertyOrder(3)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ResourceLinks? Links { get; set; }
-
- [JsonPropertyName("meta")]
- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
- public IDictionary? Meta { get; set; }
}
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/SingleOrManyData.cs b/src/JsonApiDotNetCore/Serialization/Objects/SingleOrManyData.cs
index 1d2f99e126..1126f84f26 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/SingleOrManyData.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/SingleOrManyData.cs
@@ -13,7 +13,7 @@ namespace JsonApiDotNetCore.Serialization.Objects;
public readonly struct SingleOrManyData
// The "new()" constraint exists for parity with SingleOrManyDataConverterFactory, which creates empty instances
// to ensure ManyValue never contains null items.
- where T : class, IResourceIdentity, new()
+ where T : ResourceIdentifierObject, new()
{
public object? Value => ManyValue != null ? ManyValue : SingleValue;
diff --git a/src/JsonApiDotNetCore/Serialization/Request/Adapters/BaseAdapter.cs b/src/JsonApiDotNetCore/Serialization/Request/Adapters/BaseAdapter.cs
index 64e2f6d53b..fb1111bea1 100644
--- a/src/JsonApiDotNetCore/Serialization/Request/Adapters/BaseAdapter.cs
+++ b/src/JsonApiDotNetCore/Serialization/Request/Adapters/BaseAdapter.cs
@@ -11,7 +11,7 @@ public abstract class BaseAdapter
{
[AssertionMethod]
protected static void AssertHasData(SingleOrManyData data, RequestAdapterState state)
- where T : class, IResourceIdentity, new()
+ where T : ResourceIdentifierObject, new()
{
if (!data.IsAssigned)
{
@@ -21,7 +21,7 @@ protected static void AssertHasData(SingleOrManyData data, RequestAdapterS
[AssertionMethod]
protected static void AssertDataHasSingleValue(SingleOrManyData data, bool allowNull, RequestAdapterState state)
- where T : class, IResourceIdentity, new()
+ where T : ResourceIdentifierObject, new()
{
if (data.SingleValue == null)
{
@@ -44,7 +44,7 @@ protected static void AssertDataHasSingleValue(SingleOrManyData data, bool
[AssertionMethod]
protected static void AssertDataHasManyValue(SingleOrManyData data, RequestAdapterState state)
- where T : class, IResourceIdentity, new()
+ where T : ResourceIdentifierObject, new()
{
if (data.ManyValue == null)
{
diff --git a/src/JsonApiDotNetCore/Serialization/Request/Adapters/ResourceIdentityAdapter.cs b/src/JsonApiDotNetCore/Serialization/Request/Adapters/ResourceIdentityAdapter.cs
index d163eb56d1..61c6cc1857 100644
--- a/src/JsonApiDotNetCore/Serialization/Request/Adapters/ResourceIdentityAdapter.cs
+++ b/src/JsonApiDotNetCore/Serialization/Request/Adapters/ResourceIdentityAdapter.cs
@@ -25,7 +25,7 @@ protected ResourceIdentityAdapter(IResourceGraph resourceGraph, IResourceFactory
_resourceFactory = resourceFactory;
}
- protected (IIdentifiable resource, ResourceType resourceType) ConvertResourceIdentity(IResourceIdentity identity, ResourceIdentityRequirements requirements,
+ protected (IIdentifiable resource, ResourceType resourceType) ConvertResourceIdentity(ResourceIdentity identity, ResourceIdentityRequirements requirements,
RequestAdapterState state)
{
ArgumentGuard.NotNull(identity, nameof(identity));
@@ -38,7 +38,7 @@ protected ResourceIdentityAdapter(IResourceGraph resourceGraph, IResourceFactory
return (resource, resourceType);
}
- private ResourceType ResolveType(IResourceIdentity identity, ResourceIdentityRequirements requirements, RequestAdapterState state)
+ private ResourceType ResolveType(ResourceIdentity identity, ResourceIdentityRequirements requirements, RequestAdapterState state)
{
AssertHasType(identity.Type, state);
@@ -93,7 +93,7 @@ private static void AssertIsCompatibleResourceType(ResourceType actual, Resource
}
}
- private IIdentifiable CreateResource(IResourceIdentity identity, ResourceIdentityRequirements requirements, Type resourceClrType, RequestAdapterState state)
+ private IIdentifiable CreateResource(ResourceIdentity identity, ResourceIdentityRequirements requirements, Type resourceClrType, RequestAdapterState state)
{
if (state.Request.Kind != EndpointKind.AtomicOperations)
{
@@ -120,7 +120,7 @@ private IIdentifiable CreateResource(IResourceIdentity identity, ResourceIdentit
return resource;
}
- private static void AssertHasNoLid(IResourceIdentity identity, RequestAdapterState state)
+ private static void AssertHasNoLid(ResourceIdentity identity, RequestAdapterState state)
{
if (identity.Lid != null)
{
@@ -129,7 +129,7 @@ private static void AssertHasNoLid(IResourceIdentity identity, RequestAdapterSta
}
}
- private static void AssertNoIdWithLid(IResourceIdentity identity, RequestAdapterState state)
+ private static void AssertNoIdWithLid(ResourceIdentity identity, RequestAdapterState state)
{
if (identity.Id != null && identity.Lid != null)
{
@@ -137,7 +137,7 @@ private static void AssertNoIdWithLid(IResourceIdentity identity, RequestAdapter
}
}
- private static void AssertHasIdOrLid(IResourceIdentity identity, ResourceIdentityRequirements requirements, RequestAdapterState state)
+ private static void AssertHasIdOrLid(ResourceIdentity identity, ResourceIdentityRequirements requirements, RequestAdapterState state)
{
string? message = null;
@@ -160,7 +160,7 @@ private static void AssertHasIdOrLid(IResourceIdentity identity, ResourceIdentit
}
}
- private static void AssertHasNoId(IResourceIdentity identity, RequestAdapterState state)
+ private static void AssertHasNoId(ResourceIdentity identity, RequestAdapterState state)
{
if (identity.Id != null)
{
@@ -169,7 +169,7 @@ private static void AssertHasNoId(IResourceIdentity identity, RequestAdapterStat
}
}
- private static void AssertSameIdValue(IResourceIdentity identity, string? expected, RequestAdapterState state)
+ private static void AssertSameIdValue(ResourceIdentity identity, string? expected, RequestAdapterState state)
{
if (expected != null && identity.Id != expected)
{
@@ -180,7 +180,7 @@ private static void AssertSameIdValue(IResourceIdentity identity, string? expect
}
}
- private static void AssertSameLidValue(IResourceIdentity identity, string? expected, RequestAdapterState state)
+ private static void AssertSameLidValue(ResourceIdentity identity, string? expected, RequestAdapterState state)
{
if (expected != null && identity.Lid != expected)
{
@@ -191,7 +191,7 @@ private static void AssertSameLidValue(IResourceIdentity identity, string? expec
}
}
- private void AssignStringId(IResourceIdentity identity, IIdentifiable resource, RequestAdapterState state)
+ private void AssignStringId(ResourceIdentity identity, IIdentifiable resource, RequestAdapterState state)
{
if (identity.Id != null)
{
diff --git a/src/JsonApiDotNetCore/Serialization/Request/Adapters/ResourceIdentityRequirements.cs b/src/JsonApiDotNetCore/Serialization/Request/Adapters/ResourceIdentityRequirements.cs
index 11db5e8ee3..d5498397bf 100644
--- a/src/JsonApiDotNetCore/Serialization/Request/Adapters/ResourceIdentityRequirements.cs
+++ b/src/JsonApiDotNetCore/Serialization/Request/Adapters/ResourceIdentityRequirements.cs
@@ -5,7 +5,7 @@
namespace JsonApiDotNetCore.Serialization.Request.Adapters;
///
-/// Defines requirements to validate an instance against.
+/// Defines requirements to validate a instance against.
///
[PublicAPI]
public sealed class ResourceIdentityRequirements
From 792ab16e44eb090465bf2e28ef9d016987aab05d Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Sun, 21 Aug 2022 13:56:20 +0200
Subject: [PATCH 17/50] Tweak benchmarks
---
benchmarks/Benchmarks.csproj | 4 +-
.../OperationsDeserializationBenchmarks.cs | 1 +
.../ResourceDeserializationBenchmarks.cs | 1 +
.../QueryStringParserBenchmarks.cs | 31 +---
.../OperationsSerializationBenchmarks.cs | 1 +
.../ResourceSerializationBenchmarks.cs | 1 +
.../SerializationBenchmarkBase.cs | 147 +-----------------
benchmarks/Tools/FakeLinkBuilder.cs | 39 +++++
.../Tools/FakeRequestQueryStringAccessor.cs | 18 +++
.../Tools/NeverResourceDefinitionAccessor.cs | 103 ++++++++++++
benchmarks/Tools/NoMetaBuilder.cs | 18 +++
11 files changed, 191 insertions(+), 173 deletions(-)
create mode 100644 benchmarks/Tools/FakeLinkBuilder.cs
create mode 100644 benchmarks/Tools/FakeRequestQueryStringAccessor.cs
create mode 100644 benchmarks/Tools/NeverResourceDefinitionAccessor.cs
create mode 100644 benchmarks/Tools/NoMetaBuilder.cs
diff --git a/benchmarks/Benchmarks.csproj b/benchmarks/Benchmarks.csproj
index 4bde435c15..f461a4831b 100644
--- a/benchmarks/Benchmarks.csproj
+++ b/benchmarks/Benchmarks.csproj
@@ -1,7 +1,8 @@
-
+
Exe
$(TargetFrameworkName)
+ true
@@ -10,6 +11,5 @@
-
diff --git a/benchmarks/Deserialization/OperationsDeserializationBenchmarks.cs b/benchmarks/Deserialization/OperationsDeserializationBenchmarks.cs
index d28684e27b..99adce73cb 100644
--- a/benchmarks/Deserialization/OperationsDeserializationBenchmarks.cs
+++ b/benchmarks/Deserialization/OperationsDeserializationBenchmarks.cs
@@ -7,6 +7,7 @@
namespace Benchmarks.Deserialization;
[MarkdownExporter]
+[MemoryDiagnoser]
// ReSharper disable once ClassCanBeSealed.Global
public class OperationsDeserializationBenchmarks : DeserializationBenchmarkBase
{
diff --git a/benchmarks/Deserialization/ResourceDeserializationBenchmarks.cs b/benchmarks/Deserialization/ResourceDeserializationBenchmarks.cs
index 23a6205bf5..e503a329bb 100644
--- a/benchmarks/Deserialization/ResourceDeserializationBenchmarks.cs
+++ b/benchmarks/Deserialization/ResourceDeserializationBenchmarks.cs
@@ -7,6 +7,7 @@
namespace Benchmarks.Deserialization;
[MarkdownExporter]
+[MemoryDiagnoser]
// ReSharper disable once ClassCanBeSealed.Global
public class ResourceDeserializationBenchmarks : DeserializationBenchmarkBase
{
diff --git a/benchmarks/QueryString/QueryStringParserBenchmarks.cs b/benchmarks/QueryString/QueryStringParserBenchmarks.cs
index efa4f12659..4218c2e3dc 100644
--- a/benchmarks/QueryString/QueryStringParserBenchmarks.cs
+++ b/benchmarks/QueryString/QueryStringParserBenchmarks.cs
@@ -1,13 +1,12 @@
using System.ComponentModel.Design;
using BenchmarkDotNet.Attributes;
+using Benchmarks.Tools;
using JsonApiDotNetCore;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Middleware;
using JsonApiDotNetCore.QueryStrings;
using JsonApiDotNetCore.QueryStrings.Internal;
using JsonApiDotNetCore.Resources;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging.Abstractions;
namespace Benchmarks.QueryString;
@@ -71,31 +70,9 @@ public void DescendingSort()
[Benchmark]
public void ComplexQuery()
{
- Run(100, () =>
- {
- const string queryString =
- "?filter[alt-attr-name]=abc,eq:abc&sort=-alt-attr-name&include=child&page[size]=1&fields[alt-resource-name]=alt-attr-name";
-
- _queryStringAccessor.SetQueryString(queryString);
- _queryStringReader.ReadAll(null);
- });
- }
-
- private void Run(int iterations, Action action)
- {
- for (int index = 0; index < iterations; index++)
- {
- action();
- }
- }
-
- private sealed class FakeRequestQueryStringAccessor : IRequestQueryStringAccessor
- {
- public IQueryCollection Query { get; private set; } = new QueryCollection();
+ const string queryString = "?filter[alt-attr-name]=abc,eq:abc&sort=-alt-attr-name&include=child&page[size]=1&fields[alt-resource-name]=alt-attr-name";
- public void SetQueryString(string queryString)
- {
- Query = new QueryCollection(QueryHelpers.ParseQuery(queryString));
- }
+ _queryStringAccessor.SetQueryString(queryString);
+ _queryStringReader.ReadAll(null);
}
}
diff --git a/benchmarks/Serialization/OperationsSerializationBenchmarks.cs b/benchmarks/Serialization/OperationsSerializationBenchmarks.cs
index 7076ca5cb8..471c9604c7 100644
--- a/benchmarks/Serialization/OperationsSerializationBenchmarks.cs
+++ b/benchmarks/Serialization/OperationsSerializationBenchmarks.cs
@@ -9,6 +9,7 @@
namespace Benchmarks.Serialization;
[MarkdownExporter]
+[MemoryDiagnoser]
// ReSharper disable once ClassCanBeSealed.Global
public class OperationsSerializationBenchmarks : SerializationBenchmarkBase
{
diff --git a/benchmarks/Serialization/ResourceSerializationBenchmarks.cs b/benchmarks/Serialization/ResourceSerializationBenchmarks.cs
index 12f5c2e788..a985bd5936 100644
--- a/benchmarks/Serialization/ResourceSerializationBenchmarks.cs
+++ b/benchmarks/Serialization/ResourceSerializationBenchmarks.cs
@@ -12,6 +12,7 @@
namespace Benchmarks.Serialization;
[MarkdownExporter]
+[MemoryDiagnoser]
// ReSharper disable once ClassCanBeSealed.Global
public class ResourceSerializationBenchmarks : SerializationBenchmarkBase
{
diff --git a/benchmarks/Serialization/SerializationBenchmarkBase.cs b/benchmarks/Serialization/SerializationBenchmarkBase.cs
index e1bcb10843..d9cfefd0b6 100644
--- a/benchmarks/Serialization/SerializationBenchmarkBase.cs
+++ b/benchmarks/Serialization/SerializationBenchmarkBase.cs
@@ -1,18 +1,14 @@
-using System.Collections.Immutable;
using System.Text.Json;
using System.Text.Json.Serialization;
+using Benchmarks.Tools;
using JetBrains.Annotations;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Middleware;
using JsonApiDotNetCore.Queries;
-using JsonApiDotNetCore.Queries.Expressions;
using JsonApiDotNetCore.Queries.Internal;
-using JsonApiDotNetCore.QueryStrings;
using JsonApiDotNetCore.Resources;
using JsonApiDotNetCore.Resources.Annotations;
-using JsonApiDotNetCore.Serialization.Objects;
using JsonApiDotNetCore.Serialization.Response;
-using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging.Abstractions;
namespace Benchmarks.Serialization;
@@ -45,9 +41,9 @@ protected SerializationBenchmarkBase()
// ReSharper restore VirtualMemberCallInConstructor
var linkBuilder = new FakeLinkBuilder();
- var metaBuilder = new FakeMetaBuilder();
+ var metaBuilder = new NoMetaBuilder();
IQueryConstraintProvider[] constraintProviders = Array.Empty();
- var resourceDefinitionAccessor = new FakeResourceDefinitionAccessor();
+ var resourceDefinitionAccessor = new NeverResourceDefinitionAccessor();
var sparseFieldSetCache = new SparseFieldSetCache(constraintProviders, resourceDefinitionAccessor);
var requestQueryStringAccessor = new FakeRequestQueryStringAccessor();
@@ -122,141 +118,4 @@ public sealed class OutgoingResource : Identifiable
[HasMany]
public ISet Multi5 { get; set; } = null!;
}
-
- private sealed class FakeResourceDefinitionAccessor : IResourceDefinitionAccessor
- {
- public IImmutableSet OnApplyIncludes(ResourceType resourceType, IImmutableSet existingIncludes)
- {
- return existingIncludes;
- }
-
- public FilterExpression? OnApplyFilter(ResourceType resourceType, FilterExpression? existingFilter)
- {
- return existingFilter;
- }
-
- public SortExpression? OnApplySort(ResourceType resourceType, SortExpression? existingSort)
- {
- return existingSort;
- }
-
- public PaginationExpression? OnApplyPagination(ResourceType resourceType, PaginationExpression? existingPagination)
- {
- return existingPagination;
- }
-
- public SparseFieldSetExpression? OnApplySparseFieldSet(ResourceType resourceType, SparseFieldSetExpression? existingSparseFieldSet)
- {
- return existingSparseFieldSet;
- }
-
- public object? GetQueryableHandlerForQueryStringParameter(Type resourceClrType, string parameterName)
- {
- return null;
- }
-
- public IDictionary? GetMeta(ResourceType resourceType, IIdentifiable resourceInstance)
- {
- return null;
- }
-
- public Task OnPrepareWriteAsync(TResource resource, WriteOperationKind writeOperation, CancellationToken cancellationToken)
- where TResource : class, IIdentifiable
- {
- return Task.CompletedTask;
- }
-
- public Task OnSetToOneRelationshipAsync(TResource leftResource, HasOneAttribute hasOneRelationship,
- IIdentifiable? rightResourceId, WriteOperationKind writeOperation, CancellationToken cancellationToken)
- where TResource : class, IIdentifiable
- {
- return Task.FromResult(rightResourceId);
- }
-
- public Task OnSetToManyRelationshipAsync(TResource leftResource, HasManyAttribute hasManyRelationship, ISet rightResourceIds,
- WriteOperationKind writeOperation, CancellationToken cancellationToken)
- where TResource : class, IIdentifiable
- {
- return Task.CompletedTask;
- }
-
- public Task OnAddToRelationshipAsync(TResource leftResource, HasManyAttribute hasManyRelationship, ISet rightResourceIds,
- CancellationToken cancellationToken)
- where TResource : class, IIdentifiable
- {
- return Task.CompletedTask;
- }
-
- public Task OnRemoveFromRelationshipAsync(TResource leftResource, HasManyAttribute hasManyRelationship, ISet rightResourceIds,
- CancellationToken cancellationToken)
- where TResource : class, IIdentifiable
- {
- return Task.CompletedTask;
- }
-
- public Task OnWritingAsync(TResource resource, WriteOperationKind writeOperation, CancellationToken cancellationToken)
- where TResource : class, IIdentifiable
- {
- return Task.CompletedTask;
- }
-
- public Task OnWriteSucceededAsync(TResource resource, WriteOperationKind writeOperation, CancellationToken cancellationToken)
- where TResource : class, IIdentifiable
- {
- return Task.CompletedTask;
- }
-
- public void OnDeserialize(IIdentifiable resource)
- {
- }
-
- public void OnSerialize(IIdentifiable resource)
- {
- }
- }
-
- private sealed class FakeLinkBuilder : ILinkBuilder
- {
- public TopLevelLinks GetTopLevelLinks()
- {
- return new TopLevelLinks
- {
- Self = "TopLevel:Self"
- };
- }
-
- public ResourceLinks GetResourceLinks(ResourceType resourceType, IIdentifiable resource)
- {
- return new ResourceLinks
- {
- Self = "Resource:Self"
- };
- }
-
- public RelationshipLinks GetRelationshipLinks(RelationshipAttribute relationship, IIdentifiable leftResource)
- {
- return new RelationshipLinks
- {
- Self = "Relationship:Self",
- Related = "Relationship:Related"
- };
- }
- }
-
- private sealed class FakeMetaBuilder : IMetaBuilder
- {
- public void Add(IDictionary values)
- {
- }
-
- public IDictionary? Build()
- {
- return null;
- }
- }
-
- private sealed class FakeRequestQueryStringAccessor : IRequestQueryStringAccessor
- {
- public IQueryCollection Query { get; } = new QueryCollection(0);
- }
}
diff --git a/benchmarks/Tools/FakeLinkBuilder.cs b/benchmarks/Tools/FakeLinkBuilder.cs
new file mode 100644
index 0000000000..3468237507
--- /dev/null
+++ b/benchmarks/Tools/FakeLinkBuilder.cs
@@ -0,0 +1,39 @@
+using JsonApiDotNetCore.Configuration;
+using JsonApiDotNetCore.Resources;
+using JsonApiDotNetCore.Resources.Annotations;
+using JsonApiDotNetCore.Serialization.Objects;
+using JsonApiDotNetCore.Serialization.Response;
+using Microsoft.AspNetCore.Http;
+
+namespace Benchmarks.Tools;
+
+///
+/// Renders hard-coded fake links, without depending on .
+///
+internal sealed class FakeLinkBuilder : ILinkBuilder
+{
+ public TopLevelLinks GetTopLevelLinks()
+ {
+ return new TopLevelLinks
+ {
+ Self = "TopLevel:Self"
+ };
+ }
+
+ public ResourceLinks GetResourceLinks(ResourceType resourceType, IIdentifiable resource)
+ {
+ return new ResourceLinks
+ {
+ Self = "Resource:Self"
+ };
+ }
+
+ public RelationshipLinks GetRelationshipLinks(RelationshipAttribute relationship, IIdentifiable leftResource)
+ {
+ return new RelationshipLinks
+ {
+ Self = "Relationship:Self",
+ Related = "Relationship:Related"
+ };
+ }
+}
diff --git a/benchmarks/Tools/FakeRequestQueryStringAccessor.cs b/benchmarks/Tools/FakeRequestQueryStringAccessor.cs
new file mode 100644
index 0000000000..8b2b5540a1
--- /dev/null
+++ b/benchmarks/Tools/FakeRequestQueryStringAccessor.cs
@@ -0,0 +1,18 @@
+using JsonApiDotNetCore.QueryStrings;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.WebUtilities;
+
+namespace Benchmarks.Tools;
+
+///
+/// Enables to inject a query string, instead of obtaining it from .
+///
+internal sealed class FakeRequestQueryStringAccessor : IRequestQueryStringAccessor
+{
+ public IQueryCollection Query { get; private set; } = new QueryCollection();
+
+ public void SetQueryString(string queryString)
+ {
+ Query = new QueryCollection(QueryHelpers.ParseQuery(queryString));
+ }
+}
diff --git a/benchmarks/Tools/NeverResourceDefinitionAccessor.cs b/benchmarks/Tools/NeverResourceDefinitionAccessor.cs
new file mode 100644
index 0000000000..6e93519dae
--- /dev/null
+++ b/benchmarks/Tools/NeverResourceDefinitionAccessor.cs
@@ -0,0 +1,103 @@
+using System.Collections.Immutable;
+using JsonApiDotNetCore.Configuration;
+using JsonApiDotNetCore.Middleware;
+using JsonApiDotNetCore.Queries.Expressions;
+using JsonApiDotNetCore.Resources;
+using JsonApiDotNetCore.Resources.Annotations;
+
+namespace Benchmarks.Tools;
+
+///
+/// Never calls into instances.
+///
+internal sealed class NeverResourceDefinitionAccessor : IResourceDefinitionAccessor
+{
+ public IImmutableSet OnApplyIncludes(ResourceType resourceType, IImmutableSet existingIncludes)
+ {
+ return existingIncludes;
+ }
+
+ public FilterExpression? OnApplyFilter(ResourceType resourceType, FilterExpression? existingFilter)
+ {
+ return existingFilter;
+ }
+
+ public SortExpression? OnApplySort(ResourceType resourceType, SortExpression? existingSort)
+ {
+ return existingSort;
+ }
+
+ public PaginationExpression? OnApplyPagination(ResourceType resourceType, PaginationExpression? existingPagination)
+ {
+ return existingPagination;
+ }
+
+ public SparseFieldSetExpression? OnApplySparseFieldSet(ResourceType resourceType, SparseFieldSetExpression? existingSparseFieldSet)
+ {
+ return existingSparseFieldSet;
+ }
+
+ public object? GetQueryableHandlerForQueryStringParameter(Type resourceClrType, string parameterName)
+ {
+ return null;
+ }
+
+ public IDictionary? GetMeta(ResourceType resourceType, IIdentifiable resourceInstance)
+ {
+ return null;
+ }
+
+ public Task OnPrepareWriteAsync(TResource resource, WriteOperationKind writeOperation, CancellationToken cancellationToken)
+ where TResource : class, IIdentifiable
+ {
+ return Task.CompletedTask;
+ }
+
+ public Task OnSetToOneRelationshipAsync(TResource leftResource, HasOneAttribute hasOneRelationship,
+ IIdentifiable? rightResourceId, WriteOperationKind writeOperation, CancellationToken cancellationToken)
+ where TResource : class, IIdentifiable
+ {
+ return Task.FromResult(rightResourceId);
+ }
+
+ public Task OnSetToManyRelationshipAsync(TResource leftResource, HasManyAttribute hasManyRelationship, ISet rightResourceIds,
+ WriteOperationKind writeOperation, CancellationToken cancellationToken)
+ where TResource : class, IIdentifiable
+ {
+ return Task.CompletedTask;
+ }
+
+ public Task OnAddToRelationshipAsync(TResource leftResource, HasManyAttribute hasManyRelationship, ISet rightResourceIds,
+ CancellationToken cancellationToken)
+ where TResource : class, IIdentifiable
+ {
+ return Task.CompletedTask;
+ }
+
+ public Task OnRemoveFromRelationshipAsync(TResource leftResource, HasManyAttribute hasManyRelationship, ISet rightResourceIds,
+ CancellationToken cancellationToken)
+ where TResource : class, IIdentifiable
+ {
+ return Task.CompletedTask;
+ }
+
+ public Task OnWritingAsync(TResource resource, WriteOperationKind writeOperation, CancellationToken cancellationToken)
+ where TResource : class, IIdentifiable
+ {
+ return Task.CompletedTask;
+ }
+
+ public Task OnWriteSucceededAsync(TResource resource, WriteOperationKind writeOperation, CancellationToken cancellationToken)
+ where TResource : class, IIdentifiable
+ {
+ return Task.CompletedTask;
+ }
+
+ public void OnDeserialize(IIdentifiable resource)
+ {
+ }
+
+ public void OnSerialize(IIdentifiable resource)
+ {
+ }
+}
diff --git a/benchmarks/Tools/NoMetaBuilder.cs b/benchmarks/Tools/NoMetaBuilder.cs
new file mode 100644
index 0000000000..db3ed7857e
--- /dev/null
+++ b/benchmarks/Tools/NoMetaBuilder.cs
@@ -0,0 +1,18 @@
+using JsonApiDotNetCore.Serialization.Response;
+
+namespace Benchmarks.Tools;
+
+///
+/// Doesn't produce any top-level meta.
+///
+internal sealed class NoMetaBuilder : IMetaBuilder
+{
+ public void Add(IDictionary values)
+ {
+ }
+
+ public IDictionary? Build()
+ {
+ return null;
+ }
+}
From a00ab50528ed6ba3db84d536287450d29b49a92d Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Mon, 18 Jul 2022 02:01:56 +0200
Subject: [PATCH 18/50] Use System.Text.Json source generator (see
https://devblogs.microsoft.com/dotnet/try-the-new-system-text-json-source-generator)
---
.../DeserializationBenchmarkBase.cs | 6 ++--
.../OperationsDeserializationBenchmarks.cs | 2 +-
.../ResourceDeserializationBenchmarks.cs | 2 +-
.../OperationsSerializationBenchmarks.cs | 2 +-
.../ResourceSerializationBenchmarks.cs | 2 +-
.../SerializationBenchmarkBase.cs | 6 ++--
.../Configuration/IJsonApiOptions.cs | 17 +++++++++++
.../Configuration/JsonApiOptions.cs | 23 +++++++++------
.../Middleware/JsonApiMiddleware.cs | 28 ++++++++++---------
.../JsonApiSerializationContext.cs | 17 +++++++++++
.../JsonConverters/JsonObjectConverter.cs | 14 +---------
.../Serialization/Objects/Document.cs | 2 ++
.../Serialization/Request/JsonApiReader.cs | 2 +-
.../Serialization/Response/JsonApiWriter.cs | 2 +-
.../Response/ResponseModelAdapterTests.cs | 6 ++--
15 files changed, 82 insertions(+), 49 deletions(-)
create mode 100644 src/JsonApiDotNetCore/Serialization/JsonApiSerializationContext.cs
diff --git a/benchmarks/Deserialization/DeserializationBenchmarkBase.cs b/benchmarks/Deserialization/DeserializationBenchmarkBase.cs
index bbf746d1a8..80a9753597 100644
--- a/benchmarks/Deserialization/DeserializationBenchmarkBase.cs
+++ b/benchmarks/Deserialization/DeserializationBenchmarkBase.cs
@@ -1,10 +1,10 @@
using System.ComponentModel.Design;
-using System.Text.Json;
using JetBrains.Annotations;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Middleware;
using JsonApiDotNetCore.Resources;
using JsonApiDotNetCore.Resources.Annotations;
+using JsonApiDotNetCore.Serialization;
using JsonApiDotNetCore.Serialization.JsonConverters;
using JsonApiDotNetCore.Serialization.Request.Adapters;
using Microsoft.Extensions.Logging.Abstractions;
@@ -13,7 +13,7 @@ namespace Benchmarks.Deserialization;
public abstract class DeserializationBenchmarkBase
{
- protected readonly JsonSerializerOptions SerializerReadOptions;
+ protected readonly JsonApiSerializationContext SerializationReadContext;
protected readonly DocumentAdapter DocumentAdapter;
protected DeserializationBenchmarkBase()
@@ -21,7 +21,7 @@ protected DeserializationBenchmarkBase()
var options = new JsonApiOptions();
IResourceGraph resourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add().Build();
options.SerializerOptions.Converters.Add(new ResourceObjectConverter(resourceGraph));
- SerializerReadOptions = ((IJsonApiOptions)options).SerializerReadOptions;
+ SerializationReadContext = ((IJsonApiOptions)options).SerializationReadContext;
var serviceContainer = new ServiceContainer();
var resourceFactory = new ResourceFactory(serviceContainer);
diff --git a/benchmarks/Deserialization/OperationsDeserializationBenchmarks.cs b/benchmarks/Deserialization/OperationsDeserializationBenchmarks.cs
index 99adce73cb..efe0ae568f 100644
--- a/benchmarks/Deserialization/OperationsDeserializationBenchmarks.cs
+++ b/benchmarks/Deserialization/OperationsDeserializationBenchmarks.cs
@@ -270,7 +270,7 @@ public class OperationsDeserializationBenchmarks : DeserializationBenchmarkBase
[Benchmark]
public object? DeserializeOperationsRequest()
{
- var document = JsonSerializer.Deserialize(RequestBody, SerializerReadOptions)!;
+ Document document = JsonSerializer.Deserialize(RequestBody, SerializationReadContext.Document)!;
return DocumentAdapter.Convert(document);
}
diff --git a/benchmarks/Deserialization/ResourceDeserializationBenchmarks.cs b/benchmarks/Deserialization/ResourceDeserializationBenchmarks.cs
index e503a329bb..3d2cdd35af 100644
--- a/benchmarks/Deserialization/ResourceDeserializationBenchmarks.cs
+++ b/benchmarks/Deserialization/ResourceDeserializationBenchmarks.cs
@@ -133,7 +133,7 @@ public class ResourceDeserializationBenchmarks : DeserializationBenchmarkBase
[Benchmark]
public object? DeserializeResourceRequest()
{
- var document = JsonSerializer.Deserialize(RequestBody, SerializerReadOptions)!;
+ Document document = JsonSerializer.Deserialize(RequestBody, SerializationReadContext.Document)!;
return DocumentAdapter.Convert(document);
}
diff --git a/benchmarks/Serialization/OperationsSerializationBenchmarks.cs b/benchmarks/Serialization/OperationsSerializationBenchmarks.cs
index 471c9604c7..2be9da5da6 100644
--- a/benchmarks/Serialization/OperationsSerializationBenchmarks.cs
+++ b/benchmarks/Serialization/OperationsSerializationBenchmarks.cs
@@ -116,7 +116,7 @@ private static IEnumerable CreateResponseOperations(IJsonApi
public string SerializeOperationsResponse()
{
Document responseDocument = ResponseModelAdapter.Convert(_responseOperations);
- return JsonSerializer.Serialize(responseDocument, SerializerWriteOptions);
+ return JsonSerializer.Serialize(responseDocument, SerializationWriteContext.Document);
}
protected override JsonApiRequest CreateJsonApiRequest(IResourceGraph resourceGraph)
diff --git a/benchmarks/Serialization/ResourceSerializationBenchmarks.cs b/benchmarks/Serialization/ResourceSerializationBenchmarks.cs
index a985bd5936..f896846ee2 100644
--- a/benchmarks/Serialization/ResourceSerializationBenchmarks.cs
+++ b/benchmarks/Serialization/ResourceSerializationBenchmarks.cs
@@ -107,7 +107,7 @@ private static OutgoingResource CreateResponseResource()
public string SerializeResourceResponse()
{
Document responseDocument = ResponseModelAdapter.Convert(ResponseResource);
- return JsonSerializer.Serialize(responseDocument, SerializerWriteOptions);
+ return JsonSerializer.Serialize(responseDocument, SerializationWriteContext.Document);
}
protected override JsonApiRequest CreateJsonApiRequest(IResourceGraph resourceGraph)
diff --git a/benchmarks/Serialization/SerializationBenchmarkBase.cs b/benchmarks/Serialization/SerializationBenchmarkBase.cs
index d9cfefd0b6..be1a711ad9 100644
--- a/benchmarks/Serialization/SerializationBenchmarkBase.cs
+++ b/benchmarks/Serialization/SerializationBenchmarkBase.cs
@@ -1,4 +1,3 @@
-using System.Text.Json;
using System.Text.Json.Serialization;
using Benchmarks.Tools;
using JetBrains.Annotations;
@@ -8,6 +7,7 @@
using JsonApiDotNetCore.Queries.Internal;
using JsonApiDotNetCore.Resources;
using JsonApiDotNetCore.Resources.Annotations;
+using JsonApiDotNetCore.Serialization;
using JsonApiDotNetCore.Serialization.Response;
using Microsoft.Extensions.Logging.Abstractions;
@@ -15,7 +15,7 @@ namespace Benchmarks.Serialization;
public abstract class SerializationBenchmarkBase
{
- protected readonly JsonSerializerOptions SerializerWriteOptions;
+ protected readonly JsonApiSerializationContext SerializationWriteContext;
protected readonly IResponseModelAdapter ResponseModelAdapter;
protected readonly IResourceGraph ResourceGraph;
@@ -33,7 +33,7 @@ protected SerializationBenchmarkBase()
};
ResourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add().Build();
- SerializerWriteOptions = ((IJsonApiOptions)options).SerializerWriteOptions;
+ SerializationWriteContext = ((IJsonApiOptions)options).SerializationWriteContext;
// ReSharper disable VirtualMemberCallInConstructor
JsonApiRequest request = CreateJsonApiRequest(ResourceGraph);
diff --git a/src/JsonApiDotNetCore/Configuration/IJsonApiOptions.cs b/src/JsonApiDotNetCore/Configuration/IJsonApiOptions.cs
index 597d22294d..477500d79b 100644
--- a/src/JsonApiDotNetCore/Configuration/IJsonApiOptions.cs
+++ b/src/JsonApiDotNetCore/Configuration/IJsonApiOptions.cs
@@ -1,6 +1,8 @@
using System.Data;
using System.Text.Json;
+using JetBrains.Annotations;
using JsonApiDotNetCore.Resources.Annotations;
+using JsonApiDotNetCore.Serialization;
using JsonApiDotNetCore.Serialization.Objects;
namespace JsonApiDotNetCore.Configuration;
@@ -8,6 +10,7 @@ namespace JsonApiDotNetCore.Configuration;
///
/// Global options that configure the behavior of JsonApiDotNetCore.
///
+[PublicAPI]
public interface IJsonApiOptions
{
///
@@ -156,13 +159,27 @@ public interface IJsonApiOptions
///
JsonSerializerOptions SerializerOptions { get; }
+ ///
+ /// Gets the source-generated JSON serialization context used for deserializing request bodies. This value is based on
+ /// and is intended for internal use.
+ ///
+ JsonApiSerializationContext SerializationReadContext { get; }
+
///
/// Gets the settings used for deserializing request bodies. This value is based on and is intended for internal use.
///
+ [Obsolete("Use SerializationReadContext.Options instead.")]
JsonSerializerOptions SerializerReadOptions { get; }
+ ///
+ /// Gets the source-generated JSON serialization context used for serializing response bodies. This value is based on
+ /// and is intended for internal use.
+ ///
+ JsonApiSerializationContext SerializationWriteContext { get; }
+
///
/// Gets the settings used for serializing response bodies. This value is based on and is intended for internal use.
///
+ [Obsolete("Use SerializationWriteContext.Options instead.")]
JsonSerializerOptions SerializerWriteOptions { get; }
}
diff --git a/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs b/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs
index 2e7cc54282..bb167e4db2 100644
--- a/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs
+++ b/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs
@@ -3,6 +3,7 @@
using System.Text.Json;
using JetBrains.Annotations;
using JsonApiDotNetCore.Resources.Annotations;
+using JsonApiDotNetCore.Serialization;
using JsonApiDotNetCore.Serialization.JsonConverters;
namespace JsonApiDotNetCore.Configuration;
@@ -11,14 +12,20 @@ namespace JsonApiDotNetCore.Configuration;
[PublicAPI]
public sealed class JsonApiOptions : IJsonApiOptions
{
- private readonly Lazy _lazySerializerWriteOptions;
- private readonly Lazy _lazySerializerReadOptions;
+ private readonly Lazy _lazySerializerReadContext;
+ private readonly Lazy _lazySerializerWriteContext;
///
- JsonSerializerOptions IJsonApiOptions.SerializerReadOptions => _lazySerializerReadOptions.Value;
+ JsonApiSerializationContext IJsonApiOptions.SerializationReadContext => _lazySerializerReadContext.Value;
///
- JsonSerializerOptions IJsonApiOptions.SerializerWriteOptions => _lazySerializerWriteOptions.Value;
+ JsonSerializerOptions IJsonApiOptions.SerializerReadOptions => ((IJsonApiOptions)this).SerializationReadContext.Options;
+
+ ///
+ JsonApiSerializationContext IJsonApiOptions.SerializationWriteContext => _lazySerializerWriteContext.Value;
+
+ ///
+ JsonSerializerOptions IJsonApiOptions.SerializerWriteOptions => ((IJsonApiOptions)this).SerializationWriteContext.Options;
///
public string? Namespace { get; set; }
@@ -110,16 +117,16 @@ static JsonApiOptions()
public JsonApiOptions()
{
- _lazySerializerReadOptions =
- new Lazy(() => new JsonSerializerOptions(SerializerOptions), LazyThreadSafetyMode.ExecutionAndPublication);
+ _lazySerializerReadContext = new Lazy(() => new JsonApiSerializationContext(new JsonSerializerOptions(SerializerOptions)),
+ LazyThreadSafetyMode.ExecutionAndPublication);
- _lazySerializerWriteOptions = new Lazy(() => new JsonSerializerOptions(SerializerOptions)
+ _lazySerializerWriteContext = new Lazy(() => new JsonApiSerializationContext(new JsonSerializerOptions(SerializerOptions)
{
Converters =
{
new WriteOnlyDocumentConverter(),
new WriteOnlyRelationshipObjectConverter()
}
- }, LazyThreadSafetyMode.ExecutionAndPublication);
+ }), LazyThreadSafetyMode.ExecutionAndPublication);
}
}
diff --git a/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs b/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs
index 2e15e6ae9a..6ea3853e92 100644
--- a/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs
+++ b/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs
@@ -4,6 +4,7 @@
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Diagnostics;
using JsonApiDotNetCore.Resources.Annotations;
+using JsonApiDotNetCore.Serialization;
using JsonApiDotNetCore.Serialization.Objects;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
@@ -44,7 +45,7 @@ public async Task InvokeAsync(HttpContext httpContext, IControllerResourceMappin
using (CodeTimingSessionManager.Current.Measure("JSON:API middleware"))
{
- if (!await ValidateIfMatchHeaderAsync(httpContext, options.SerializerWriteOptions))
+ if (!await ValidateIfMatchHeaderAsync(httpContext, options.SerializationWriteContext))
{
return;
}
@@ -54,8 +55,8 @@ public async Task InvokeAsync(HttpContext httpContext, IControllerResourceMappin
if (primaryResourceType != null)
{
- if (!await ValidateContentTypeHeaderAsync(HeaderConstants.MediaType, httpContext, options.SerializerWriteOptions) ||
- !await ValidateAcceptHeaderAsync(MediaType, httpContext, options.SerializerWriteOptions))
+ if (!await ValidateContentTypeHeaderAsync(HeaderConstants.MediaType, httpContext, options.SerializationWriteContext) ||
+ !await ValidateAcceptHeaderAsync(MediaType, httpContext, options.SerializationWriteContext))
{
return;
}
@@ -66,8 +67,8 @@ public async Task InvokeAsync(HttpContext httpContext, IControllerResourceMappin
}
else if (IsRouteForOperations(routeValues))
{
- if (!await ValidateContentTypeHeaderAsync(HeaderConstants.AtomicOperationsMediaType, httpContext, options.SerializerWriteOptions) ||
- !await ValidateAcceptHeaderAsync(AtomicOperationsMediaType, httpContext, options.SerializerWriteOptions))
+ if (!await ValidateContentTypeHeaderAsync(HeaderConstants.AtomicOperationsMediaType, httpContext, options.SerializationWriteContext) ||
+ !await ValidateAcceptHeaderAsync(AtomicOperationsMediaType, httpContext, options.SerializationWriteContext))
{
return;
}
@@ -91,11 +92,11 @@ public async Task InvokeAsync(HttpContext httpContext, IControllerResourceMappin
}
}
- private async Task ValidateIfMatchHeaderAsync(HttpContext httpContext, JsonSerializerOptions serializerOptions)
+ private async Task ValidateIfMatchHeaderAsync(HttpContext httpContext, JsonApiSerializationContext serializationContext)
{
if (httpContext.Request.Headers.ContainsKey(HeaderNames.IfMatch))
{
- await FlushResponseAsync(httpContext.Response, serializerOptions, new ErrorObject(HttpStatusCode.PreconditionFailed)
+ await FlushResponseAsync(httpContext.Response, serializationContext, new ErrorObject(HttpStatusCode.PreconditionFailed)
{
Title = "Detection of mid-air edit collisions using ETags is not supported.",
Source = new ErrorSource
@@ -120,13 +121,14 @@ private async Task ValidateIfMatchHeaderAsync(HttpContext httpContext, Jso
: null;
}
- private static async Task ValidateContentTypeHeaderAsync(string allowedContentType, HttpContext httpContext, JsonSerializerOptions serializerOptions)
+ private static async Task ValidateContentTypeHeaderAsync(string allowedContentType, HttpContext httpContext,
+ JsonApiSerializationContext serializationContext)
{
string? contentType = httpContext.Request.ContentType;
if (contentType != null && contentType != allowedContentType)
{
- await FlushResponseAsync(httpContext.Response, serializerOptions, new ErrorObject(HttpStatusCode.UnsupportedMediaType)
+ await FlushResponseAsync(httpContext.Response, serializationContext, new ErrorObject(HttpStatusCode.UnsupportedMediaType)
{
Title = "The specified Content-Type header value is not supported.",
Detail = $"Please specify '{allowedContentType}' instead of '{contentType}' for the Content-Type header value.",
@@ -143,7 +145,7 @@ private static async Task ValidateContentTypeHeaderAsync(string allowedCon
}
private static async Task ValidateAcceptHeaderAsync(MediaTypeHeaderValue allowedMediaTypeValue, HttpContext httpContext,
- JsonSerializerOptions serializerOptions)
+ JsonApiSerializationContext serializationContext)
{
string[] acceptHeaders = httpContext.Request.Headers.GetCommaSeparatedValues("Accept");
@@ -176,7 +178,7 @@ private static async Task ValidateAcceptHeaderAsync(MediaTypeHeaderValue a
if (!seenCompatibleMediaType)
{
- await FlushResponseAsync(httpContext.Response, serializerOptions, new ErrorObject(HttpStatusCode.NotAcceptable)
+ await FlushResponseAsync(httpContext.Response, serializationContext, new ErrorObject(HttpStatusCode.NotAcceptable)
{
Title = "The specified Accept header value does not contain any supported media types.",
Detail = $"Please include '{allowedMediaTypeValue}' in the Accept header values.",
@@ -192,7 +194,7 @@ private static async Task ValidateAcceptHeaderAsync(MediaTypeHeaderValue a
return true;
}
- private static async Task FlushResponseAsync(HttpResponse httpResponse, JsonSerializerOptions serializerOptions, ErrorObject error)
+ private static async Task FlushResponseAsync(HttpResponse httpResponse, JsonApiSerializationContext serializationContext, ErrorObject error)
{
httpResponse.ContentType = HeaderConstants.MediaType;
httpResponse.StatusCode = (int)error.StatusCode;
@@ -202,7 +204,7 @@ private static async Task FlushResponseAsync(HttpResponse httpResponse, JsonSeri
Errors = error.AsList()
};
- await JsonSerializer.SerializeAsync(httpResponse.Body, errorDocument, serializerOptions);
+ await JsonSerializer.SerializeAsync(httpResponse.Body, errorDocument, serializationContext.Document);
await httpResponse.Body.FlushAsync();
}
diff --git a/src/JsonApiDotNetCore/Serialization/JsonApiSerializationContext.cs b/src/JsonApiDotNetCore/Serialization/JsonApiSerializationContext.cs
new file mode 100644
index 0000000000..38180d9369
--- /dev/null
+++ b/src/JsonApiDotNetCore/Serialization/JsonApiSerializationContext.cs
@@ -0,0 +1,17 @@
+using System.Text.Json.Serialization;
+using JsonApiDotNetCore.Serialization.Objects;
+
+namespace JsonApiDotNetCore.Serialization;
+
+// Workaround for https://youtrack.jetbrains.com/issue/RSRP-487028
+partial class JsonApiSerializationContext
+{
+}
+
+///
+/// Provides compile-time metadata about the set of JSON:API types used in JSON serialization of request/response bodies.
+///
+[JsonSerializable(typeof(Document))]
+public sealed partial class JsonApiSerializationContext : JsonSerializerContext
+{
+}
diff --git a/src/JsonApiDotNetCore/Serialization/JsonConverters/JsonObjectConverter.cs b/src/JsonApiDotNetCore/Serialization/JsonConverters/JsonObjectConverter.cs
index 32e4351e12..97d7589cc6 100644
--- a/src/JsonApiDotNetCore/Serialization/JsonConverters/JsonObjectConverter.cs
+++ b/src/JsonApiDotNetCore/Serialization/JsonConverters/JsonObjectConverter.cs
@@ -7,24 +7,12 @@ public abstract class JsonObjectConverter : JsonConverter
{
protected static TValue? ReadSubTree(ref Utf8JsonReader reader, JsonSerializerOptions options)
{
- if (typeof(TValue) != typeof(object) && options.GetConverter(typeof(TValue)) is JsonConverter converter)
- {
- return converter.Read(ref reader, typeof(TValue), options);
- }
-
return JsonSerializer.Deserialize(ref reader, options);
}
protected static void WriteSubTree(Utf8JsonWriter writer, TValue value, JsonSerializerOptions options)
{
- if (typeof(TValue) != typeof(object) && options.GetConverter(typeof(TValue)) is JsonConverter converter)
- {
- converter.Write(writer, value, options);
- }
- else
- {
- JsonSerializer.Serialize(writer, value, options);
- }
+ JsonSerializer.Serialize(writer, value, options);
}
protected static JsonException GetEndOfStreamError()
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/Document.cs b/src/JsonApiDotNetCore/Serialization/Objects/Document.cs
index 2f40aeb27b..87c3a0acfa 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/Document.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/Document.cs
@@ -1,10 +1,12 @@
using System.Text.Json.Serialization;
+using JetBrains.Annotations;
namespace JsonApiDotNetCore.Serialization.Objects;
///
/// See https://jsonapi.org/format/1.1/#document-top-level and https://jsonapi.org/ext/atomic/#document-structure.
///
+[PublicAPI]
public sealed class Document
{
[JsonPropertyName("jsonapi")]
diff --git a/src/JsonApiDotNetCore/Serialization/Request/JsonApiReader.cs b/src/JsonApiDotNetCore/Serialization/Request/JsonApiReader.cs
index 0942683487..0282ab39bd 100644
--- a/src/JsonApiDotNetCore/Serialization/Request/JsonApiReader.cs
+++ b/src/JsonApiDotNetCore/Serialization/Request/JsonApiReader.cs
@@ -80,7 +80,7 @@ private Document DeserializeDocument(string requestBody)
using IDisposable _ =
CodeTimingSessionManager.Current.Measure("JsonSerializer.Deserialize", MeasurementSettings.ExcludeJsonSerializationInPercentages);
- var document = JsonSerializer.Deserialize(requestBody, _options.SerializerReadOptions);
+ Document? document = JsonSerializer.Deserialize(requestBody, _options.SerializationReadContext.Document);
AssertHasDocument(document, requestBody);
diff --git a/src/JsonApiDotNetCore/Serialization/Response/JsonApiWriter.cs b/src/JsonApiDotNetCore/Serialization/Response/JsonApiWriter.cs
index 20f4ad242b..2bfefde98b 100644
--- a/src/JsonApiDotNetCore/Serialization/Response/JsonApiWriter.cs
+++ b/src/JsonApiDotNetCore/Serialization/Response/JsonApiWriter.cs
@@ -125,7 +125,7 @@ private string SerializeDocument(Document document)
{
using IDisposable _ = CodeTimingSessionManager.Current.Measure("JsonSerializer.Serialize", MeasurementSettings.ExcludeJsonSerializationInPercentages);
- return JsonSerializer.Serialize(document, _options.SerializerWriteOptions);
+ return JsonSerializer.Serialize(document, _options.SerializationWriteContext.Document);
}
private bool SetETagResponseHeader(HttpRequest request, HttpResponse response, string responseContent)
diff --git a/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Response/ResponseModelAdapterTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Response/ResponseModelAdapterTests.cs
index d9459f7ec1..f0af041de5 100644
--- a/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Response/ResponseModelAdapterTests.cs
+++ b/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Response/ResponseModelAdapterTests.cs
@@ -38,7 +38,7 @@ public void Resources_in_deeply_nested_circular_chain_are_written_in_relationshi
Document document = responseModelAdapter.Convert(article);
// Assert
- string text = JsonSerializer.Serialize(document, new JsonSerializerOptions(options.SerializerWriteOptions));
+ string text = JsonSerializer.Serialize(document, options.SerializationWriteContext.Document);
text.Should().BeJson(@"{
""data"": {
@@ -175,7 +175,7 @@ public void Resources_in_deeply_nested_circular_chains_are_written_in_relationsh
});
// Assert
- string text = JsonSerializer.Serialize(document, new JsonSerializerOptions(options.SerializerWriteOptions));
+ string text = JsonSerializer.Serialize(document, options.SerializationWriteContext.Document);
text.Should().BeJson(@"{
""data"": [
@@ -333,7 +333,7 @@ public void Resources_in_overlapping_deeply_nested_circular_chains_are_written_i
Document document = responseModelAdapter.Convert(article);
// Assert
- string text = JsonSerializer.Serialize(document, new JsonSerializerOptions(options.SerializerWriteOptions));
+ string text = JsonSerializer.Serialize(document, options.SerializationWriteContext.Document);
text.Should().BeJson(@"{
""data"": {
From f760e8f789b044ca35074b3ca5f84e084c422076 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Sun, 21 Aug 2022 15:04:02 +0200
Subject: [PATCH 19/50] Revert "Use System.Text.Json source generator (see
https://devblogs.microsoft.com/dotnet/try-the-new-system-text-json-source-generator)"
This reverts commit a00ab50528ed6ba3db84d536287450d29b49a92d.
---
.../DeserializationBenchmarkBase.cs | 6 ++--
.../OperationsDeserializationBenchmarks.cs | 2 +-
.../ResourceDeserializationBenchmarks.cs | 2 +-
.../OperationsSerializationBenchmarks.cs | 2 +-
.../ResourceSerializationBenchmarks.cs | 2 +-
.../SerializationBenchmarkBase.cs | 6 ++--
.../Configuration/IJsonApiOptions.cs | 17 -----------
.../Configuration/JsonApiOptions.cs | 23 ++++++---------
.../Middleware/JsonApiMiddleware.cs | 28 +++++++++----------
.../JsonApiSerializationContext.cs | 17 -----------
.../JsonConverters/JsonObjectConverter.cs | 14 +++++++++-
.../Serialization/Objects/Document.cs | 2 --
.../Serialization/Request/JsonApiReader.cs | 2 +-
.../Serialization/Response/JsonApiWriter.cs | 2 +-
.../Response/ResponseModelAdapterTests.cs | 6 ++--
15 files changed, 49 insertions(+), 82 deletions(-)
delete mode 100644 src/JsonApiDotNetCore/Serialization/JsonApiSerializationContext.cs
diff --git a/benchmarks/Deserialization/DeserializationBenchmarkBase.cs b/benchmarks/Deserialization/DeserializationBenchmarkBase.cs
index 80a9753597..bbf746d1a8 100644
--- a/benchmarks/Deserialization/DeserializationBenchmarkBase.cs
+++ b/benchmarks/Deserialization/DeserializationBenchmarkBase.cs
@@ -1,10 +1,10 @@
using System.ComponentModel.Design;
+using System.Text.Json;
using JetBrains.Annotations;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Middleware;
using JsonApiDotNetCore.Resources;
using JsonApiDotNetCore.Resources.Annotations;
-using JsonApiDotNetCore.Serialization;
using JsonApiDotNetCore.Serialization.JsonConverters;
using JsonApiDotNetCore.Serialization.Request.Adapters;
using Microsoft.Extensions.Logging.Abstractions;
@@ -13,7 +13,7 @@ namespace Benchmarks.Deserialization;
public abstract class DeserializationBenchmarkBase
{
- protected readonly JsonApiSerializationContext SerializationReadContext;
+ protected readonly JsonSerializerOptions SerializerReadOptions;
protected readonly DocumentAdapter DocumentAdapter;
protected DeserializationBenchmarkBase()
@@ -21,7 +21,7 @@ protected DeserializationBenchmarkBase()
var options = new JsonApiOptions();
IResourceGraph resourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add().Build();
options.SerializerOptions.Converters.Add(new ResourceObjectConverter(resourceGraph));
- SerializationReadContext = ((IJsonApiOptions)options).SerializationReadContext;
+ SerializerReadOptions = ((IJsonApiOptions)options).SerializerReadOptions;
var serviceContainer = new ServiceContainer();
var resourceFactory = new ResourceFactory(serviceContainer);
diff --git a/benchmarks/Deserialization/OperationsDeserializationBenchmarks.cs b/benchmarks/Deserialization/OperationsDeserializationBenchmarks.cs
index efe0ae568f..99adce73cb 100644
--- a/benchmarks/Deserialization/OperationsDeserializationBenchmarks.cs
+++ b/benchmarks/Deserialization/OperationsDeserializationBenchmarks.cs
@@ -270,7 +270,7 @@ public class OperationsDeserializationBenchmarks : DeserializationBenchmarkBase
[Benchmark]
public object? DeserializeOperationsRequest()
{
- Document document = JsonSerializer.Deserialize(RequestBody, SerializationReadContext.Document)!;
+ var document = JsonSerializer.Deserialize(RequestBody, SerializerReadOptions)!;
return DocumentAdapter.Convert(document);
}
diff --git a/benchmarks/Deserialization/ResourceDeserializationBenchmarks.cs b/benchmarks/Deserialization/ResourceDeserializationBenchmarks.cs
index 3d2cdd35af..e503a329bb 100644
--- a/benchmarks/Deserialization/ResourceDeserializationBenchmarks.cs
+++ b/benchmarks/Deserialization/ResourceDeserializationBenchmarks.cs
@@ -133,7 +133,7 @@ public class ResourceDeserializationBenchmarks : DeserializationBenchmarkBase
[Benchmark]
public object? DeserializeResourceRequest()
{
- Document document = JsonSerializer.Deserialize(RequestBody, SerializationReadContext.Document)!;
+ var document = JsonSerializer.Deserialize(RequestBody, SerializerReadOptions)!;
return DocumentAdapter.Convert(document);
}
diff --git a/benchmarks/Serialization/OperationsSerializationBenchmarks.cs b/benchmarks/Serialization/OperationsSerializationBenchmarks.cs
index 2be9da5da6..471c9604c7 100644
--- a/benchmarks/Serialization/OperationsSerializationBenchmarks.cs
+++ b/benchmarks/Serialization/OperationsSerializationBenchmarks.cs
@@ -116,7 +116,7 @@ private static IEnumerable CreateResponseOperations(IJsonApi
public string SerializeOperationsResponse()
{
Document responseDocument = ResponseModelAdapter.Convert(_responseOperations);
- return JsonSerializer.Serialize(responseDocument, SerializationWriteContext.Document);
+ return JsonSerializer.Serialize(responseDocument, SerializerWriteOptions);
}
protected override JsonApiRequest CreateJsonApiRequest(IResourceGraph resourceGraph)
diff --git a/benchmarks/Serialization/ResourceSerializationBenchmarks.cs b/benchmarks/Serialization/ResourceSerializationBenchmarks.cs
index f896846ee2..a985bd5936 100644
--- a/benchmarks/Serialization/ResourceSerializationBenchmarks.cs
+++ b/benchmarks/Serialization/ResourceSerializationBenchmarks.cs
@@ -107,7 +107,7 @@ private static OutgoingResource CreateResponseResource()
public string SerializeResourceResponse()
{
Document responseDocument = ResponseModelAdapter.Convert(ResponseResource);
- return JsonSerializer.Serialize(responseDocument, SerializationWriteContext.Document);
+ return JsonSerializer.Serialize(responseDocument, SerializerWriteOptions);
}
protected override JsonApiRequest CreateJsonApiRequest(IResourceGraph resourceGraph)
diff --git a/benchmarks/Serialization/SerializationBenchmarkBase.cs b/benchmarks/Serialization/SerializationBenchmarkBase.cs
index be1a711ad9..d9cfefd0b6 100644
--- a/benchmarks/Serialization/SerializationBenchmarkBase.cs
+++ b/benchmarks/Serialization/SerializationBenchmarkBase.cs
@@ -1,3 +1,4 @@
+using System.Text.Json;
using System.Text.Json.Serialization;
using Benchmarks.Tools;
using JetBrains.Annotations;
@@ -7,7 +8,6 @@
using JsonApiDotNetCore.Queries.Internal;
using JsonApiDotNetCore.Resources;
using JsonApiDotNetCore.Resources.Annotations;
-using JsonApiDotNetCore.Serialization;
using JsonApiDotNetCore.Serialization.Response;
using Microsoft.Extensions.Logging.Abstractions;
@@ -15,7 +15,7 @@ namespace Benchmarks.Serialization;
public abstract class SerializationBenchmarkBase
{
- protected readonly JsonApiSerializationContext SerializationWriteContext;
+ protected readonly JsonSerializerOptions SerializerWriteOptions;
protected readonly IResponseModelAdapter ResponseModelAdapter;
protected readonly IResourceGraph ResourceGraph;
@@ -33,7 +33,7 @@ protected SerializationBenchmarkBase()
};
ResourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add().Build();
- SerializationWriteContext = ((IJsonApiOptions)options).SerializationWriteContext;
+ SerializerWriteOptions = ((IJsonApiOptions)options).SerializerWriteOptions;
// ReSharper disable VirtualMemberCallInConstructor
JsonApiRequest request = CreateJsonApiRequest(ResourceGraph);
diff --git a/src/JsonApiDotNetCore/Configuration/IJsonApiOptions.cs b/src/JsonApiDotNetCore/Configuration/IJsonApiOptions.cs
index 477500d79b..597d22294d 100644
--- a/src/JsonApiDotNetCore/Configuration/IJsonApiOptions.cs
+++ b/src/JsonApiDotNetCore/Configuration/IJsonApiOptions.cs
@@ -1,8 +1,6 @@
using System.Data;
using System.Text.Json;
-using JetBrains.Annotations;
using JsonApiDotNetCore.Resources.Annotations;
-using JsonApiDotNetCore.Serialization;
using JsonApiDotNetCore.Serialization.Objects;
namespace JsonApiDotNetCore.Configuration;
@@ -10,7 +8,6 @@ namespace JsonApiDotNetCore.Configuration;
///
/// Global options that configure the behavior of JsonApiDotNetCore.
///
-[PublicAPI]
public interface IJsonApiOptions
{
///
@@ -159,27 +156,13 @@ public interface IJsonApiOptions
///
JsonSerializerOptions SerializerOptions { get; }
- ///
- /// Gets the source-generated JSON serialization context used for deserializing request bodies. This value is based on
- /// and is intended for internal use.
- ///
- JsonApiSerializationContext SerializationReadContext { get; }
-
///
/// Gets the settings used for deserializing request bodies. This value is based on and is intended for internal use.
///
- [Obsolete("Use SerializationReadContext.Options instead.")]
JsonSerializerOptions SerializerReadOptions { get; }
- ///
- /// Gets the source-generated JSON serialization context used for serializing response bodies. This value is based on
- /// and is intended for internal use.
- ///
- JsonApiSerializationContext SerializationWriteContext { get; }
-
///
/// Gets the settings used for serializing response bodies. This value is based on and is intended for internal use.
///
- [Obsolete("Use SerializationWriteContext.Options instead.")]
JsonSerializerOptions SerializerWriteOptions { get; }
}
diff --git a/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs b/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs
index bb167e4db2..2e7cc54282 100644
--- a/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs
+++ b/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs
@@ -3,7 +3,6 @@
using System.Text.Json;
using JetBrains.Annotations;
using JsonApiDotNetCore.Resources.Annotations;
-using JsonApiDotNetCore.Serialization;
using JsonApiDotNetCore.Serialization.JsonConverters;
namespace JsonApiDotNetCore.Configuration;
@@ -12,20 +11,14 @@ namespace JsonApiDotNetCore.Configuration;
[PublicAPI]
public sealed class JsonApiOptions : IJsonApiOptions
{
- private readonly Lazy _lazySerializerReadContext;
- private readonly Lazy _lazySerializerWriteContext;
+ private readonly Lazy _lazySerializerWriteOptions;
+ private readonly Lazy _lazySerializerReadOptions;
///
- JsonApiSerializationContext IJsonApiOptions.SerializationReadContext => _lazySerializerReadContext.Value;
+ JsonSerializerOptions IJsonApiOptions.SerializerReadOptions => _lazySerializerReadOptions.Value;
///
- JsonSerializerOptions IJsonApiOptions.SerializerReadOptions => ((IJsonApiOptions)this).SerializationReadContext.Options;
-
- ///
- JsonApiSerializationContext IJsonApiOptions.SerializationWriteContext => _lazySerializerWriteContext.Value;
-
- ///
- JsonSerializerOptions IJsonApiOptions.SerializerWriteOptions => ((IJsonApiOptions)this).SerializationWriteContext.Options;
+ JsonSerializerOptions IJsonApiOptions.SerializerWriteOptions => _lazySerializerWriteOptions.Value;
///
public string? Namespace { get; set; }
@@ -117,16 +110,16 @@ static JsonApiOptions()
public JsonApiOptions()
{
- _lazySerializerReadContext = new Lazy(() => new JsonApiSerializationContext(new JsonSerializerOptions(SerializerOptions)),
- LazyThreadSafetyMode.ExecutionAndPublication);
+ _lazySerializerReadOptions =
+ new Lazy(() => new JsonSerializerOptions(SerializerOptions), LazyThreadSafetyMode.ExecutionAndPublication);
- _lazySerializerWriteContext = new Lazy(() => new JsonApiSerializationContext(new JsonSerializerOptions(SerializerOptions)
+ _lazySerializerWriteOptions = new Lazy(() => new JsonSerializerOptions(SerializerOptions)
{
Converters =
{
new WriteOnlyDocumentConverter(),
new WriteOnlyRelationshipObjectConverter()
}
- }), LazyThreadSafetyMode.ExecutionAndPublication);
+ }, LazyThreadSafetyMode.ExecutionAndPublication);
}
}
diff --git a/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs b/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs
index 6ea3853e92..2e15e6ae9a 100644
--- a/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs
+++ b/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs
@@ -4,7 +4,6 @@
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Diagnostics;
using JsonApiDotNetCore.Resources.Annotations;
-using JsonApiDotNetCore.Serialization;
using JsonApiDotNetCore.Serialization.Objects;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
@@ -45,7 +44,7 @@ public async Task InvokeAsync(HttpContext httpContext, IControllerResourceMappin
using (CodeTimingSessionManager.Current.Measure("JSON:API middleware"))
{
- if (!await ValidateIfMatchHeaderAsync(httpContext, options.SerializationWriteContext))
+ if (!await ValidateIfMatchHeaderAsync(httpContext, options.SerializerWriteOptions))
{
return;
}
@@ -55,8 +54,8 @@ public async Task InvokeAsync(HttpContext httpContext, IControllerResourceMappin
if (primaryResourceType != null)
{
- if (!await ValidateContentTypeHeaderAsync(HeaderConstants.MediaType, httpContext, options.SerializationWriteContext) ||
- !await ValidateAcceptHeaderAsync(MediaType, httpContext, options.SerializationWriteContext))
+ if (!await ValidateContentTypeHeaderAsync(HeaderConstants.MediaType, httpContext, options.SerializerWriteOptions) ||
+ !await ValidateAcceptHeaderAsync(MediaType, httpContext, options.SerializerWriteOptions))
{
return;
}
@@ -67,8 +66,8 @@ public async Task InvokeAsync(HttpContext httpContext, IControllerResourceMappin
}
else if (IsRouteForOperations(routeValues))
{
- if (!await ValidateContentTypeHeaderAsync(HeaderConstants.AtomicOperationsMediaType, httpContext, options.SerializationWriteContext) ||
- !await ValidateAcceptHeaderAsync(AtomicOperationsMediaType, httpContext, options.SerializationWriteContext))
+ if (!await ValidateContentTypeHeaderAsync(HeaderConstants.AtomicOperationsMediaType, httpContext, options.SerializerWriteOptions) ||
+ !await ValidateAcceptHeaderAsync(AtomicOperationsMediaType, httpContext, options.SerializerWriteOptions))
{
return;
}
@@ -92,11 +91,11 @@ public async Task InvokeAsync(HttpContext httpContext, IControllerResourceMappin
}
}
- private async Task ValidateIfMatchHeaderAsync(HttpContext httpContext, JsonApiSerializationContext serializationContext)
+ private async Task ValidateIfMatchHeaderAsync(HttpContext httpContext, JsonSerializerOptions serializerOptions)
{
if (httpContext.Request.Headers.ContainsKey(HeaderNames.IfMatch))
{
- await FlushResponseAsync(httpContext.Response, serializationContext, new ErrorObject(HttpStatusCode.PreconditionFailed)
+ await FlushResponseAsync(httpContext.Response, serializerOptions, new ErrorObject(HttpStatusCode.PreconditionFailed)
{
Title = "Detection of mid-air edit collisions using ETags is not supported.",
Source = new ErrorSource
@@ -121,14 +120,13 @@ private async Task ValidateIfMatchHeaderAsync(HttpContext httpContext, Jso
: null;
}
- private static async Task ValidateContentTypeHeaderAsync(string allowedContentType, HttpContext httpContext,
- JsonApiSerializationContext serializationContext)
+ private static async Task ValidateContentTypeHeaderAsync(string allowedContentType, HttpContext httpContext, JsonSerializerOptions serializerOptions)
{
string? contentType = httpContext.Request.ContentType;
if (contentType != null && contentType != allowedContentType)
{
- await FlushResponseAsync(httpContext.Response, serializationContext, new ErrorObject(HttpStatusCode.UnsupportedMediaType)
+ await FlushResponseAsync(httpContext.Response, serializerOptions, new ErrorObject(HttpStatusCode.UnsupportedMediaType)
{
Title = "The specified Content-Type header value is not supported.",
Detail = $"Please specify '{allowedContentType}' instead of '{contentType}' for the Content-Type header value.",
@@ -145,7 +143,7 @@ private static async Task ValidateContentTypeHeaderAsync(string allowedCon
}
private static async Task ValidateAcceptHeaderAsync(MediaTypeHeaderValue allowedMediaTypeValue, HttpContext httpContext,
- JsonApiSerializationContext serializationContext)
+ JsonSerializerOptions serializerOptions)
{
string[] acceptHeaders = httpContext.Request.Headers.GetCommaSeparatedValues("Accept");
@@ -178,7 +176,7 @@ private static async Task ValidateAcceptHeaderAsync(MediaTypeHeaderValue a
if (!seenCompatibleMediaType)
{
- await FlushResponseAsync(httpContext.Response, serializationContext, new ErrorObject(HttpStatusCode.NotAcceptable)
+ await FlushResponseAsync(httpContext.Response, serializerOptions, new ErrorObject(HttpStatusCode.NotAcceptable)
{
Title = "The specified Accept header value does not contain any supported media types.",
Detail = $"Please include '{allowedMediaTypeValue}' in the Accept header values.",
@@ -194,7 +192,7 @@ private static async Task ValidateAcceptHeaderAsync(MediaTypeHeaderValue a
return true;
}
- private static async Task FlushResponseAsync(HttpResponse httpResponse, JsonApiSerializationContext serializationContext, ErrorObject error)
+ private static async Task FlushResponseAsync(HttpResponse httpResponse, JsonSerializerOptions serializerOptions, ErrorObject error)
{
httpResponse.ContentType = HeaderConstants.MediaType;
httpResponse.StatusCode = (int)error.StatusCode;
@@ -204,7 +202,7 @@ private static async Task FlushResponseAsync(HttpResponse httpResponse, JsonApiS
Errors = error.AsList()
};
- await JsonSerializer.SerializeAsync(httpResponse.Body, errorDocument, serializationContext.Document);
+ await JsonSerializer.SerializeAsync(httpResponse.Body, errorDocument, serializerOptions);
await httpResponse.Body.FlushAsync();
}
diff --git a/src/JsonApiDotNetCore/Serialization/JsonApiSerializationContext.cs b/src/JsonApiDotNetCore/Serialization/JsonApiSerializationContext.cs
deleted file mode 100644
index 38180d9369..0000000000
--- a/src/JsonApiDotNetCore/Serialization/JsonApiSerializationContext.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System.Text.Json.Serialization;
-using JsonApiDotNetCore.Serialization.Objects;
-
-namespace JsonApiDotNetCore.Serialization;
-
-// Workaround for https://youtrack.jetbrains.com/issue/RSRP-487028
-partial class JsonApiSerializationContext
-{
-}
-
-///
-/// Provides compile-time metadata about the set of JSON:API types used in JSON serialization of request/response bodies.
-///
-[JsonSerializable(typeof(Document))]
-public sealed partial class JsonApiSerializationContext : JsonSerializerContext
-{
-}
diff --git a/src/JsonApiDotNetCore/Serialization/JsonConverters/JsonObjectConverter.cs b/src/JsonApiDotNetCore/Serialization/JsonConverters/JsonObjectConverter.cs
index 97d7589cc6..32e4351e12 100644
--- a/src/JsonApiDotNetCore/Serialization/JsonConverters/JsonObjectConverter.cs
+++ b/src/JsonApiDotNetCore/Serialization/JsonConverters/JsonObjectConverter.cs
@@ -7,12 +7,24 @@ public abstract class JsonObjectConverter : JsonConverter
{
protected static TValue? ReadSubTree(ref Utf8JsonReader reader, JsonSerializerOptions options)
{
+ if (typeof(TValue) != typeof(object) && options.GetConverter(typeof(TValue)) is JsonConverter converter)
+ {
+ return converter.Read(ref reader, typeof(TValue), options);
+ }
+
return JsonSerializer.Deserialize(ref reader, options);
}
protected static void WriteSubTree(Utf8JsonWriter writer, TValue value, JsonSerializerOptions options)
{
- JsonSerializer.Serialize(writer, value, options);
+ if (typeof(TValue) != typeof(object) && options.GetConverter(typeof(TValue)) is JsonConverter converter)
+ {
+ converter.Write(writer, value, options);
+ }
+ else
+ {
+ JsonSerializer.Serialize(writer, value, options);
+ }
}
protected static JsonException GetEndOfStreamError()
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/Document.cs b/src/JsonApiDotNetCore/Serialization/Objects/Document.cs
index 87c3a0acfa..2f40aeb27b 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/Document.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/Document.cs
@@ -1,12 +1,10 @@
using System.Text.Json.Serialization;
-using JetBrains.Annotations;
namespace JsonApiDotNetCore.Serialization.Objects;
///
/// See https://jsonapi.org/format/1.1/#document-top-level and https://jsonapi.org/ext/atomic/#document-structure.
///
-[PublicAPI]
public sealed class Document
{
[JsonPropertyName("jsonapi")]
diff --git a/src/JsonApiDotNetCore/Serialization/Request/JsonApiReader.cs b/src/JsonApiDotNetCore/Serialization/Request/JsonApiReader.cs
index 0282ab39bd..0942683487 100644
--- a/src/JsonApiDotNetCore/Serialization/Request/JsonApiReader.cs
+++ b/src/JsonApiDotNetCore/Serialization/Request/JsonApiReader.cs
@@ -80,7 +80,7 @@ private Document DeserializeDocument(string requestBody)
using IDisposable _ =
CodeTimingSessionManager.Current.Measure("JsonSerializer.Deserialize", MeasurementSettings.ExcludeJsonSerializationInPercentages);
- Document? document = JsonSerializer.Deserialize(requestBody, _options.SerializationReadContext.Document);
+ var document = JsonSerializer.Deserialize(requestBody, _options.SerializerReadOptions);
AssertHasDocument(document, requestBody);
diff --git a/src/JsonApiDotNetCore/Serialization/Response/JsonApiWriter.cs b/src/JsonApiDotNetCore/Serialization/Response/JsonApiWriter.cs
index 2bfefde98b..20f4ad242b 100644
--- a/src/JsonApiDotNetCore/Serialization/Response/JsonApiWriter.cs
+++ b/src/JsonApiDotNetCore/Serialization/Response/JsonApiWriter.cs
@@ -125,7 +125,7 @@ private string SerializeDocument(Document document)
{
using IDisposable _ = CodeTimingSessionManager.Current.Measure("JsonSerializer.Serialize", MeasurementSettings.ExcludeJsonSerializationInPercentages);
- return JsonSerializer.Serialize(document, _options.SerializationWriteContext.Document);
+ return JsonSerializer.Serialize(document, _options.SerializerWriteOptions);
}
private bool SetETagResponseHeader(HttpRequest request, HttpResponse response, string responseContent)
diff --git a/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Response/ResponseModelAdapterTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Response/ResponseModelAdapterTests.cs
index f0af041de5..d9459f7ec1 100644
--- a/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Response/ResponseModelAdapterTests.cs
+++ b/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Response/ResponseModelAdapterTests.cs
@@ -38,7 +38,7 @@ public void Resources_in_deeply_nested_circular_chain_are_written_in_relationshi
Document document = responseModelAdapter.Convert(article);
// Assert
- string text = JsonSerializer.Serialize(document, options.SerializationWriteContext.Document);
+ string text = JsonSerializer.Serialize(document, new JsonSerializerOptions(options.SerializerWriteOptions));
text.Should().BeJson(@"{
""data"": {
@@ -175,7 +175,7 @@ public void Resources_in_deeply_nested_circular_chains_are_written_in_relationsh
});
// Assert
- string text = JsonSerializer.Serialize(document, options.SerializationWriteContext.Document);
+ string text = JsonSerializer.Serialize(document, new JsonSerializerOptions(options.SerializerWriteOptions));
text.Should().BeJson(@"{
""data"": [
@@ -333,7 +333,7 @@ public void Resources_in_overlapping_deeply_nested_circular_chains_are_written_i
Document document = responseModelAdapter.Convert(article);
// Assert
- string text = JsonSerializer.Serialize(document, options.SerializationWriteContext.Document);
+ string text = JsonSerializer.Serialize(document, new JsonSerializerOptions(options.SerializerWriteOptions));
text.Should().BeJson(@"{
""data"": {
From aedb16496dfa8f4e8861e0bac6cc9512bdbd7e31 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Sat, 3 Sep 2022 17:40:09 +0200
Subject: [PATCH 20/50] Package updates
---
Directory.Build.props | 8 ++++----
benchmarks/Benchmarks.csproj | 7 +++++--
test/TestBuildingBlocks/TestBuildingBlocks.csproj | 2 +-
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index 515d7de1ba..380996c725 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -4,7 +4,7 @@
6.0.*
6.0.*
6.0.*
- 4.2.*
+ 4.3.*
2.14.1
5.0.3
$(MSBuildThisFileDirectory)CodingGuidelines.ruleset
@@ -17,7 +17,7 @@
-
+
@@ -34,7 +34,7 @@
3.1.2
- 4.18.1
- 17.2.0
+ 4.18.2
+ 17.3.1
diff --git a/benchmarks/Benchmarks.csproj b/benchmarks/Benchmarks.csproj
index f461a4831b..3958713af4 100644
--- a/benchmarks/Benchmarks.csproj
+++ b/benchmarks/Benchmarks.csproj
@@ -1,4 +1,4 @@
-
+
Exe
$(TargetFrameworkName)
@@ -10,6 +10,9 @@
-
+
+
+
+
diff --git a/test/TestBuildingBlocks/TestBuildingBlocks.csproj b/test/TestBuildingBlocks/TestBuildingBlocks.csproj
index 2f383d72e9..ed335f630f 100644
--- a/test/TestBuildingBlocks/TestBuildingBlocks.csproj
+++ b/test/TestBuildingBlocks/TestBuildingBlocks.csproj
@@ -16,7 +16,7 @@
-
+
From e4020c629b7165709c5b2bbf598b819f0a68918d Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Wed, 7 Sep 2022 10:44:48 +0200
Subject: [PATCH 21/50] Increment version number (used for pre-release builds
from ci)
---
Directory.Build.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index 380996c725..3a3d018a65 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -6,7 +6,7 @@
6.0.*
4.3.*
2.14.1
- 5.0.3
+ 5.0.4
$(MSBuildThisFileDirectory)CodingGuidelines.ruleset
9999
enable
From 6b69ed3f8f396348b1665e6395acfb77ab74c4bd Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Fri, 9 Sep 2022 14:36:27 +0200
Subject: [PATCH 22/50] Fixed error in documentation example
---
docs/usage/extensibility/controllers.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/usage/extensibility/controllers.md b/docs/usage/extensibility/controllers.md
index 0c71f45090..7e54d3fb9c 100644
--- a/docs/usage/extensibility/controllers.md
+++ b/docs/usage/extensibility/controllers.md
@@ -39,7 +39,7 @@ DELETE http://localhost:14140/articles/1 HTTP/1.1
```json
{
"links": {
- "self": "/articles"
+ "self": "/articles/1"
},
"errors": [
{
From 79d918a7a442de304205a5195cd707215d472a93 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Sat, 1 Oct 2022 12:41:40 +0200
Subject: [PATCH 23/50] Update links to JSON:API v1.1-final
---
README.md | 2 +-
docs/usage/reading/including-relationships.md | 2 +-
src/JsonApiDotNetCore/Serialization/Objects/Document.cs | 2 +-
src/JsonApiDotNetCore/Serialization/Objects/ErrorLinks.cs | 2 +-
src/JsonApiDotNetCore/Serialization/Objects/ErrorObject.cs | 2 +-
src/JsonApiDotNetCore/Serialization/Objects/ErrorSource.cs | 2 +-
src/JsonApiDotNetCore/Serialization/Objects/JsonApiObject.cs | 2 +-
.../Serialization/Objects/RelationshipLinks.cs | 2 +-
.../Serialization/Objects/RelationshipObject.cs | 2 +-
.../Serialization/Objects/ResourceIdentifierObject.cs | 2 +-
src/JsonApiDotNetCore/Serialization/Objects/ResourceLinks.cs | 2 +-
src/JsonApiDotNetCore/Serialization/Objects/ResourceObject.cs | 2 +-
src/JsonApiDotNetCore/Serialization/Objects/TopLevelLinks.cs | 2 +-
13 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index e2291f080e..35adb3fe9f 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ These are some steps you can take to help you understand what this project is an
- [Embercasts: Full Stack Ember with ASP.NET Core](https://www.embercasts.com/course/full-stack-ember-with-dotnet/watch/whats-in-this-course-cs) (paid course, 2017)
### Official documentation
-- [The JSON:API specification](https://jsonapi.org/format/1.1/)
+- [The JSON:API specification](https://jsonapi.org/format/)
- [JsonApiDotNetCore website](https://www.jsonapi.net/)
- [Roadmap](ROADMAP.md)
diff --git a/docs/usage/reading/including-relationships.md b/docs/usage/reading/including-relationships.md
index f22d2321aa..0b69a007c1 100644
--- a/docs/usage/reading/including-relationships.md
+++ b/docs/usage/reading/including-relationships.md
@@ -1,6 +1,6 @@
# Including Relationships
-JsonApiDotNetCore supports [request include params](http://jsonapi.org/format/#fetching-includes) out of the box,
+JsonApiDotNetCore supports [request include params](https://jsonapi.org/format/#fetching-includes) out of the box,
for side-loading related resources.
```http
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/Document.cs b/src/JsonApiDotNetCore/Serialization/Objects/Document.cs
index 2f40aeb27b..e0d7d5def3 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/Document.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/Document.cs
@@ -3,7 +3,7 @@
namespace JsonApiDotNetCore.Serialization.Objects;
///
-/// See https://jsonapi.org/format/1.1/#document-top-level and https://jsonapi.org/ext/atomic/#document-structure.
+/// See https://jsonapi.org/format#document-top-level and https://jsonapi.org/ext/atomic/#document-structure.
///
public sealed class Document
{
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/ErrorLinks.cs b/src/JsonApiDotNetCore/Serialization/Objects/ErrorLinks.cs
index 4b8d4de528..6ba2c2a6f6 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/ErrorLinks.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/ErrorLinks.cs
@@ -4,7 +4,7 @@
namespace JsonApiDotNetCore.Serialization.Objects;
///
-/// See "links" in https://jsonapi.org/format/1.1/#error-objects.
+/// See "links" in https://jsonapi.org/format/#error-objects.
///
[PublicAPI]
public sealed class ErrorLinks
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/ErrorObject.cs b/src/JsonApiDotNetCore/Serialization/Objects/ErrorObject.cs
index 87ad1ebefe..68a2a19d3a 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/ErrorObject.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/ErrorObject.cs
@@ -5,7 +5,7 @@
namespace JsonApiDotNetCore.Serialization.Objects;
///
-/// See https://jsonapi.org/format/1.1/#error-objects.
+/// See https://jsonapi.org/format/#error-objects.
///
[PublicAPI]
public sealed class ErrorObject
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/ErrorSource.cs b/src/JsonApiDotNetCore/Serialization/Objects/ErrorSource.cs
index 156f734aa2..b9242895f4 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/ErrorSource.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/ErrorSource.cs
@@ -4,7 +4,7 @@
namespace JsonApiDotNetCore.Serialization.Objects;
///
-/// See "source" in https://jsonapi.org/format/1.1/#error-objects.
+/// See "source" in https://jsonapi.org/format/#error-objects.
///
[PublicAPI]
public sealed class ErrorSource
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/JsonApiObject.cs b/src/JsonApiDotNetCore/Serialization/Objects/JsonApiObject.cs
index 4a48f90099..66daec22ff 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/JsonApiObject.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/JsonApiObject.cs
@@ -4,7 +4,7 @@
namespace JsonApiDotNetCore.Serialization.Objects;
///
-/// See https://jsonapi.org/format/1.1/#document-jsonapi-object.
+/// See https://jsonapi.org/format/#document-jsonapi-object.
///
[PublicAPI]
public sealed class JsonApiObject
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/RelationshipLinks.cs b/src/JsonApiDotNetCore/Serialization/Objects/RelationshipLinks.cs
index f3f6c2bf02..4c1095e1a7 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/RelationshipLinks.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/RelationshipLinks.cs
@@ -4,7 +4,7 @@
namespace JsonApiDotNetCore.Serialization.Objects;
///
-/// See "links" in https://jsonapi.org/format/1.1/#document-resource-object-relationships.
+/// See "links" in https://jsonapi.org/format/#document-resource-object-relationships.
///
[PublicAPI]
public sealed class RelationshipLinks
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/RelationshipObject.cs b/src/JsonApiDotNetCore/Serialization/Objects/RelationshipObject.cs
index 9411ecf83a..c677e9a0fb 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/RelationshipObject.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/RelationshipObject.cs
@@ -4,7 +4,7 @@
namespace JsonApiDotNetCore.Serialization.Objects;
///
-/// See https://jsonapi.org/format/1.1/#document-resource-object-relationships.
+/// See https://jsonapi.org/format/#document-resource-object-relationships.
///
[PublicAPI]
public sealed class RelationshipObject
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/ResourceIdentifierObject.cs b/src/JsonApiDotNetCore/Serialization/Objects/ResourceIdentifierObject.cs
index 20c30909ed..e82ebe16bf 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/ResourceIdentifierObject.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/ResourceIdentifierObject.cs
@@ -4,7 +4,7 @@
namespace JsonApiDotNetCore.Serialization.Objects;
///
-/// See https://jsonapi.org/format/1.1/#document-resource-identifier-objects.
+/// See https://jsonapi.org/format/#document-resource-identifier-objects.
///
[PublicAPI]
public class ResourceIdentifierObject : ResourceIdentity
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/ResourceLinks.cs b/src/JsonApiDotNetCore/Serialization/Objects/ResourceLinks.cs
index 22c396082d..6f749cca88 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/ResourceLinks.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/ResourceLinks.cs
@@ -4,7 +4,7 @@
namespace JsonApiDotNetCore.Serialization.Objects;
///
-/// See https://jsonapi.org/format/1.1/#document-resource-object-links.
+/// See https://jsonapi.org/format/#document-resource-object-links.
///
[PublicAPI]
public sealed class ResourceLinks
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/ResourceObject.cs b/src/JsonApiDotNetCore/Serialization/Objects/ResourceObject.cs
index ed38a40f9a..fc1ff3d146 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/ResourceObject.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/ResourceObject.cs
@@ -4,7 +4,7 @@
namespace JsonApiDotNetCore.Serialization.Objects;
///
-/// See https://jsonapi.org/format/1.1/#document-resource-objects.
+/// See https://jsonapi.org/format/#document-resource-objects.
///
[PublicAPI]
public sealed class ResourceObject : ResourceIdentifierObject
diff --git a/src/JsonApiDotNetCore/Serialization/Objects/TopLevelLinks.cs b/src/JsonApiDotNetCore/Serialization/Objects/TopLevelLinks.cs
index 14578253c2..f83510fb23 100644
--- a/src/JsonApiDotNetCore/Serialization/Objects/TopLevelLinks.cs
+++ b/src/JsonApiDotNetCore/Serialization/Objects/TopLevelLinks.cs
@@ -4,7 +4,7 @@
namespace JsonApiDotNetCore.Serialization.Objects;
///
-/// See "links" in https://jsonapi.org/format/1.1/#document-top-level.
+/// See "links" in https://jsonapi.org/format/#document-top-level.
///
[PublicAPI]
public sealed class TopLevelLinks
From 1dc249bf5c8f46216a871913f6d9931a91c59525 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Wed, 28 Sep 2022 04:39:53 +0200
Subject: [PATCH 24/50] Improve error message when duplicate controllers are
found, to include the fully qualified type names of the conflicting
controllers
---
src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs | 3 ++-
.../DuplicateResourceControllerTests.cs | 5 ++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs b/src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs
index fe95d93446..58f8d18560 100644
--- a/src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs
+++ b/src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs
@@ -78,7 +78,8 @@ public void Apply(ApplicationModel application)
{
if (_controllerPerResourceTypeMap.ContainsKey(resourceType))
{
- throw new InvalidConfigurationException($"Multiple controllers found for resource type '{resourceType}'.");
+ throw new InvalidConfigurationException(
+ $"Multiple controllers found for resource type '{resourceType}': '{_controllerPerResourceTypeMap[resourceType].ControllerType}' and '{controller.ControllerType}'.");
}
_resourceTypePerControllerTypeMap.Add(controller.ControllerType, resourceType);
diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/NonJsonApiControllers/DuplicateResourceControllerTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/NonJsonApiControllers/DuplicateResourceControllerTests.cs
index b130523588..0f1b1178f4 100644
--- a/test/JsonApiDotNetCoreTests/IntegrationTests/NonJsonApiControllers/DuplicateResourceControllerTests.cs
+++ b/test/JsonApiDotNetCoreTests/IntegrationTests/NonJsonApiControllers/DuplicateResourceControllerTests.cs
@@ -20,6 +20,9 @@ public void Fails_at_startup_when_multiple_controllers_exist_for_same_resource_t
Action action = () => _ = Factory;
// Assert
- action.Should().ThrowExactly().WithMessage("Multiple controllers found for resource type 'knownResources'.");
+ InvalidConfigurationException exception = action.Should().ThrowExactly().Which!;
+ exception.Message.Should().StartWith("Multiple controllers found for resource type 'knownResources': ");
+ exception.Message.Should().Contain($"'{typeof(KnownResourcesController).FullName}'");
+ exception.Message.Should().Contain($"'{typeof(DuplicateKnownResourcesController).FullName}'");
}
}
From 70c06b941d2201c53c8e0940cd4cf0420cfa40df Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Wed, 28 Sep 2022 03:14:21 +0200
Subject: [PATCH 25/50] Multi-target Annotations against .NET Standard 1.0
---
JsonApiDotNetCore.sln | 15 +++++++++++++
...ndpoints.cs => JsonApiEndpoints.shared.cs} | 0
.../JsonApiDotNetCore.Annotations.csproj | 22 +++++++++++++++++--
.../Annotations/AttrAttribute.netstandard.cs | 14 ++++++++++++
...bilities.cs => AttrCapabilities.shared.cs} | 3 +++
.../EagerLoadAttribute.netstandard.cs | 12 ++++++++++
.../HasManyAttribute.netstandard.cs | 12 ++++++++++
.../HasOneAttribute.netstandard.cs | 12 ++++++++++
.../{LinkTypes.cs => LinkTypes.shared.cs} | 0
...ibute.cs => NoResourceAttribute.shared.cs} | 0
.../RelationshipAttribute.netstandard.cs | 16 ++++++++++++++
...tribute.cs => ResourceAttribute.shared.cs} | 0
.../ResourceFieldAttribute.netstandard.cs | 13 +++++++++++
...te.cs => ResourceLinksAttribute.shared.cs} | 0
...dentifiable.cs => IIdentifiable.shared.cs} | 4 ++++
.../Resources/Identifiable.netstandard.cs | 16 ++++++++++++++
test/AnnotationTests/AnnotationTests.csproj | 20 +++++++++++++++++
test/AnnotationTests/Models/HiddenNode.cs | 14 ++++++++++++
test/AnnotationTests/Models/TreeNode.cs | 20 +++++++++++++++++
19 files changed, 191 insertions(+), 2 deletions(-)
rename src/JsonApiDotNetCore.Annotations/Controllers/{JsonApiEndpoints.cs => JsonApiEndpoints.shared.cs} (100%)
create mode 100644 src/JsonApiDotNetCore.Annotations/Resources/Annotations/AttrAttribute.netstandard.cs
rename src/JsonApiDotNetCore.Annotations/Resources/Annotations/{AttrCapabilities.cs => AttrCapabilities.shared.cs} (96%)
create mode 100644 src/JsonApiDotNetCore.Annotations/Resources/Annotations/EagerLoadAttribute.netstandard.cs
create mode 100644 src/JsonApiDotNetCore.Annotations/Resources/Annotations/HasManyAttribute.netstandard.cs
create mode 100644 src/JsonApiDotNetCore.Annotations/Resources/Annotations/HasOneAttribute.netstandard.cs
rename src/JsonApiDotNetCore.Annotations/Resources/Annotations/{LinkTypes.cs => LinkTypes.shared.cs} (100%)
rename src/JsonApiDotNetCore.Annotations/Resources/Annotations/{NoResourceAttribute.cs => NoResourceAttribute.shared.cs} (100%)
create mode 100644 src/JsonApiDotNetCore.Annotations/Resources/Annotations/RelationshipAttribute.netstandard.cs
rename src/JsonApiDotNetCore.Annotations/Resources/Annotations/{ResourceAttribute.cs => ResourceAttribute.shared.cs} (100%)
create mode 100644 src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceFieldAttribute.netstandard.cs
rename src/JsonApiDotNetCore.Annotations/Resources/Annotations/{ResourceLinksAttribute.cs => ResourceLinksAttribute.shared.cs} (100%)
rename src/JsonApiDotNetCore.Annotations/Resources/{IIdentifiable.cs => IIdentifiable.shared.cs} (94%)
create mode 100644 src/JsonApiDotNetCore.Annotations/Resources/Identifiable.netstandard.cs
create mode 100644 test/AnnotationTests/AnnotationTests.csproj
create mode 100644 test/AnnotationTests/Models/HiddenNode.cs
create mode 100644 test/AnnotationTests/Models/TreeNode.cs
diff --git a/JsonApiDotNetCore.sln b/JsonApiDotNetCore.sln
index 21b1cca7ce..e034595875 100644
--- a/JsonApiDotNetCore.sln
+++ b/JsonApiDotNetCore.sln
@@ -52,6 +52,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCore.Annotatio
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DatabasePerTenantExample", "src\Examples\DatabasePerTenantExample\DatabasePerTenantExample.csproj", "{60334658-BE51-43B3-9C4D-F2BBF56C89CE}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnnotationTests", "test\AnnotationTests\AnnotationTests.csproj", "{24B0C12F-38CD-4245-8785-87BEFAD55B00}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -266,6 +268,18 @@ Global
{60334658-BE51-43B3-9C4D-F2BBF56C89CE}.Release|x64.Build.0 = Release|Any CPU
{60334658-BE51-43B3-9C4D-F2BBF56C89CE}.Release|x86.ActiveCfg = Release|Any CPU
{60334658-BE51-43B3-9C4D-F2BBF56C89CE}.Release|x86.Build.0 = Release|Any CPU
+ {24B0C12F-38CD-4245-8785-87BEFAD55B00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {24B0C12F-38CD-4245-8785-87BEFAD55B00}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {24B0C12F-38CD-4245-8785-87BEFAD55B00}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {24B0C12F-38CD-4245-8785-87BEFAD55B00}.Debug|x64.Build.0 = Debug|Any CPU
+ {24B0C12F-38CD-4245-8785-87BEFAD55B00}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {24B0C12F-38CD-4245-8785-87BEFAD55B00}.Debug|x86.Build.0 = Debug|Any CPU
+ {24B0C12F-38CD-4245-8785-87BEFAD55B00}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {24B0C12F-38CD-4245-8785-87BEFAD55B00}.Release|Any CPU.Build.0 = Release|Any CPU
+ {24B0C12F-38CD-4245-8785-87BEFAD55B00}.Release|x64.ActiveCfg = Release|Any CPU
+ {24B0C12F-38CD-4245-8785-87BEFAD55B00}.Release|x64.Build.0 = Release|Any CPU
+ {24B0C12F-38CD-4245-8785-87BEFAD55B00}.Release|x86.ActiveCfg = Release|Any CPU
+ {24B0C12F-38CD-4245-8785-87BEFAD55B00}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -288,6 +302,7 @@ Global
{0E0B5C51-F7E2-4F40-A4E4-DED0E9731DC9} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}
{83FF097C-C8C6-477B-9FAB-DF99B84978B5} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF}
{60334658-BE51-43B3-9C4D-F2BBF56C89CE} = {026FBC6C-AF76-4568-9B87-EC73457899FD}
+ {24B0C12F-38CD-4245-8785-87BEFAD55B00} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A2421882-8F0A-4905-928F-B550B192F9A4}
diff --git a/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.cs b/src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs
similarity index 100%
rename from src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.cs
rename to src/JsonApiDotNetCore.Annotations/Controllers/JsonApiEndpoints.shared.cs
diff --git a/src/JsonApiDotNetCore.Annotations/JsonApiDotNetCore.Annotations.csproj b/src/JsonApiDotNetCore.Annotations/JsonApiDotNetCore.Annotations.csproj
index 7c78f620ed..5f4d7c1d76 100644
--- a/src/JsonApiDotNetCore.Annotations/JsonApiDotNetCore.Annotations.csproj
+++ b/src/JsonApiDotNetCore.Annotations/JsonApiDotNetCore.Annotations.csproj
@@ -1,9 +1,10 @@
-
+
- $(TargetFrameworkName)
+ $(TargetFrameworkName);netstandard1.0
true
true
JsonApiDotNetCore
+ latest
@@ -27,4 +28,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/AttrAttribute.netstandard.cs b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/AttrAttribute.netstandard.cs
new file mode 100644
index 0000000000..a7915240dc
--- /dev/null
+++ b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/AttrAttribute.netstandard.cs
@@ -0,0 +1,14 @@
+using JetBrains.Annotations;
+
+namespace JsonApiDotNetCore.Resources.Annotations;
+
+///
+/// A simplified version, provided for convenience to multi-target against NetStandard. Does not actually work with JsonApiDotNetCore.
+///
+[PublicAPI]
+[AttributeUsage(AttributeTargets.Property)]
+public sealed class AttrAttribute : ResourceFieldAttribute
+{
+ ///
+ public AttrCapabilities Capabilities { get; set; }
+}
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/AttrCapabilities.cs b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/AttrCapabilities.shared.cs
similarity index 96%
rename from src/JsonApiDotNetCore.Annotations/Resources/Annotations/AttrCapabilities.cs
rename to src/JsonApiDotNetCore.Annotations/Resources/Annotations/AttrCapabilities.shared.cs
index c6f849fdff..2812be6d39 100644
--- a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/AttrCapabilities.cs
+++ b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/AttrCapabilities.shared.cs
@@ -1,8 +1,11 @@
+using JetBrains.Annotations;
+
namespace JsonApiDotNetCore.Resources.Annotations;
///
/// Indicates capabilities that can be performed on an .
///
+[PublicAPI]
[Flags]
public enum AttrCapabilities
{
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/EagerLoadAttribute.netstandard.cs b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/EagerLoadAttribute.netstandard.cs
new file mode 100644
index 0000000000..47052a078c
--- /dev/null
+++ b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/EagerLoadAttribute.netstandard.cs
@@ -0,0 +1,12 @@
+using JetBrains.Annotations;
+
+namespace JsonApiDotNetCore.Resources.Annotations;
+
+///
+/// A simplified version, provided for convenience to multi-target against NetStandard. Does not actually work with JsonApiDotNetCore.
+///
+[PublicAPI]
+[AttributeUsage(AttributeTargets.Property)]
+public sealed class EagerLoadAttribute : Attribute
+{
+}
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/HasManyAttribute.netstandard.cs b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/HasManyAttribute.netstandard.cs
new file mode 100644
index 0000000000..1cdeb9f62f
--- /dev/null
+++ b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/HasManyAttribute.netstandard.cs
@@ -0,0 +1,12 @@
+using JetBrains.Annotations;
+
+namespace JsonApiDotNetCore.Resources.Annotations;
+
+///
+/// A simplified version, provided for convenience to multi-target against NetStandard. Does not actually work with JsonApiDotNetCore.
+///
+[PublicAPI]
+[AttributeUsage(AttributeTargets.Property)]
+public sealed class HasManyAttribute : RelationshipAttribute
+{
+}
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/HasOneAttribute.netstandard.cs b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/HasOneAttribute.netstandard.cs
new file mode 100644
index 0000000000..1c16fb01b2
--- /dev/null
+++ b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/HasOneAttribute.netstandard.cs
@@ -0,0 +1,12 @@
+using JetBrains.Annotations;
+
+namespace JsonApiDotNetCore.Resources.Annotations;
+
+///
+/// A simplified version, provided for convenience to multi-target against NetStandard. Does not actually work with JsonApiDotNetCore.
+///
+[PublicAPI]
+[AttributeUsage(AttributeTargets.Property)]
+public sealed class HasOneAttribute : RelationshipAttribute
+{
+}
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/LinkTypes.cs b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/LinkTypes.shared.cs
similarity index 100%
rename from src/JsonApiDotNetCore.Annotations/Resources/Annotations/LinkTypes.cs
rename to src/JsonApiDotNetCore.Annotations/Resources/Annotations/LinkTypes.shared.cs
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/NoResourceAttribute.cs b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/NoResourceAttribute.shared.cs
similarity index 100%
rename from src/JsonApiDotNetCore.Annotations/Resources/Annotations/NoResourceAttribute.cs
rename to src/JsonApiDotNetCore.Annotations/Resources/Annotations/NoResourceAttribute.shared.cs
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/RelationshipAttribute.netstandard.cs b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/RelationshipAttribute.netstandard.cs
new file mode 100644
index 0000000000..51517b3d51
--- /dev/null
+++ b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/RelationshipAttribute.netstandard.cs
@@ -0,0 +1,16 @@
+using JetBrains.Annotations;
+
+namespace JsonApiDotNetCore.Resources.Annotations;
+
+///
+/// A simplified version, provided for convenience to multi-target against NetStandard. Does not actually work with JsonApiDotNetCore.
+///
+[PublicAPI]
+public abstract class RelationshipAttribute : ResourceFieldAttribute
+{
+ ///
+ public LinkTypes Links { get; set; } = LinkTypes.NotConfigured;
+
+ ///
+ public bool CanInclude { get; set; } = true;
+}
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceAttribute.cs b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceAttribute.shared.cs
similarity index 100%
rename from src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceAttribute.cs
rename to src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceAttribute.shared.cs
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceFieldAttribute.netstandard.cs b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceFieldAttribute.netstandard.cs
new file mode 100644
index 0000000000..958794365d
--- /dev/null
+++ b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceFieldAttribute.netstandard.cs
@@ -0,0 +1,13 @@
+using JetBrains.Annotations;
+
+namespace JsonApiDotNetCore.Resources.Annotations;
+
+///
+/// A simplified version, provided for convenience to multi-target against NetStandard. Does not actually work with JsonApiDotNetCore.
+///
+[PublicAPI]
+public abstract class ResourceFieldAttribute : Attribute
+{
+ ///
+ public string PublicName { get; set; } = null!;
+}
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceLinksAttribute.cs b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceLinksAttribute.shared.cs
similarity index 100%
rename from src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceLinksAttribute.cs
rename to src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceLinksAttribute.shared.cs
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/IIdentifiable.cs b/src/JsonApiDotNetCore.Annotations/Resources/IIdentifiable.shared.cs
similarity index 94%
rename from src/JsonApiDotNetCore.Annotations/Resources/IIdentifiable.cs
rename to src/JsonApiDotNetCore.Annotations/Resources/IIdentifiable.shared.cs
index 2c6dc02025..b6dc5e3b22 100644
--- a/src/JsonApiDotNetCore.Annotations/Resources/IIdentifiable.cs
+++ b/src/JsonApiDotNetCore.Annotations/Resources/IIdentifiable.shared.cs
@@ -1,8 +1,11 @@
+using JetBrains.Annotations;
+
namespace JsonApiDotNetCore.Resources;
///
/// Defines the basic contract for a JSON:API resource. All resource classes must implement .
///
+[PublicAPI]
public interface IIdentifiable
{
///
@@ -22,6 +25,7 @@ public interface IIdentifiable
///
/// The resource identifier type.
///
+[PublicAPI]
public interface IIdentifiable : IIdentifiable
{
///
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Identifiable.netstandard.cs b/src/JsonApiDotNetCore.Annotations/Resources/Identifiable.netstandard.cs
new file mode 100644
index 0000000000..a5a7179af6
--- /dev/null
+++ b/src/JsonApiDotNetCore.Annotations/Resources/Identifiable.netstandard.cs
@@ -0,0 +1,16 @@
+namespace JsonApiDotNetCore.Resources;
+
+///
+/// A simplified version, provided for convenience to multi-target against NetStandard. Does not actually work with JsonApiDotNetCore.
+///
+public abstract class Identifiable : IIdentifiable
+{
+ ///
+ public virtual TId Id { get; set; } = default!;
+
+ ///
+ public string? StringId { get; set; }
+
+ ///
+ public string? LocalId { get; set; }
+}
diff --git a/test/AnnotationTests/AnnotationTests.csproj b/test/AnnotationTests/AnnotationTests.csproj
new file mode 100644
index 0000000000..51df20d735
--- /dev/null
+++ b/test/AnnotationTests/AnnotationTests.csproj
@@ -0,0 +1,20 @@
+
+
+ $(TargetFrameworkName);netstandard1.0
+ latest
+
+
+
+
+ PreserveNewest
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/AnnotationTests/Models/HiddenNode.cs b/test/AnnotationTests/Models/HiddenNode.cs
new file mode 100644
index 0000000000..c348f3b5b0
--- /dev/null
+++ b/test/AnnotationTests/Models/HiddenNode.cs
@@ -0,0 +1,14 @@
+using JetBrains.Annotations;
+using JsonApiDotNetCore.Resources;
+using JsonApiDotNetCore.Resources.Annotations;
+
+namespace AnnotationTests.Models;
+
+[PublicAPI]
+[NoResource]
+[ResourceLinks(TopLevelLinks = LinkTypes.None, ResourceLinks = LinkTypes.None, RelationshipLinks = LinkTypes.None)]
+public sealed class HiddenNode : Identifiable
+{
+ [EagerLoad]
+ public HiddenNode? Parent { get; set; }
+}
diff --git a/test/AnnotationTests/Models/TreeNode.cs b/test/AnnotationTests/Models/TreeNode.cs
new file mode 100644
index 0000000000..955db81720
--- /dev/null
+++ b/test/AnnotationTests/Models/TreeNode.cs
@@ -0,0 +1,20 @@
+using JetBrains.Annotations;
+using JsonApiDotNetCore.Controllers;
+using JsonApiDotNetCore.Resources;
+using JsonApiDotNetCore.Resources.Annotations;
+
+namespace AnnotationTests.Models;
+
+[PublicAPI]
+[Resource(PublicName = "tree-node", ControllerNamespace = "Models", GenerateControllerEndpoints = JsonApiEndpoints.Query)]
+public sealed class TreeNode : Identifiable
+{
+ [Attr(PublicName = "name", Capabilities = AttrCapabilities.AllowSort)]
+ public string? DisplayName { get; set; }
+
+ [HasOne(PublicName = "orders", CanInclude = true, Links = LinkTypes.All)]
+ public TreeNode? Parent { get; set; }
+
+ [HasMany(PublicName = "orders", CanInclude = true, Links = LinkTypes.All)]
+ public ISet Children { get; set; } = new HashSet();
+}
From ba0278b2e678caa94a0003fc951407be2ebb13c4 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Sat, 24 Sep 2022 00:45:00 +0200
Subject: [PATCH 26/50] Update to latest Resharper version (disabled in Ubuntu
cibuild)
---
.config/dotnet-tools.json | 2 +-
Build.ps1 | 7 +++++--
.../Configuration/ResourceGraphBuilder.cs | 2 +-
test/TestBuildingBlocks/IntegrationTest.cs | 3 +--
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index 3bd80e6084..d914fc369d 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
- "version": "2021.3.4",
+ "version": "2022.2.3",
"commands": [
"jb"
]
diff --git a/Build.ps1 b/Build.ps1
index 4a92feed89..daccb81df1 100644
--- a/Build.ps1
+++ b/Build.ps1
@@ -105,8 +105,11 @@ CheckLastExitCode
dotnet build -c Release
CheckLastExitCode
-RunInspectCode
-RunCleanupCode
+# https://youtrack.jetbrains.com/issue/RSRP-488628/Breaking-InspectCode-fails-with-Roslyn-Worker-process-exited-unexpectedly-after-update
+if ($env:APPVEYOR_BUILD_WORKER_IMAGE -ne 'Ubuntu') {
+ RunInspectCode
+ RunCleanupCode
+}
dotnet test -c Release --no-build --collect:"XPlat Code Coverage"
CheckLastExitCode
diff --git a/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs b/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs
index e07318c7f7..36eb9d37e8 100644
--- a/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs
+++ b/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs
@@ -317,7 +317,7 @@ private IReadOnlyCollection GetRelationships(Type resourc
private void SetPublicName(ResourceFieldAttribute field, PropertyInfo property)
{
- // ReSharper disable once ConstantNullCoalescingCondition
+ // ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract
field.PublicName ??= FormatPropertyName(property);
}
diff --git a/test/TestBuildingBlocks/IntegrationTest.cs b/test/TestBuildingBlocks/IntegrationTest.cs
index 99ced55b01..4fb2e5cd26 100644
--- a/test/TestBuildingBlocks/IntegrationTest.cs
+++ b/test/TestBuildingBlocks/IntegrationTest.cs
@@ -79,8 +79,7 @@ public abstract class IntegrationTest
private string? SerializeRequest(object? requestBody)
{
- return requestBody == null ? null :
- requestBody is string stringRequestBody ? stringRequestBody : JsonSerializer.Serialize(requestBody, SerializerOptions);
+ return requestBody == null ? null : requestBody as string ?? JsonSerializer.Serialize(requestBody, SerializerOptions);
}
protected abstract HttpClient CreateClient();
From 4c61b4998861deb819b9cde19443f16560029d62 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Sat, 24 Sep 2022 05:31:24 +0200
Subject: [PATCH 27/50] Revert workaround for bug that was fixed in recent
Resharper version
---
Build.ps1 | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Build.ps1 b/Build.ps1
index daccb81df1..d8be7da5e6 100644
--- a/Build.ps1
+++ b/Build.ps1
@@ -8,8 +8,7 @@ function CheckLastExitCode {
function RunInspectCode {
$outputPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.xml')
- # passing --build instead of --no-build as workaround for https://youtrack.jetbrains.com/issue/RSRP-487054
- 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 --no-build --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal
CheckLastExitCode
[xml]$xml = Get-Content "$outputPath"
From add5bdad36bdd17a563bc7a8aa7302ae9ae9f85e Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Sat, 24 Sep 2022 00:56:34 +0200
Subject: [PATCH 28/50] Reduce the severity of 'Introduce optional parameters'
for non-private members to Hint level, because they tend to cause
backwards-compatibility issues in publicly exposed signatures
---
JsonApiDotNetCore.sln.DotSettings | 1 +
WarningSeverities.DotSettings | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/JsonApiDotNetCore.sln.DotSettings b/JsonApiDotNetCore.sln.DotSettings
index 95c0c2b7b2..a40e86f270 100644
--- a/JsonApiDotNetCore.sln.DotSettings
+++ b/JsonApiDotNetCore.sln.DotSettings
@@ -54,6 +54,7 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$, $NAME$);
WARNING
WARNING
WARNING
+ HINT
WARNING
DO_NOT_SHOW
HINT
diff --git a/WarningSeverities.DotSettings b/WarningSeverities.DotSettings
index f4a9ae32e8..0d4eeba96f 100644
--- a/WarningSeverities.DotSettings
+++ b/WarningSeverities.DotSettings
@@ -87,7 +87,6 @@
WARNING
WARNING
WARNING
- WARNING
WARNING
WARNING
WARNING
From 3a1e039674fd556e1dcab05d84e562fc9e688e57 Mon Sep 17 00:00:00 2001
From: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Date: Sat, 24 Sep 2022 01:28:45 +0200
Subject: [PATCH 29/50] Reduce the use of nameof() in parameter validations by
using CallerArgumentExpressionAttribute instead
---
JsonApiDotNetCore.sln.DotSettings | 19 ++++++-
.../ArgumentGuard.cs | 32 ++++-------
.../CollectionConverter.cs | 6 +-
.../Configuration/ResourceType.cs | 16 +++---
.../Annotations/RelationshipAttribute.cs | 2 +-
.../Annotations/ResourceFieldAttribute.cs | 8 +--
.../Internal/RuntimeTypeConverter.cs | 2 +-
.../TypeExtensions.cs | 4 +-
.../EntityFrameworkCoreTransaction.cs | 4 +-
.../EntityFrameworkCoreTransactionFactory.cs | 4 +-
.../AtomicOperations/LocalIdTracker.cs | 14 ++---
.../AtomicOperations/LocalIdValidator.cs | 6 +-
.../OperationProcessorAccessor.cs | 4 +-
.../AtomicOperations/OperationsProcessor.cs | 16 +++---
.../Processors/AddToRelationshipProcessor.cs | 4 +-
.../Processors/CreateProcessor.cs | 6 +-
.../Processors/DeleteProcessor.cs | 4 +-
.../RemoveFromRelationshipProcessor.cs | 4 +-
.../Processors/SetRelationshipProcessor.cs | 4 +-
.../Processors/UpdateProcessor.cs | 4 +-
.../RevertRequestStateOnDispose.cs | 2 +-
src/JsonApiDotNetCore/CollectionExtensions.cs | 8 +--
.../ApplicationBuilderExtensions.cs | 2 +-
.../InverseNavigationResolver.cs | 4 +-
.../JsonApiApplicationBuilder.cs | 8 +--
.../Configuration/JsonApiValidationFilter.cs | 2 +-
.../Configuration/ResourceDescriptor.cs | 4 +-
.../Configuration/ResourceGraph.cs | 12 ++--
.../Configuration/ResourceGraphBuilder.cs | 8 +--
.../Configuration/ResourceNameFormatter.cs | 2 +-
.../ServiceCollectionExtensions.cs | 8 +--
.../Configuration/ServiceDiscoveryFacade.cs | 8 +--
.../Configuration/TypeLocator.cs | 16 +++---
.../DisableQueryStringAttribute.cs | 2 +-
.../Controllers/BaseJsonApiController.cs | 24 ++++----
.../BaseJsonApiOperationsController.cs | 14 ++---
.../Controllers/CoreJsonApiController.cs | 4 +-
.../Diagnostics/AspNetCodeTimerSession.cs | 4 +-
.../Diagnostics/CodeTimingSessionManager.cs | 2 +-
.../Errors/InvalidModelStateException.cs | 20 +++----
.../Errors/JsonApiException.cs | 4 +-
.../Errors/MissingResourceInRelationship.cs | 6 +-
.../UnsuccessfulActionResultException.cs | 2 +-
.../AsyncConvertEmptyActionResultFilter.cs | 4 +-
.../Middleware/AsyncJsonApiExceptionFilter.cs | 4 +-
.../AsyncQueryStringActionFilter.cs | 6 +-
.../Middleware/ExceptionHandler.cs | 12 ++--
.../Middleware/HttpContextExtensions.cs | 4 +-
.../Middleware/JsonApiInputFormatter.cs | 4 +-
.../Middleware/JsonApiMiddleware.cs | 10 ++--
.../Middleware/JsonApiOutputFormatter.cs | 4 +-
.../Middleware/JsonApiRequest.cs | 2 +-
.../Middleware/JsonApiRoutingConvention.cs | 6 +-
.../Queries/ExpressionInScope.cs | 2 +-
.../Queries/Expressions/AnyExpression.cs | 4 +-
.../Expressions/ComparisonExpression.cs | 4 +-
.../Queries/Expressions/CountExpression.cs | 2 +-
.../Queries/Expressions/HasExpression.cs | 2 +-
.../Expressions/IncludeChainConverter.cs | 2 +-
.../Expressions/IncludeElementExpression.cs | 4 +-
.../Queries/Expressions/IncludeExpression.cs | 2 +-
.../Queries/Expressions/IsTypeExpression.cs | 2 +-
.../Expressions/LiteralConstantExpression.cs | 2 +-
.../Queries/Expressions/LogicalExpression.cs | 4 +-
.../Expressions/MatchTextExpression.cs | 4 +-
.../Queries/Expressions/NotExpression.cs | 2 +-
.../Expressions/PaginationExpression.cs | 2 +-
.../PaginationQueryStringValueExpression.cs | 2 +-
.../QueryStringParameterScopeExpression.cs | 2 +-
.../Expressions/QueryableHandlerExpression.cs | 2 +-
.../ResourceFieldChainExpression.cs | 4 +-
.../Expressions/SortElementExpression.cs | 4 +-
.../Queries/Expressions/SortExpression.cs | 2 +-
.../Expressions/SparseFieldSetExpression.cs | 2 +-
.../SparseFieldSetExpressionExtensions.cs | 8 +--
.../Expressions/SparseFieldTableExpression.cs | 2 +-
.../Queries/FieldSelection.cs | 2 +-
.../Queries/FieldSelectors.cs | 8 +--
.../Queries/Internal/EvaluatedIncludeCache.cs | 2 +-
.../Queries/Internal/Parsing/FilterParser.cs | 4 +-
.../Queries/Internal/Parsing/IncludeParser.cs | 4 +-
.../Internal/Parsing/PaginationParser.cs | 2 +-
.../QueryStringParameterScopeParser.cs | 2 +-
.../Internal/Parsing/QueryTokenizer.cs | 2 +-
.../Queries/Internal/Parsing/SortParser.cs | 2 +-
.../Internal/Parsing/SparseFieldSetParser.cs | 2 +-
.../Internal/Parsing/SparseFieldTypeParser.cs | 2 +-
.../Queries/Internal/QueryLayerComposer.cs | 56 +++++++++----------
.../QueryableBuilding/IncludeClauseBuilder.cs | 6 +-
.../LambdaParameterNameFactory.cs | 2 +-
.../LambdaParameterNameScope.cs | 4 +-
.../Internal/QueryableBuilding/LambdaScope.cs | 6 +-
.../QueryableBuilding/LambdaScopeFactory.cs | 4 +-
.../QueryableBuilding/OrderClauseBuilder.cs | 6 +-
.../QueryableBuilding/QueryClauseBuilder.cs | 6 +-
.../QueryableBuilding/QueryableBuilder.cs | 14 ++---
.../QueryableBuilding/SelectClauseBuilder.cs | 14 ++---
.../SkipTakeClauseBuilder.cs | 6 +-
.../QueryableBuilding/WhereClauseBuilder.cs | 8 +--
.../Queries/Internal/SparseFieldSetCache.cs | 10 ++--
src/JsonApiDotNetCore/Queries/QueryLayer.cs | 2 +-
.../FilterQueryStringParameterReader.cs | 6 +-
.../IncludeQueryStringParameterReader.cs | 4 +-
.../Internal/LegacyFilterNotationConverter.cs | 6 +-
.../PaginationQueryStringParameterReader.cs | 4 +-
.../Internal/QueryStringParameterReader.cs | 4 +-
.../Internal/QueryStringReader.cs | 8 +--
.../Internal/RequestQueryStringAccessor.cs | 2 +-
...ourceDefinitionQueryableParameterReader.cs | 4 +-
.../SortQueryStringParameterReader.cs | 4 +-
...parseFieldSetQueryStringParameterReader.cs | 4 +-
.../Repositories/DbContextExtensions.cs | 10 ++--
.../Repositories/DbContextResolver.cs | 2 +-
.../EntityFrameworkCoreRepository.cs | 36 ++++++------
.../ResourceRepositoryAccessor.cs | 8 +--
.../Resources/AbstractResourceWrapper.cs | 2 +-
.../Resources/IdentifiableExtensions.cs | 4 +-
.../Resources/JsonApiResourceDefinition.cs | 4 +-
.../Resources/OperationContainer.cs | 8 +--
.../Resources/ResourceChangeTracker.cs | 10 ++--
.../Resources/ResourceDefinitionAccessor.cs | 50 ++++++++---------
.../Resources/ResourceFactory.cs | 6 +-
.../SortExpressionLambdaConverter.cs | 4 +-
.../JsonConverters/ResourceObjectConverter.cs | 2 +-
.../Adapters/AtomicOperationObjectAdapter.cs | 8 +--
.../Adapters/AtomicReferenceAdapter.cs | 6 +-
.../Request/Adapters/AtomicReferenceResult.cs | 4 +-
.../Request/Adapters/DocumentAdapter.cs | 10 ++--
.../DocumentInOperationsRequestAdapter.cs | 6 +-
...tInResourceOrRelationshipRequestAdapter.cs | 6 +-
.../Adapters/RelationshipDataAdapter.cs | 6 +-
.../Adapters/RequestAdapterPosition.cs | 2 +-
.../Request/Adapters/RequestAdapterState.cs | 4 +-
.../Request/Adapters/ResourceDataAdapter.cs | 8 +--
.../ResourceIdentifierObjectAdapter.cs | 6 +-
.../Adapters/ResourceIdentityAdapter.cs | 10 ++--
.../Request/Adapters/ResourceObjectAdapter.cs | 10 ++--
.../Serialization/Request/JsonApiReader.cs | 8 +--
.../Request/JsonInvalidAttributeInfo.cs | 4 +-
.../Request/ModelConversionException.cs | 2 +-
.../Serialization/Response/ETagGenerator.cs | 2 +-
.../Response/FingerprintGenerator.cs | 2 +-
.../Serialization/Response/JsonApiWriter.cs | 14 ++---
.../Serialization/Response/LinkBuilder.cs | 18 +++---
.../Serialization/Response/MetaBuilder.cs | 8 +--
.../Response/ResourceObjectTreeNode.cs | 14 ++---
.../Response/ResponseModelAdapter.cs | 16 +++---
.../Services/AsyncCollectionExtensions.cs | 6 +-
.../Services/JsonApiResourceService.cs | 32 +++++------
.../MusicTrackReleaseDefinition.cs | 2 +-
.../EagerLoading/BuildingDefinition.cs | 2 +-
.../HitCountingResourceDefinition.cs | 2 +-
.../InjectionDbContext.cs | 2 +-
.../InjectionFakers.cs | 2 +-
.../ResourceTypeCapturingDefinition.cs | 4 +-
.../WheelSortDefinition.cs | 2 +-
.../DependencyContainerRegistrationTests.cs | 6 +-
.../ServiceCollectionExtensions.cs | 2 +-
.../ResourceConstructionExpressionTests.cs | 2 +-
159 files changed, 529 insertions(+), 528 deletions(-)
diff --git a/JsonApiDotNetCore.sln.DotSettings b/JsonApiDotNetCore.sln.DotSettings
index a40e86f270..1ffdf4a909 100644
--- a/JsonApiDotNetCore.sln.DotSettings
+++ b/JsonApiDotNetCore.sln.DotSettings
@@ -600,12 +600,12 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$, $NAME$);
CSHARP
False
Replace argument null check with Guard clause
- JsonApiDotNetCore.ArgumentGuard.NotNull($argument$, nameof($argument$));
+ JsonApiDotNetCore.ArgumentGuard.NotNull($argument$);
$left$ = $right$;
$left$ = $right$ ?? throw new ArgumentNullException(nameof($argument$));
WARNING
True
- Replace classic argument null check with Guard clause
+ Replace argument == null check with Guard clause
True
True
False
@@ -615,7 +615,7 @@ $left$ = $right$;
CSHARP
False
Replace argument null check with Guard clause
- JsonApiDotNetCore.ArgumentGuard.NotNull($argument$, nameof($argument$));
+ JsonApiDotNetCore.ArgumentGuard.NotNull($argument$);
if ($argument$ == null) throw new ArgumentNullException(nameof($argument$));
WARNING
True
@@ -631,6 +631,19 @@ $left$ = $right$;
$collection$.IsNullOrEmpty()
$collection$ == null || !$collection$.Any()
WARNING
+ True
+ Replace argument is null check with Guard clause
+ True
+ True
+ False
+
+ IdentifierPlaceholder
+ True
+ CSHARP
+ False
+ JsonApiDotNetCore.ArgumentGuard.NotNull($argument$);
+ if ($argument$ is null) throw new ArgumentNullException(nameof($argument$));
+ WARNING
True
True
True
diff --git a/src/JsonApiDotNetCore.Annotations/ArgumentGuard.cs b/src/JsonApiDotNetCore.Annotations/ArgumentGuard.cs
index be336e56a0..e0c786a106 100644
--- a/src/JsonApiDotNetCore.Annotations/ArgumentGuard.cs
+++ b/src/JsonApiDotNetCore.Annotations/ArgumentGuard.cs
@@ -1,52 +1,40 @@
+using System.Runtime.CompilerServices;
using JetBrains.Annotations;
using SysNotNull = System.Diagnostics.CodeAnalysis.NotNullAttribute;
#pragma warning disable AV1008 // Class should not be static
+#pragma warning disable AV1553 // Do not use optional parameters with default value null for strings, collections or tasks
namespace JsonApiDotNetCore;
internal static class ArgumentGuard
{
[AssertionMethod]
- public static void NotNull([NoEnumeration] [SysNotNull] T? value, [InvokerParameterName] string name)
+ public static void NotNull([NoEnumeration] [SysNotNull] T? value, [CallerArgumentExpression("value")] string? parameterName = null)
where T : class
{
- if (value is null)
- {
- throw new ArgumentNullException(name);
- }
- }
-
- [AssertionMethod]
- public static void NotNullNorEmpty([SysNotNull] IEnumerable? value, [InvokerParameterName] string name)
- {
- NotNull(value, name);
-
- if (!value.Any())
- {
- throw new ArgumentException($"Must have one or more {name}.", name);
- }
+ ArgumentNullException.ThrowIfNull(value, parameterName);
}
[AssertionMethod]
- public static void NotNullNorEmpty([SysNotNull] IEnumerable? value, [InvokerParameterName] string name, string collectionName)
+ public static void NotNullNorEmpty([SysNotNull] IEnumerable? value, [CallerArgumentExpression("value")] string? parameterName = null)
{
- NotNull(value, name);
+ ArgumentNullException.ThrowIfNull(value, parameterName);
if (!value.Any())
{
- throw new ArgumentException($"Must have one or more {collectionName}.", name);
+ throw new ArgumentException("Collection cannot be null or empty.", parameterName);
}
}
[AssertionMethod]
- public static void NotNullNorEmpty([SysNotNull] string? value, [InvokerParameterName] string name)
+ public static void NotNullNorEmpty([SysNotNull] string? value, [CallerArgumentExpression("value")] string? parameterName = null)
{
- NotNull(value, name);
+ ArgumentNullException.ThrowIfNull(value, parameterName);
if (value == string.Empty)
{
- throw new ArgumentException("String cannot be null or empty.", name);
+ throw new ArgumentException("String cannot be null or empty.", parameterName);
}
}
}
diff --git a/src/JsonApiDotNetCore.Annotations/CollectionConverter.cs b/src/JsonApiDotNetCore.Annotations/CollectionConverter.cs
index a308607c3b..fa1c0c90bd 100644
--- a/src/JsonApiDotNetCore.Annotations/CollectionConverter.cs
+++ b/src/JsonApiDotNetCore.Annotations/CollectionConverter.cs
@@ -26,8 +26,8 @@ internal sealed class CollectionConverter
///
public IEnumerable CopyToTypedCollection(IEnumerable source, Type collectionType)
{
- ArgumentGuard.NotNull(source, nameof(source));
- ArgumentGuard.NotNull(collectionType, nameof(collectionType));
+ ArgumentGuard.NotNull(source);
+ ArgumentGuard.NotNull(collectionType);
Type concreteCollectionType = ToConcreteCollectionType(collectionType);
dynamic concreteCollectionInstance = Activator.CreateInstance(concreteCollectionType)!;
@@ -121,7 +121,7 @@ public IReadOnlyCollection ExtractResources(object? value)
///
public bool TypeCanContainHashSet(Type collectionType)
{
- ArgumentGuard.NotNull(collectionType, nameof(collectionType));
+ ArgumentGuard.NotNull(collectionType);
if (collectionType.IsGenericType)
{
diff --git a/src/JsonApiDotNetCore.Annotations/Configuration/ResourceType.cs b/src/JsonApiDotNetCore.Annotations/Configuration/ResourceType.cs
index 515dfe8a63..0263958b00 100644
--- a/src/JsonApiDotNetCore.Annotations/Configuration/ResourceType.cs
+++ b/src/JsonApiDotNetCore.Annotations/Configuration/ResourceType.cs
@@ -100,9 +100,9 @@ public ResourceType(string publicName, Type clrType, Type identityClrType, IRead
LinkTypes topLevelLinks = LinkTypes.NotConfigured, LinkTypes resourceLinks = LinkTypes.NotConfigured,
LinkTypes relationshipLinks = LinkTypes.NotConfigured)
{
- ArgumentGuard.NotNullNorEmpty(publicName, nameof(publicName));
- ArgumentGuard.NotNull(clrType, nameof(clrType));
- ArgumentGuard.NotNull(identityClrType, nameof(identityClrType));
+ ArgumentGuard.NotNullNorEmpty(publicName);
+ ArgumentGuard.NotNull(clrType);
+ ArgumentGuard.NotNull(identityClrType);
PublicName = publicName;
ClrType = clrType;
@@ -153,7 +153,7 @@ public AttrAttribute GetAttributeByPublicName(string publicName)
public AttrAttribute? FindAttributeByPublicName(string publicName)
{
- ArgumentGuard.NotNull(publicName, nameof(publicName));
+ ArgumentGuard.NotNull(publicName);
return _fieldsByPublicName.TryGetValue(publicName, out ResourceFieldAttribute? field) && field is AttrAttribute attribute ? attribute : null;
}
@@ -167,7 +167,7 @@ public AttrAttribute GetAttributeByPropertyName(string propertyName)
public AttrAttribute? FindAttributeByPropertyName(string propertyName)
{
- ArgumentGuard.NotNull(propertyName, nameof(propertyName));
+ ArgumentGuard.NotNull(propertyName);
return _fieldsByPropertyName.TryGetValue(propertyName, out ResourceFieldAttribute? field) && field is AttrAttribute attribute ? attribute : null;
}
@@ -180,7 +180,7 @@ public RelationshipAttribute GetRelationshipByPublicName(string publicName)
public RelationshipAttribute? FindRelationshipByPublicName(string publicName)
{
- ArgumentGuard.NotNull(publicName, nameof(publicName));
+ ArgumentGuard.NotNull(publicName);
return _fieldsByPublicName.TryGetValue(publicName, out ResourceFieldAttribute? field) && field is RelationshipAttribute relationship
? relationship
@@ -197,7 +197,7 @@ public RelationshipAttribute GetRelationshipByPropertyName(string propertyName)
public RelationshipAttribute? FindRelationshipByPropertyName(string propertyName)
{
- ArgumentGuard.NotNull(propertyName, nameof(propertyName));
+ ArgumentGuard.NotNull(propertyName);
return _fieldsByPropertyName.TryGetValue(propertyName, out ResourceFieldAttribute? field) && field is RelationshipAttribute relationship
? relationship
@@ -217,7 +217,7 @@ public IReadOnlySet GetAllConcreteDerivedTypes()
///
public ResourceType GetTypeOrDerived(Type clrType)
{
- ArgumentGuard.NotNull(clrType, nameof(clrType));
+ ArgumentGuard.NotNull(clrType);
ResourceType? derivedType = FindTypeOrDerived(this, clrType);
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/RelationshipAttribute.cs b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/RelationshipAttribute.cs
index 11320a7abc..c1b24e9567 100644
--- a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/RelationshipAttribute.cs
+++ b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/RelationshipAttribute.cs
@@ -57,7 +57,7 @@ public ResourceType RightType
get => _rightType!;
internal set
{
- ArgumentGuard.NotNull(value, nameof(value));
+ ArgumentGuard.NotNull(value);
_rightType = value;
}
}
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceFieldAttribute.cs b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceFieldAttribute.cs
index 599b17a42a..9f32610dc9 100644
--- a/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceFieldAttribute.cs
+++ b/src/JsonApiDotNetCore.Annotations/Resources/Annotations/ResourceFieldAttribute.cs
@@ -43,7 +43,7 @@ public PropertyInfo Property
get => _property!;
internal set
{
- ArgumentGuard.NotNull(value, nameof(value));
+ ArgumentGuard.NotNull(value);
_property = value;
}
}
@@ -56,7 +56,7 @@ public ResourceType Type
get => _type!;
internal set
{
- ArgumentGuard.NotNull(value, nameof(value));
+ ArgumentGuard.NotNull(value);
_type = value;
}
}
@@ -67,7 +67,7 @@ internal set
///
public object? GetValue(object resource)
{
- ArgumentGuard.NotNull(resource, nameof(resource));
+ ArgumentGuard.NotNull(resource);
if (Property.GetMethod == null)
{
@@ -92,7 +92,7 @@ internal set
///
public void SetValue(object resource, object? newValue)
{
- ArgumentGuard.NotNull(resource, nameof(resource));
+ ArgumentGuard.NotNull(resource);
if (Property.SetMethod == null)
{
diff --git a/src/JsonApiDotNetCore.Annotations/Resources/Internal/RuntimeTypeConverter.cs b/src/JsonApiDotNetCore.Annotations/Resources/Internal/RuntimeTypeConverter.cs
index 8722458938..d79ed4c635 100644
--- a/src/JsonApiDotNetCore.Annotations/Resources/Internal/RuntimeTypeConverter.cs
+++ b/src/JsonApiDotNetCore.Annotations/Resources/Internal/RuntimeTypeConverter.cs
@@ -10,7 +10,7 @@ public static class RuntimeTypeConverter
{
public static object? ConvertType(object? value, Type type)
{
- ArgumentGuard.NotNull(type, nameof(type));
+ ArgumentGuard.NotNull(type);
if (value == null)
{
diff --git a/src/JsonApiDotNetCore.Annotations/TypeExtensions.cs b/src/JsonApiDotNetCore.Annotations/TypeExtensions.cs
index c28ea84332..b31f82d48e 100644
--- a/src/JsonApiDotNetCore.Annotations/TypeExtensions.cs
+++ b/src/JsonApiDotNetCore.Annotations/TypeExtensions.cs
@@ -15,7 +15,7 @@ public static bool IsOrImplementsInterface(this Type? source)
///
private static bool IsOrImplementsInterface(this Type? source, Type interfaceType)
{
- ArgumentGuard.NotNull(interfaceType, nameof(interfaceType));
+ ArgumentGuard.NotNull(interfaceType);
if (source == null)
{
@@ -41,7 +41,7 @@ private static bool AreTypesEqual(Type left, Type right, bool isLeftGeneric)
///
public static string GetFriendlyTypeName(this Type type)
{
- ArgumentGuard.NotNull(type, nameof(type));
+ ArgumentGuard.NotNull(type);
// Based on https://stackoverflow.com/questions/2581642/how-do-i-get-the-type-name-of-a-generic-type-argument.
diff --git a/src/JsonApiDotNetCore/AtomicOperations/EntityFrameworkCoreTransaction.cs b/src/JsonApiDotNetCore/AtomicOperations/EntityFrameworkCoreTransaction.cs
index be5125c414..f59f86162d 100644
--- a/src/JsonApiDotNetCore/AtomicOperations/EntityFrameworkCoreTransaction.cs
+++ b/src/JsonApiDotNetCore/AtomicOperations/EntityFrameworkCoreTransaction.cs
@@ -19,8 +19,8 @@ public sealed class EntityFrameworkCoreTransaction : IOperationsTransaction
public EntityFrameworkCoreTransaction(IDbContextTransaction transaction, DbContext dbContext)
{
- ArgumentGuard.NotNull(transaction, nameof(transaction));
- ArgumentGuard.NotNull(dbContext, nameof(dbContext));
+ ArgumentGuard.NotNull(transaction);
+ ArgumentGuard.NotNull(dbContext);
_transaction = transaction;
_dbContext = dbContext;
diff --git a/src/JsonApiDotNetCore/AtomicOperations/EntityFrameworkCoreTransactionFactory.cs b/src/JsonApiDotNetCore/AtomicOperations/EntityFrameworkCoreTransactionFactory.cs
index 96c66e12ab..8ef44cb627 100644
--- a/src/JsonApiDotNetCore/AtomicOperations/EntityFrameworkCoreTransactionFactory.cs
+++ b/src/JsonApiDotNetCore/AtomicOperations/EntityFrameworkCoreTransactionFactory.cs
@@ -15,8 +15,8 @@ public sealed class EntityFrameworkCoreTransactionFactory : IOperationsTransacti
public EntityFrameworkCoreTransactionFactory(IDbContextResolver dbContextResolver, IJsonApiOptions options)
{
- ArgumentGuard.NotNull(dbContextResolver, nameof(dbContextResolver));
- ArgumentGuard.NotNull(options, nameof(options));
+ ArgumentGuard.NotNull(dbContextResolver);
+ ArgumentGuard.NotNull(options);
_dbContextResolver = dbContextResolver;
_options = options;
diff --git a/src/JsonApiDotNetCore/AtomicOperations/LocalIdTracker.cs b/src/JsonApiDotNetCore/AtomicOperations/LocalIdTracker.cs
index b0a1b3ee2f..2def7bfecc 100644
--- a/src/JsonApiDotNetCore/AtomicOperations/LocalIdTracker.cs
+++ b/src/JsonApiDotNetCore/AtomicOperations/LocalIdTracker.cs
@@ -17,8 +17,8 @@ public void Reset()
///
public void Declare(string localId, ResourceType resourceType)
{
- ArgumentGuard.NotNullNorEmpty(localId, nameof(localId));
- ArgumentGuard.NotNull(resourceType, nameof(resourceType));
+ ArgumentGuard.NotNullNorEmpty(localId);
+ ArgumentGuard.NotNull(resourceType);
AssertIsNotDeclared(localId);
@@ -36,9 +36,9 @@ private void AssertIsNotDeclared(string localId)
///
public void Assign(string localId, ResourceType resourceType, string stringId)
{
- ArgumentGuard.NotNullNorEmpty(localId, nameof(localId));
- ArgumentGuard.NotNull(resourceType, nameof(resourceType));
- ArgumentGuard.NotNullNorEmpty(stringId, nameof(stringId));
+ ArgumentGuard.NotNullNorEmpty(localId);
+ ArgumentGuard.NotNull(resourceType);
+ ArgumentGuard.NotNullNorEmpty(stringId);
AssertIsDeclared(localId);
@@ -57,8 +57,8 @@ public void Assign(string localId, ResourceType resourceType, string stringId)
///
public string GetValue(string localId, ResourceType resourceType)
{
- ArgumentGuard.NotNullNorEmpty(localId, nameof(localId));
- ArgumentGuard.NotNull(resourceType, nameof(resourceType));
+ ArgumentGuard.NotNullNorEmpty(localId);
+ ArgumentGuard.NotNull(resourceType);
AssertIsDeclared(localId);
diff --git a/src/JsonApiDotNetCore/AtomicOperations/LocalIdValidator.cs b/src/JsonApiDotNetCore/AtomicOperations/LocalIdValidator.cs
index 9cb463ab10..fb75fe3c7f 100644
--- a/src/JsonApiDotNetCore/AtomicOperations/LocalIdValidator.cs
+++ b/src/JsonApiDotNetCore/AtomicOperations/LocalIdValidator.cs
@@ -18,8 +18,8 @@ public sealed class LocalIdValidator
public LocalIdValidator(ILocalIdTracker localIdTracker, IResourceGraph resourceGraph)
{
- ArgumentGuard.NotNull(localIdTracker, nameof(localIdTracker));
- ArgumentGuard.NotNull(resourceGraph, nameof(resourceGraph));
+ ArgumentGuard.NotNull(localIdTracker);
+ ArgumentGuard.NotNull(resourceGraph);
_localIdTracker = localIdTracker;
_resourceGraph = resourceGraph;
@@ -27,7 +27,7 @@ public LocalIdValidator(ILocalIdTracker localIdTracker, IResourceGraph resourceG
public void Validate(IEnumerable operations)
{
- ArgumentGuard.NotNull(operations, nameof(operations));
+ ArgumentGuard.NotNull(operations);
_localIdTracker.Reset();
diff --git a/src/JsonApiDotNetCore/AtomicOperations/OperationProcessorAccessor.cs b/src/JsonApiDotNetCore/AtomicOperations/OperationProcessorAccessor.cs
index c032f78f8d..c2397267b3 100644
--- a/src/JsonApiDotNetCore/AtomicOperations/OperationProcessorAccessor.cs
+++ b/src/JsonApiDotNetCore/AtomicOperations/OperationProcessorAccessor.cs
@@ -15,7 +15,7 @@ public class OperationProcessorAccessor : IOperationProcessorAccessor
public OperationProcessorAccessor(IServiceProvider serviceProvider)
{
- ArgumentGuard.NotNull(serviceProvider, nameof(serviceProvider));
+ ArgumentGuard.NotNull(serviceProvider);
_serviceProvider = serviceProvider;
}
@@ -23,7 +23,7 @@ public OperationProcessorAccessor(IServiceProvider serviceProvider)
///
public Task ProcessAsync(OperationContainer operation, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(operation, nameof(operation));
+ ArgumentGuard.NotNull(operation);
IOperationProcessor processor = ResolveProcessor(operation);
return processor.ProcessAsync(operation, cancellationToken);
diff --git a/src/JsonApiDotNetCore/AtomicOperations/OperationsProcessor.cs b/src/JsonApiDotNetCore/AtomicOperations/OperationsProcessor.cs
index 6524252abf..6ecdfd6077 100644
--- a/src/JsonApiDotNetCore/AtomicOperations/OperationsProcessor.cs
+++ b/src/JsonApiDotNetCore/AtomicOperations/OperationsProcessor.cs
@@ -25,13 +25,13 @@ public OperationsProcessor(IOperationProcessorAccessor operationProcessorAccesso
ILocalIdTracker localIdTracker, IResourceGraph resourceGraph, IJsonApiRequest request, ITargetedFields targetedFields,
ISparseFieldSetCache sparseFieldSetCache)
{
- ArgumentGuard.NotNull(operationProcessorAccessor, nameof(operationProcessorAccessor));
- ArgumentGuard.NotNull(operationsTransactionFactory, nameof(operationsTransactionFactory));
- ArgumentGuard.NotNull(localIdTracker, nameof(localIdTracker));
- ArgumentGuard.NotNull(resourceGraph, nameof(resourceGraph));
- ArgumentGuard.NotNull(request, nameof(request));
- ArgumentGuard.NotNull(targetedFields, nameof(targetedFields));
- ArgumentGuard.NotNull(sparseFieldSetCache, nameof(sparseFieldSetCache));
+ ArgumentGuard.NotNull(operationProcessorAccessor);
+ ArgumentGuard.NotNull(operationsTransactionFactory);
+ ArgumentGuard.NotNull(localIdTracker);
+ ArgumentGuard.NotNull(resourceGraph);
+ ArgumentGuard.NotNull(request);
+ ArgumentGuard.NotNull(targetedFields);
+ ArgumentGuard.NotNull(sparseFieldSetCache);
_operationProcessorAccessor = operationProcessorAccessor;
_operationsTransactionFactory = operationsTransactionFactory;
@@ -46,7 +46,7 @@ public OperationsProcessor(IOperationProcessorAccessor operationProcessorAccesso
///
public virtual async Task> ProcessAsync(IList operations, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(operations, nameof(operations));
+ ArgumentGuard.NotNull(operations);
_localIdValidator.Validate(operations);
_localIdTracker.Reset();
diff --git a/src/JsonApiDotNetCore/AtomicOperations/Processors/AddToRelationshipProcessor.cs b/src/JsonApiDotNetCore/AtomicOperations/Processors/AddToRelationshipProcessor.cs
index fc16847eec..c8997be8cd 100644
--- a/src/JsonApiDotNetCore/AtomicOperations/Processors/AddToRelationshipProcessor.cs
+++ b/src/JsonApiDotNetCore/AtomicOperations/Processors/AddToRelationshipProcessor.cs
@@ -13,7 +13,7 @@ public class AddToRelationshipProcessor : IAddToRelationshipProc
public AddToRelationshipProcessor(IAddToRelationshipService service)
{
- ArgumentGuard.NotNull(service, nameof(service));
+ ArgumentGuard.NotNull(service);
_service = service;
}
@@ -21,7 +21,7 @@ public AddToRelationshipProcessor(IAddToRelationshipService serv
///
public virtual async Task ProcessAsync(OperationContainer operation, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(operation, nameof(operation));
+ ArgumentGuard.NotNull(operation);
var leftId = (TId)operation.Resource.GetTypedId();
ISet rightResourceIds = operation.GetSecondaryResources();
diff --git a/src/JsonApiDotNetCore/AtomicOperations/Processors/CreateProcessor.cs b/src/JsonApiDotNetCore/AtomicOperations/Processors/CreateProcessor.cs
index b06ebd626e..e105f54a50 100644
--- a/src/JsonApiDotNetCore/AtomicOperations/Processors/CreateProcessor.cs
+++ b/src/JsonApiDotNetCore/AtomicOperations/Processors/CreateProcessor.cs
@@ -14,8 +14,8 @@ public class CreateProcessor : ICreateProcessor
public CreateProcessor(ICreateService service, ILocalIdTracker localIdTracker)
{
- ArgumentGuard.NotNull(service, nameof(service));
- ArgumentGuard.NotNull(localIdTracker, nameof(localIdTracker));
+ ArgumentGuard.NotNull(service);
+ ArgumentGuard.NotNull(localIdTracker);
_service = service;
_localIdTracker = localIdTracker;
@@ -24,7 +24,7 @@ public CreateProcessor(ICreateService service, ILocalIdTracker l
///
public virtual async Task ProcessAsync(OperationContainer operation, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(operation, nameof(operation));
+ ArgumentGuard.NotNull(operation);
TResource? newResource = await _service.CreateAsync((TResource)operation.Resource, cancellationToken);
diff --git a/src/JsonApiDotNetCore/AtomicOperations/Processors/DeleteProcessor.cs b/src/JsonApiDotNetCore/AtomicOperations/Processors/DeleteProcessor.cs
index e4001b75c1..356742f9b7 100644
--- a/src/JsonApiDotNetCore/AtomicOperations/Processors/DeleteProcessor.cs
+++ b/src/JsonApiDotNetCore/AtomicOperations/Processors/DeleteProcessor.cs
@@ -13,7 +13,7 @@ public class DeleteProcessor : IDeleteProcessor
public DeleteProcessor(IDeleteService service)
{
- ArgumentGuard.NotNull(service, nameof(service));
+ ArgumentGuard.NotNull(service);
_service = service;
}
@@ -21,7 +21,7 @@ public DeleteProcessor(IDeleteService service)
///
public virtual async Task ProcessAsync(OperationContainer operation, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(operation, nameof(operation));
+ ArgumentGuard.NotNull(operation);
var id = (TId)operation.Resource.GetTypedId();
await _service.DeleteAsync(id, cancellationToken);
diff --git a/src/JsonApiDotNetCore/AtomicOperations/Processors/RemoveFromRelationshipProcessor.cs b/src/JsonApiDotNetCore/AtomicOperations/Processors/RemoveFromRelationshipProcessor.cs
index 493ed2066f..b308d6935a 100644
--- a/src/JsonApiDotNetCore/AtomicOperations/Processors/RemoveFromRelationshipProcessor.cs
+++ b/src/JsonApiDotNetCore/AtomicOperations/Processors/RemoveFromRelationshipProcessor.cs
@@ -13,7 +13,7 @@ public class RemoveFromRelationshipProcessor : IRemoveFromRelati
public RemoveFromRelationshipProcessor(IRemoveFromRelationshipService service)
{
- ArgumentGuard.NotNull(service, nameof(service));
+ ArgumentGuard.NotNull(service);
_service = service;
}
@@ -21,7 +21,7 @@ public RemoveFromRelationshipProcessor(IRemoveFromRelationshipService
public virtual async Task ProcessAsync(OperationContainer operation, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(operation, nameof(operation));
+ ArgumentGuard.NotNull(operation);
var leftId = (TId)operation.Resource.GetTypedId();
ISet rightResourceIds = operation.GetSecondaryResources();
diff --git a/src/JsonApiDotNetCore/AtomicOperations/Processors/SetRelationshipProcessor.cs b/src/JsonApiDotNetCore/AtomicOperations/Processors/SetRelationshipProcessor.cs
index 5eb09ccbc3..083bd0d0fc 100644
--- a/src/JsonApiDotNetCore/AtomicOperations/Processors/SetRelationshipProcessor.cs
+++ b/src/JsonApiDotNetCore/AtomicOperations/Processors/SetRelationshipProcessor.cs
@@ -15,7 +15,7 @@ public class SetRelationshipProcessor : ISetRelationshipProcesso
public SetRelationshipProcessor(ISetRelationshipService service)
{
- ArgumentGuard.NotNull(service, nameof(service));
+ ArgumentGuard.NotNull(service);
_service = service;
}
@@ -23,7 +23,7 @@ public SetRelationshipProcessor(ISetRelationshipService service)
///
public virtual async Task ProcessAsync(OperationContainer operation, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(operation, nameof(operation));
+ ArgumentGuard.NotNull(operation);
var leftId = (TId)operation.Resource.GetTypedId();
object? rightValue = GetRelationshipRightValue(operation);
diff --git a/src/JsonApiDotNetCore/AtomicOperations/Processors/UpdateProcessor.cs b/src/JsonApiDotNetCore/AtomicOperations/Processors/UpdateProcessor.cs
index a02ac2d3ff..5611f8d1c2 100644
--- a/src/JsonApiDotNetCore/AtomicOperations/Processors/UpdateProcessor.cs
+++ b/src/JsonApiDotNetCore/AtomicOperations/Processors/UpdateProcessor.cs
@@ -13,7 +13,7 @@ public class UpdateProcessor : IUpdateProcessor
public UpdateProcessor(IUpdateService service)
{
- ArgumentGuard.NotNull(service, nameof(service));
+ ArgumentGuard.NotNull(service);
_service = service;
}
@@ -21,7 +21,7 @@ public UpdateProcessor(IUpdateService service)
///
public virtual async Task ProcessAsync(OperationContainer operation, CancellationToken cancellationToken)
{
- ArgumentGuard.NotNull(operation, nameof(operation));
+ ArgumentGuard.NotNull(operation);
var resource = (TResource)operation.Resource;
TResource? updated = await _service.UpdateAsync(resource.Id, resource, cancellationToken);
diff --git a/src/JsonApiDotNetCore/AtomicOperations/RevertRequestStateOnDispose.cs b/src/JsonApiDotNetCore/AtomicOperations/RevertRequestStateOnDispose.cs
index 453f78f1f2..1951333d0c 100644
--- a/src/JsonApiDotNetCore/AtomicOperations/RevertRequestStateOnDispose.cs
+++ b/src/JsonApiDotNetCore/AtomicOperations/RevertRequestStateOnDispose.cs
@@ -16,7 +16,7 @@ internal sealed class RevertRequestStateOnDispose : IDisposable
public RevertRequestStateOnDispose(IJsonApiRequest request, ITargetedFields? targetedFields)
{
- ArgumentGuard.NotNull(request, nameof(request));
+ ArgumentGuard.NotNull(request);
_sourceRequest = request;
_backupRequest.CopyFrom(request);
diff --git a/src/JsonApiDotNetCore/CollectionExtensions.cs b/src/JsonApiDotNetCore/CollectionExtensions.cs
index a7f5e72ab6..133231eb23 100644
--- a/src/JsonApiDotNetCore/CollectionExtensions.cs
+++ b/src/JsonApiDotNetCore/CollectionExtensions.cs
@@ -18,8 +18,8 @@ public static bool IsNullOrEmpty([NotNullWhen(false)] this IEnumerable? so
public static int FindIndex(this IReadOnlyList source, Predicate match)
{
- ArgumentGuard.NotNull(source, nameof(source));
- ArgumentGuard.NotNull(match, nameof(match));
+ ArgumentGuard.NotNull(source);
+ ArgumentGuard.NotNull(match);
for (int index = 0; index < source.Count; index++)
{
@@ -82,8 +82,8 @@ public static IEnumerable WhereNotNull(this IEnumerable source)
public static void AddRange(this ICollection source, IEnumerable itemsToAdd)
{
- ArgumentGuard.NotNull(source, nameof(source));
- ArgumentGuard.NotNull(itemsToAdd, nameof(itemsToAdd));
+ ArgumentGuard.NotNull(source);
+ ArgumentGuard.NotNull(itemsToAdd);
foreach (T item in itemsToAdd)
{
diff --git a/src/JsonApiDotNetCore/Configuration/ApplicationBuilderExtensions.cs b/src/JsonApiDotNetCore/Configuration/ApplicationBuilderExtensions.cs
index a941e27218..8ed4e42a42 100644
--- a/src/JsonApiDotNetCore/Configuration/ApplicationBuilderExtensions.cs
+++ b/src/JsonApiDotNetCore/Configuration/ApplicationBuilderExtensions.cs
@@ -22,7 +22,7 @@ public static class ApplicationBuilderExtensions
///
public static void UseJsonApi(this IApplicationBuilder builder)
{
- ArgumentGuard.NotNull(builder, nameof(builder));
+ ArgumentGuard.NotNull(builder);
using (IServiceScope scope = builder.ApplicationServices.CreateScope())
{
diff --git a/src/JsonApiDotNetCore/Configuration/InverseNavigationResolver.cs b/src/JsonApiDotNetCore/Configuration/InverseNavigationResolver.cs
index 8e5f3f15a3..821be639f9 100644
--- a/src/JsonApiDotNetCore/Configuration/InverseNavigationResolver.cs
+++ b/src/JsonApiDotNetCore/Configuration/InverseNavigationResolver.cs
@@ -15,8 +15,8 @@ public sealed class InverseNavigationResolver : IInverseNavigationResolver
public InverseNavigationResolver(IResourceGraph resourceGraph, IEnumerable dbContextResolvers)
{
- ArgumentGuard.NotNull(resourceGraph, nameof(resourceGraph));
- ArgumentGuard.NotNull(dbContextResolvers, nameof(dbContextResolvers));
+ ArgumentGuard.NotNull(resourceGraph);
+ ArgumentGuard.NotNull(dbContextResolvers);
_resourceGraph = resourceGraph;
_dbContextResolvers = dbContextResolvers;
diff --git a/src/JsonApiDotNetCore/Configuration/JsonApiApplicationBuilder.cs b/src/JsonApiDotNetCore/Configuration/JsonApiApplicationBuilder.cs
index 7cd4307ad1..82e0ff52e1 100644
--- a/src/JsonApiDotNetCore/Configuration/JsonApiApplicationBuilder.cs
+++ b/src/JsonApiDotNetCore/Configuration/JsonApiApplicationBuilder.cs
@@ -39,8 +39,8 @@ internal sealed class JsonApiApplicationBuilder : IJsonApiApplicationBuilder, ID
public JsonApiApplicationBuilder(IServiceCollection services, IMvcCoreBuilder mvcBuilder)
{
- ArgumentGuard.NotNull(services, nameof(services));
- ArgumentGuard.NotNull(mvcBuilder, nameof(mvcBuilder));
+ ArgumentGuard.NotNull(services);
+ ArgumentGuard.NotNull(mvcBuilder);
_services = services;
_mvcBuilder = mvcBuilder;
@@ -73,7 +73,7 @@ public void ConfigureAutoDiscovery(Action? configureAuto
///
public void ConfigureResourceGraph(ICollection dbContextTypes, Action? configureResourceGraph)
{
- ArgumentGuard.NotNull(dbContextTypes, nameof(dbContextTypes));
+ ArgumentGuard.NotNull(dbContextTypes);
_serviceDiscoveryFacade.DiscoverResources();
@@ -126,7 +126,7 @@ public void DiscoverInjectables()
///
public void ConfigureServiceContainer(ICollection dbContextTypes)
{
- ArgumentGuard.NotNull(dbContextTypes, nameof(dbContextTypes));
+ ArgumentGuard.NotNull(dbContextTypes);
if (dbContextTypes.Any())
{
diff --git a/src/JsonApiDotNetCore/Configuration/JsonApiValidationFilter.cs b/src/JsonApiDotNetCore/Configuration/JsonApiValidationFilter.cs
index 6b193bdc6f..a27acf8ebd 100644
--- a/src/JsonApiDotNetCore/Configuration/JsonApiValidationFilter.cs
+++ b/src/JsonApiDotNetCore/Configuration/JsonApiValidationFilter.cs
@@ -15,7 +15,7 @@ internal sealed class JsonApiValidationFilter : IPropertyValidationFilter
public JsonApiValidationFilter(IHttpContextAccessor httpContextAccessor)
{
- ArgumentGuard.NotNull(httpContextAccessor, nameof(httpContextAccessor));
+ ArgumentGuard.NotNull(httpContextAccessor);
_httpContextAccessor = httpContextAccessor;
}
diff --git a/src/JsonApiDotNetCore/Configuration/ResourceDescriptor.cs b/src/JsonApiDotNetCore/Configuration/ResourceDescriptor.cs
index 8747cdd18f..885f67567c 100644
--- a/src/JsonApiDotNetCore/Configuration/ResourceDescriptor.cs
+++ b/src/JsonApiDotNetCore/Configuration/ResourceDescriptor.cs
@@ -7,8 +7,8 @@ internal sealed class ResourceDescriptor
public ResourceDescriptor(Type resourceClrType, Type idClrType)
{
- ArgumentGuard.NotNull(resourceClrType, nameof(resourceClrType));
- ArgumentGuard.NotNull(idClrType, nameof(idClrType));
+ ArgumentGuard.NotNull(resourceClrType);
+ ArgumentGuard.NotNull(idClrType);
ResourceClrType = resourceClrType;
IdClrType = idClrType;
diff --git a/src/JsonApiDotNetCore/Configuration/ResourceGraph.cs b/src/JsonApiDotNetCore/Configuration/ResourceGraph.cs
index d693fa2c3c..0dbaeb9623 100644
--- a/src/JsonApiDotNetCore/Configuration/ResourceGraph.cs
+++ b/src/JsonApiDotNetCore/Configuration/ResourceGraph.cs
@@ -18,7 +18,7 @@ public sealed class ResourceGraph : IResourceGraph
public ResourceGraph(IReadOnlySet resourceTypeSet)
{
- ArgumentGuard.NotNull(resourceTypeSet, nameof(resourceTypeSet));
+ ArgumentGuard.NotNull(resourceTypeSet);
_resourceTypeSet = resourceTypeSet;
@@ -51,7 +51,7 @@ public ResourceType GetResourceType(string publicName)
///
public ResourceType? FindResourceType(string publicName)
{
- ArgumentGuard.NotNull(publicName, nameof(publicName));
+ ArgumentGuard.NotNull(publicName);
return _resourceTypesByPublicName.TryGetValue(publicName, out ResourceType? resourceType) ? resourceType : null;
}
@@ -72,7 +72,7 @@ public ResourceType GetResourceType(Type resourceClrType)
///
public ResourceType? FindResourceType(Type resourceClrType)
{
- ArgumentGuard.NotNull(resourceClrType, nameof(resourceClrType));
+ ArgumentGuard.NotNull(resourceClrType);
Type typeToFind = IsLazyLoadingProxyForResourceType(resourceClrType) ? resourceClrType.BaseType! : resourceClrType;
return _resourceTypesByClrType.TryGetValue(typeToFind, out ResourceType? resourceType) ? resourceType : null;
@@ -94,7 +94,7 @@ public ResourceType GetResourceType()
public IReadOnlyCollection GetFields(Expression> selector)
where TResource : class, IIdentifiable
{
- ArgumentGuard.NotNull(selector, nameof(selector));
+ ArgumentGuard.NotNull(selector);
return FilterFields(selector);
}
@@ -103,7 +103,7 @@ public IReadOnlyCollection GetFields(Expressi
public IReadOnlyCollection GetAttributes(Expression> selector)
where TResource : class, IIdentifiable
{
- ArgumentGuard.NotNull(selector, nameof(selector));
+ ArgumentGuard.NotNull(selector);
return FilterFields(selector);
}
@@ -112,7 +112,7 @@ public IReadOnlyCollection GetAttributes(Expression GetRelationships(Expression> selector)
where TResource : class, IIdentifiable
{
- ArgumentGuard.NotNull(selector, nameof(selector));
+ ArgumentGuard.NotNull(selector);
return FilterFields(selector);
}
diff --git a/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs b/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs
index 36eb9d37e8..2af0e63caf 100644
--- a/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs
+++ b/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs
@@ -22,8 +22,8 @@ public class ResourceGraphBuilder
public ResourceGraphBuilder(IJsonApiOptions options, ILoggerFactory loggerFactory)
{
- ArgumentGuard.NotNull(options, nameof(options));
- ArgumentGuard.NotNull(loggerFactory, nameof(loggerFactory));
+ ArgumentGuard.NotNull(options);
+ ArgumentGuard.NotNull(loggerFactory);
_options = options;
_logger = loggerFactory.CreateLogger();
@@ -144,7 +144,7 @@ private static void ValidateRelationshipsInDerivedType(ResourceType resourceType
public ResourceGraphBuilder Add(DbContext dbContext)
{
- ArgumentGuard.NotNull(dbContext, nameof(dbContext));
+ ArgumentGuard.NotNull(dbContext);
foreach (IEntityType entityType in dbContext.Model.GetEntityTypes())
{
@@ -200,7 +200,7 @@ public ResourceGraphBuilder Add(string? publicName = null)
public ResourceGraphBuilder Add(Type resourceClrType, Type? idClrType = null, string? publicName = null)
#pragma warning restore AV1553 // Do not use optional parameters with default value null for strings, collections or tasks
{
- ArgumentGuard.NotNull(resourceClrType, nameof(resourceClrType));
+ ArgumentGuard.NotNull(resourceClrType);
if (_resourceTypesByClrType.ContainsKey(resourceClrType))
{
diff --git a/src/JsonApiDotNetCore/Configuration/ResourceNameFormatter.cs b/src/JsonApiDotNetCore/Configuration/ResourceNameFormatter.cs
index 82a54ff010..a6e12951a9 100644
--- a/src/JsonApiDotNetCore/Configuration/ResourceNameFormatter.cs
+++ b/src/JsonApiDotNetCore/Configuration/ResourceNameFormatter.cs
@@ -19,7 +19,7 @@ public ResourceNameFormatter(JsonNamingPolicy? namingPolicy)
///
public string FormatResourceName(Type resourceClrType)
{
- ArgumentGuard.NotNull(resourceClrType, nameof(resourceClrType));
+ ArgumentGuard.NotNull(resourceClrType);
var resourceAttribute = resourceClrType.GetCustomAttribute(true);
diff --git a/src/JsonApiDotNetCore/Configuration/ServiceCollectionExtensions.cs b/src/JsonApiDotNetCore/Configuration/ServiceCollectionExtensions.cs
index 8b5356fdef..7ea42a2470 100644
--- a/src/JsonApiDotNetCore/Configuration/ServiceCollectionExtensions.cs
+++ b/src/JsonApiDotNetCore/Configuration/ServiceCollectionExtensions.cs
@@ -22,7 +22,7 @@ public static IServiceCollection AddJsonApi(this IServiceCollection services, Ac
ICollection? dbContextTypes = null)
#pragma warning restore AV1553 // Do not use optional parameters with default value null for strings, collections or tasks
{
- ArgumentGuard.NotNull(services, nameof(services));
+ ArgumentGuard.NotNull(services);
SetupApplicationBuilder(services, options, discovery, resources, mvcBuilder, dbContextTypes ?? Array.Empty());
@@ -59,7 +59,7 @@ private static void SetupApplicationBuilder(IServiceCollection services, Action<
///
public static IServiceCollection AddResourceService(this IServiceCollection services)
{
- ArgumentGuard.NotNull(services, nameof(services));
+ ArgumentGuard.NotNull(services);
RegisterTypeForUnboundInterfaces(services, typeof(TService), ServiceDiscoveryFacade.ServiceUnboundInterfaces);
@@ -72,7 +72,7 @@ public static IServiceCollection AddResourceService(this IServiceColle
///
public static IServiceCollection AddResourceRepository(this IServiceCollection services)
{
- ArgumentGuard.NotNull(services, nameof(services));
+ ArgumentGuard.NotNull(services);
RegisterTypeForUnboundInterfaces(services, typeof(TRepository), ServiceDiscoveryFacade.RepositoryUnboundInterfaces);
@@ -85,7 +85,7 @@ public static IServiceCollection AddResourceRepository(this IServic
///
public static IServiceCollection AddResourceDefinition(this IServiceCollection services)
{
- ArgumentGuard.NotNull(services, nameof(services));
+ ArgumentGuard.NotNull(services);
RegisterTypeForUnboundInterfaces(services, typeof(TResourceDefinition), ServiceDiscoveryFacade.ResourceDefinitionUnboundInterfaces);
diff --git a/src/JsonApiDotNetCore/Configuration/ServiceDiscoveryFacade.cs b/src/JsonApiDotNetCore/Configuration/ServiceDiscoveryFacade.cs
index 7498391afd..85f95c232f 100644
--- a/src/JsonApiDotNetCore/Configuration/ServiceDiscoveryFacade.cs
+++ b/src/JsonApiDotNetCore/Configuration/ServiceDiscoveryFacade.cs
@@ -52,9 +52,9 @@ public sealed class ServiceDiscoveryFacade
public ServiceDiscoveryFacade(IServiceCollection services, ResourceGraphBuilder resourceGraphBuilder, ILoggerFactory loggerFactory)
{
- ArgumentGuard.NotNull(services, nameof(services));
- ArgumentGuard.NotNull(resourceGraphBuilder, nameof(resourceGraphBuilder));
- ArgumentGuard.NotNull(loggerFactory, nameof(loggerFactory));
+ ArgumentGuard.NotNull(services);
+ ArgumentGuard.NotNull(resourceGraphBuilder);
+ ArgumentGuard.NotNull(loggerFactory);
_logger = loggerFactory.CreateLogger();
_services = services;
@@ -74,7 +74,7 @@ public ServiceDiscoveryFacade AddCurrentAssembly()
///
public ServiceDiscoveryFacade AddAssembly(Assembly assembly)
{
- ArgumentGuard.NotNull(assembly, nameof(assembly));
+ ArgumentGuard.NotNull(assembly);
_assemblyCache.RegisterAssembly(assembly);
_logger.LogDebug($"Registering assembly '{assembly.FullName}' for discovery of resources and injectables.");
diff --git a/src/JsonApiDotNetCore/Configuration/TypeLocator.cs b/src/JsonApiDotNetCore/Configuration/TypeLocator.cs
index 2f004ffdf1..e4b1da8d01 100644
--- a/src/JsonApiDotNetCore/Configuration/TypeLocator.cs
+++ b/src/JsonApiDotNetCore/Configuration/TypeLocator.cs
@@ -66,9 +66,9 @@ internal sealed class TypeLocator
public (Type implementationType, Type serviceInterface)? GetContainerRegistrationFromAssembly(Assembly assembly, Type unboundInterface,
params Type[] interfaceTypeArguments)
{
- ArgumentGuard.NotNull(assembly, nameof(assembly));
- ArgumentGuard.NotNull(unboundInterface, nameof(unboundInterface));
- ArgumentGuard.NotNull(interfaceTypeArguments, nameof(interfaceTypeArguments));
+ ArgumentGuard.NotNull(assembly);
+ ArgumentGuard.NotNull(unboundInterface);
+ ArgumentGuard.NotNull(interfaceTypeArguments);
if (!unboundInterface.IsInterface || !unboundInterface.IsGenericType || unboundInterface != unboundInterface.GetGenericTypeDefinition())
{
@@ -129,9 +129,9 @@ private static (Type implementationType, Type serviceInterface)? GetContainerReg
///
public IReadOnlyCollection GetDerivedTypesForUnboundType(Assembly assembly, Type unboundType, params Type[] typeArguments)
{
- ArgumentGuard.NotNull(assembly, nameof(assembly));
- ArgumentGuard.NotNull(unboundType, nameof(unboundType));
- ArgumentGuard.NotNull(typeArguments, nameof(typeArguments));
+ ArgumentGuard.NotNull(assembly);
+ ArgumentGuard.NotNull(unboundType);
+ ArgumentGuard.NotNull(typeArguments);
Type closedType = unboundType.MakeGenericType(typeArguments);
return GetDerivedTypes(assembly, closedType).ToArray();
@@ -153,8 +153,8 @@ public IReadOnlyCollection GetDerivedTypesForUnboundType(Assembly assembly
///
public IEnumerable GetDerivedTypes(Assembly assembly, Type baseType)
{
- ArgumentGuard.NotNull(assembly, nameof(assembly));
- ArgumentGuard.NotNull(baseType, nameof(baseType));
+ ArgumentGuard.NotNull(assembly);
+ ArgumentGuard.NotNull(baseType);
foreach (Type type in assembly.GetTypes())
{
diff --git a/src/JsonApiDotNetCore/Controllers/Annotations/DisableQueryStringAttribute.cs b/src/JsonApiDotNetCore/Controllers/Annotations/DisableQueryStringAttribute.cs
index 975472ab28..eba4b8340c 100644
--- a/src/JsonApiDotNetCore/Controllers/Annotations/DisableQueryStringAttribute.cs
+++ b/src/JsonApiDotNetCore/Controllers/Annotations/DisableQueryStringAttribute.cs
@@ -46,7 +46,7 @@ public DisableQueryStringAttribute(JsonApiQueryStringParameters parameters)
///
public DisableQueryStringAttribute(string parameterNames)
{
- ArgumentGuard.NotNullNorEmpty(parameterNames, nameof(parameterNames));
+ ArgumentGuard.NotNullNorEmpty(parameterNames);
ParameterNames = parameterNames.Split(",").ToHashSet();
}
diff --git a/src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs b/src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs
index cabe4d49d8..22efab2840 100644
--- a/src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs
+++ b/src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs
@@ -63,9 +63,9 @@ protected BaseJsonApiController(IJsonApiOptions options, IResourceGraph resource
IUpdateService? update = null, ISetRelationshipService? setRelationship = null,
IDeleteService? delete = null, IRemoveFromRelationshipService? removeFromRelationship = null)
{
- ArgumentGuard.NotNull(options, nameof(options));
- ArgumentGuard.NotNull(resourceGraph, nameof(resourceGraph));
- ArgumentGuard.NotNull(loggerFactory, nameof(loggerFactory));
+ ArgumentGuard.NotNull(options);
+ ArgumentGuard.NotNull(resourceGraph);
+ ArgumentGuard.NotNull(loggerFactory);
_options = options;
_resourceGraph = resourceGraph;
@@ -139,7 +139,7 @@ public virtual async Task GetSecondaryAsync(TId id, string relati
relationshipName
});
- ArgumentGuard.NotNullNorEmpty(relationshipName, nameof(relationshipName));
+ ArgumentGuard.NotNullNorEmpty(relationshipName);
if (_getSecondary == null)
{
@@ -168,7 +168,7 @@ public virtual async Task GetRelationshipAsync(TId id, string rel
relationshipName
});
- ArgumentGuard.NotNullNorEmpty(relationshipName, nameof(relationshipName));
+ ArgumentGuard.NotNullNorEmpty(relationshipName);
if (_getRelationship == null)
{
@@ -192,7 +192,7 @@ public virtual async Task PostAsync([FromBody] TResource resource
resource
});
- ArgumentGuard.NotNull(resource, nameof(resource));
+ ArgumentGuard.NotNull(resource);
if (_create == null)
{
@@ -245,8 +245,8 @@ public virtual async Task PostRelationshipAsync(TId id, string re
rightResourceIds
});
- ArgumentGuard.NotNullNorEmpty(relationshipName, nameof(relationshipName));
- ArgumentGuard.NotNull(rightResourceIds, nameof(rightResourceIds));
+ ArgumentGuard.NotNullNorEmpty(relationshipName);
+ ArgumentGuard.NotNull(rightResourceIds);
if (_addToRelationship == null)
{
@@ -272,7 +272,7 @@ public virtual async Task PatchAsync(TId id, [FromBody] TResource
resource
});
- ArgumentGuard.NotNull(resource, nameof(resource));
+ ArgumentGuard.NotNull(resource);
if (_update == null)
{
@@ -320,7 +320,7 @@ public virtual async Task PatchRelationshipAsync(TId id, string r
rightValue
});
- ArgumentGuard.NotNullNorEmpty(relationshipName, nameof(relationshipName));
+ ArgumentGuard.NotNullNorEmpty(relationshipName);
if (_setRelationship == null)
{
@@ -381,8 +381,8 @@ public virtual async Task DeleteRelationshipAsync(TId id, string
rightResourceIds
});
- ArgumentGuard.NotNullNorEmpty(relationshipName, nameof(relationshipName));
- ArgumentGuard.NotNull(rightResourceIds, nameof(rightResourceIds));
+ ArgumentGuard.NotNullNorEmpty(relationshipName);
+ ArgumentGuard.NotNull(rightResourceIds);
if (_removeFromRelationship == null)
{
diff --git a/src/JsonApiDotNetCore/Controllers/BaseJsonApiOperationsController.cs b/src/JsonApiDotNetCore/Controllers/BaseJsonApiOperationsController.cs
index a948d67edc..2ea8f89a87 100644
--- a/src/JsonApiDotNetCore/Controllers/BaseJsonApiOperationsController.cs
+++ b/src/JsonApiDotNetCore/Controllers/BaseJsonApiOperationsController.cs
@@ -27,12 +27,12 @@ public abstract class BaseJsonApiOperationsController : CoreJsonApiController
protected BaseJsonApiOperationsController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory,
IOperationsProcessor processor, IJsonApiRequest request, ITargetedFields targetedFields)
{
- ArgumentGuard.NotNull(options, nameof(options));
- ArgumentGuard.NotNull(resourceGraph, nameof(resourceGraph));
- ArgumentGuard.NotNull(loggerFactory, nameof(loggerFactory));
- ArgumentGuard.NotNull(processor, nameof(processor));
- ArgumentGuard.NotNull(request, nameof(request));
- ArgumentGuard.NotNull(targetedFields, nameof(targetedFields));
+ ArgumentGuard.NotNull(options);
+ ArgumentGuard.NotNull(resourceGraph);
+ ArgumentGuard.NotNull(loggerFactory);
+ ArgumentGuard.NotNull(processor);
+ ArgumentGuard.NotNull(request);
+ ArgumentGuard.NotNull(targetedFields);
_options = options;
_resourceGraph = resourceGraph;
@@ -109,7 +109,7 @@ public virtual async Task PostOperationsAsync([FromBody] IList errors)
{
IReadOnlyList? errorList = ToErrorList(errors);
- ArgumentGuard.NotNullNorEmpty(errorList, nameof(errors));
+ ArgumentGuard.NotNullNorEmpty(errorList);
return new ObjectResult(errorList)
{
diff --git a/src/JsonApiDotNetCore/Diagnostics/AspNetCodeTimerSession.cs b/src/JsonApiDotNetCore/Diagnostics/AspNetCodeTimerSession.cs
index bef29dba78..a42d734580 100644
--- a/src/JsonApiDotNetCore/Diagnostics/AspNetCodeTimerSession.cs
+++ b/src/JsonApiDotNetCore/Diagnostics/AspNetCodeTimerSession.cs
@@ -37,14 +37,14 @@ public ICodeTimer CodeTimer
public AspNetCodeTimerSession(IHttpContextAccessor httpContextAccessor)
{
- ArgumentGuard.NotNull(httpContextAccessor, nameof(httpContextAccessor));
+ ArgumentGuard.NotNull(httpContextAccessor);
_httpContextAccessor = httpContextAccessor;
}
public AspNetCodeTimerSession(HttpContext httpContext)
{
- ArgumentGuard.NotNull(httpContext, nameof(httpContext));
+ ArgumentGuard.NotNull(httpContext);
_httpContext = httpContext;
}
diff --git a/src/JsonApiDotNetCore/Diagnostics/CodeTimingSessionManager.cs b/src/JsonApiDotNetCore/Diagnostics/CodeTimingSessionManager.cs
index d858aa6f4b..5a862409bc 100644
--- a/src/JsonApiDotNetCore/Diagnostics/CodeTimingSessionManager.cs
+++ b/src/JsonApiDotNetCore/Diagnostics/CodeTimingSessionManager.cs
@@ -62,7 +62,7 @@ private static void AssertHasActiveSession()
public static void Capture(ICodeTimerSession session)
{
- ArgumentGuard.NotNull(session, nameof(session));
+ ArgumentGuard.NotNull(session);
AssertNoActiveSession();
diff --git a/src/JsonApiDotNetCore/Errors/InvalidModelStateException.cs b/src/JsonApiDotNetCore/Errors/InvalidModelStateException.cs
index eede4fed25..be4de87fc8 100644
--- a/src/JsonApiDotNetCore/Errors/InvalidModelStateException.cs
+++ b/src/JsonApiDotNetCore/Errors/InvalidModelStateException.cs
@@ -26,9 +26,9 @@ public InvalidModelStateException(IReadOnlyDictionary
private static IEnumerable FromModelStateDictionary(IReadOnlyDictionary modelState, Type modelType,
IResourceGraph resourceGraph, bool includeExceptionStackTraceInErrors, Func? getCollectionElementTypeCallback)
{
- ArgumentGuard.NotNull(modelState, nameof(modelState));
- ArgumentGuard.NotNull(modelType, nameof(modelType));
- ArgumentGuard.NotNull(resourceGraph, nameof(resourceGraph));
+ ArgumentGuard.NotNull(modelState);
+ ArgumentGuard.NotNull(modelType);
+ ArgumentGuard.NotNull(resourceGraph);
List errorObjects = new();
@@ -229,8 +229,8 @@ private abstract class ModelStateKeySegment
protected ModelStateKeySegment(Type modelType, bool isInComplexType, string nextKey, string? sourcePointer, ModelStateKeySegment? parent,
Func? getCollectionElementTypeCallback)
{
- ArgumentGuard.NotNull(modelType, nameof(modelType));
- ArgumentGuard.NotNull(nextKey, nameof(nextKey));
+ ArgumentGuard.NotNull(modelType);
+ ArgumentGuard.NotNull(nextKey);
ModelType = modelType;
IsInComplexType = isInComplexType;
@@ -242,15 +242,15 @@ protected ModelStateKeySegment(Type modelType, bool isInComplexType, string next
public ModelStateKeySegment? GetNextSegment(Type modelType, bool isInComplexType, string? sourcePointer)
{
- ArgumentGuard.NotNull(modelType, nameof(modelType));
+ ArgumentGuard.NotNull(modelType);
return _nextKey == string.Empty ? null : CreateSegment(modelType, _nextKey, isInComplexType, this, sourcePointer, GetCollectionElementTypeCallback);
}
public static ModelStateKeySegment Create(Type modelType, string key, Func? getCollectionElementTypeCallback)
{
- ArgumentGuard.NotNull(modelType, nameof(modelType));
- ArgumentGuard.NotNull(key, nameof(key));
+ ArgumentGuard.NotNull(modelType);
+ ArgumentGuard.NotNull(key);
return CreateSegment(modelType, key, false, null, null, getCollectionElementTypeCallback);
}
@@ -359,14 +359,14 @@ public PropertySegment(string propertyName, Type modelType, bool isInComplexType
Func? getCollectionElementTypeCallback)
: base(modelType, isInComplexType, nextKey, sourcePointer, parent, getCollectionElementTypeCallback)
{
- ArgumentGuard.NotNull(propertyName, nameof(propertyName));
+ ArgumentGuard.NotNull(propertyName);
PropertyName = propertyName;
}
public static string GetPublicNameForProperty(PropertyInfo property)
{
- ArgumentGuard.NotNull(property, nameof(property));
+ ArgumentGuard.NotNull(property);
var jsonNameAttribute = property.GetCustomAttribute(true);
return jsonNameAttribute?.Name ?? property.Name;
diff --git a/src/JsonApiDotNetCore/Errors/JsonApiException.cs b/src/JsonApiDotNetCore/Errors/JsonApiException.cs
index 6bb62177dc..4571843e8d 100644
--- a/src/JsonApiDotNetCore/Errors/JsonApiException.cs
+++ b/src/JsonApiDotNetCore/Errors/JsonApiException.cs
@@ -24,7 +24,7 @@ public class JsonApiException : Exception
public JsonApiException(ErrorObject error, Exception? innerException = null)
: base(null, innerException)
{
- ArgumentGuard.NotNull(error, nameof(error));
+ ArgumentGuard.NotNull(error);
Errors = error.AsArray();
}
@@ -33,7 +33,7 @@ public JsonApiException(IEnumerable errors, Exception? innerExcepti
: base(null, innerException)
{
IReadOnlyList? errorList = ToErrorList(errors);
- ArgumentGuard.NotNullNorEmpty(errorList, nameof(errors));
+ ArgumentGuard.NotNullNorEmpty(errorList);
Errors = errorList;
}
diff --git a/src/JsonApiDotNetCore/Errors/MissingResourceInRelationship.cs b/src/JsonApiDotNetCore/Errors/MissingResourceInRelationship.cs
index e80181898d..42082d6126 100644
--- a/src/JsonApiDotNetCore/Errors/MissingResourceInRelationship.cs
+++ b/src/JsonApiDotNetCore/Errors/MissingResourceInRelationship.cs
@@ -11,9 +11,9 @@ public sealed class MissingResourceInRelationship
public MissingResourceInRelationship(string relationshipName, string resourceType, string resourceId)
{
- ArgumentGuard.NotNullNorEmpty(relationshipName, nameof(relationshipName));
- ArgumentGuard.NotNullNorEmpty(resourceType, nameof(resourceType));
- ArgumentGuard.NotNullNorEmpty(resourceId, nameof(resourceId));
+ ArgumentGuard.NotNullNorEmpty(relationshipName);
+ ArgumentGuard.NotNullNorEmpty(resourceType);
+ ArgumentGuard.NotNullNorEmpty(resourceId);
RelationshipName = relationshipName;
ResourceType = resourceType;
diff --git a/src/JsonApiDotNetCore/Errors/UnsuccessfulActionResultException.cs b/src/JsonApiDotNetCore/Errors/UnsuccessfulActionResultException.cs
index c5c55e4b70..e739ec9cbf 100644
--- a/src/JsonApiDotNetCore/Errors/UnsuccessfulActionResultException.cs
+++ b/src/JsonApiDotNetCore/Errors/UnsuccessfulActionResultException.cs
@@ -26,7 +26,7 @@ public UnsuccessfulActionResultException(ProblemDetails problemDetails)
private static ErrorObject ToError(ProblemDetails problemDetails)
{
- ArgumentGuard.NotNull(problemDetails, nameof(problemDetails));
+ ArgumentGuard.NotNull(problemDetails);
HttpStatusCode status = problemDetails.Status != null ? (HttpStatusCode)problemDetails.Status.Value : HttpStatusCode.InternalServerError;
diff --git a/src/JsonApiDotNetCore/Middleware/AsyncConvertEmptyActionResultFilter.cs b/src/JsonApiDotNetCore/Middleware/AsyncConvertEmptyActionResultFilter.cs
index cf51a82733..82e443a9af 100644
--- a/src/JsonApiDotNetCore/Middleware/AsyncConvertEmptyActionResultFilter.cs
+++ b/src/JsonApiDotNetCore/Middleware/AsyncConvertEmptyActionResultFilter.cs
@@ -10,8 +10,8 @@ public sealed class AsyncConvertEmptyActionResultFilter : IAsyncConvertEmptyActi
///
public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
{
- ArgumentGuard.NotNull(context, nameof(context));
- ArgumentGuard.NotNull(next, nameof(next));
+ ArgumentGuard.NotNull(context);
+ ArgumentGuard.NotNull(next);
if (context.HttpContext.IsJsonApiRequest())
{
diff --git a/src/JsonApiDotNetCore/Middleware/AsyncJsonApiExceptionFilter.cs b/src/JsonApiDotNetCore/Middleware/AsyncJsonApiExceptionFilter.cs
index e87fc98389..58d568a3ec 100644
--- a/src/JsonApiDotNetCore/Middleware/AsyncJsonApiExceptionFilter.cs
+++ b/src/JsonApiDotNetCore/Middleware/AsyncJsonApiExceptionFilter.cs
@@ -13,7 +13,7 @@ public sealed class AsyncJsonApiExceptionFilter : IAsyncJsonApiExceptionFilter
public AsyncJsonApiExceptionFilter(IExceptionHandler exceptionHandler)
{
- ArgumentGuard.NotNull(exceptionHandler, nameof(exceptionHandler));
+ ArgumentGuard.NotNull(exceptionHandler);
_exceptionHandler = exceptionHandler;
}
@@ -21,7 +21,7 @@ public AsyncJsonApiExceptionFilter(IExceptionHandler exceptionHandler)
///
public Task OnExceptionAsync(ExceptionContext context)
{
- ArgumentGuard.NotNull(context, nameof(context));
+ ArgumentGuard.NotNull(context);
if (context.HttpContext.IsJsonApiRequest())
{
diff --git a/src/JsonApiDotNetCore/Middleware/AsyncQueryStringActionFilter.cs b/src/JsonApiDotNetCore/Middleware/AsyncQueryStringActionFilter.cs
index 6f31c28d2a..89164c844f 100644
--- a/src/JsonApiDotNetCore/Middleware/AsyncQueryStringActionFilter.cs
+++ b/src/JsonApiDotNetCore/Middleware/AsyncQueryStringActionFilter.cs
@@ -12,7 +12,7 @@ public sealed class AsyncQueryStringActionFilter : IAsyncQueryStringActionFilter
public AsyncQueryStringActionFilter(IQueryStringReader queryStringReader)
{
- ArgumentGuard.NotNull(queryStringReader, nameof(queryStringReader));
+ ArgumentGuard.NotNull(queryStringReader);
_queryStringReader = queryStringReader;
}
@@ -20,8 +20,8 @@ public AsyncQueryStringActionFilter(IQueryStringReader queryStringReader)
///
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
- ArgumentGuard.NotNull(context, nameof(context));
- ArgumentGuard.NotNull(next, nameof(next));
+ ArgumentGuard.NotNull(context);
+ ArgumentGuard.NotNull(next);
if (context.HttpContext.IsJsonApiRequest())
{
diff --git a/src/JsonApiDotNetCore/Middleware/ExceptionHandler.cs b/src/JsonApiDotNetCore/Middleware/ExceptionHandler.cs
index ea1d67743d..b8690402a5 100644
--- a/src/JsonApiDotNetCore/Middleware/ExceptionHandler.cs
+++ b/src/JsonApiDotNetCore/Middleware/ExceptionHandler.cs
@@ -17,8 +17,8 @@ public class ExceptionHandler : IExceptionHandler
public ExceptionHandler(ILoggerFactory loggerFactory, IJsonApiOptions options)
{
- ArgumentGuard.NotNull(loggerFactory, nameof(loggerFactory));
- ArgumentGuard.NotNull(options, nameof(options));
+ ArgumentGuard.NotNull(loggerFactory);
+ ArgumentGuard.NotNull(options);
_options = options;
_logger = loggerFactory.CreateLogger();
@@ -26,7 +26,7 @@ public ExceptionHandler(ILoggerFactory loggerFactory, IJsonApiOptions options)
public IReadOnlyList HandleException(Exception exception)
{
- ArgumentGuard.NotNull(exception, nameof(exception));
+ ArgumentGuard.NotNull(exception);
Exception demystified = exception.Demystify();
@@ -45,7 +45,7 @@ private void LogException(Exception exception)
protected virtual LogLevel GetLogLevel(Exception exception)
{
- ArgumentGuard.NotNull(exception, nameof(exception));
+ ArgumentGuard.NotNull(exception);
if (exception is OperationCanceledException)
{
@@ -62,14 +62,14 @@ protected virtual LogLevel GetLogLevel(Exception exception)
protected virtual string GetLogMessage(Exception exception)
{
- ArgumentGuard.NotNull(exception, nameof(exception));
+ ArgumentGuard.NotNull(exception);
return exception is JsonApiException jsonApiException ? jsonApiException.GetSummary() : exception.Message;
}
protected virtual IReadOnlyList CreateErrorResponse(Exception exception)
{
- ArgumentGuard.NotNull(exception, nameof(exception));
+ ArgumentGuard.NotNull(exception);
IReadOnlyList errors = exception is JsonApiException jsonApiException ? jsonApiException.Errors :
exception is OperationCanceledException ? new ErrorObject((HttpStatusCode)499)
diff --git a/src/JsonApiDotNetCore/Middleware/HttpContextExtensions.cs b/src/JsonApiDotNetCore/Middleware/HttpContextExtensions.cs
index b6785e8198..a675aeeaff 100644
--- a/src/JsonApiDotNetCore/Middleware/HttpContextExtensions.cs
+++ b/src/JsonApiDotNetCore/Middleware/HttpContextExtensions.cs
@@ -13,7 +13,7 @@ public static class HttpContextExtensions
///
public static bool IsJsonApiRequest(this HttpContext httpContext)
{
- ArgumentGuard.NotNull(httpContext, nameof(httpContext));
+ ArgumentGuard.NotNull(httpContext);
string? value = httpContext.Items[IsJsonApiRequestKey] as string;
return value == bool.TrueString;
@@ -21,7 +21,7 @@ public static bool IsJsonApiRequest(this HttpContext httpContext)
internal static void RegisterJsonApiRequest(this HttpContext httpContext)
{
- ArgumentGuard.NotNull(httpContext, nameof(httpContext));
+ ArgumentGuard.NotNull(httpContext);
httpContext.Items[IsJsonApiRequestKey] = bool.TrueString;
}
diff --git a/src/JsonApiDotNetCore/Middleware/JsonApiInputFormatter.cs b/src/JsonApiDotNetCore/Middleware/JsonApiInputFormatter.cs
index 077f0573f0..59563c9268 100644
--- a/src/JsonApiDotNetCore/Middleware/JsonApiInputFormatter.cs
+++ b/src/JsonApiDotNetCore/Middleware/JsonApiInputFormatter.cs
@@ -10,7 +10,7 @@ public sealed class JsonApiInputFormatter : IJsonApiInputFormatter
///
public bool CanRead(InputFormatterContext context)
{
- ArgumentGuard.NotNull(context, nameof(context));
+ ArgumentGuard.NotNull(context);
return context.HttpContext.IsJsonApiRequest();
}
@@ -18,7 +18,7 @@ public bool CanRead(InputFormatterContext context)
///
public async Task ReadAsync(InputFormatterContext context)
{
- ArgumentGuard.NotNull(context, nameof(context));
+ ArgumentGuard.NotNull(context);
var reader = context.HttpContext.RequestServices.GetRequiredService();
diff --git a/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs b/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs
index 2e15e6ae9a..b38ad986dd 100644
--- a/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs
+++ b/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs
@@ -36,11 +36,11 @@ public JsonApiMiddleware(RequestDelegate next, IHttpContextAccessor httpContextA
public async Task InvokeAsync(HttpContext httpContext, IControllerResourceMapping controllerResourceMapping, IJsonApiOptions options,
IJsonApiRequest request, ILogger logger)
{
- ArgumentGuard.NotNull(httpContext, nameof(httpContext));
- ArgumentGuard.NotNull(controllerResourceMapping, nameof(controllerResourceMapping));
- ArgumentGuard.NotNull(options, nameof(options));
- ArgumentGuard.NotNull(request, nameof(request));
- ArgumentGuard.NotNull(logger, nameof(logger));
+ ArgumentGuard.NotNull(httpContext);
+ ArgumentGuard.NotNull(controllerResourceMapping);
+ ArgumentGuard.NotNull(options);
+ ArgumentGuard.NotNull(request);
+ ArgumentGuard.NotNull(logger);
using (CodeTimingSessionManager.Current.Measure("JSON:API middleware"))
{
diff --git a/src/JsonApiDotNetCore/Middleware/JsonApiOutputFormatter.cs b/src/JsonApiDotNetCore/Middleware/JsonApiOutputFormatter.cs
index c32bb9d9f9..8c97a12ea4 100644
--- a/src/JsonApiDotNetCore/Middleware/JsonApiOutputFormatter.cs
+++ b/src/JsonApiDotNetCore/Middleware/JsonApiOutputFormatter.cs
@@ -10,7 +10,7 @@ public sealed class JsonApiOutputFormatter : IJsonApiOutputFormatter
///
public bool CanWriteResult(OutputFormatterCanWriteContext context)
{
- ArgumentGuard.NotNull(context, nameof(context));
+ ArgumentGuard.NotNull(context);
return context.HttpContext.IsJsonApiRequest();
}
@@ -18,7 +18,7 @@ public bool CanWriteResult(OutputFormatterCanWriteContext context)
///
public async Task WriteAsync(OutputFormatterWriteContext context)
{
- ArgumentGuard.NotNull(context, nameof(context));
+ ArgumentGuard.NotNull(context);
var writer = context.HttpContext.RequestServices.GetRequiredService();
await writer.WriteAsync(context.Object, context.HttpContext);
diff --git a/src/JsonApiDotNetCore/Middleware/JsonApiRequest.cs b/src/JsonApiDotNetCore/Middleware/JsonApiRequest.cs
index a28c01fcd6..98e42823a3 100644
--- a/src/JsonApiDotNetCore/Middleware/JsonApiRequest.cs
+++ b/src/JsonApiDotNetCore/Middleware/JsonApiRequest.cs
@@ -38,7 +38,7 @@ public sealed class JsonApiRequest : IJsonApiRequest
///
public void CopyFrom(IJsonApiRequest other)
{
- ArgumentGuard.NotNull(other, nameof(other));
+ ArgumentGuard.NotNull(other);
Kind = other.Kind;
PrimaryId = other.PrimaryId;
diff --git a/src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs b/src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs
index fe95d93446..a05aa979ef 100644
--- a/src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs
+++ b/src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs
@@ -36,8 +36,8 @@ public sealed class JsonApiRoutingConvention : IJsonApiRoutingConvention
public JsonApiRoutingConvention(IJsonApiOptions options, IResourceGraph resourceGraph)
{
- ArgumentGuard.NotNull(options, nameof(options));
- ArgumentGuard.NotNull(resourceGraph, nameof(resourceGraph));
+ ArgumentGuard.NotNull(options);
+ ArgumentGuard.NotNull(resourceGraph);
_options = options;
_resourceGraph = resourceGraph;
@@ -60,7 +60,7 @@ public JsonApiRoutingConvention(IJsonApiOptions options, IResourceGraph resource
///
public void Apply(ApplicationModel application)
{
- ArgumentGuard.NotNull(application, nameof(application));
+ ArgumentGuard.NotNull(application);
foreach (ControllerModel controller in application.Controllers)
{
diff --git a/src/JsonApiDotNetCore/Queries/ExpressionInScope.cs b/src/JsonApiDotNetCore/Queries/ExpressionInScope.cs
index 37d40f127b..6ac6f75059 100644
--- a/src/JsonApiDotNetCore/Queries/ExpressionInScope.cs
+++ b/src/JsonApiDotNetCore/Queries/ExpressionInScope.cs
@@ -15,7 +15,7 @@ public class ExpressionInScope
public ExpressionInScope(ResourceFieldChainExpression? scope, QueryExpression expression)
{
- ArgumentGuard.NotNull(expression, nameof(expression));
+ ArgumentGuard.NotNull(expression);
Scope = scope;
Expression = expression;
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/AnyExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/AnyExpression.cs
index 980a7846bc..2b855b1bdb 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/AnyExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/AnyExpression.cs
@@ -16,8 +16,8 @@ public class AnyExpression : FilterExpression
public AnyExpression(ResourceFieldChainExpression targetAttribute, IImmutableSet constants)
{
- ArgumentGuard.NotNull(targetAttribute, nameof(targetAttribute));
- ArgumentGuard.NotNull(constants, nameof(constants));
+ ArgumentGuard.NotNull(targetAttribute);
+ ArgumentGuard.NotNull(constants);
if (constants.Count < 2)
{
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/ComparisonExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/ComparisonExpression.cs
index 9bf1c3bde8..cdae713f3d 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/ComparisonExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/ComparisonExpression.cs
@@ -15,8 +15,8 @@ public class ComparisonExpression : FilterExpression
public ComparisonExpression(ComparisonOperator @operator, QueryExpression left, QueryExpression right)
{
- ArgumentGuard.NotNull(left, nameof(left));
- ArgumentGuard.NotNull(right, nameof(right));
+ ArgumentGuard.NotNull(left);
+ ArgumentGuard.NotNull(right);
Operator = @operator;
Left = left;
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/CountExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/CountExpression.cs
index 5de89ead7c..2eff0a86e9 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/CountExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/CountExpression.cs
@@ -13,7 +13,7 @@ public class CountExpression : FunctionExpression
public CountExpression(ResourceFieldChainExpression targetCollection)
{
- ArgumentGuard.NotNull(targetCollection, nameof(targetCollection));
+ ArgumentGuard.NotNull(targetCollection);
TargetCollection = targetCollection;
}
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/HasExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/HasExpression.cs
index c5387106d6..825119fe33 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/HasExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/HasExpression.cs
@@ -15,7 +15,7 @@ public class HasExpression : FilterExpression
public HasExpression(ResourceFieldChainExpression targetCollection, FilterExpression? filter)
{
- ArgumentGuard.NotNull(targetCollection, nameof(targetCollection));
+ ArgumentGuard.NotNull(targetCollection);
TargetCollection = targetCollection;
Filter = filter;
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/IncludeChainConverter.cs b/src/JsonApiDotNetCore/Queries/Expressions/IncludeChainConverter.cs
index b35c48efbd..8b2034a374 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/IncludeChainConverter.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/IncludeChainConverter.cs
@@ -29,7 +29,7 @@ internal sealed class IncludeChainConverter
///
public IReadOnlyCollection GetRelationshipChains(IncludeExpression include)
{
- ArgumentGuard.NotNull(include, nameof(include));
+ ArgumentGuard.NotNull(include);
if (!include.Elements.Any())
{
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/IncludeElementExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/IncludeElementExpression.cs
index e76aaf0946..01c25dad4e 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/IncludeElementExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/IncludeElementExpression.cs
@@ -21,8 +21,8 @@ public IncludeElementExpression(RelationshipAttribute relationship)
public IncludeElementExpression(RelationshipAttribute relationship, IImmutableSet children)
{
- ArgumentGuard.NotNull(relationship, nameof(relationship));
- ArgumentGuard.NotNull(children, nameof(children));
+ ArgumentGuard.NotNull(relationship);
+ ArgumentGuard.NotNull(children);
Relationship = relationship;
Children = children;
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/IncludeExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/IncludeExpression.cs
index a63d87719d..69373c9abf 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/IncludeExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/IncludeExpression.cs
@@ -17,7 +17,7 @@ public class IncludeExpression : QueryExpression
public IncludeExpression(IImmutableSet elements)
{
- ArgumentGuard.NotNullNorEmpty(elements, nameof(elements));
+ ArgumentGuard.NotNullNorEmpty(elements);
Elements = elements;
}
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/IsTypeExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/IsTypeExpression.cs
index a30e31308b..4e259b358e 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/IsTypeExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/IsTypeExpression.cs
@@ -18,7 +18,7 @@ public class IsTypeExpression : FilterExpression
public IsTypeExpression(ResourceFieldChainExpression? targetToOneRelationship, ResourceType derivedType, FilterExpression? child)
{
- ArgumentGuard.NotNull(derivedType, nameof(derivedType));
+ ArgumentGuard.NotNull(derivedType);
TargetToOneRelationship = targetToOneRelationship;
DerivedType = derivedType;
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/LiteralConstantExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/LiteralConstantExpression.cs
index 17c62f230f..578643d5db 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/LiteralConstantExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/LiteralConstantExpression.cs
@@ -12,7 +12,7 @@ public class LiteralConstantExpression : IdentifierExpression
public LiteralConstantExpression(string text)
{
- ArgumentGuard.NotNull(text, nameof(text));
+ ArgumentGuard.NotNull(text);
Value = text;
}
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/LogicalExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/LogicalExpression.cs
index c8d8ffb24b..08f970aee5 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/LogicalExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/LogicalExpression.cs
@@ -21,7 +21,7 @@ public LogicalExpression(LogicalOperator @operator, params FilterExpression[] te
public LogicalExpression(LogicalOperator @operator, IImmutableList terms)
{
- ArgumentGuard.NotNull(terms, nameof(terms));
+ ArgumentGuard.NotNull(terms);
if (terms.Count < 2)
{
@@ -34,7 +34,7 @@ public LogicalExpression(LogicalOperator @operator, IImmutableList terms = filters.WhereNotNull().ToImmutableArray();
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/MatchTextExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/MatchTextExpression.cs
index a9c598402b..5d9ed08859 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/MatchTextExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/MatchTextExpression.cs
@@ -16,8 +16,8 @@ public class MatchTextExpression : FilterExpression
public MatchTextExpression(ResourceFieldChainExpression targetAttribute, LiteralConstantExpression textValue, TextMatchKind matchKind)
{
- ArgumentGuard.NotNull(targetAttribute, nameof(targetAttribute));
- ArgumentGuard.NotNull(textValue, nameof(textValue));
+ ArgumentGuard.NotNull(targetAttribute);
+ ArgumentGuard.NotNull(textValue);
TargetAttribute = targetAttribute;
TextValue = textValue;
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/NotExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/NotExpression.cs
index 4d28c4a9c3..ae198cd3ee 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/NotExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/NotExpression.cs
@@ -13,7 +13,7 @@ public class NotExpression : FilterExpression
public NotExpression(FilterExpression child)
{
- ArgumentGuard.NotNull(child, nameof(child));
+ ArgumentGuard.NotNull(child);
Child = child;
}
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/PaginationExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/PaginationExpression.cs
index 97ff8b1456..2ecd9901a2 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/PaginationExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/PaginationExpression.cs
@@ -14,7 +14,7 @@ public class PaginationExpression : QueryExpression
public PaginationExpression(PageNumber pageNumber, PageSize? pageSize)
{
- ArgumentGuard.NotNull(pageNumber, nameof(pageNumber));
+ ArgumentGuard.NotNull(pageNumber);
PageNumber = pageNumber;
PageSize = pageSize;
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/PaginationQueryStringValueExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/PaginationQueryStringValueExpression.cs
index 594dab297a..a65e9c0a15 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/PaginationQueryStringValueExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/PaginationQueryStringValueExpression.cs
@@ -13,7 +13,7 @@ public class PaginationQueryStringValueExpression : QueryExpression
public PaginationQueryStringValueExpression(IImmutableList elements)
{
- ArgumentGuard.NotNullNorEmpty(elements, nameof(elements));
+ ArgumentGuard.NotNullNorEmpty(elements);
Elements = elements;
}
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/QueryStringParameterScopeExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/QueryStringParameterScopeExpression.cs
index e567da8778..bc2d018033 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/QueryStringParameterScopeExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/QueryStringParameterScopeExpression.cs
@@ -13,7 +13,7 @@ public class QueryStringParameterScopeExpression : QueryExpression
public QueryStringParameterScopeExpression(LiteralConstantExpression parameterName, ResourceFieldChainExpression? scope)
{
- ArgumentGuard.NotNull(parameterName, nameof(parameterName));
+ ArgumentGuard.NotNull(parameterName);
ParameterName = parameterName;
Scope = scope;
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/QueryableHandlerExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/QueryableHandlerExpression.cs
index 1d9c910955..872cdb1aac 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/QueryableHandlerExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/QueryableHandlerExpression.cs
@@ -15,7 +15,7 @@ public class QueryableHandlerExpression : QueryExpression
public QueryableHandlerExpression(object queryableHandler, StringValues parameterValue)
{
- ArgumentGuard.NotNull(queryableHandler, nameof(queryableHandler));
+ ArgumentGuard.NotNull(queryableHandler);
_queryableHandler = queryableHandler;
_parameterValue = parameterValue;
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/ResourceFieldChainExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/ResourceFieldChainExpression.cs
index 7decec6221..9224642133 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/ResourceFieldChainExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/ResourceFieldChainExpression.cs
@@ -14,14 +14,14 @@ public class ResourceFieldChainExpression : IdentifierExpression
public ResourceFieldChainExpression(ResourceFieldAttribute field)
{
- ArgumentGuard.NotNull(field, nameof(field));
+ ArgumentGuard.NotNull(field);
Fields = ImmutableArray.Create(field);
}
public ResourceFieldChainExpression(IImmutableList fields)
{
- ArgumentGuard.NotNullNorEmpty(fields, nameof(fields));
+ ArgumentGuard.NotNullNorEmpty(fields);
Fields = fields;
}
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/SortElementExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/SortElementExpression.cs
index 78de440a42..bfdf30e8d5 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/SortElementExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/SortElementExpression.cs
@@ -15,7 +15,7 @@ public class SortElementExpression : QueryExpression
public SortElementExpression(ResourceFieldChainExpression targetAttribute, bool isAscending)
{
- ArgumentGuard.NotNull(targetAttribute, nameof(targetAttribute));
+ ArgumentGuard.NotNull(targetAttribute);
TargetAttribute = targetAttribute;
IsAscending = isAscending;
@@ -23,7 +23,7 @@ public SortElementExpression(ResourceFieldChainExpression targetAttribute, bool
public SortElementExpression(CountExpression count, bool isAscending)
{
- ArgumentGuard.NotNull(count, nameof(count));
+ ArgumentGuard.NotNull(count);
Count = count;
IsAscending = isAscending;
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/SortExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/SortExpression.cs
index dc0aebd320..53b067d4e8 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/SortExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/SortExpression.cs
@@ -13,7 +13,7 @@ public class SortExpression : QueryExpression
public SortExpression(IImmutableList elements)
{
- ArgumentGuard.NotNullNorEmpty(elements, nameof(elements));
+ ArgumentGuard.NotNullNorEmpty(elements);
Elements = elements;
}
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/SparseFieldSetExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/SparseFieldSetExpression.cs
index bc1e611bd8..f36427b2e1 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/SparseFieldSetExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/SparseFieldSetExpression.cs
@@ -14,7 +14,7 @@ public class SparseFieldSetExpression : QueryExpression
public SparseFieldSetExpression(IImmutableSet fields)
{
- ArgumentGuard.NotNullNorEmpty(fields, nameof(fields));
+ ArgumentGuard.NotNullNorEmpty(fields);
Fields = fields;
}
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/SparseFieldSetExpressionExtensions.cs b/src/JsonApiDotNetCore/Queries/Expressions/SparseFieldSetExpressionExtensions.cs
index 53f9ff0eb6..c7c331eb46 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/SparseFieldSetExpressionExtensions.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/SparseFieldSetExpressionExtensions.cs
@@ -14,8 +14,8 @@ public static class SparseFieldSetExpressionExtensions
Expression> fieldSelector, IResourceGraph resourceGraph)
where TResource : class, IIdentifiable
{
- ArgumentGuard.NotNull(fieldSelector, nameof(fieldSelector));
- ArgumentGuard.NotNull(resourceGraph, nameof(resourceGraph));
+ ArgumentGuard.NotNull(fieldSelector);
+ ArgumentGuard.NotNull(resourceGraph);
SparseFieldSetExpression? newSparseFieldSet = sparseFieldSet;
@@ -42,8 +42,8 @@ public static class SparseFieldSetExpressionExtensions
Expression> fieldSelector, IResourceGraph resourceGraph)
where TResource : class, IIdentifiable
{
- ArgumentGuard.NotNull(fieldSelector, nameof(fieldSelector));
- ArgumentGuard.NotNull(resourceGraph, nameof(resourceGraph));
+ ArgumentGuard.NotNull(fieldSelector);
+ ArgumentGuard.NotNull(resourceGraph);
SparseFieldSetExpression? newSparseFieldSet = sparseFieldSet;
diff --git a/src/JsonApiDotNetCore/Queries/Expressions/SparseFieldTableExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/SparseFieldTableExpression.cs
index 8e52df9b3b..c69be71292 100644
--- a/src/JsonApiDotNetCore/Queries/Expressions/SparseFieldTableExpression.cs
+++ b/src/JsonApiDotNetCore/Queries/Expressions/SparseFieldTableExpression.cs
@@ -15,7 +15,7 @@ public class SparseFieldTableExpression : QueryExpression
public SparseFieldTableExpression(IImmutableDictionary table)
{
- ArgumentGuard.NotNullNorEmpty(table, nameof(table), "entries");
+ ArgumentGuard.NotNullNorEmpty(table);
Table = table;
}
diff --git a/src/JsonApiDotNetCore/Queries/FieldSelection.cs b/src/JsonApiDotNetCore/Queries/FieldSelection.cs
index 54c59005bf..7f62db1fcf 100644
--- a/src/JsonApiDotNetCore/Queries/FieldSelection.cs
+++ b/src/JsonApiDotNetCore/Queries/FieldSelection.cs
@@ -23,7 +23,7 @@ public IReadOnlySet GetResourceTypes()
public FieldSelectors GetOrCreateSelectors(ResourceType resourceType)
#pragma warning restore AV1130 // Return type in method signature should be an interface to an unchangeable collection
{
- ArgumentGuard.NotNull(resourceType, nameof(resourceType));
+ ArgumentGuard.NotNull(resourceType);
if (!ContainsKey(resourceType))
{
diff --git a/src/JsonApiDotNetCore/Queries/FieldSelectors.cs b/src/JsonApiDotNetCore/Queries/FieldSelectors.cs
index a07b4f0c79..ffd95c01bc 100644
--- a/src/JsonApiDotNetCore/Queries/FieldSelectors.cs
+++ b/src/JsonApiDotNetCore/Queries/FieldSelectors.cs
@@ -30,21 +30,21 @@ public bool ContainsOnlyRelationships
public bool ContainsField(ResourceFieldAttribute field)
{
- ArgumentGuard.NotNull(field, nameof(field));
+ ArgumentGuard.NotNull(field);
return ContainsKey(field);
}
public void IncludeAttribute(AttrAttribute attribute)
{
- ArgumentGuard.NotNull(attribute, nameof(attribute));
+ ArgumentGuard.NotNull(attribute);
this[attribute] = null;
}
public void IncludeAttributes(IEnumerable attributes)
{
- ArgumentGuard.NotNull(attributes, nameof(attributes));
+ ArgumentGuard.NotNull(attributes);
foreach (AttrAttribute attribute in attributes)
{
@@ -54,7 +54,7 @@ public void IncludeAttributes(IEnumerable attributes)
public void IncludeRelationship(RelationshipAttribute relationship, QueryLayer? queryLayer)
{
- ArgumentGuard.NotNull(relationship, nameof(relationship));
+ ArgumentGuard.NotNull(relationship);
this[relationship] = queryLayer;
}
diff --git a/src/JsonApiDotNetCore/Queries/Internal/EvaluatedIncludeCache.cs b/src/JsonApiDotNetCore/Queries/Internal/EvaluatedIncludeCache.cs
index 509baf73ee..bbd383fa28 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/EvaluatedIncludeCache.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/EvaluatedIncludeCache.cs
@@ -10,7 +10,7 @@ internal sealed class EvaluatedIncludeCache : IEvaluatedIncludeCache
///
public void Set(IncludeExpression include)
{
- ArgumentGuard.NotNull(include, nameof(include));
+ ArgumentGuard.NotNull(include);
_include = include;
}
diff --git a/src/JsonApiDotNetCore/Queries/Internal/Parsing/FilterParser.cs b/src/JsonApiDotNetCore/Queries/Internal/Parsing/FilterParser.cs
index 705f057bc5..c68e0f77f7 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/Parsing/FilterParser.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/Parsing/FilterParser.cs
@@ -18,7 +18,7 @@ public class FilterParser : QueryExpressionParser
public FilterParser(IResourceFactory resourceFactory, Action? validateSingleFieldCallback = null)
{
- ArgumentGuard.NotNull(resourceFactory, nameof(resourceFactory));
+ ArgumentGuard.NotNull(resourceFactory);
_resourceFactory = resourceFactory;
_validateSingleFieldCallback = validateSingleFieldCallback;
@@ -26,7 +26,7 @@ public FilterParser(IResourceFactory resourceFactory, Action
{
diff --git a/src/JsonApiDotNetCore/Queries/Internal/Parsing/IncludeParser.cs b/src/JsonApiDotNetCore/Queries/Internal/Parsing/IncludeParser.cs
index 14d2f1ec15..7418be160f 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/Parsing/IncludeParser.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/Parsing/IncludeParser.cs
@@ -15,7 +15,7 @@ public class IncludeParser : QueryExpressionParser
public IncludeExpression Parse(string source, ResourceType resourceTypeInScope, int? maximumDepth)
{
- ArgumentGuard.NotNull(resourceTypeInScope, nameof(resourceTypeInScope));
+ ArgumentGuard.NotNull(resourceTypeInScope);
Tokenize(source);
@@ -266,7 +266,7 @@ private sealed class HiddenRootRelationshipAttribute : RelationshipAttribute
{
public HiddenRootRelationshipAttribute(ResourceType rightType)
{
- ArgumentGuard.NotNull(rightType, nameof(rightType));
+ ArgumentGuard.NotNull(rightType);
RightType = rightType;
PublicName = "<>";
diff --git a/src/JsonApiDotNetCore/Queries/Internal/Parsing/PaginationParser.cs b/src/JsonApiDotNetCore/Queries/Internal/Parsing/PaginationParser.cs
index 29c7713b11..50b542de6e 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/Parsing/PaginationParser.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/Parsing/PaginationParser.cs
@@ -19,7 +19,7 @@ public PaginationParser(Action? va
public PaginationQueryStringValueExpression Parse(string source, ResourceType resourceTypeInScope)
{
- ArgumentGuard.NotNull(resourceTypeInScope, nameof(resourceTypeInScope));
+ ArgumentGuard.NotNull(resourceTypeInScope);
_resourceTypeInScope = resourceTypeInScope;
diff --git a/src/JsonApiDotNetCore/Queries/Internal/Parsing/QueryStringParameterScopeParser.cs b/src/JsonApiDotNetCore/Queries/Internal/Parsing/QueryStringParameterScopeParser.cs
index 3cba8e4515..ef95b3ed92 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/Parsing/QueryStringParameterScopeParser.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/Parsing/QueryStringParameterScopeParser.cs
@@ -22,7 +22,7 @@ public QueryStringParameterScopeParser(FieldChainRequirements chainRequirements,
public QueryStringParameterScopeExpression Parse(string source, ResourceType resourceTypeInScope)
{
- ArgumentGuard.NotNull(resourceTypeInScope, nameof(resourceTypeInScope));
+ ArgumentGuard.NotNull(resourceTypeInScope);
_resourceTypeInScope = resourceTypeInScope;
diff --git a/src/JsonApiDotNetCore/Queries/Internal/Parsing/QueryTokenizer.cs b/src/JsonApiDotNetCore/Queries/Internal/Parsing/QueryTokenizer.cs
index 3f04ce92aa..cd920554c9 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/Parsing/QueryTokenizer.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/Parsing/QueryTokenizer.cs
@@ -27,7 +27,7 @@ public sealed class QueryTokenizer
public QueryTokenizer(string source)
{
- ArgumentGuard.NotNull(source, nameof(source));
+ ArgumentGuard.NotNull(source);
_source = source;
}
diff --git a/src/JsonApiDotNetCore/Queries/Internal/Parsing/SortParser.cs b/src/JsonApiDotNetCore/Queries/Internal/Parsing/SortParser.cs
index 84782c2b3e..7f4a142ef0 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/Parsing/SortParser.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/Parsing/SortParser.cs
@@ -19,7 +19,7 @@ public SortParser(Action? validate
public SortExpression Parse(string source, ResourceType resourceTypeInScope)
{
- ArgumentGuard.NotNull(resourceTypeInScope, nameof(resourceTypeInScope));
+ ArgumentGuard.NotNull(resourceTypeInScope);
_resourceTypeInScope = resourceTypeInScope;
diff --git a/src/JsonApiDotNetCore/Queries/Internal/Parsing/SparseFieldSetParser.cs b/src/JsonApiDotNetCore/Queries/Internal/Parsing/SparseFieldSetParser.cs
index b4e54f0c46..0cabbcf76e 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/Parsing/SparseFieldSetParser.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/Parsing/SparseFieldSetParser.cs
@@ -19,7 +19,7 @@ public SparseFieldSetParser(Action
public SparseFieldSetExpression? Parse(string source, ResourceType resourceType)
{
- ArgumentGuard.NotNull(resourceType, nameof(resourceType));
+ ArgumentGuard.NotNull(resourceType);
_resourceType = resourceType;
diff --git a/src/JsonApiDotNetCore/Queries/Internal/Parsing/SparseFieldTypeParser.cs b/src/JsonApiDotNetCore/Queries/Internal/Parsing/SparseFieldTypeParser.cs
index b23dfdfea1..eceb05d211 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/Parsing/SparseFieldTypeParser.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/Parsing/SparseFieldTypeParser.cs
@@ -12,7 +12,7 @@ public class SparseFieldTypeParser : QueryExpressionParser
public SparseFieldTypeParser(IResourceGraph resourceGraph)
{
- ArgumentGuard.NotNull(resourceGraph, nameof(resourceGraph));
+ ArgumentGuard.NotNull(resourceGraph);
_resourceGraph = resourceGraph;
}
diff --git a/src/JsonApiDotNetCore/Queries/Internal/QueryLayerComposer.cs b/src/JsonApiDotNetCore/Queries/Internal/QueryLayerComposer.cs
index 40af882044..29e0935954 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/QueryLayerComposer.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/QueryLayerComposer.cs
@@ -25,13 +25,13 @@ public QueryLayerComposer(IEnumerable constraintProvid
IJsonApiOptions options, IPaginationContext paginationContext, ITargetedFields targetedFields, IEvaluatedIncludeCache evaluatedIncludeCache,
ISparseFieldSetCache sparseFieldSetCache)
{
- ArgumentGuard.NotNull(constraintProviders, nameof(constraintProviders));
- ArgumentGuard.NotNull(resourceDefinitionAccessor, nameof(resourceDefinitionAccessor));
- ArgumentGuard.NotNull(options, nameof(options));
- ArgumentGuard.NotNull(paginationContext, nameof(paginationContext));
- ArgumentGuard.NotNull(targetedFields, nameof(targetedFields));
- ArgumentGuard.NotNull(evaluatedIncludeCache, nameof(evaluatedIncludeCache));
- ArgumentGuard.NotNull(sparseFieldSetCache, nameof(sparseFieldSetCache));
+ ArgumentGuard.NotNull(constraintProviders);
+ ArgumentGuard.NotNull(resourceDefinitionAccessor);
+ ArgumentGuard.NotNull(options);
+ ArgumentGuard.NotNull(paginationContext);
+ ArgumentGuard.NotNull(targetedFields);
+ ArgumentGuard.NotNull(evaluatedIncludeCache);
+ ArgumentGuard.NotNull(sparseFieldSetCache);
_constraintProviders = constraintProviders;
_resourceDefinitionAccessor = resourceDefinitionAccessor;
@@ -65,7 +65,7 @@ public QueryLayerComposer(IEnumerable constraintProvid
///
public FilterExpression? GetSecondaryFilterFromConstraints(TId primaryId, HasManyAttribute hasManyRelationship)
{
- ArgumentGuard.NotNull(hasManyRelationship, nameof(hasManyRelationship));
+ ArgumentGuard.NotNull(hasManyRelationship);
if (hasManyRelationship.InverseNavigationProperty == null)
{
@@ -131,7 +131,7 @@ private static FilterExpression GetInverseHasManyRelationshipFilter(TId pri
///
public QueryLayer ComposeFromConstraints(ResourceType requestResourceType)
{
- ArgumentGuard.NotNull(requestResourceType, nameof(requestResourceType));
+ ArgumentGuard.NotNull(requestResourceType);
ExpressionInScope[] constraints = _constraintProviders.SelectMany(provider => provider.GetConstraints()).ToArray();
@@ -268,7 +268,7 @@ private static IImmutableSet ApplyIncludeElementUpdate
///
public QueryLayer ComposeForGetById(TId id, ResourceType primaryResourceType, TopFieldSelection fieldSelection)
{
- ArgumentGuard.NotNull(primaryResourceType, nameof(primaryResourceType));
+ ArgumentGuard.NotNull(primaryResourceType);
AttrAttribute idAttribute = GetIdAttribute(primaryResourceType);
@@ -296,7 +296,7 @@ public QueryLayer ComposeForGetById(TId id, ResourceType primaryResourceTyp
///
public QueryLayer ComposeSecondaryLayerForRelationship(ResourceType secondaryResourceType)
{
- ArgumentGuard.NotNull(secondaryResourceType, nameof(secondaryResourceType));
+ ArgumentGuard.NotNull(secondaryResourceType);
QueryLayer secondaryLayer = ComposeFromConstraints(secondaryResourceType);
secondaryLayer.Selection = GetSelectionForRelationship(secondaryResourceType);
@@ -320,9 +320,9 @@ private FieldSelection GetSelectionForRelationship(ResourceType secondaryResourc
public QueryLayer WrapLayerForSecondaryEndpoint(QueryLayer secondaryLayer, ResourceType primaryResourceType, TId primaryId,
RelationshipAttribute relationship)
{
- ArgumentGuard.NotNull(secondaryLayer, nameof(secondaryLayer));
- ArgumentGuard.NotNull(primaryResourceType, nameof(primaryResourceType));
- ArgumentGuard.NotNull(relationship, nameof(relationship));
+ ArgumentGuard.NotNull(secondaryLayer);
+ ArgumentGuard.NotNull(primaryResourceType);
+ ArgumentGuard.NotNull(relationship);
IncludeExpression? innerInclude = secondaryLayer.Include;
secondaryLayer.Include = null;
@@ -377,7 +377,7 @@ private IncludeExpression RewriteIncludeForSecondaryEndpoint(IncludeExpression?
///
public QueryLayer ComposeForUpdate(TId id, ResourceType primaryResourceType)
{
- ArgumentGuard.NotNull(primaryResourceType, nameof(primaryResourceType));
+ ArgumentGuard.NotNull(primaryResourceType);
IImmutableSet includeElements = _targetedFields.Relationships
.Select(relationship => new IncludeElementExpression(relationship)).ToImmutableHashSet();
@@ -397,7 +397,7 @@ public QueryLayer ComposeForUpdate(TId id, ResourceType primaryResourceType
///
public IEnumerable<(QueryLayer, RelationshipAttribute)> ComposeForGetTargetedSecondaryResourceIds(IIdentifiable primaryResource)
{
- ArgumentGuard.NotNull(primaryResource, nameof(primaryResource));
+ ArgumentGuard.NotNull(primaryResource);
foreach (RelationshipAttribute relationship in _targetedFields.Relationships)
{
@@ -415,8 +415,8 @@ public QueryLayer ComposeForUpdate(TId id, ResourceType primaryResourceType
///
public QueryLayer ComposeForGetRelationshipRightIds(RelationshipAttribute relationship, ICollection rightResourceIds)
{
- ArgumentGuard.NotNull(relationship, nameof(relationship));
- ArgumentGuard.NotNull(rightResourceIds, nameof(rightResourceIds));
+ ArgumentGuard.NotNull(relationship);
+ ArgumentGuard.NotNull(rightResourceIds);
AttrAttribute rightIdAttribute = GetIdAttribute(relationship.RightType);
@@ -440,8 +440,8 @@ public QueryLayer ComposeForGetRelationshipRightIds(RelationshipAttribute relati
///
public QueryLayer ComposeForHasMany(HasManyAttribute hasManyRelationship, TId leftId, ICollection rightResourceIds)
{
- ArgumentGuard.NotNull(hasManyRelationship, nameof(hasManyRelationship));
- ArgumentGuard.NotNull(rightResourceIds, nameof(rightResourceIds));
+ ArgumentGuard.NotNull(hasManyRelationship);
+ ArgumentGuard.NotNull(rightResourceIds);
AttrAttribute leftIdAttribute = GetIdAttribute(hasManyRelationship.LeftType);
AttrAttribute rightIdAttribute = GetIdAttribute(hasManyRelationship.RightType);
@@ -476,15 +476,15 @@ public QueryLayer ComposeForHasMany(HasManyAttribute hasManyRelationship, T
protected virtual IImmutableSet GetIncludeElements(IImmutableSet includeElements,
ResourceType resourceType)
{
- ArgumentGuard.NotNull(resourceType, nameof(resourceType));
+ ArgumentGuard.NotNull(resourceType);
return _resourceDefinitionAccessor.OnApplyIncludes(resourceType, includeElements);
}
protected virtual FilterExpression? GetFilter(IReadOnlyCollection expressionsInScope, ResourceType resourceType)
{
- ArgumentGuard.NotNull(expressionsInScope, nameof(expressionsInScope));
- ArgumentGuard.NotNull(resourceType, nameof(resourceType));
+ ArgumentGuard.NotNull(expressionsInScope);
+ ArgumentGuard.NotNull(resourceType);
FilterExpression[] filters = expressionsInScope.OfType().ToArray();
FilterExpression? filter = LogicalExpression.Compose(LogicalOperator.And, filters);
@@ -494,8 +494,8 @@ protected virtual IImmutableSet GetIncludeElements(IIm
protected virtual SortExpression GetSort(IReadOnlyCollection expressionsInScope, ResourceType resourceType)
{
- ArgumentGuard.NotNull(expressionsInScope, nameof(expressionsInScope));
- ArgumentGuard.NotNull(resourceType, nameof(resourceType));
+ ArgumentGuard.NotNull(expressionsInScope);
+ ArgumentGuard.NotNull(resourceType);
SortExpression? sort = expressionsInScope.OfType().FirstOrDefault();
@@ -513,8 +513,8 @@ protected virtual SortExpression GetSort(IReadOnlyCollection ex
protected virtual PaginationExpression GetPagination(IReadOnlyCollection expressionsInScope, ResourceType resourceType)
{
- ArgumentGuard.NotNull(expressionsInScope, nameof(expressionsInScope));
- ArgumentGuard.NotNull(resourceType, nameof(resourceType));
+ ArgumentGuard.NotNull(expressionsInScope);
+ ArgumentGuard.NotNull(resourceType);
PaginationExpression? pagination = expressionsInScope.OfType().FirstOrDefault();
@@ -529,7 +529,7 @@ protected virtual PaginationExpression GetPagination(IReadOnlyCollection
public IncludeClauseBuilder(Expression source, LambdaScope lambdaScope, ResourceType resourceType)
: base(lambdaScope)
{
- ArgumentGuard.NotNull(source, nameof(source));
- ArgumentGuard.NotNull(resourceType, nameof(resourceType));
+ ArgumentGuard.NotNull(source);
+ ArgumentGuard.NotNull(resourceType);
_source = source;
_resourceType = resourceType;
@@ -30,7 +30,7 @@ public IncludeClauseBuilder(Expression source, LambdaScope lambdaScope, Resource
public Expression ApplyInclude(IncludeExpression include)
{
- ArgumentGuard.NotNull(include, nameof(include));
+ ArgumentGuard.NotNull(include);
return Visit(include, null);
}
diff --git a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaParameterNameFactory.cs b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaParameterNameFactory.cs
index 864b71c843..32691e05ab 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaParameterNameFactory.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaParameterNameFactory.cs
@@ -13,7 +13,7 @@ public sealed class LambdaParameterNameFactory
public LambdaParameterNameScope Create(string typeName)
{
- ArgumentGuard.NotNullNorEmpty(typeName, nameof(typeName));
+ ArgumentGuard.NotNullNorEmpty(typeName);
string parameterName = typeName.Camelize();
parameterName = EnsureNameIsUnique(parameterName);
diff --git a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaParameterNameScope.cs b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaParameterNameScope.cs
index 2bad41d310..031dae0a0f 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaParameterNameScope.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaParameterNameScope.cs
@@ -11,8 +11,8 @@ public sealed class LambdaParameterNameScope : IDisposable
public LambdaParameterNameScope(string name, LambdaParameterNameFactory owner)
{
- ArgumentGuard.NotNullNorEmpty(name, nameof(name));
- ArgumentGuard.NotNull(owner, nameof(owner));
+ ArgumentGuard.NotNullNorEmpty(name);
+ ArgumentGuard.NotNull(owner);
Name = name;
_owner = owner;
diff --git a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaScope.cs b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaScope.cs
index e5502031a3..52caddbe62 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaScope.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaScope.cs
@@ -23,8 +23,8 @@ private LambdaScope(LambdaParameterNameScope parameterNameScope, ParameterExpres
public static LambdaScope Create(LambdaParameterNameFactory nameFactory, Type elementType, Expression? accessorExpression)
{
- ArgumentGuard.NotNull(nameFactory, nameof(nameFactory));
- ArgumentGuard.NotNull(elementType, nameof(elementType));
+ ArgumentGuard.NotNull(nameFactory);
+ ArgumentGuard.NotNull(elementType);
LambdaParameterNameScope parameterNameScope = nameFactory.Create(elementType.Name);
ParameterExpression parameter = Expression.Parameter(elementType, parameterNameScope.Name);
@@ -35,7 +35,7 @@ public static LambdaScope Create(LambdaParameterNameFactory nameFactory, Type el
public LambdaScope WithAccessor(Expression accessorExpression)
{
- ArgumentGuard.NotNull(accessorExpression, nameof(accessorExpression));
+ ArgumentGuard.NotNull(accessorExpression);
return new LambdaScope(_parameterNameScope, Parameter, accessorExpression);
}
diff --git a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaScopeFactory.cs b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaScopeFactory.cs
index 9c13a63d28..6e4955cf40 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaScopeFactory.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaScopeFactory.cs
@@ -10,14 +10,14 @@ public sealed class LambdaScopeFactory
public LambdaScopeFactory(LambdaParameterNameFactory nameFactory)
{
- ArgumentGuard.NotNull(nameFactory, nameof(nameFactory));
+ ArgumentGuard.NotNull(nameFactory);
_nameFactory = nameFactory;
}
public LambdaScope CreateScope(Type elementType, Expression? accessorExpression = null)
{
- ArgumentGuard.NotNull(elementType, nameof(elementType));
+ ArgumentGuard.NotNull(elementType);
return LambdaScope.Create(_nameFactory, elementType, accessorExpression);
}
diff --git a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/OrderClauseBuilder.cs b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/OrderClauseBuilder.cs
index 7ae8dd2392..775893adcc 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/OrderClauseBuilder.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/OrderClauseBuilder.cs
@@ -17,8 +17,8 @@ public class OrderClauseBuilder : QueryClauseBuilder
public OrderClauseBuilder(Expression source, LambdaScope lambdaScope, Type extensionType)
: base(lambdaScope)
{
- ArgumentGuard.NotNull(source, nameof(source));
- ArgumentGuard.NotNull(extensionType, nameof(extensionType));
+ ArgumentGuard.NotNull(source);
+ ArgumentGuard.NotNull(extensionType);
_source = source;
_extensionType = extensionType;
@@ -26,7 +26,7 @@ public OrderClauseBuilder(Expression source, LambdaScope lambdaScope, Type exten
public Expression ApplyOrderBy(SortExpression expression)
{
- ArgumentGuard.NotNull(expression, nameof(expression));
+ ArgumentGuard.NotNull(expression);
return Visit(expression, null);
}
diff --git a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/QueryClauseBuilder.cs b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/QueryClauseBuilder.cs
index d04ff57e9d..fdbb3bc0c3 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/QueryClauseBuilder.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/QueryClauseBuilder.cs
@@ -14,7 +14,7 @@ public abstract class QueryClauseBuilder : QueryExpressionVisitor(Expression accessorExpression, Func action)
{
- ArgumentGuard.NotNull(accessorExpression, nameof(accessorExpression));
- ArgumentGuard.NotNull(action, nameof(action));
+ ArgumentGuard.NotNull(accessorExpression);
+ ArgumentGuard.NotNull(action);
LambdaScope backupScope = LambdaScope;
diff --git a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/QueryableBuilder.cs b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/QueryableBuilder.cs
index d571ac1dce..a497846285 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/QueryableBuilder.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/QueryableBuilder.cs
@@ -24,12 +24,12 @@ public class QueryableBuilder
public QueryableBuilder(Expression source, Type elementType, Type extensionType, LambdaParameterNameFactory nameFactory, IResourceFactory resourceFactory,
IModel entityModel, LambdaScopeFactory? lambdaScopeFactory = null)
{
- ArgumentGuard.NotNull(source, nameof(source));
- ArgumentGuard.NotNull(elementType, nameof(elementType));
- ArgumentGuard.NotNull(extensionType, nameof(extensionType));
- ArgumentGuard.NotNull(nameFactory, nameof(nameFactory));
- ArgumentGuard.NotNull(resourceFactory, nameof(resourceFactory));
- ArgumentGuard.NotNull(entityModel, nameof(entityModel));
+ ArgumentGuard.NotNull(source);
+ ArgumentGuard.NotNull(elementType);
+ ArgumentGuard.NotNull(extensionType);
+ ArgumentGuard.NotNull(nameFactory);
+ ArgumentGuard.NotNull(resourceFactory);
+ ArgumentGuard.NotNull(entityModel);
_source = source;
_elementType = elementType;
@@ -42,7 +42,7 @@ public QueryableBuilder(Expression source, Type elementType, Type extensionType,
public virtual Expression ApplyQuery(QueryLayer layer)
{
- ArgumentGuard.NotNull(layer, nameof(layer));
+ ArgumentGuard.NotNull(layer);
Expression expression = _source;
diff --git a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/SelectClauseBuilder.cs b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/SelectClauseBuilder.cs
index 690c49de24..1f1c10301a 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/SelectClauseBuilder.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/SelectClauseBuilder.cs
@@ -31,11 +31,11 @@ public SelectClauseBuilder(Expression source, LambdaScope lambdaScope, IModel en
IResourceFactory resourceFactory)
: base(lambdaScope)
{
- ArgumentGuard.NotNull(source, nameof(source));
- ArgumentGuard.NotNull(entityModel, nameof(entityModel));
- ArgumentGuard.NotNull(extensionType, nameof(extensionType));
- ArgumentGuard.NotNull(nameFactory, nameof(nameFactory));
- ArgumentGuard.NotNull(resourceFactory, nameof(resourceFactory));
+ ArgumentGuard.NotNull(source);
+ ArgumentGuard.NotNull(entityModel);
+ ArgumentGuard.NotNull(extensionType);
+ ArgumentGuard.NotNull(nameFactory);
+ ArgumentGuard.NotNull(resourceFactory);
_source = source;
_entityModel = entityModel;
@@ -46,7 +46,7 @@ public SelectClauseBuilder(Expression source, LambdaScope lambdaScope, IModel en
public Expression ApplySelect(FieldSelection selection, ResourceType resourceType)
{
- ArgumentGuard.NotNull(selection, nameof(selection));
+ ArgumentGuard.NotNull(selection);
Expression bodyInitializer = CreateLambdaBodyInitializer(selection, resourceType, LambdaScope, false);
@@ -272,7 +272,7 @@ private sealed class PropertySelector
public PropertySelector(PropertyInfo property, QueryLayer? nextLayer = null)
{
- ArgumentGuard.NotNull(property, nameof(property));
+ ArgumentGuard.NotNull(property);
Property = property;
NextLayer = nextLayer;
diff --git a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/SkipTakeClauseBuilder.cs b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/SkipTakeClauseBuilder.cs
index 4bb9bfd6f5..90109dbfec 100644
--- a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/SkipTakeClauseBuilder.cs
+++ b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/SkipTakeClauseBuilder.cs
@@ -17,8 +17,8 @@ public class SkipTakeClauseBuilder : QueryClauseBuilder