I believe commit 1117602 introduced in v10.0.7-pre1 a regression in Mapster.
Previously, when using the EmptyCollectionIfNull destination transform, a null collection in the source would correctly map to an empty collection in the destination. After this change, that behavior no longer works.
class FooDto
{
public string[] Strings { get; set; }
}
record Foo(List<string> Strings);
// Configure
TypeAdapterConfig.GlobalSettings.Default
.AddDestinationTransform(DestinationTransform.EmptyCollectionIfNull);
// Arrange
var fooDto = new FooDto();
// Act
var foo = fooDto.Adapt<Foo>();
// Assert
foo.Strings.ShouldNotBeNull();
Expected Behavior
foo.Strings should be initialized as an empty array (string[0]), not null.
Actual Behavior
foo.Strings is null.
Impact
This regression makes migration from AutoMapper significantly more difficult, as AutoMapper applies this behavior by default (null collections are mapped to empty ones).
I believe commit 1117602 introduced in v10.0.7-pre1 a regression in Mapster.
Previously, when using the EmptyCollectionIfNull destination transform, a null collection in the source would correctly map to an empty collection in the destination. After this change, that behavior no longer works.
Expected Behavior
foo.Strings should be initialized as an empty array (string[0]), not null.
Actual Behavior
foo.Strings is null.
Impact
This regression makes migration from AutoMapper significantly more difficult, as AutoMapper applies this behavior by default (null collections are mapped to empty ones).