Skip to content

Commit 5d2b18b

Browse files
author
Bart Koelman
committed
Fixed broken custom pattern suggestion
1 parent eca88ed commit 5d2b18b

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using JetBrains.Annotations;
4+
5+
namespace JsonApiDotNetCore
6+
{
7+
internal static class CollectionExtensions
8+
{
9+
[Pure]
10+
[ContractAnnotation("source: null => true")]
11+
public static bool IsNullOrEmpty<T>(this IEnumerable<T> source)
12+
{
13+
if (source == null)
14+
{
15+
return true;
16+
}
17+
18+
return !source.Any();
19+
}
20+
}
21+
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private Expression CreateAssignmentRightHandSideForLayer(QueryLayer layer, Lambd
167167
return CreateCollectionInitializer(outerLambdaScope, selectorPropertyInfo, bodyElementType, layer, lambdaScopeFactory);
168168
}
169169

170-
if (layer.Projection == null || !layer.Projection.Any())
170+
if (layer.Projection.IsNullOrEmpty())
171171
{
172172
return propertyAccess;
173173
}

src/JsonApiDotNetCore/Serialization/RequestDeserializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private object DeserializeOperationsDocument(string body)
6868
JToken bodyToken = LoadJToken(body);
6969
var document = bodyToken.ToObject<AtomicOperationsDocument>();
7070

71-
if (document?.Operations == null || !document.Operations.Any())
71+
if ((document?.Operations).IsNullOrEmpty())
7272
{
7373
throw new JsonApiSerializationException("No operations found.", null);
7474
}

0 commit comments

Comments
 (0)