Skip to content

Commit 2c53bf4

Browse files
authored
1 parent 97859da commit 2c53bf4

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/AutoMapper/Execution/TypeMapPlanBuilder.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace AutoMapper.Execution;
22
public ref struct TypeMapPlanBuilder(IGlobalConfiguration configuration, TypeMap typeMap)
33
{
4+
const int DefaultMaxDepth = 64;
45
static readonly MethodInfo MappingError = typeof(TypeMapPlanBuilder).GetStaticMethod(nameof(MemberMappingError));
56
static readonly MethodInfo IncTypeDepthInfo = typeof(ResolutionContext).GetInstanceMethod(nameof(ResolutionContext.IncrementTypeDepth));
67
static readonly MethodInfo DecTypeDepthInfo = typeof(ResolutionContext).GetInstanceMethod(nameof(ResolutionContext.DecrementTypeDepth));
@@ -106,6 +107,10 @@ private static void CheckForCycles(IGlobalConfiguration configuration, TypeMap t
106107
continue;
107108
}
108109
memberTypeMap.PreserveReferences = true;
110+
if (memberTypeMap.MaxDepth == 0)
111+
{
112+
memberTypeMap.MaxDepth = DefaultMaxDepth;
113+
}
109114
Trace(typeMap, memberTypeMap, memberMap);
110115
if (memberMap.Inline)
111116
{

0 commit comments

Comments
 (0)