Skip to content

Commit 2fab5fb

Browse files
author
Bart Koelman
authored
Updated dependencies to .NET 5 with EF Core 5 (#1022)
1 parent 6b286aa commit 2fab5fb

File tree

204 files changed

+512
-498
lines changed

Some content is hidden

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

204 files changed

+512
-498
lines changed

.config/dotnet-tools.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"jetbrains.resharper.globaltools": {
6-
"version": "2021.1.3",
6+
"version": "2021.1.4",
77
"commands": [
88
"jb"
99
]
@@ -21,7 +21,7 @@
2121
]
2222
},
2323
"dotnet-reportgenerator-globaltool": {
24-
"version": "4.8.9",
24+
"version": "4.8.12",
2525
"commands": [
2626
"reportgenerator"
2727
]

Directory.Build.props

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project>
22
<PropertyGroup>
3-
<NetCoreAppVersion>netcoreapp3.1</NetCoreAppVersion>
4-
<AspNetCoreVersion>3.1.*</AspNetCoreVersion>
5-
<EFCoreVersion>3.1.*</EFCoreVersion>
6-
<NpgsqlPostgreSQLVersion>3.1.*</NpgsqlPostgreSQLVersion>
3+
<NetCoreAppVersion>net5.0</NetCoreAppVersion>
4+
<AspNetCoreVersion>5.0.*</AspNetCoreVersion>
5+
<EFCoreVersion>5.0.*</EFCoreVersion>
6+
<NpgsqlPostgreSQLVersion>5.0.*</NpgsqlPostgreSQLVersion>
77
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodingGuidelines.ruleset</CodeAnalysisRuleSet>
88
</PropertyGroup>
99

@@ -22,7 +22,7 @@
2222
<!-- Test Project Dependencies -->
2323
<PropertyGroup>
2424
<BogusVersion>33.0.2</BogusVersion>
25-
<CoverletVersion>3.0.3</CoverletVersion>
25+
<CoverletVersion>3.1.0</CoverletVersion>
2626
<FluentAssertionsVersion>5.10.3</FluentAssertionsVersion>
2727
<MoqVersion>4.16.1</MoqVersion>
2828
<XUnitVersion>2.4.*</XUnitVersion>

JsonApiDotNetCore.sln.DotSettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$, $NAME$);</s:String>
5656
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=LocalizableElement/@EntryIndexedValue">DO_NOT_SHOW</s:String>
5757
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=LoopCanBePartlyConvertedToQuery/@EntryIndexedValue">HINT</s:String>
5858
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MemberCanBeInternal/@EntryIndexedValue">SUGGESTION</s:String>
59+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MethodHasAsyncOverload/@EntryIndexedValue">WARNING</s:String>
60+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MethodHasAsyncOverloadWithCancellation/@EntryIndexedValue">WARNING</s:String>
5961
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PatternAlwaysMatches/@EntryIndexedValue">SUGGESTION</s:String>
6062
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PublicConstructorInAbstractClass/@EntryIndexedValue">WARNING</s:String>
6163
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArrayCreationExpression/@EntryIndexedValue">SUGGESTION</s:String>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ See also our [versioning policy](./VERSIONING_POLICY.md).
9090
| .NET Version | EF Core Version | JsonApiDotNetCore Version |
9191
| ----------------- | --------------- | ------------------------- |
9292
| .NET Core 2.x | 2.x | v3.x |
93-
| .NET Core 3.1 | 3.1, 5 | v4 |
94-
| .NET 5 | 5 | v4 |
93+
| .NET Core 3.1 | 3.1, 5 | v4.x |
94+
| .NET 5 | 5 | v4.x, v5.x |
9595

9696

9797
## Contributing

benchmarks/LinkBuilder/LinkBuilderGetNamespaceFromPathBenchmarks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private static void GetNamespaceFromPathUsingReadOnlySpan(string path, string re
6767

6868
if (isAtEnd || hasDelimiterAfterSegment)
6969
{
70-
_ = pathSpan.Slice(0, index).ToString();
70+
_ = pathSpan[..index].ToString();
7171
}
7272
}
7373
}

