Skip to content

Commit c68a5c6

Browse files
author
Bart Koelman
committed
Switched to STJ in attribute change tracking. This used to take options into account, which is unneeded because we only care about whether there's a diff, not so much what that diff looks like. And we don't expect self-references here (it would have crashed in the past, and will now too).
1 parent a7ffbcd commit c68a5c6

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/JsonApiDotNetCore/Resources/ResourceChangeTracker.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System.Collections.Generic;
2+
using System.Text.Json;
23
using JetBrains.Annotations;
34
using JsonApiDotNetCore.Configuration;
45
using JsonApiDotNetCore.Resources.Annotations;
5-
using Newtonsoft.Json;
66

77
namespace JsonApiDotNetCore.Resources
88
{
@@ -11,21 +11,18 @@ namespace JsonApiDotNetCore.Resources
1111
public sealed class ResourceChangeTracker<TResource> : IResourceChangeTracker<TResource>
1212
where TResource : class, IIdentifiable
1313
{
14-
private readonly IJsonApiOptions _options;
1514
private readonly IResourceGraph _resourceGraph;
1615
private readonly ITargetedFields _targetedFields;
1716

1817
private IDictionary<string, string> _initiallyStoredAttributeValues;
1918
private IDictionary<string, string> _requestAttributeValues;
2019
private IDictionary<string, string> _finallyStoredAttributeValues;
2120

22-
public ResourceChangeTracker(IJsonApiOptions options, IResourceGraph resourceGraph, ITargetedFields targetedFields)
21+
public ResourceChangeTracker(IResourceGraph resourceGraph, ITargetedFields targetedFields)
2322
{
24-
ArgumentGuard.NotNull(options, nameof(options));
2523
ArgumentGuard.NotNull(resourceGraph, nameof(resourceGraph));
2624
ArgumentGuard.NotNull(targetedFields, nameof(targetedFields));
2725

28-
_options = options;
2926
_resourceGraph = resourceGraph;
3027
_targetedFields = targetedFields;
3128
}
@@ -63,7 +60,7 @@ private IDictionary<string, string> CreateAttributeDictionary(TResource resource
6360
foreach (AttrAttribute attribute in attributes)
6461
{
6562
object value = attribute.GetValue(resource);
66-
string json = JsonConvert.SerializeObject(value, _options.SerializerSettings);
63+
string json = JsonSerializer.Serialize(value);
6764
result.Add(attribute.PublicName, json);
6865
}
6966

0 commit comments

Comments
 (0)