Skip to content

Wrong code generated when mapping method has additional parameter #2231

Description

@kockicica

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
Code generation is broken in Riok.Mapperly versions 5.0.0-next.4 and 5.0.0-next.5 when mapping method contains additional parameter. Earlier versions generate proper code.

Repro
This repository demonstrates the issue: https://github.com/kockicica/mapperly-test

Actual relevant generated code

    [global::System.CodeDom.Compiler.GeneratedCode("Riok.Mapperly", "5.0.0.0")]
    private global::Data.ScenarioAction MapToScenarioAction(global::Model.ScenarioAction source)
    {
        var target = new global::Data.ScenarioAction();
        if (id != null)
        {
            target.Id = id.Value;
        }
        target.Name = source.Name;
        target.Type = source.Type;
        target.Required = source.Required;
        target.Duration = source.Duration;
        if (source.Params != null)
        {
            target.Params = new global::System.Collections.Generic.Dictionary<string, object>(source.Params);
        }
        else
        {
            target.Params = null;
        }
        return target;
    }

Expected relevant generated code

    [global::System.CodeDom.Compiler.GeneratedCode("Riok.Mapperly", "5.0.0.0")]
    private global::Data.ScenarioAction MapToScenarioAction(global::Model.ScenarioAction source)
    {
        var target = new global::Data.ScenarioAction();
        target.Id = source.Id;
        target.Name = source.Name;
        target.Type = source.Type;
        target.Required = source.Required;
        target.Duration = source.Duration;
        if (source.Params != null)
        {
            target.Params = new global::System.Collections.Generic.Dictionary<string, object>(source.Params);
        }
        else
        {
            target.Params = null;
        }
        return target;
    }

Environment (please complete the following information):

  • Mapperly Version: 5.0.0-next.4 and 5.0.0-next.5
  • Target Framework: net10.0
  • Compiler Version: 5.3.0-2.26153.122 (4d3023de605a78ba3e59e50c657eed70f125c68a)
  • C# Language Version: 14.0
  • OS: Windows 11

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