Skip to content

Conversation

@DocSvartz
Copy link
Contributor

@DocSvartz DocSvartz commented Dec 31, 2025

Potential issues:

  • MaptoTarget cases:

    • Nullable insider case
    • Not Update if using in ctor (can be fix to AutoProperty, custom property only manual mapping)
  • Double initialization of member destination (in the constructor and the properties themselves) (not Critical, using in not null branch)

class AutoCtorDestX
{
    public AutoCtorDestX(int x) 
    {
        X = x;
    }

    public int X { get; set; }
}


.Block(Mapster.Tests.AutoCtorDestX $result) {
    .If ($var1 == null) {
        .Return #Label1 { null }
    } .Else {
        .Default(System.Void)
    };
    $result = ($var2 ?? .New Mapster.Tests.AutoCtorDestX($var1.X)); // X is first init , not using if var2 is not null
 
    .Block() {
        $result.X = $var1.X //  X is double init
    };
    .Return #Label1 { $result };
    .Label
        null
    .LabelTarget #Label1:
}
if 

class AutoCtorDestX
{
    public AutoCtorDestX(int x) 
    {
        X = x;
    }

    public int X { get;}  // X is not Update
}

@DocSvartz DocSvartz linked an issue Dec 31, 2025 that may be closed by this pull request
@DocSvartz DocSvartz marked this pull request as draft December 31, 2025 06:27
@DocSvartz DocSvartz marked this pull request as ready for review January 1, 2026 06:41
@DocSvartz DocSvartz merged commit 78b802a into MapsterMapper:development Jan 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Question: Why the changed defaults in v9?

1 participant