Skip to content

Commit 16ae780

Browse files
author
Bart Koelman
committed
Reformat solution
1 parent 3ca0047 commit 16ae780

File tree

75 files changed

+156
-243
lines changed

Some content is hidden

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

75 files changed

+156
-243
lines changed

benchmarks/Deserialization/DeserializationBenchmarkBase.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ protected DeserializationBenchmarkBase()
2828
var resourceDefinitionAccessor = new ResourceDefinitionAccessor(resourceGraph, serviceContainer);
2929

3030
serviceContainer.AddService(typeof(IResourceDefinitionAccessor), resourceDefinitionAccessor);
31-
32-
serviceContainer.AddService(typeof(IResourceDefinition<IncomingResource, int>),
33-
new JsonApiResourceDefinition<IncomingResource, int>(resourceGraph));
31+
serviceContainer.AddService(typeof(IResourceDefinition<IncomingResource, int>), new JsonApiResourceDefinition<IncomingResource, int>(resourceGraph));
3432

3533
// ReSharper disable once VirtualMemberCallInConstructor
3634
JsonApiRequest request = CreateJsonApiRequest(resourceGraph);

benchmarks/QueryString/QueryStringParserBenchmarks.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ public QueryStringParserBenchmarks()
2828
EnableLegacyFilterNotation = true
2929
};
3030

31-
IResourceGraph resourceGraph =
32-
new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<QueryableResource, int>("alt-resource-name").Build();
31+
IResourceGraph resourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<QueryableResource, int>("alt-resource-name").Build();
3332

