Skip to content

Commit 7b8250b

Browse files
authored
Update master with dev-v4 (#591)
* Feat/context decoupling (#557) * feat: started work on decoupling * feat: add total record count * feat: green tests, new managers * feat: changed startup * feat: most annoying commit of my life, rewriting dozens of controllers * feat: rename: QueryManager -> RequestManager, deeper seperation of concerns, 12 tests running... * feat: removed JsonApiContext dependency from controller, fixed namespaced tests * feat: decoupled controllers * chore: renamed resourcegraphbuilder, took out some extensions, made benchmarks work again * feat: json api context decoupling mroe and more * chore: readded solutions * feat: upgrading to 2.2, setting contextentity in middleware * fix: removed outdated authorization test * fix: requestmeta tests * fix: some acceptance tests * fix: pagination * fix: total records in meta * feat: introduced JsonApiActionFilter * fix: more tests * Feat/serializer context decoupling (#558) * feat: started work on decoupling * feat: add total record count * feat: green tests, new managers * feat: changed startup * feat: most annoying commit of my life, rewriting dozens of controllers * feat: rename: QueryManager -> RequestManager, deeper seperation of concerns, 12 tests running... * feat: removed JsonApiContext dependency from controller, fixed namespaced tests * feat: decoupled controllers * chore: renamed resourcegraphbuilder, took out some extensions, made benchmarks work again * feat: json api context decoupling mroe and more * chore: readded solutions * feat: upgrading to 2.2, setting contextentity in middleware * fix: removed outdated authorization test * fix: requestmeta tests * fix: some acceptance tests * fix: pagination * fix: total records in meta * feat: introduced JsonApiActionFilter * fix: more tests * feat: decoupled deserializer and serializer * chore: remove / cleanup old serializers * chore: remove operation services * tests: unit tests client/server (de)serializers * chore: various edits to run tests * fix: rm dasherized resolver * chore: remove JsonApiContext and corresponding interface * chore: reorganize namespaces * chore: rm old tests * chore: rm unused document builder * chore: add comments to deserialization classes * chore: add comments * chore: rm IJsonApiContext from sort attr instantiation * feat: (re)introduced omit null value behaviour (and now omit default value behaviour too) using a serializer options provider * chore: remove more jsonapicontext references * chore: minor renames, add wiki for serialization * chore: improve wiki * chore: wiki * chore: wiki * chore: add a bunch of comments, renamed a few services * chore: wired up nested sparse field selection * chore: wired up omit behaviour * chore: prettied some comments * chore: remove (almost) all references to jsonapicontext in unit tests project * chore: removed last bits of jsonapicontext * fix: tests serialization passing again * chore: rename included query service to include query service * chore: improve comment * chore: improve comment * chore: delete jsonapicontext tests * chore: remove space * test: email config * chore: rename client / server (de)serializer to request/response (de)serializer * chore: rename client / server (de)serializer to request/response (de)serializer * feat: introduce IQueryParameter * chore: move request/response (de)serializer to client/server namespace for easier future isolation * chore: update namespaces * chore: rm textfile * chore: fixing failing unit tests * chore: rename query services, adjustment namespace * chore: reorganised test files for serialization, added relationship path serialization tests * feat: request relationship in response serializer * chore: wired up response serializer in formatter layer * feat: IGetRelationshipService now returns TResource instead of object, which decouples it from serializers requirements * fix: support for serving document of resource type different from request resource, as required by resourceservice.getrelationships() * chore: simplified linkbuilders * chore: several fixes for e2e tests * fix: various e2e tests, decoupled service layer from serialization format * fix: inclusion edgecase * chore: fix error formatting tests * chore: naming consistency sparsefield and include query services * chore: various adjustments to make e2e test project build and pass again * chore: fix build various e2e tests * chore: fix build various e2e tests * fix: e2e test Can_Include_Nested_Relationships * fix: e2e test Can_Patch_Entity * fix: e2e test Patch_Entity_With_HasMany_Does_Not_Include_Relationships * fix: e2e test Can_Create_Entity_With_Client_Defined_Id_If_Configured * chore: rename base document parser and builder * fix: e2e test Can_Create_Guid_Identifiable_Entity_With_Client_Defined_Id_If_Configured * fix: unit tests various * feat: reorganisation inheritance serialization layer * fix: unit tests after inheritance update * fix: wire up correct resource object builder implementation in serializers * fix: e2e remaining CreatingDataTests * chore: refactor creatingdata tests * fix: e2e test paging * fix: e2e controller tests * chore: wiring up new resource object builders to dependency graph * chore: response resource object builder unit test, restored repo and resourcedef unit tests * chore: finishing touches comments serialization * Feat/serialization wiki (#561) * docs: add decoupling architecture, wiki folder * docs: add v4 wiki * chore: restructure of intro * chore: v4 * chore: remove example projects * chore: remove bulk related code * chore: remove bulk related tests * chore: remove logic related to ER splitting * chore: remove split test project * chore: update other test projects to pass again * chore: fix typo * Added value types support to the filters isnull & isnotnull. (#549) (#573) * fix: missing reference' * chore: fix spacing * feat: draft of reflectively retrieving all query parameters * chore: scaffolded required query parameter service * chore: migrate parsing logic sparsefields * chore: reorganising test models in unit test project * tests: add includeservicetests * chore: migrate parsing logic of filter to filter service * chore: prefix private variables underscore in editorconfig * feat: common query parameter base service * feat: interfaces of query parameter services * feat: sort service and filter service * feat: wired up filter and sort service with refactored data and repo layer * feat: new omit default and null value services, wired them up in serialization * feat: refactored remaining query services, introduced new queryparser for better extensibility * feat: wired up new query parser in action filter, slimmed down current request * chores: various test fixes, minor fixes * chores: various test fixes, minor fixes * chore: add more unit tests * docs: query parameters wiki * fix: typo * chore: rename, update wiki * chore: various minor fixes, PR self review * feat: added new overload in query controllers (#580) * Cleaning repository of remaining business logic (#579) * feat: first draft of attribute diffing in repo layer * chore: remove EF Core-specific DetachRelationshipPointers from repository interface * chore: replace SingleOrDefaultAsync with FirstOrDefaultAsync for increased performance * chore: decoupled ResourceDefinition from repository layer in Filter implementation * chore: remove updatevaluehelper * fix: Can_Patch_Entity test * fix: EntityResourceTest, variable name updatedFields -> targetedFields * chore: add comment referencing to github issue * chore: rename pageManager -> pageService * chore: remove deprecations * fix: undid wrong replace all of BeforeUpdate -> pageService * chore: remove unreferenced method in ResponseSerializer * Allow for multiple naming conventions (camelCase vs kebab-case) (#581) * feat: draft of DI-registered ApplicationModelConvention * feat: injectable IResourceNameFormatter and IJsonApiRoutingCOnvention now working * test: kebab vs camelcase configuration * feat: kebab vs camel completed * chore: spacing * style: spacing * refactor: share logic between resource name formatter implementations * docs: resource formatter comments * docs: comments improved * chore: remove static reference to ResourceNameFormatter * chore: reviewer fixes * style: removed spacing * style: removed spacing * fix: #583 * feat: throw error on deeply nested selections * docs: add extra comment * chore: processed Wisepotatos review * Separation of concerns ResourceGraph (#586) * refactor: move HasManyThrough GetValue and SetValue logic to HasManyThroughAttribute * feat: remove GetPublicAttributeName from ResourceGraph and remove dependency on ResourceGraph of controller layer * style: spacing in BaseJsonApiController<,> * feat: remove GetEntityFromControllerName from ResourceGraph * feat: remove GetInverseRelationship from ResourceGraph * feat: decouples UsesDbContext from ResourceGraph and introduces decoupled application instantation * chore: remove redundant injections of IResourceGraph * refactor: merge IContextEntityProvider and IFieldsExplorer into IResourceGraphExplorer * style: cleanup of variable names * chore: various fixes for PR review, mostly style and variable naming * style: rename IResourceGraphExplorer back to IResourceGraph, consitent usage of IContextEntityProvider * docs: comments for DefaultActionFilter and DefaultTypeFilter * docs: comments JsonApiApplicationBuilder * style: consistent variable naming| * chore: wire up IControllerResourceMapping * refactor: routing convention implements controller mapping interface * Update variable / class naming conventions (#589) style: DefaultResourceRepository and DefaultEntityService as consie 833da6a style: rename old repository interfaces 519513d style: ContextEntity --> ResourceContext d038582 style: rename Entity to Resource f2e411c style: TEntity --> TResource 3af6f9b style: DependentType, PrincipalType --> RightType, LeftType ce08b4f style: replaced principal with left and dependent with right whenev b162519 chore: remove redundant bindings throughout entire codebase e509956 refactor: regroupe hook container and executors 48495d3 style: IGenericProcessor --> IHasManyThroughUpdateHelper f19e606 chore: delete rogue file 7d235ab style: rename GenericProcessorFactory --> GenericServiceFactory. 6a186a5 chore: fix NoEntityFrameworkExample project 354a1be * chore: process feedback * Fix DiscoveryTests and NoEntityFrameworkExample project/tests (#590) * fix: DiscoveryTests project * fix: NoEntityFrameworkExample project + tests * Simplify DefaultResourceService constructor (#592) * refactor: simplify resource service constructor with IEnumerable<IQueryParameterService> * feat: FirstOrDefault<TQueryParameterService>() extension method * style: remove whitespace * fix: fix build.sh * fix: appveyor build * fix: hotfix constructor ServiceDiscoveryFacadeTests * upgrade to .net core 2.1 * .NET core 2.1 -> 2.2 (#594) * merge: merge into correct email: * feat: upgrade to 2.2 * chore: spacing fix * chore: revert silencing error * chore: small spacing fix * chore: rm whitespace * fix: public setters to allow testing * .NET Core 2.2 -> 3.0 (#597) * merge: merge into correct email: * feat: upgrade to 2.2 * chore: spacing fix * chore: revert silencing error * chore: small spacing fix * chore: remove unneeeded dependencies * chore: fix framework dependencies * chore: updates * chore: test fixes * chore: start integration tests * chore: cleanup name of dertest * chore: start of getRepostory * chore: upgrade testsdk version + xunit version * feat: use template in version control of packages in integrationTests * feat: unit test assemblyinfo add, port old test to integration (attribute updater) * docs: add version compatibility * chore: add asterisk for version number * feat: port defaultentityrepositorytests to integration tests * chore: should add logging, done. * tests: bad response from tests * chore: fixes for lang version and making ifs more noticable * fix: fix routing issue with upgrade to enableendpointrouting * chore: HostEnvironment -> IWebHostEnvironment * chore: act -> Act, assert -> Assert, arrange -> Arrange * chore: fix tests * chore: re-add unit test for defaultentityrepository for test IAsyncQueryProvider that's actually a List * refactor: make if statements more conscise * chore: final stretch * tests: revert for good tests * Revert "tests: revert for good tests" This reverts commit 98b1119. * Revert "chore: final stretch" This reverts commit d6f763f. * fix: client generated id tests * fix: create data tests with workaround for efcore 3.0 bug * refactor: DetachRelationships usage of is operator * fix: move MetaStartup to other assembly as .net core 3 bug workaround * fix: UpdatingRelationshipTests locally evaluated queries error * feat: reintroduced generic processor (RepositoryRelationshipUpdateHelper) to fix locally evaluated expressions issue * feat: full sql support for UpdateRelationshipsAsync using expression trees * fix: DeletingDataTest * fix: paging test * fix: paging unit tests * chore: remove RE-split models, duplicate models to NoEntityFrameworkExample * fix: NoEntityFrameworkExample tests fixed by workaround assembly problem * fix: connection string e2e test projects * chore: minor cleanup * chore: minor cleanup * chore: cleanup * chore: update travis.yml * chore: retry travis.yml * chore: retry .travis.yml * chore: appveyor.yml * fix: CI builds * chore: attempt to fix travis.yml * chore: spacing * chore: postgres version bump * chore: fix readme + downgrade postgres * chore: revert
1 parent 676b654 commit 7b8250b

File tree

488 files changed

+14039
-16075
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

488 files changed

+14039
-16075
lines changed

.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,14 @@ charset = utf-8
1212

1313
[*.{csproj,props}]
1414
indent_size = 2
15+
16+
[*.{cs,vb}]
17+
dotnet_naming_rule.private_members_with_underscore.symbols = private_fields
18+
dotnet_naming_rule.private_members_with_underscore.style = prefix_underscore
19+
dotnet_naming_rule.private_members_with_underscore.severity = suggestion
20+
21+
dotnet_naming_symbols.private_fields.applicable_kinds = field
22+
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
23+
24+
dotnet_naming_style.prefix_underscore.capitalization = camel_case
25+
dotnet_naming_style.prefix_underscore.required_prefix = _

.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
language: csharp
2-
dist: trusty
32
sudo: required
43
services:
54
- postgresql
65
before_script:
76
- psql -c 'create database JsonApiDotNetCoreExample;' -U postgres
87
mono: none
9-
dotnet: 2.1.300 # https://www.microsoft.com/net/download/linux
8+
dotnet: 3.0.100 # https://www.microsoft.com/net/download/linux
109
branches:
1110
only:
1211
- master

Build.ps1

-6
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ CheckLastExitCode
3535
dotnet test ./test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj
3636
CheckLastExitCode
3737

38-
dotnet test ./test/OperationsExampleTests/OperationsExampleTests.csproj
39-
CheckLastExitCode
40-
41-
dotnet test ./test/ResourceEntitySeparationExampleTests/ResourceEntitySeparationExampleTests.csproj
42-
CheckLastExitCode
43-
4438
dotnet test ./test/DiscoveryTests/DiscoveryTests.csproj
4539
CheckLastExitCode
4640

Directory.Build.props

+15-22
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
11
<Project>
2-
32
<PropertyGroup>
4-
<NetCoreAppVersion>netcoreapp2.0</NetCoreAppVersion>
5-
<NetStandardVersion>netstandard2.0</NetStandardVersion>
6-
7-
<AspNetCoreVersion>2.1.0</AspNetCoreVersion>
8-
9-
<MicrosoftLoggingVersion>2.1.0</MicrosoftLoggingVersion>
10-
<MicrosoftConfigurationVersion>2.1.0</MicrosoftConfigurationVersion>
11-
<MicrosoftOptionsVersion>2.1.0</MicrosoftOptionsVersion>
12-
13-
<EFCoreVersion>2.1.0</EFCoreVersion>
14-
<EFCoreToolsVersion>2.1.0</EFCoreToolsVersion>
15-
16-
<NpgsqlVersion>4.0.0</NpgsqlVersion>
17-
<NpgsqlPostgreSQLVersion>2.1.0</NpgsqlPostgreSQLVersion>
18-
3+
<NetCoreAppVersion>netcoreapp3.0</NetCoreAppVersion>
4+
<NetStandardVersion>netstandard2.1</NetStandardVersion>
5+
<AspNetCoreVersion>3.*</AspNetCoreVersion>
6+
<MicrosoftLoggingVersion>3.*</MicrosoftLoggingVersion>
7+
<MicrosoftConfigurationVersion>3.*</MicrosoftConfigurationVersion>
8+
<MicrosoftOptionsVersion>3.*</MicrosoftOptionsVersion>
9+
<EFCoreVersion>3.*</EFCoreVersion>
10+
<EFCoreToolsVersion>3.*</EFCoreToolsVersion>
11+
<NpgsqlVersion>4.1.1</NpgsqlVersion>
12+
<NpgsqlPostgreSQLVersion>3.0.1</NpgsqlPostgreSQLVersion>
1913
<TuplesVersion>4.5.0</TuplesVersion>
2014
</PropertyGroup>
2115

2216
<!-- Test Project Dependencies -->
2317
<PropertyGroup>
24-
<TestSdkVersion>15.7.2</TestSdkVersion>
25-
<XUnitVersion>2.3.1</XUnitVersion>
26-
<BogusVersion>22.1.2</BogusVersion>
27-
<MoqVersion>4.8.3</MoqVersion>
18+
<TestSdkVersion>16.3.0</TestSdkVersion>
19+
<XUnitVersion>2.4.1</XUnitVersion>
20+
<BogusVersion>28.4.1</BogusVersion>
21+
<MoqVersion>4.13.1</MoqVersion>
2822
</PropertyGroup>
29-
30-
</Project>
23+
</Project>

JsonApiDotnetCore.sln

+195-241
Large diffs are not rendered by default.

README.md

+21-9
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ See [the documentation](https://json-api-dotnet.github.io/#/) for detailed usage
4242

4343
```csharp
4444
public class Article : Identifiable
45-
{
45+
{
4646
[Attr("name")]
4747
public string Name { get; set; }
4848
}
@@ -53,10 +53,12 @@ public class Article : Identifiable
5353
```csharp
5454
public class ArticlesController : JsonApiController<Article>
5555
{
56-
public ArticlesController(
57-
IJsonApiContext jsonApiContext,
58-
IResourceService<Article> resourceService)
59-
: base(jsonApiContext, resourceService) { }
56+
public ArticlesController(
57+
IJsonApiOptions jsonApiOptions,
58+
IResourceService<Article> resourceService,
59+
ILoggerFactory loggerFactory)
60+
: base(jsonApiOptions, resourceService, loggerFactory)
61+
{ }
6062
}
6163
```
6264

@@ -79,19 +81,18 @@ public class Startup
7981

8082
### Development
8183

82-
Restore all nuget packages with:
84+
Restore all NuGet packages with:
8385

8486
```bash
8587
dotnet restore
8688
```
8789

8890
#### Testing
8991

90-
Running tests locally requires access to a postgresql database.
91-
If you have docker installed, this can be propped up via:
92+
Running tests locally requires access to a PostgreSQL database. If you have docker installed, this can be propped up via:
9293

9394
```bash
94-
docker run --rm --name jsonapi-dotnet-core-testing -e POSTGRES_DB=JsonApiDotNetCoreExample -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres
95+
docker run --rm --name jsonapi-dotnet-core-testing -e POSTGRES_DB=JsonApiDotNetCoreExample -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:12.0
9596
```
9697

9798
And then to run the tests:
@@ -107,3 +108,14 @@ Sometimes the compiled files can be dirty / corrupt from other branches / failed
107108
```bash
108109
dotnet clean
109110
```
111+
112+
## Compatibility
113+
114+
A lot of changes were introduced in v4.0.0, the following chart should help you with compatibility issues between .NET Core versions
115+
116+
| .NET Core Version | JADNC Version |
117+
| ----------------- | ------------- |
118+
| 2.* | v3.* |
119+
| 3.* | v4.* |
120+
121+

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
version: '{build}'
2-
os: Visual Studio 2017
2+
os: Visual Studio 2019
33

44
environment:
55
POSTGRES_PORT: tcp://localhost:5432

benchmarks/LinkBuilder/LinkBuilder_ GetNamespaceFromPath_Benchmarks.cs

+36-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
using BenchmarkDotNet.Attributes;
22
using BenchmarkDotNet.Attributes.Exporters;
33
using BenchmarkDotNet.Attributes.Jobs;
4+
using System;
45

56
namespace Benchmarks.LinkBuilder
67
{
7-
[MarkdownExporter, SimpleJob(launchCount : 3, warmupCount : 10, targetCount : 20), MemoryDiagnoser]
8+
[MarkdownExporter, SimpleJob(launchCount: 3, warmupCount: 10, targetCount: 20), MemoryDiagnoser]
89
public class LinkBuilder_GetNamespaceFromPath_Benchmarks
910
{
1011
private const string PATH = "/api/some-really-long-namespace-path/resources/current/articles";
@@ -14,7 +15,7 @@ public class LinkBuilder_GetNamespaceFromPath_Benchmarks
1415
public void UsingSplit() => GetNamespaceFromPath_BySplitting(PATH, ENTITY_NAME);
1516

1617
[Benchmark]
17-
public void Current() => GetNameSpaceFromPath_Current(PATH, ENTITY_NAME);
18+
public void Current() => GetNameSpaceFromPathCurrent(PATH, ENTITY_NAME);
1819

1920
public static string GetNamespaceFromPath_BySplitting(string path, string entityName)
2021
{
@@ -32,7 +33,38 @@ public static string GetNamespaceFromPath_BySplitting(string path, string entity
3233
return nSpace;
3334
}
3435

35-
public static string GetNameSpaceFromPath_Current(string path, string entityName)
36-
=> JsonApiDotNetCore.Builders.LinkBuilder.GetNamespaceFromPath(path, entityName);
36+
public static string GetNameSpaceFromPathCurrent(string path, string entityName)
37+
{
38+
39+
var entityNameSpan = entityName.AsSpan();
40+
var pathSpan = path.AsSpan();
41+
const char delimiter = '/';
42+
for (var i = 0; i < pathSpan.Length; i++)
43+
{
44+
if (pathSpan[i].Equals(delimiter))
45+
{
46+
var nextPosition = i + 1;
47+
if (pathSpan.Length > i + entityNameSpan.Length)
48+
{
49+
var possiblePathSegment = pathSpan.Slice(nextPosition, entityNameSpan.Length);
50+
if (entityNameSpan.SequenceEqual(possiblePathSegment))
51+
{
52+
// check to see if it's the last position in the string
53+
// or if the next character is a /
54+
var lastCharacterPosition = nextPosition + entityNameSpan.Length;
55+
56+
if (lastCharacterPosition == pathSpan.Length || pathSpan.Length >= lastCharacterPosition + 2 && pathSpan[lastCharacterPosition].Equals(delimiter))
57+
{
58+
return pathSpan.Slice(0, i).ToString();
59+
}
60+
}
61+
}
62+
}
63+
}
64+
65+
return string.Empty;
66+
67+
68+
}
3769
}
3870
}

benchmarks/Program.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using BenchmarkDotNet.Running;
1+
using BenchmarkDotNet.Running;
22
using Benchmarks.JsonApiContext;
33
using Benchmarks.LinkBuilder;
44
using Benchmarks.Query;
@@ -9,8 +9,8 @@ namespace Benchmarks {
99
class Program {
1010
static void Main(string[] args) {
1111
var switcher = new BenchmarkSwitcher(new[] {
12-
typeof(JsonApiDeserializer_Benchmarks),
13-
typeof(JsonApiSerializer_Benchmarks),
12+
typeof(JsonApideserializer_Benchmarks),
13+
//typeof(JsonApiSerializer_Benchmarks),
1414
typeof(QueryParser_Benchmarks),
1515
typeof(LinkBuilder_GetNamespaceFromPath_Benchmarks),
1616
typeof(ContainsMediaTypeParameters_Benchmarks),

benchmarks/Query/QueryParser_Benchmarks.cs

+7-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using BenchmarkDotNet.Attributes.Jobs;
66
using JsonApiDotNetCore.Configuration;
77
using JsonApiDotNetCore.Internal;
8+
using JsonApiDotNetCore.Managers.Contracts;
89
using JsonApiDotNetCore.Models;
910
using JsonApiDotNetCore.Services;
1011
using Microsoft.AspNetCore.Http.Internal;
@@ -21,14 +22,14 @@ public class QueryParser_Benchmarks {
2122
private const string DESCENDING_SORT = "-" + ATTRIBUTE;
2223

2324
public QueryParser_Benchmarks() {
24-
var controllerContextMock = new Mock<IControllerContext>();
25-
controllerContextMock.Setup(m => m.RequestEntity).Returns(new ContextEntity {
25+
var requestMock = new Mock<IRequestContext>();
26+
requestMock.Setup(m => m.GetRequestResource()).Returns(new ResourceContext {
2627
Attributes = new List<AttrAttribute> {
2728
new AttrAttribute(ATTRIBUTE, ATTRIBUTE)
2829
}
2930
});
3031
var options = new JsonApiOptions();
31-
_queryParser = new BenchmarkFacade(controllerContextMock.Object, options);
32+
_queryParser = new BenchmarkFacade(requestMock.Object, options);
3233
}
3334

3435
[Benchmark]
@@ -56,10 +57,10 @@ private void Run(int iterations, Action action) {
5657
}
5758

5859
// this facade allows us to expose and micro-benchmark protected methods
59-
private class BenchmarkFacade : QueryParser {
60+
private class BenchmarkFacade : QueryParameterDiscovery {
6061
public BenchmarkFacade(
61-
IControllerContext controllerContext,
62-
JsonApiOptions options) : base(controllerContext, options) { }
62+
IRequestContext currentRequest,
63+
JsonApiOptions options) : base(currentRequest, options) { }
6364

6465
public void _ParseSortParameters(string value) => base.ParseSortParameters(value);
6566
}

benchmarks/RequestMiddleware/ContainsMediaTypeParameters_Benchmarks.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ContainsMediaTypeParameters_Benchmarks
1414

1515
[Benchmark]
1616
public void Current()
17-
=> JsonApiDotNetCore.Middleware.RequestMiddleware.ContainsMediaTypeParameters(MEDIA_TYPE);
17+
=> JsonApiDotNetCore.Middleware.CurrentRequestMiddleware.ContainsMediaTypeParameters(MEDIA_TYPE);
1818

1919
private bool UsingSplitImpl(string mediaType)
2020
{

benchmarks/Serialization/JsonApiDeserializer_Benchmarks.cs

+14-9
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
using BenchmarkDotNet.Attributes.Exporters;
55
using JsonApiDotNetCore.Builders;
66
using JsonApiDotNetCore.Configuration;
7-
using JsonApiDotNetCore.Internal.Generics;
7+
using JsonApiDotNetCore.Managers.Contracts;
88
using JsonApiDotNetCore.Models;
99
using JsonApiDotNetCore.Serialization;
10+
using JsonApiDotNetCore.Serialization.Contracts;
11+
1012
using JsonApiDotNetCore.Services;
1113
using Moq;
1214
using Newtonsoft.Json;
1315
using Newtonsoft.Json.Serialization;
14-
15-
namespace Benchmarks.Serialization {
16+
namespace Benchmarks.Serialization
17+
{
1618
[MarkdownExporter]
17-
public class JsonApiDeserializer_Benchmarks {
19+
public class JsonApideserializer_Benchmarks {
1820
private const string TYPE_NAME = "simple-types";
1921
private static readonly string Content = JsonConvert.SerializeObject(new Document {
2022
Data = new ResourceObject {
@@ -29,28 +31,31 @@ public class JsonApiDeserializer_Benchmarks {
2931
}
3032
});
3133

32-
private readonly JsonApiDeSerializer _jsonApiDeSerializer;
34+
private readonly JsonApideserializer _jsonApideserializer;
3335

34-
public JsonApiDeserializer_Benchmarks() {
36+
public JsonApideserializer_Benchmarks() {
3537
var resourceGraphBuilder = new ResourceGraphBuilder();
3638
resourceGraphBuilder.AddResource<SimpleType>(TYPE_NAME);
3739
var resourceGraph = resourceGraphBuilder.Build();
40+
var currentRequestMock = new Mock<IRequestContext>();
41+
42+
currentRequestMock.Setup(m => m.GetUpdatedAttributes()).Returns(new Dictionary<AttrAttribute, object>());
3843

3944
var jsonApiContextMock = new Mock<IJsonApiContext>();
4045
jsonApiContextMock.SetupAllProperties();
4146
jsonApiContextMock.Setup(m => m.ResourceGraph).Returns(resourceGraph);
42-
jsonApiContextMock.Setup(m => m.AttributesToUpdate).Returns(new Dictionary<AttrAttribute, object>());
47+
jsonApiContextMock.Setup(m => m.RequestManager.GetUpdatedAttributes()).Returns(new Dictionary<AttrAttribute, object>());
4348

4449
var jsonApiOptions = new JsonApiOptions();
4550
jsonApiOptions.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
4651
jsonApiContextMock.Setup(m => m.Options).Returns(jsonApiOptions);
4752

4853

49-
_jsonApiDeSerializer = new JsonApiDeSerializer(jsonApiContextMock.Object);
54+
_jsonApideserializer = new JsonApideserializer(jsonApiContextMock.Object, currentRequestMock.Object);
5055
}
5156

5257
[Benchmark]
53-
public object DeserializeSimpleObject() => _jsonApiDeSerializer.Deserialize<SimpleType>(Content);
58+
public object DeserializeSimpleObject() => _jsonApideserializer.Deserialize<SimpleType>(Content);
5459

5560
private class SimpleType : Identifiable {
5661
[Attr("name")]

0 commit comments

Comments
 (0)