Skip to content

Commit a47f0f3

Browse files
committed
chore: removed unused obsolete methods, fixed some tests that still relied on these methods
1 parent ec4e76e commit a47f0f3

22 files changed

+29
-146
lines changed

benchmarks/Serialization/JsonApiDeserializer_Benchmarks.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ public JsonApiDeserializer_Benchmarks() {
4545
jsonApiOptions.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
4646
jsonApiContextMock.Setup(m => m.Options).Returns(jsonApiOptions);
4747

48-
var genericProcessorFactoryMock = new Mock<IGenericProcessorFactory>();
4948

50-
_jsonApiDeSerializer = new JsonApiDeSerializer(jsonApiContextMock.Object, genericProcessorFactoryMock.Object);
49+
_jsonApiDeSerializer = new JsonApiDeSerializer(jsonApiContextMock.Object);
5150
}
5251

5352
[Benchmark]

src/Examples/JsonApiDotNetCoreExample/Controllers/TodoCollectionsController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public override async Task<IActionResult> PatchAsync(Guid id, [FromBody] TodoIte
3333
if (entity.Name == "PRE-ATTACH-TEST")
3434
{
3535
var targetTodoId = entity.TodoItems.First().Id;
36-
var todoItemContext = _dbResolver.GetDbSet<TodoItem>();
36+
var todoItemContext = _dbResolver.GetContext().Set<TodoItem>();
3737
await todoItemContext.Where(ti => ti.Id == targetTodoId).FirstOrDefaultAsync();
3838
}
3939
return await base.PatchAsync(id, entity);

src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,6 @@ public class JsonApiOptions
181181
/// </example>
182182
public bool ValidateModelState { get; set; }
183183

184-
[Obsolete("JsonContract resolver can now be set on SerializerSettings.")]
185-
public IContractResolver JsonContractResolver
186-
{
187-
get => SerializerSettings.ContractResolver;
188-
set => SerializerSettings.ContractResolver = value;
189-
}
190184
public JsonSerializerSettings SerializerSettings { get; } = new JsonSerializerSettings()
191185
{
192186
NullValueHandling = NullValueHandling.Ignore,

src/JsonApiDotNetCore/Data/DbContextResolver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public DbContextResolver(TContext context)
1515

1616
public DbContext GetContext() => _context;
1717

18-
public DbSet<TEntity> GetDbSet<TEntity>() where TEntity : class
19-
=> _context.GetDbSet<TEntity>();
18+
public DbSet<TEntity> GetDbSet<TEntity>() where TEntity : class => null;
19+
2020
}
2121
}

