Skip to content

InsufficientExecutionStackException with read-only property #2078

Description

@nas-rda

Please do the checklist before filing an issue:

  • I have read the documentation, including the FAQ
  • I can reproduce the bug using the latest prerelease version
  • I have searched existing discussion and issue to avoid duplicates

Describe the bug
Adding a clone/copy map definition with a class that has a read-only property throws InsufficientExecutionStackException (similar to #1882 ?)

Repro
https://github.com/nas-rda/Mapperly1882Extended

Declaration code

public class Sample
{
    public string Value { get; set; }

    public Task? ReadonlyProperty => null;
}

[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target, UseDeepCloning = true)]
public static partial class Map
{
    public static partial void Copy(this Sample source, Sample target);
}

Actual relevant generated code
None. InsufficientExecutionStackException is thrown in MapperGenerator.

Expected relevant generated code

public static partial class Map
{
    public static partial void Copy(this Sample source, Sample target)
    {
        target.Value = source.Value;
    }
}

Reported relevant diagnostics
None.

Environment (please complete the following information):

  • Mapperly Version: 4.3.1-next.0
  • Nullable reference types: enabled
  • .NET Version: 10.0.0
  • Target Framework: net10.0
  • Compiler Version: 18.0.2+b0f34d51f
  • C# Language Version: 14.0
  • IDE: Rider 2025.3.0.4
  • OS: Windows 10 22H2

Workaround
Using MapperIgnoreTarget(nameof(@Sample.ReadonlyProperty)) will not cause the exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions