Skip to content

Commit fd237a0

Browse files
Fix false-positive warning on possible multiple enumeration
1 parent 05b1163 commit fd237a0

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/JsonApiDotNetCore/Queries/NoSqlQueryLayerComposer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using JsonApiDotNetCore.Resources;
99
using JsonApiDotNetCore.Resources.Annotations;
1010

11+
#pragma warning disable AV1551 // Method overload should call another overload
1112
#pragma warning disable AV2310 // Code block should not contain inline comment
1213

1314
namespace JsonApiDotNetCore.Queries
@@ -36,6 +37,8 @@ public class NoSqlQueryLayerComposer : QueryLayerComposer, INoSqlQueryLayerCompo
3637
private readonly IEnumerable<IQueryConstraintProvider> _constraintProviders;
3738
private readonly ITargetedFields _targetedFields;
3839

40+
// ReSharper disable PossibleMultipleEnumeration
41+
3942
public NoSqlQueryLayerComposer(
4043
IEnumerable<IQueryConstraintProvider> constraintProviders,
4144
IResourceDefinitionAccessor resourceDefinitionAccessor,
@@ -50,6 +53,8 @@ public NoSqlQueryLayerComposer(
5053
_targetedFields = targetedFields;
5154
}
5255

56+
// ReSharper restore PossibleMultipleEnumeration
57+
5358
/// <inheritdoc />
5459
public FilterExpression? GetPrimaryFilterFromConstraintsForNoSql(ResourceType primaryResourceType)
5560
{

src/JsonApiDotNetCore/Services/NoSqlResourceService.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Microsoft.Extensions.Logging;
2121
using SysNotNull = System.Diagnostics.CodeAnalysis.NotNullAttribute;
2222

23+
#pragma warning disable AV1551 // Method overload should call another overload
2324
#pragma warning disable AV2310 // Code block should not contain inline comment
2425
#pragma warning disable AV2318 // Work-tracking TO DO comment should be removed
2526
#pragma warning disable AV2407 // Region should be removed
@@ -642,16 +643,13 @@ private static void AssertRelationshipInJsonApiRequestIsNotNull([SysNotNull] Rel
642643
Type type = resource.GetType();
643644
PropertyInfo? property = type.GetProperty(propertyName);
644645

645-
if (property is null)
646-
{
647-
throw new JsonApiException(new ErrorObject(HttpStatusCode.InternalServerError)
646+
return property is not null
647+
? property.GetValue(resource)?.ToString()
648+
: throw new JsonApiException(new ErrorObject(HttpStatusCode.InternalServerError)
648649
{
649650
Title = "Invalid property.",
650651
Detail = $"The '{type.Name}' type does not have a '{propertyName}' property."
651652
});
652-
}
653-
654-
return property.GetValue(resource)?.ToString();
655653
}
656654

657655
#endregion Implementation

0 commit comments

Comments
 (0)