src/JsonApiDotNetCore/Data/DefaultEntityRepository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public DefaultEntityRepository(
5656
ResourceDefinition<TEntity> resourceDefinition = null)
5757
{
5858
_context = contextResolver.GetContext();
59-
_dbSet = contextResolver.GetDbSet<TEntity>();
59+
_dbSet = _context.Set<TEntity>();
6060
_jsonApiContext = jsonApiContext;
6161
_genericProcessorFactory = _jsonApiContext.GenericProcessorFactory;
6262
_resourceDefinition = resourceDefinition;
@@ -69,7 +69,7 @@ public DefaultEntityRepository(
6969
ResourceDefinition<TEntity> resourceDefinition = null)
7070
{
7171
_context = contextResolver.GetContext();
72-
_dbSet = contextResolver.GetDbSet<TEntity>();
72+
_dbSet = _context.Set<TEntity>();
7373
_jsonApiContext = jsonApiContext;
7474
_logger = loggerFactory.CreateLogger<DefaultEntityRepository<TEntity, TId>>();
7575
_genericProcessorFactory = _jsonApiContext.GenericProcessorFactory;

src/JsonApiDotNetCore/Data/IDbContextResolver.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
using System;
12
using Microsoft.EntityFrameworkCore;
23

34
namespace JsonApiDotNetCore.Data
45
{
56
public interface IDbContextResolver
67
{
78
DbContext GetContext();
9+
10+
[Obsolete("Use DbContext.Set<TEntity>() instead", error: true)]
811
DbSet<TEntity> GetDbSet<TEntity>()
912
where TEntity : class;
1013
}

src/JsonApiDotNetCore/Extensions/IQueryableExtensions.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ private static MethodInfo ContainsMethod
3030
}
3131
}
3232

33-
[Obsolete("Use overload Sort<T>(IJsonApiContext, List<SortQuery>) instead.", error: true)]
34-
public static IQueryable<TSource> Sort<TSource>(this IQueryable<TSource> source, List<SortQuery> sortQueries) => null;
35-
36-
[Obsolete("Use overload Sort<T>(IJsonApiContext, SortQuery) instead.", error: true)]
37-
public static IOrderedQueryable<TSource> Sort<TSource>(this IQueryable<TSource> source, SortQuery sortQuery) => null;
38-
39-
[Obsolete("Use overload Sort<T>(IJsonApiContext, SortQuery) instead.", error: true)]
40-
public static IOrderedQueryable<TSource> Sort<TSource>(this IOrderedQueryable<TSource> source, SortQuery sortQuery) => null;
41-
4233
public static IQueryable<TSource> Sort<TSource>(this IQueryable<TSource> source, IJsonApiContext jsonApiContext, List<SortQuery> sortQueries)
4334
{
4435
if (sortQueries == null || sortQueries.Count == 0)

src/JsonApiDotNetCore/Extensions/ModelStateExtensions.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,6 @@ namespace JsonApiDotNetCore.Extensions
77
{
88
public static class ModelStateExtensions
99
{
10-
[Obsolete("Use Generic Method ConvertToErrorCollection<T>(IResourceGraph resourceGraph) instead for full validation errors")]
11-
public static ErrorCollection ConvertToErrorCollection(this ModelStateDictionary modelState)
12-
{
13-
ErrorCollection collection = new ErrorCollection();
14-
foreach (var entry in modelState)
15-
{
16-
if (entry.Value.Errors.Any() == false)
17-
continue;
18-
19-
foreach (var modelError in entry.Value.Errors)
20-
{
21-
if (modelError.Exception is JsonApiException jex)
22-
collection.Errors.AddRange(jex.GetError().Errors);
23-
else
24-
collection.Errors.Add(new Error(400, entry.Key, modelError.ErrorMessage, modelError.Exception != null ? ErrorMeta.FromException(modelError.Exception) : null));
25-
}
26-
}
27-
28-
return collection;
29-
}
3010
public static ErrorCollection ConvertToErrorCollection<T>(this ModelStateDictionary modelState, IResourceGraph resourceGraph)
3111
{
3212
ErrorCollection collection = new ErrorCollection();

src/JsonApiDotNetCore/Internal/ContextGraph.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/JsonApiDotNetCore/Internal/Error.cs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,7 @@ namespace JsonApiDotNetCore.Internal
99
{
1010
public class Error
1111
{
12-
public Error()
13-
{ }
14-
15-
[Obsolete("Use Error constructors with int typed status")]
16-
public Error(string status, string title, ErrorMeta meta = null, object source = null)
17-
{
18-
Status = status;
19-
Title = title;
20-
Meta = meta;
21-
Source = source;
22-
}
12+
public Error() { }
2313

2414
public Error(int status, string title, ErrorMeta meta = null, object source = null)
2515
{
@@ -29,16 +19,6 @@ public Error(int status, string title, ErrorMeta meta = null, object source = nu
2919
Source = source;
3020
}
3121

32-
[Obsolete("Use Error constructors with int typed status")]
33-
public Error(string status, string title, string detail, ErrorMeta meta = null, object source = null)
34-
{
35-
Status = status;
36-
Title = title;
37-
Detail = detail;
38-
Meta = meta;
39-
Source = source;
40-
}
41-
4222
public Error(int status, string title, string detail, ErrorMeta meta = null, object source = null)
4323
{
4424
Status = status.ToString();

0 commit comments

Comments
 (0)