3433
var request = new JsonApiRequest
3534
{

benchmarks/Serialization/SerializationBenchmarkBase.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ public Task OnPrepareWriteAsync<TResource>(TResource resource, WriteOperationKin
173173
return Task.FromResult(rightResourceId);
174174
}
175175

176-
public Task OnSetToManyRelationshipAsync<TResource>(TResource leftResource, HasManyAttribute hasManyRelationship,
177-
ISet<IIdentifiable> rightResourceIds, WriteOperationKind writeOperation, CancellationToken cancellationToken)
176+
public Task OnSetToManyRelationshipAsync<TResource>(TResource leftResource, HasManyAttribute hasManyRelationship, ISet<IIdentifiable> rightResourceIds,
177+
WriteOperationKind writeOperation, CancellationToken cancellationToken)
178178
where TResource : class, IIdentifiable
179179
{
180180
return Task.CompletedTask;
@@ -187,8 +187,8 @@ public Task OnAddToRelationshipAsync<TResource, TId>(TId leftResourceId, HasMany
187187
return Task.CompletedTask;
188188
}
189189

190-
public Task OnRemoveFromRelationshipAsync<TResource>(TResource leftResource, HasManyAttribute hasManyRelationship,
191-
ISet<IIdentifiable> rightResourceIds, CancellationToken cancellationToken)
190+
public Task OnRemoveFromRelationshipAsync<TResource>(TResource leftResource, HasManyAttribute hasManyRelationship, ISet<IIdentifiable> rightResourceIds,
191+
CancellationToken cancellationToken)
192192
where TResource : class, IIdentifiable
193193
{
194194
return Task.CompletedTask;

src/Examples/GettingStarted/GettingStarted.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
<ItemGroup>
77
<ProjectReference Include="..\..\JsonApiDotNetCore\JsonApiDotNetCore.csproj" />
8-
<ProjectReference Include="..\..\JsonApiDotNetCore.SourceGenerators\JsonApiDotNetCore.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
8+
<ProjectReference Include="..\..\JsonApiDotNetCore.SourceGenerators\JsonApiDotNetCore.SourceGenerators.csproj" OutputItemType="Analyzer"
9+
ReferenceOutputAssembly="false" />
910
</ItemGroup>
1011

1112
<ItemGroup>

src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ public sealed class JsonApiOptions : IJsonApiOptions
104104

105105
public JsonApiOptions()
106106
{
107-
_lazySerializerReadOptions =
108-
new Lazy<JsonSerializerOptions>(() => new JsonSerializerOptions(SerializerOptions), LazyThreadSafetyMode.PublicationOnly);
107+
_lazySerializerReadOptions = new Lazy<JsonSerializerOptions>(() => new JsonSerializerOptions(SerializerOptions), LazyThreadSafetyMode.PublicationOnly);
109108

110109
_lazySerializerWriteOptions = new Lazy<JsonSerializerOptions>(() => new JsonSerializerOptions(SerializerOptions)
111110
{

src/JsonApiDotNetCore/Configuration/ResourceGraph.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ private IEnumerable<string> ToMemberNames<TResource>(Expression<Func<TResource,
178178
}
179179
else
180180
{
181-
throw new ArgumentException(
182-
$"The expression '{selector}' should select a single property or select multiple properties into an anonymous type. " +
181+
throw new ArgumentException($"The expression '{selector}' should select a single property or select multiple properties into an anonymous type. " +
183182
"For example: 'article => article.Title' or 'article => new { article.Title, article.PageCount }'.");
184183
}
185184
}

src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,7 @@ private void AssertNoDuplicatePublicName(ResourceType resourceType, string effec
289289

290290
if (existingClrType != null)
291291
{
292-
throw new InvalidConfigurationException(
293-
$"Resource '{existingClrType}' and '{resourceType.ClrType}' both use public name '{effectivePublicName}'.");
292+
throw new InvalidConfigurationException($"Resource '{existingClrType}' and '{resourceType.ClrType}' both use public name '{effectivePublicName}'.");
294293
}
295294
}
296295

@@ -328,8 +327,8 @@ private static void AssertNoInfiniteRecursion(int recursionDepth)
328327

329328
private Type TypeOrElementType(Type type)
330329
{
331-
Type[] interfaces = type.GetInterfaces()
332-
.Where(@interface => @interface.IsGenericType && @interface.GetGenericTypeDefinition() == typeof(IEnumerable<>)).ToArray();
330+
Type[] interfaces = type.GetInterfaces().Where(@interface => @interface.IsGenericType && @interface.GetGenericTypeDefinition() == typeof(IEnumerable<>))
331+
.ToArray();
333332

334333
return interfaces.Length == 1 ? interfaces.Single().GenericTypeArguments[0] : type;
335334
}

src/JsonApiDotNetCore/Configuration/ResourceType.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ public AttrAttribute GetAttributeByPropertyName(string propertyName)
119119
{
120120
AttrAttribute? attribute = FindAttributeByPropertyName(propertyName);
121121

122-
return attribute ??
123-
throw new InvalidOperationException($"Attribute for property '{propertyName}' does not exist on resource type '{ClrType.Name}'.");
122+
return attribute ?? throw new InvalidOperationException($"Attribute for property '{propertyName}' does not exist on resource type '{ClrType.Name}'.");
124123
}
125124

126125
public AttrAttribute? FindAttributeByPropertyName(string propertyName)

src/JsonApiDotNetCore/Configuration/ServiceDiscoveryFacade.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ private void RegisterImplementations(Assembly assembly, Type interfaceType, Reso
158158
? ArrayFactory.Create(resourceDescriptor.ResourceClrType, resourceDescriptor.IdClrType)
159159
: ArrayFactory.Create(resourceDescriptor.ResourceClrType);
160160

161-
(Type implementation, Type registrationInterface)? result =
162-
_typeLocator.GetGenericInterfaceImplementation(assembly, interfaceType, genericArguments);
161+
(Type implementation, Type registrationInterface)? result = _typeLocator.GetGenericInterfaceImplementation(assembly, interfaceType, genericArguments);
163162

164163
if (result != null)
165164
{

src/JsonApiDotNetCore/Configuration/TypeLocator.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,9 @@ internal sealed class TypeLocator
6161
ArgumentGuard.NotNull(openGenericInterface, nameof(openGenericInterface));
6262
ArgumentGuard.NotNull(interfaceGenericTypeArguments, nameof(interfaceGenericTypeArguments));
6363

64-
if (!openGenericInterface.IsInterface || !openGenericInterface.IsGenericType ||
65-
openGenericInterface != openGenericInterface.GetGenericTypeDefinition())
64+
if (!openGenericInterface.IsInterface || !openGenericInterface.IsGenericType || openGenericInterface != openGenericInterface.GetGenericTypeDefinition())
6665
{
67-
throw new ArgumentException($"Specified type '{openGenericInterface.FullName}' is not an open generic interface.",
68-
nameof(openGenericInterface));
66+
throw new ArgumentException($"Specified type '{openGenericInterface.FullName}' is not an open generic interface.", nameof(openGenericInterface));
6967
}
7068

7169
if (interfaceGenericTypeArguments.Length != openGenericInterface.GetGenericArguments().Length)

src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ protected BaseJsonApiController(IJsonApiOptions options, IResourceGraph resource
4848
/// </summary>
4949
protected BaseJsonApiController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory,
5050
IResourceQueryService<TResource, TId>? queryService = null, IResourceCommandService<TResource, TId>? commandService = null)
51-
: this(options, resourceGraph, loggerFactory, queryService, queryService, queryService, queryService, commandService, commandService,
52-
commandService, commandService, commandService, commandService)
51+
: this(options, resourceGraph, loggerFactory, queryService, queryService, queryService, queryService, commandService, commandService, commandService,
52+
commandService, commandService, commandService)
5353
{
5454
}
5555

src/JsonApiDotNetCore/Controllers/BaseJsonApiOperationsController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ protected virtual void ValidateModelState(IList<OperationContainer> operations)
148148
Dictionary<string, ModelStateEntry?> modelStateDictionary = requestModelState.ToDictionary(tuple => tuple.key, tuple => tuple.entry);
149149

150150
throw new InvalidModelStateException(modelStateDictionary, typeof(IList<OperationContainer>), _options.IncludeExceptionStackTraceInErrors,
151-
_resourceGraph,
152-
(collectionType, index) => collectionType == typeof(IList<OperationContainer>) ? operations[index].Resource.GetType() : null);
151+
_resourceGraph, (collectionType, index) => collectionType == typeof(IList<OperationContainer>) ? operations[index].Resource.GetType() : null);
153152
}
154153
}
155154

src/JsonApiDotNetCore/Controllers/JsonApiCommandController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public abstract class JsonApiCommandController<TResource, TId> : JsonApiControll
2323
/// </summary>
2424
protected JsonApiCommandController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory,
2525
IResourceCommandService<TResource, TId> commandService)
26-
: base(options, resourceGraph, loggerFactory, null, null, null, null, commandService, commandService, commandService, commandService,
27-
commandService, commandService)
26+
: base(options, resourceGraph, loggerFactory, null, null, null, null, commandService, commandService, commandService, commandService, commandService,
27+
commandService)
2828
{
2929
}
3030
}

src/JsonApiDotNetCore/Controllers/JsonApiOperationsController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace JsonApiDotNetCore.Controllers;
1313
/// </summary>
1414
public abstract class JsonApiOperationsController : BaseJsonApiOperationsController
1515
{
16-
protected JsonApiOperationsController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory,
17-
IOperationsProcessor processor, IJsonApiRequest request, ITargetedFields targetedFields)
16+
protected JsonApiOperationsController(IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, IOperationsProcessor processor,
17+
IJsonApiRequest request, ITargetedFields targetedFields)
1818
: base(options, resourceGraph, loggerFactory, processor, request, targetedFields)
1919
{
2020
}

src/JsonApiDotNetCore/Errors/InvalidModelStateException.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ private static IEnumerable<ErrorObject> FromModelStateDictionary(IReadOnlyDictio
4141
return errorObjects;
4242
}
4343

44-
private static IEnumerable<(ModelStateEntry entry, string? sourcePointer)> ResolveSourcePointers(
45-
IReadOnlyDictionary<string, ModelStateEntry?> modelState, Type modelType, IResourceGraph resourceGraph,
46-
Func<Type, int, Type?>? getCollectionElementTypeCallback)
44+
private static IEnumerable<(ModelStateEntry entry, string? sourcePointer)> ResolveSourcePointers(IReadOnlyDictionary<string, ModelStateEntry?> modelState,
45+
Type modelType, IResourceGraph resourceGraph, Func<Type, int, Type?>? getCollectionElementTypeCallback)
4746
{
4847
foreach (string key in modelState.Keys)
4948
{
@@ -245,9 +244,7 @@ protected ModelStateKeySegment(Type modelType, bool isInComplexType, string next
245244
{
246245
ArgumentGuard.NotNull(modelType, nameof(modelType));
247246

248-
return _nextKey == string.Empty
249-
? null
250-
: CreateSegment(modelType, _nextKey, isInComplexType, this, sourcePointer, GetCollectionElementTypeCallback);
247+
return _nextKey == string.Empty ? null : CreateSegment(modelType, _nextKey, isInComplexType, this, sourcePointer, GetCollectionElementTypeCallback);
251248
}
252249

253250
public static ModelStateKeySegment Create(Type modelType, string key, Func<Type, int, Type?>? getCollectionElementTypeCallback)
@@ -258,8 +255,8 @@ public static ModelStateKeySegment Create(Type modelType, string key, Func<Type,
258255
return CreateSegment(modelType, key, false, null, null, getCollectionElementTypeCallback);
259256
}
260257

261-
private static ModelStateKeySegment CreateSegment(Type modelType, string key, bool isInComplexType, ModelStateKeySegment? parent,
262-
string? sourcePointer, Func<Type, int, Type?>? getCollectionElementTypeCallback)
258+
private static ModelStateKeySegment CreateSegment(Type modelType, string key, bool isInComplexType, ModelStateKeySegment? parent, string? sourcePointer,
259+
Func<Type, int, Type?>? getCollectionElementTypeCallback)
263260
{
264261
string? segmentValue = null;
265262
string? nextKey = null;
@@ -321,8 +318,8 @@ private sealed class ArrayIndexerSegment : ModelStateKeySegment
321318

322319
public int ArrayIndex { get; }
323320

324-
public ArrayIndexerSegment(int arrayIndex, Type modelType, bool isInComplexType, string nextKey, string? sourcePointer,
325-
ModelStateKeySegment? parent, Func<Type, int, Type?>? getCollectionElementTypeCallback)
321+
public ArrayIndexerSegment(int arrayIndex, Type modelType, bool isInComplexType, string nextKey, string? sourcePointer, ModelStateKeySegment? parent,
322+
Func<Type, int, Type?>? getCollectionElementTypeCallback)
326323
: base(modelType, isInComplexType, nextKey, sourcePointer, parent, getCollectionElementTypeCallback)
327324
{
328325
ArrayIndex = arrayIndex;
@@ -358,8 +355,8 @@ private sealed class PropertySegment : ModelStateKeySegment
358355
{
359356
public string PropertyName { get; }
360357

361-
public PropertySegment(string propertyName, Type modelType, bool isInComplexType, string nextKey, string? sourcePointer,
362-
ModelStateKeySegment? parent, Func<Type, int, Type?>? getCollectionElementTypeCallback)
358+
public PropertySegment(string propertyName, Type modelType, bool isInComplexType, string nextKey, string? sourcePointer, ModelStateKeySegment? parent,
359+
Func<Type, int, Type?>? getCollectionElementTypeCallback)
363360
: base(modelType, isInComplexType, nextKey, sourcePointer, parent, getCollectionElementTypeCallback)
364361
{
365362
ArgumentGuard.NotNull(propertyName, nameof(propertyName));

src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ private async Task<bool> ValidateIfMatchHeaderAsync(HttpContext httpContext, Jso
120120
: null;
121121
}
122122

123-
private static async Task<bool> ValidateContentTypeHeaderAsync(string allowedContentType, HttpContext httpContext,
124-
JsonSerializerOptions serializerOptions)
123+
private static async Task<bool> ValidateContentTypeHeaderAsync(string allowedContentType, HttpContext httpContext, JsonSerializerOptions serializerOptions)
125124
{
126125
string? contentType = httpContext.Request.ContentType;
127126

src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ public JsonApiRoutingConvention(IJsonApiOptions options, IResourceGraph resource
4646
/// <inheritdoc />
4747
public ResourceType? GetResourceTypeForController(Type? controllerType)
4848
{
49-
return controllerType != null && _resourceTypePerControllerTypeMap.TryGetValue(controllerType, out ResourceType? resourceType)
50-
? resourceType
51-
: null;
49+
return controllerType != null && _resourceTypePerControllerTypeMap.TryGetValue(controllerType, out ResourceType? resourceType) ? resourceType : null;
5250
}
5351

5452
/// <inheritdoc />
@@ -163,8 +161,7 @@ private string TemplateFromController(ControllerModel model)
163161

164162
if ((nextBaseType == aspNetControllerType || nextBaseType == coreControllerType) && currentType.IsGenericType)
165163
{
166-
Type? resourceClrType = currentType.GetGenericArguments()
167-
.FirstOrDefault(typeArgument => typeArgument.IsOrImplementsInterface<IIdentifiable>());
164+
Type? resourceClrType = currentType.GetGenericArguments().FirstOrDefault(typeArgument => typeArgument.IsOrImplementsInterface<IIdentifiable>());
168165

169166
if (resourceClrType != null)
170167
{

src/JsonApiDotNetCore/Queries/Internal/QueryLayerComposer.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,25 +104,22 @@ public QueryLayerComposer(IEnumerable<IQueryConstraintProvider> constraintProvid
104104
return LogicalExpression.Compose(LogicalOperator.And, inverseFilter, primaryFilter, secondaryFilter);
105105
}
106106

107-
private static FilterExpression GetInverseRelationshipFilter<TId>(TId primaryId, HasManyAttribute relationship,
108-
RelationshipAttribute inverseRelationship)
107+
private static FilterExpression GetInverseRelationshipFilter<TId>(TId primaryId, HasManyAttribute relationship, RelationshipAttribute inverseRelationship)
109108
{
110109
return inverseRelationship is HasManyAttribute hasManyInverseRelationship
111110
? GetInverseHasManyRelationshipFilter(primaryId, relationship, hasManyInverseRelationship)
112111
: GetInverseHasOneRelationshipFilter(primaryId, relationship, (HasOneAttribute)inverseRelationship);
113112
}
114113

115-
private static FilterExpression GetInverseHasOneRelationshipFilter<TId>(TId primaryId, HasManyAttribute relationship,
116-
HasOneAttribute inverseRelationship)
114+
private static FilterExpression GetInverseHasOneRelationshipFilter<TId>(TId primaryId, HasManyAttribute relationship, HasOneAttribute inverseRelationship)
117115
{
118116
AttrAttribute idAttribute = GetIdAttribute(relationship.LeftType);
119117
var idChain = new ResourceFieldChainExpression(ImmutableArray.Create<ResourceFieldAttribute>(inverseRelationship, idAttribute));
120118

121119
return new ComparisonExpression(ComparisonOperator.Equals, idChain, new LiteralConstantExpression(primaryId!.ToString()!));
122120
}
123121

124-
private static FilterExpression GetInverseHasManyRelationshipFilter<TId>(TId primaryId, HasManyAttribute relationship,
125-
HasManyAttribute inverseRelationship)
122+
private static FilterExpression GetInverseHasManyRelationshipFilter<TId>(TId primaryId, HasManyAttribute relationship, HasManyAttribute inverseRelationship)
126123
{
127124
AttrAttribute idAttribute = GetIdAttribute(relationship.LeftType);
128125
var idChain = new ResourceFieldChainExpression(ImmutableArray.Create<ResourceFieldAttribute>(idAttribute));
@@ -190,8 +187,7 @@ private IncludeExpression ComposeChildren(QueryLayer topLayer, ICollection<Expre
190187
// @formatter:keep_existing_linebreaks restore
191188
// @formatter:wrap_chained_method_calls restore
192189

193-
IImmutableSet<IncludeElementExpression> includeElements =
194-
ProcessIncludeSet(include.Elements, topLayer, new List<RelationshipAttribute>(), constraints);
190+
IImmutableSet<IncludeElementExpression> includeElements = ProcessIncludeSet(include.Elements, topLayer, new List<RelationshipAttribute>(), constraints);
195191

196192
return !ReferenceEquals(includeElements, include.Elements)
197193
? includeElements.Any() ? new IncludeExpression(includeElements) : IncludeExpression.Empty

src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/QueryableBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public class QueryableBuilder
2222
private readonly IModel _entityModel;
2323
private readonly LambdaScopeFactory _lambdaScopeFactory;
2424

25-
public QueryableBuilder(Expression source, Type elementType, Type extensionType, LambdaParameterNameFactory nameFactory,
26-
IResourceFactory resourceFactory, IModel entityModel, LambdaScopeFactory? lambdaScopeFactory = null)
25+
public QueryableBuilder(Expression source, Type elementType, Type extensionType, LambdaParameterNameFactory nameFactory, IResourceFactory resourceFactory,
26+
IModel entityModel, LambdaScopeFactory? lambdaScopeFactory = null)
2727
{
2828
ArgumentGuard.NotNull(source, nameof(source));
2929
ArgumentGuard.NotNull(elementType, nameof(elementType));

0 commit comments

Comments
 (0)