Skip to content

Commit 2c33407

Browse files
committed
chore: rename base document parser and builder
1 parent f719c59 commit 2c33407

18 files changed

+41
-475
lines changed

benchmarks/Serialization/JsonApiSerializer_Benchmarks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
// var genericProcessorFactoryMock = new Mock<IGenericProcessorFactory>();
3838

39-
// var documentBuilder = new DocumentBuilder(jsonApiContextMock.Object);
39+
// var documentBuilder = new BaseDocumentBuilder(jsonApiContextMock.Object);
4040
// _jsonApiSerializer = new JsonApiSerializer(jsonApiContextMock.Object, documentBuilder);
4141
// }
4242

src/JsonApiDotNetCore/Serialization/Client/RequestSerializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
namespace JsonApiDotNetCore.Serialization.Client
1212
{
1313
/// <summary>
14-
/// Client serializer implementation of <see cref="DocumentBuilder"/>
14+
/// Client serializer implementation of <see cref="BaseDocumentBuilder"/>
1515
/// Note that this implementation does not override the default implementation
1616
/// of <see cref="ResourceObjectBuilder.GetRelationshipData"/>.
1717
/// </summary>
18-
public class RequestSerializer : DocumentBuilder, IRequestSerializer
18+
public class RequestSerializer : BaseDocumentBuilder, IRequestSerializer
1919
{
2020
private readonly Dictionary<Type, List<AttrAttribute>> _attributesToSerializeCache;
2121
private readonly Dictionary<Type, List<RelationshipAttribute>> _relationshipsToSerializeCache;

src/JsonApiDotNetCore/Serialization/Client/ResponseDeserializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
namespace JsonApiDotNetCore.Serialization.Client
1010
{
1111
/// <summary>
12-
/// Client deserializer implementation of the <see cref="DocumentParser"/>
12+
/// Client deserializer implementation of the <see cref="BaseDocumentParser"/>
1313
/// </summary>
14-
public class ResponseDeserializer : DocumentParser, IResponseDeserializer
14+
public class ResponseDeserializer : BaseDocumentParser, IResponseDeserializer
1515
{
1616
public ResponseDeserializer(IContextEntityProvider provider) : base(provider) { }
1717

src/JsonApiDotNetCore/Serialization/Common/DocumentParser.cs renamed to src/JsonApiDotNetCore/Serialization/Common/BaseDocumentParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ namespace JsonApiDotNetCore.Serialization
1616
/// Abstract base class for deserialization. Deserializes JSON content into <see cref="Document"/>s
1717
/// And constructs instances of the resource(s) in the document body.
1818
/// </summary>
19-
public abstract class DocumentParser
19+
public abstract class BaseDocumentParser
2020
{
2121
protected readonly IContextEntityProvider _provider;
2222
protected Document _document;
2323

24-
protected DocumentParser(IContextEntityProvider provider)
24+
protected BaseDocumentParser(IContextEntityProvider provider)
2525
{
2626
_provider = provider;
2727
}

src/JsonApiDotNetCore/Serialization/Common/DocumentBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ namespace JsonApiDotNetCore.Serialization
99
/// Abstract base class for serialization that extends <see cref="ResourceObjectBuilder"/>.
1010
/// Converts entities in to <see cref="ResourceObject"/>s and wraps them in a <see cref="Document"/>.
1111
/// </summary>
12-
public abstract class DocumentBuilder : ResourceObjectBuilder
12+
public abstract class BaseDocumentBuilder : ResourceObjectBuilder
1313
{
14-
protected DocumentBuilder(IResourceGraph resourceGraph, IContextEntityProvider provider, SerializerSettings behaviour) : base(resourceGraph, provider, behaviour) { }
14+
protected BaseDocumentBuilder(IResourceGraph resourceGraph, IContextEntityProvider provider, SerializerSettings behaviour) : base(resourceGraph, provider, behaviour) { }
1515

1616
/// <summary>
1717
/// Builds a <see cref="Document"/> for <paramref name="entity"/>.

src/JsonApiDotNetCore/Serialization/Server/RequestDeserializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
namespace JsonApiDotNetCore.Serialization.Server
66
{
77
/// <summary>
8-
/// Server deserializer implementation of the <see cref="DocumentParser"/>
8+
/// Server deserializer implementation of the <see cref="BaseDocumentParser"/>
99
/// </summary>
10-
public class RequestDeserializer : DocumentParser, IJsonApiDeserializer
10+
public class RequestDeserializer : BaseDocumentParser, IJsonApiDeserializer
1111
{
1212
private readonly ITargetedFields _targetedFields;
1313

src/JsonApiDotNetCore/Serialization/Server/ResponseSerializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace JsonApiDotNetCore.Serialization.Server
1414
{
1515
/// <summary>
16-
/// Server serializer implementation of <see cref="DocumentBuilder"/>
16+
/// Server serializer implementation of <see cref="BaseDocumentBuilder"/>
1717
/// </summary>
1818
/// <remarks>
1919
/// Because in JsonApiDotNetCore every json:api request is associated with exactly one
@@ -23,7 +23,7 @@ namespace JsonApiDotNetCore.Serialization.Server
2323
/// </remarks>
2424
/// <typeparam name="TResource">Type of the resource associated with the scope of the request
2525
/// for which this serializer is used.</typeparam>
26-
public class ResponseSerializer<TResource> : DocumentBuilder, IJsonApiSerializer, IJsonApiDefaultSerializer
26+
public class ResponseSerializer<TResource> : BaseDocumentBuilder, IJsonApiSerializer, IJsonApiDefaultSerializer
2727
where TResource : class, IIdentifiable
2828
{
2929
private readonly Dictionary<Type, List<AttrAttribute>> _attributesToSerializeCache = new Dictionary<Type, List<AttrAttribute>>();

src/JsonApiDotNetCore/Serialization/wiki.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ Throughout the document and the code when referring to fields, members, object t
1010
`Document` class, [see document spec](https://jsonapi.org/format/#document-structure).
1111

1212
## Deserialization
13-
The previous `JsonApiDeSerializer` implementation is now split into a `RequestDeserializer` and `ResponseDeserializer`. Both inherit from `DocumentParser` which does the shared parsing.
13+
The previous `JsonApiDeSerializer` implementation is now split into a `RequestDeserializer` and `ResponseDeserializer`. Both inherit from `BaseDocumentParser` which does the shared parsing.
1414

15-
#### DocumentParser
15+
#### BaseDocumentParser
1616
Responsible for
1717
- Converting the serialized string content into an intance of the `Document` class.
1818
- Building instances of the corresponding resource class (eg `Article`) by going through the document's primary data (`Document.Data`, [see primary data spec](https://jsonapi.org/format/#document-top-level)).
1919

20-
Responsibility of any implementation-specific parsing is shifted through the abstract `DocumentParser.AfterProcessField()` method. This method is fired once each time after a `AttrAttribute` or `RelationshipAttribute` is processed. It allows a implementation of `DocumentParser` to intercept the parsing and add steps that are only required for clients/servers.
20+
Responsibility of any implementation-specific parsing is shifted through the abstract `BaseDocumentParser.AfterProcessField()` method. This method is fired once each time after a `AttrAttribute` or `RelationshipAttribute` is processed. It allows a implementation of `BaseDocumentParser` to intercept the parsing and add steps that are only required for clients/servers.
2121

2222
#### ResponseDeserializer
2323
The client deserializer complements the base deserialization by
@@ -30,7 +30,7 @@ For server-side parsing, no extra parsing needs to be done after the base deseri
3030
* The `AfterProcessField` method is overriden so that every attribute and relationship is registered with the `ITargetedFields` service after it is processed.
3131

3232
## Serialization
33-
Like with the deserializers, `JsonApiSerializer` is now split up into a `ResponseSerializer` and `RequestSerializer`. Both inherit from a shared `DocumentBuilder` class. Additionally, `DocumentBuilder` inherits from `ResourceObjectBuilder`, which is extended by `IncludedResourceObjectBuilder`.
33+
Like with the deserializers, `JsonApiSerializer` is now split up into a `ResponseSerializer` and `RequestSerializer`. Both inherit from a shared `BaseDocumentBuilder` class. Additionally, `BaseDocumentBuilder` inherits from `ResourceObjectBuilder`, which is extended by `IncludedResourceObjectBuilder`.
3434

3535
### ResourceObjectBuilder
3636
At the core of serialization is the `ResourceObject` class [see resource object spec](https://jsonapi.org/format/#document-resource-objects).
@@ -44,7 +44,7 @@ Additionally, client and server serializers also differ in how relationship memb
4444

4545
This time, the `GetRelationshipData()` method is not abstract, but virtual with a default implementation. This default implementation is to just create a `RelationshipData` with primary data (like `{"related-foo": { "data": { "id": 1" "type": "foobar"}}}`). Some implementations (server, included builder) need additional logic, others don't (client).
4646

47-
### DocumentBuilder
47+
### BaseDocumentBuilder
4848
Responsible for
4949
- Calling the base resource object serialization for one (or many) entities and wrapping the result in a `Document`.
5050

@@ -70,7 +70,7 @@ The server serializer is also responsible for adding top-level meta data and lin
7070

7171

7272
### IncludedResourceObjectBuilder
73-
Responsible for building the *included member* of a `Document`. Note that `IncludedResourceObjectBuilder` extends `ResourceObjectBuilder` and not `DocumentBuilder` because it does not need to build an entire document but only resource objects.
73+
Responsible for building the *included member* of a `Document`. Note that `IncludedResourceObjectBuilder` extends `ResourceObjectBuilder` and not `BaseDocumentBuilder` because it does not need to build an entire document but only resource objects.
7474

7575
Relationship *inclusion chains* are at the core of building the included member. For example, consider the request `articles?included=author.blogs.reviewers.favorite-food,reviewer.blogs.author.favorite-song`. It contains the following (complex) inclusion chains:
7676
1. `author.blogs.reviewers.favorite-food`

src/JsonApiDotNetCore/Services/Operations/Processors/CreateOpProcessor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public class CreateOpProcessor<T>
2323
public CreateOpProcessor(
2424
ICreateService<T, int> service,
2525
IOperationsDeserializer deserializer,
26-
IDocumentBuilder documentBuilder,
26+
IBaseDocumentBuilder documentBuilder,
2727
IResourceGraph resourceGraph
2828
) : base(service, deserializer, documentBuilder, resourceGraph)
2929
{ }
3030
}
3131

32-
public interface IDocumentBuilder
32+
public interface IBaseDocumentBuilder
3333
{
3434
ResourceObject GetData(ContextEntity contextEntity, IIdentifiable singleResource);
3535
}
@@ -39,13 +39,13 @@ public class CreateOpProcessor<T, TId> : ICreateOpProcessor<T, TId>
3939
{
4040
private readonly ICreateService<T, TId> _service;
4141
private readonly IOperationsDeserializer _deserializer;
42-
private readonly IDocumentBuilder _documentBuilder;
42+
private readonly IBaseDocumentBuilder _documentBuilder;
4343
private readonly IResourceGraph _resourceGraph;
4444

4545
public CreateOpProcessor(
4646
ICreateService<T, TId> service,
4747
IOperationsDeserializer deserializer,
48-
IDocumentBuilder documentBuilder,
48+
IBaseDocumentBuilder documentBuilder,
4949
IResourceGraph resourceGraph)
5050
{
5151
_service = service;

src/JsonApiDotNetCore/Services/Operations/Processors/GetOpProcessor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public GetOpProcessor(
3838
IGetByIdService<T, int> getById,
3939
IGetRelationshipService<T, int> getRelationship,
4040
IOperationsDeserializer deserializer,
41-
IDocumentBuilder documentBuilder,
41+
IBaseDocumentBuilder documentBuilder,
4242
IResourceGraph resourceGraph
4343
) : base(getAll, getById, getRelationship, deserializer, documentBuilder, resourceGraph)
4444
{ }
@@ -52,7 +52,7 @@ public class GetOpProcessor<T, TId> : IGetOpProcessor<T, TId>
5252
private readonly IGetByIdService<T, TId> _getById;
5353
private readonly IGetRelationshipService<T, TId> _getRelationship;
5454
private readonly IOperationsDeserializer _deserializer;
55-
private readonly IDocumentBuilder _documentBuilder;
55+
private readonly IBaseDocumentBuilder _documentBuilder;
5656
private readonly IResourceGraph _resourceGraph;
5757

5858
/// <inheritdoc />
@@ -61,7 +61,7 @@ public GetOpProcessor(
6161
IGetByIdService<T, TId> getById,
6262
IGetRelationshipService<T, TId> getRelationship,
6363
IOperationsDeserializer deserializer,
64-
IDocumentBuilder documentBuilder,
64+
IBaseDocumentBuilder documentBuilder,
6565
IResourceGraph resourceGraph)
6666
{
6767
_getAll = getAll;

src/JsonApiDotNetCore/Services/Operations/Processors/RemoveOpProcessor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class RemoveOpProcessor<T> : RemoveOpProcessor<T, int>, IRemoveOpProcesso
2222
public RemoveOpProcessor(
2323
IDeleteService<T, int> service,
2424
IOperationsDeserializer deserializer,
25-
IDocumentBuilder documentBuilder,
25+
IBaseDocumentBuilder documentBuilder,
2626
IResourceGraph resourceGraph
2727
) : base(service, deserializer, documentBuilder, resourceGraph)
2828
{ }
@@ -33,13 +33,13 @@ public class RemoveOpProcessor<T, TId> : IRemoveOpProcessor<T, TId>
3333
{
3434
private readonly IDeleteService<T, TId> _service;
3535
private readonly IOperationsDeserializer _deserializer;
36-
private readonly IDocumentBuilder _documentBuilder;
36+
private readonly IBaseDocumentBuilder _documentBuilder;
3737
private readonly IResourceGraph _resourceGraph;
3838

3939
public RemoveOpProcessor(
4040
IDeleteService<T, TId> service,
4141
IOperationsDeserializer deserializer,
42-
IDocumentBuilder documentBuilder,
42+
IBaseDocumentBuilder documentBuilder,
4343
IResourceGraph resourceGraph)
4444
{
4545
_service = service;

src/JsonApiDotNetCore/Services/Operations/Processors/UpdateOpProcessor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class UpdateOpProcessor<T> : UpdateOpProcessor<T, int>, IUpdateOpProcesso
2222
public UpdateOpProcessor(
2323
IUpdateService<T, int> service,
2424
IOperationsDeserializer deserializer,
25-
IDocumentBuilder documentBuilder,
25+
IBaseDocumentBuilder documentBuilder,
2626
IResourceGraph resourceGraph
2727
) : base(service, deserializer, documentBuilder, resourceGraph)
2828
{ }
@@ -33,13 +33,13 @@ public class UpdateOpProcessor<T, TId> : IUpdateOpProcessor<T, TId>
3333
{
3434
private readonly IUpdateService<T, TId> _service;
3535
private readonly IOperationsDeserializer _deserializer;
36-
private readonly IDocumentBuilder _documentBuilder;
36+
private readonly IBaseDocumentBuilder _documentBuilder;
3737
private readonly IResourceGraph _resourceGraph;
3838

3939
public UpdateOpProcessor(
4040
IUpdateService<T, TId> service,
4141
IOperationsDeserializer deserializer,
42-
IDocumentBuilder documentBuilder,
42+
IBaseDocumentBuilder documentBuilder,
4343
IResourceGraph resourceGraph)
4444
{
4545
_service = service;

test/UnitTests/Builders/DocumentBuilderBehaviour_Tests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
//namespace UnitTests.Builders
99
//{
10-
// public class DocumentBuilderBehaviour_Tests
10+
// public class BaseDocumentBuilderBehaviour_Tests
1111
// {
1212

1313
// [Theory]
@@ -60,8 +60,8 @@
6060
// var httpContextAccessorMock = new Mock<IHttpContextAccessor>();
6161
// httpContextAccessorMock.SetupGet(m => m.HttpContext).Returns(httpContext);
6262

63-
// var sut = new DocumentBuilderOptionsProvider(jsonApiContextMock.Object, httpContextAccessorMock.Object);
64-
// var documentBuilderOptions = sut.GetDocumentBuilderOptions();
63+
// var sut = new BaseDocumentBuilderOptionsProvider(jsonApiContextMock.Object, httpContextAccessorMock.Object);
64+
// var documentBuilderOptions = sut.GetBaseDocumentBuilderOptions();
6565

6666
// Assert.Equal(omitsNulls, documentBuilderOptions.OmitNullValuedAttributes);
6767
// }

0 commit comments

Comments
 (0)