benchmarks/Query/QueryParserBenchmarks.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ namespace Benchmarks.Query
2020
[MemoryDiagnoser]
2121
public class QueryParserBenchmarks
2222
{
23-
private readonly DependencyFactory _dependencyFactory = new DependencyFactory();
24-
private readonly FakeRequestQueryStringAccessor _queryStringAccessor = new FakeRequestQueryStringAccessor();
23+
private readonly DependencyFactory _dependencyFactory = new();
24+
private readonly FakeRequestQueryStringAccessor _queryStringAccessor = new();
2525
private readonly QueryStringReader _queryStringReaderForSort;
2626
private readonly QueryStringReader _queryStringReaderForAll;
2727

benchmarks/Serialization/JsonApiDeserializerBenchmarks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class JsonApiDeserializerBenchmarks
2929
}
3030
});
3131

32-
private readonly DependencyFactory _dependencyFactory = new DependencyFactory();
32+
private readonly DependencyFactory _dependencyFactory = new();
3333
private readonly IJsonApiDeserializer _jsonApiDeserializer;
3434

3535
public JsonApiDeserializerBenchmarks()

benchmarks/Serialization/JsonApiSerializerBenchmarks.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ namespace Benchmarks.Serialization
1515
[MarkdownExporter]
1616
public class JsonApiSerializerBenchmarks
1717
{
18-
private static readonly BenchmarkResource Content = new BenchmarkResource
18+
private static readonly BenchmarkResource Content = new()
1919
{
2020
Id = 123,
2121
Name = Guid.NewGuid().ToString()
2222
};
2323

24-
private readonly DependencyFactory _dependencyFactory = new DependencyFactory();
24+
private readonly DependencyFactory _dependencyFactory = new();
2525
private readonly IJsonApiSerializer _jsonApiSerializer;
2626

2727
public JsonApiSerializerBenchmarks()

src/Examples/ReportsExample/Services/ReportService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private IReadOnlyCollection<Report> GetReports()
3131
{
3232
return new List<Report>
3333
{
34-
new Report
34+
new()
3535
{
3636
Title = "Status Report",
3737
Statistics = new ReportStatistics

src/JsonApiDotNetCore/AtomicOperations/Processors/SetRelationshipProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace JsonApiDotNetCore.AtomicOperations.Processors
1414
public class SetRelationshipProcessor<TResource, TId> : ISetRelationshipProcessor<TResource, TId>
1515
where TResource : class, IIdentifiable<TId>
1616
{
17-
private readonly CollectionConverter _collectionConverter = new CollectionConverter();
17+
private readonly CollectionConverter _collectionConverter = new();
1818
private readonly ISetRelationshipService<TResource, TId> _service;
1919

2020
public SetRelationshipProcessor(ISetRelationshipService<TResource, TId> service)

src/JsonApiDotNetCore/Configuration/InverseNavigationResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private void ResolveRelationships(IReadOnlyCollection<RelationshipAttribute> rel
5252
{
5353
if (!(relationship is HasManyThroughAttribute))
5454
{
55-
INavigation inverseNavigation = entityType.FindNavigation(relationship.Property.Name)?.FindInverse();
55+
INavigation inverseNavigation = entityType.FindNavigation(relationship.Property.Name)?.Inverse;
5656
relationship.InverseNavigationProperty = inverseNavigation?.PropertyInfo;
5757
}
5858
}

src/JsonApiDotNetCore/Configuration/JsonApiApplicationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace JsonApiDotNetCore.Configuration
3030
/// </summary>
3131
internal sealed class JsonApiApplicationBuilder : IJsonApiApplicationBuilder, IDisposable
3232
{
33-
private readonly JsonApiOptions _options = new JsonApiOptions();
33+
private readonly JsonApiOptions _options = new();
3434
private readonly IServiceCollection _services;
3535
private readonly IMvcCoreBuilder _mvcBuilder;
3636
private readonly ResourceGraphBuilder _resourceGraphBuilder;

src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public sealed class JsonApiOptions : IJsonApiOptions
4444
public bool IncludeTotalResourceCount { get; set; }
4545

4646
/// <inheritdoc />
47-
public PageSize DefaultPageSize { get; set; } = new PageSize(10);
47+
public PageSize DefaultPageSize { get; set; } = new(10);
4848

4949
/// <inheritdoc />
5050
public PageSize MaximumPageSize { get; set; }
@@ -80,7 +80,7 @@ public sealed class JsonApiOptions : IJsonApiOptions
8080
public IsolationLevel? TransactionIsolationLevel { get; set; }
8181

8282
/// <inheritdoc />
83-
public JsonSerializerSettings SerializerSettings { get; } = new JsonSerializerSettings
83+
public JsonSerializerSettings SerializerSettings { get; } = new()
8484
{
8585
ContractResolver = new DefaultContractResolver
8686
{

src/JsonApiDotNetCore/Configuration/JsonApiValidationFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public bool ShouldValidateEntry(ValidationEntry entry, ValidationEntry parentEnt
4141

4242
var httpContextAccessor = _serviceProvider.GetRequiredService<IHttpContextAccessor>();
4343

44-
if (httpContextAccessor.HttpContext.Request.Method == HttpMethods.Patch || request.OperationKind == OperationKind.UpdateResource)
44+
if (httpContextAccessor.HttpContext!.Request.Method == HttpMethods.Patch || request.OperationKind == OperationKind.UpdateResource)
4545
{
4646
var targetedFields = _serviceProvider.GetRequiredService<ITargetedFields>();
4747
return IsFieldTargeted(entry, targetedFields);

src/JsonApiDotNetCore/Configuration/PageNumber.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace JsonApiDotNetCore.Configuration
66
[PublicAPI]
77
public sealed class PageNumber : IEquatable<PageNumber>
88
{
9-
public static readonly PageNumber ValueOne = new PageNumber(1);
9+
public static readonly PageNumber ValueOne = new(1);
1010

1111
public int OneBasedValue { get; }
1212

src/JsonApiDotNetCore/Configuration/ResourceDescriptorAssemblyCache.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ namespace JsonApiDotNetCore.Configuration
1010
/// </summary>
1111
internal sealed class ResourceDescriptorAssemblyCache
1212
{
13-
private readonly TypeLocator _typeLocator = new TypeLocator();
14-
15-
private readonly Dictionary<Assembly, IReadOnlyCollection<ResourceDescriptor>> _resourceDescriptorsPerAssembly =
16-
new Dictionary<Assembly, IReadOnlyCollection<ResourceDescriptor>>();
13+
private readonly TypeLocator _typeLocator = new();
14+
private readonly Dictionary<Assembly, IReadOnlyCollection<ResourceDescriptor>> _resourceDescriptorsPerAssembly = new();
1715

1816
public void RegisterAssembly(Assembly assembly)
1917
{

src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public class ResourceGraphBuilder
1818
{
1919
private readonly IJsonApiOptions _options;
2020
private readonly ILogger<ResourceGraphBuilder> _logger;
21-
private readonly List<ResourceContext> _resources = new List<ResourceContext>();
22-
private readonly TypeLocator _typeLocator = new TypeLocator();
21+
private readonly List<ResourceContext> _resources = new();
22+
private readonly TypeLocator _typeLocator = new();
2323

2424
public ResourceGraphBuilder(IJsonApiOptions options, ILoggerFactory loggerFactory)
2525
{
@@ -126,7 +126,7 @@ public ResourceGraphBuilder Add(Type resourceType, Type idType = null, string pu
126126

127127
private ResourceContext CreateResourceContext(string publicName, Type resourceType, Type idType)
128128
{
129-
return new ResourceContext
129+
return new()
130130
{
131131
PublicName = publicName,
132132
ResourceType = resourceType,

src/JsonApiDotNetCore/Configuration/ServiceCollectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace JsonApiDotNetCore.Configuration
1717
[PublicAPI]
1818
public static class ServiceCollectionExtensions
1919
{
20-
private static readonly TypeLocator TypeLocator = new TypeLocator();
20+
private static readonly TypeLocator TypeLocator = new();
2121

2222
/// <summary>
2323
/// Configures JsonApiDotNetCore by registering resources manually.

src/JsonApiDotNetCore/Configuration/ServiceDiscoveryFacade.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace JsonApiDotNetCore.Configuration
1717
[PublicAPI]
1818
public class ServiceDiscoveryFacade
1919
{
20-
internal static readonly HashSet<Type> ServiceInterfaces = new HashSet<Type>
20+
internal static readonly HashSet<Type> ServiceInterfaces = new()
2121
{
2222
typeof(IResourceService<>),
2323
typeof(IResourceService<,>),
@@ -47,7 +47,7 @@ public class ServiceDiscoveryFacade
4747
typeof(IRemoveFromRelationshipService<,>)
4848
};
4949

50-
internal static readonly HashSet<Type> RepositoryInterfaces = new HashSet<Type>
50+
internal static readonly HashSet<Type> RepositoryInterfaces = new()
5151
{
5252
typeof(IResourceRepository<>),
5353
typeof(IResourceRepository<,>),
@@ -57,7 +57,7 @@ public class ServiceDiscoveryFacade
5757
typeof(IResourceReadRepository<,>)
5858
};
5959

60-
internal static readonly HashSet<Type> ResourceDefinitionInterfaces = new HashSet<Type>
60+
internal static readonly HashSet<Type> ResourceDefinitionInterfaces = new()
6161
{
6262
typeof(IResourceDefinition<>),
6363
typeof(IResourceDefinition<,>)
@@ -67,8 +67,8 @@ public class ServiceDiscoveryFacade
6767
private readonly IServiceCollection _services;
6868
private readonly ResourceGraphBuilder _resourceGraphBuilder;
6969
private readonly IJsonApiOptions _options;
70-
private readonly ResourceDescriptorAssemblyCache _assemblyCache = new ResourceDescriptorAssemblyCache();
71-
private readonly TypeLocator _typeLocator = new TypeLocator();
70+
private readonly ResourceDescriptorAssemblyCache _assemblyCache = new();
71+
private readonly TypeLocator _typeLocator = new();
7272

7373
public ServiceDiscoveryFacade(IServiceCollection services, ResourceGraphBuilder resourceGraphBuilder, IJsonApiOptions options,
7474
ILoggerFactory loggerFactory)

src/JsonApiDotNetCore/Controllers/Annotations/DisableQueryStringAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace JsonApiDotNetCore.Controllers.Annotations
2121
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface)]
2222
public sealed class DisableQueryStringAttribute : Attribute
2323
{
24-
public static readonly DisableQueryStringAttribute Empty = new DisableQueryStringAttribute(StandardQueryStringParameters.None);
24+
public static readonly DisableQueryStringAttribute Empty = new(StandardQueryStringParameters.None);
2525
public IReadOnlyCollection<string> ParameterNames { get; }
2626

2727
/// <summary>

src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public virtual async Task<IActionResult> PatchAsync(TId id, [FromBody] TResource
271271
}
272272

273273
TResource updated = await _update.UpdateAsync(id, resource, cancellationToken);
274-
return updated == null ? (IActionResult)NoContent() : Ok(updated);
274+
return updated == null ? NoContent() : Ok(updated);
275275
}
276276

277277
/// <summary>

src/JsonApiDotNetCore/Controllers/BaseJsonApiOperationsController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public virtual async Task<IActionResult> PostOperationsAsync([FromBody] IList<Op
121121
}
122122

123123
IList<OperationContainer> results = await _processor.ProcessAsync(operations, cancellationToken);
124-
return results.Any(result => result != null) ? (IActionResult)Ok(results) : NoContent();
124+
return results.Any(result => result != null) ? Ok(results) : NoContent();
125125
}
126126

127127
protected virtual void ValidateClientGeneratedIds(IEnumerable<OperationContainer> operations)

src/JsonApiDotNetCore/Errors/JsonApiException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace JsonApiDotNetCore.Errors
1313
[PublicAPI]
1414
public class JsonApiException : Exception
1515
{
16-
private static readonly JsonSerializerSettings ErrorSerializerSettings = new JsonSerializerSettings
16+
private static readonly JsonSerializerSettings ErrorSerializerSettings = new()
1717
{
1818
NullValueHandling = NullValueHandling.Ignore,
1919
Formatting = Formatting.Indented

src/JsonApiDotNetCore/Errors/ResourcesInRelationshipsNotFoundException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public ResourcesInRelationshipsNotFoundException(IEnumerable<MissingResourceInRe
1919

2020
private static Error CreateError(MissingResourceInRelationship missingResourceInRelationship)
2121
{
22-
return new Error(HttpStatusCode.NotFound)
22+
return new(HttpStatusCode.NotFound)
2323
{
2424
Title = "A related resource does not exist.",
2525
Detail = $"Related resource of type '{missingResourceInRelationship.ResourceType}' with ID '{missingResourceInRelationship.ResourceId}' " +

src/JsonApiDotNetCore/JsonApiDotNetCore.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
<ItemGroup>
2424
<PackageReference Include="Ben.Demystifier" Version="0.4.1" />
2525
<PackageReference Include="Humanizer" Version="2.11.10" />
26-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
27-
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.0" />
26+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="$(EFCoreVersion)" />
27+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="$(EFCoreVersion)" />
2828
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
2929
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
3030
<PackageReference Include="SauceControl.InheritDoc" Version="1.3.0" PrivateAssets="All" />

src/JsonApiDotNetCore/Middleware/FixedQueryFeature.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public IQueryCollection Query
2727
{
2828
get
2929
{
30-
if (_features.Collection == null)
30+
if (IsFeatureCollectionNull())
3131
{
3232
return _parsedValues ??= QueryCollection.Empty;
3333
}
@@ -49,7 +49,7 @@ public IQueryCollection Query
4949
{
5050
_parsedValues = value;
5151

52-
if (_features.Collection != null)
52+
if (!IsFeatureCollectionNull())
5353
{
5454
if (value == null)
5555
{
@@ -77,5 +77,12 @@ public FixedQueryFeature(IFeatureCollection features)
7777

7878
_features.Initalize(features);
7979
}
80+
81+
private bool IsFeatureCollectionNull()
82+
{
83+
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
84+
// Justification: This code was copied from the ASP.NET sources. A struct instance can be created without calling one of its constructors.
85+
return _features.Collection == null;
86+
}
8087
}
8188
}

src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ private static async Task<bool> ValidateContentTypeHeaderAsync(string allowedCon
125125
{
126126
string contentType = httpContext.Request.ContentType;
127127

128+
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
129+
// Justification: Workaround for https://github.com/dotnet/aspnetcore/issues/32097 (fixed in .NET 6)
128130
if (contentType != null && contentType != allowedContentType)
129131
{
130132
await FlushResponseAsync(httpContext.Response, serializerSettings, new Error(HttpStatusCode.UnsupportedMediaType)
@@ -280,9 +282,9 @@ private static string GetCustomRoute(string resourceName, string apiNamespace, H
280282
if (resourceName != null)
281283
{
282284
Endpoint endpoint = httpContext.GetEndpoint();
283-
var routeAttribute = endpoint.Metadata.GetMetadata<RouteAttribute>();
285+
var routeAttribute = endpoint?.Metadata.GetMetadata<RouteAttribute>();
284286

285-
if (routeAttribute != null)
287+
if (routeAttribute != null && httpContext.Request.Path.Value != null)
286288
{
287289
List<string> trimmedComponents = httpContext.Request.Path.Value.Trim('/').Split('/').ToList();
288290
int resourceNameIndex = trimmedComponents.FindIndex(component => component == resourceName);

src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public class JsonApiRoutingConvention : IJsonApiRoutingConvention
3333
{
3434
private readonly IJsonApiOptions _options;
3535
private readonly IResourceContextProvider _resourceContextProvider;
36-
private readonly Dictionary<string, string> _registeredControllerNameByTemplate = new Dictionary<string, string>();
37-
private readonly Dictionary<Type, ResourceContext> _resourceContextPerControllerTypeMap = new Dictionary<Type, ResourceContext>();
38-
private readonly Dictionary<ResourceContext, ControllerModel> _controllerPerResourceContextMap = new Dictionary<ResourceContext, ControllerModel>();
36+
private readonly Dictionary<string, string> _registeredControllerNameByTemplate = new();
37+
private readonly Dictionary<Type, ResourceContext> _resourceContextPerControllerTypeMap = new();
38+
private readonly Dictionary<ResourceContext, ControllerModel> _controllerPerResourceContextMap = new();
3939

4040
public JsonApiRoutingConvention(IJsonApiOptions options, IResourceContextProvider resourceContextProvider)
4141
{

src/JsonApiDotNetCore/ObjectExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static T[] AsArray<T>(this T element)
2121

2222
public static List<T> AsList<T>(this T element)
2323
{
24-
return new List<T>
24+
return new()
2525
{
2626
element
2727
};

0 commit comments

Comments
 (0)