Skip to content

Commit 1d73d87

Browse files
author
Bart Koelman
committed
Minor cleanup
1 parent a144bdd commit 1d73d87

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ private ResourceContext CreateResourceContext(string publicName, Type resourceTy
138138

139139
private IReadOnlyCollection<AttrAttribute> GetAttributes(Type resourceType)
140140
{
141-
ArgumentGuard.NotNull(resourceType, nameof(resourceType));
142-
143141
var attributes = new List<AttrAttribute>();
144142

145143
foreach (PropertyInfo property in resourceType.GetProperties())
@@ -183,8 +181,6 @@ private IReadOnlyCollection<AttrAttribute> GetAttributes(Type resourceType)
183181

184182
private IReadOnlyCollection<RelationshipAttribute> GetRelationships(Type resourceType)
185183
{
186-
ArgumentGuard.NotNull(resourceType, nameof(resourceType));
187-
188184
var attributes = new List<RelationshipAttribute>();
189185
PropertyInfo[] properties = resourceType.GetProperties();
190186

@@ -309,13 +305,9 @@ private Type GetRelationshipType(RelationshipAttribute relationship, PropertyInf
309305
return relationship is HasOneAttribute ? property.PropertyType : property.PropertyType.GetGenericArguments()[0];
310306
}
311307

312-
// ReSharper disable once ParameterOnlyUsedForPreconditionCheck.Local
313308
private IReadOnlyCollection<EagerLoadAttribute> GetEagerLoads(Type resourceType, int recursionDepth = 0)
314309
{
315-
if (recursionDepth >= 500)
316-
{
317-
throw new InvalidOperationException("Infinite recursion detected in eager-load chain.");
318-
}
310+
AssertNoInfiniteRecursion(recursionDepth);
319311

320312
var attributes = new List<EagerLoadAttribute>();
321313
PropertyInfo[] properties = resourceType.GetProperties();
@@ -339,6 +331,15 @@ private IReadOnlyCollection<EagerLoadAttribute> GetEagerLoads(Type resourceType,
339331
return attributes;
340332
}
341333

334+
[AssertionMethod]
335+
private static void AssertNoInfiniteRecursion(int recursionDepth)
336+
{
337+
if (recursionDepth >= 500)
338+
{
339+
throw new InvalidOperationException("Infinite recursion detected in eager-load chain.");
340+
}
341+
}
342+
342343
private Type TypeOrElementType(Type type)
343344
{
344345
Type[] interfaces = type.GetInterfaces()

0 commit comments

Comments
 (0)