Is there an existing issue for this?
Description
ObjectMappingHelper.IsCollectionGenericTypeInternal incorrectly handles non-generic types derived from generic collections (e.g., CarDtoList : List).
When calling:
ObjectMapper.Map<List<Car>, CarDtoList>(cars)
the collection check passes, but later mapping fails with IndexOutOfRangeException because type.GetGenericArguments()[0] is accessed on a non-generic derived type.
This causes collection mapping to fail for valid custom collection types derived from List.
Reproduction Steps
1.Define DTO/entity types:
public class Car { public string Model { get; set; } = ""; }
public class CarDto { public string Model { get; set; } = ""; }
public class CarDtoList : List<CarDto> { }
2.Call:
var cars = new List<Car> { new Car { Model = "A" } };
var mapper= serviceProvider.GetService<IObjectMapper>();
var result = mapper.Map<List<Car>, CarDtoList>(cars);
Expected behavior
If this scenario is not intended to be supported (custom non-generic derived collection types like CarDtoList : List), the framework should safely return null from collection-type detection (so mapping falls back to other strategies) instead of throwing an exception (IndexOutOfRangeException).
Actual behavior
Throws IndexOutOfRangeException in collection type detection/mapping path (around ObjectMappingHelper.cs line ~62 in my local source).
Regression?
No response
Known Workarounds
No response
Version
10.1-rc3
User Interface
Common (Default)
Database Provider
EF Core (Default)
Tiered or separate authentication server
None (Default)
Operation System
Windows (Default)
Other information
No response
Is there an existing issue for this?
Description
ObjectMappingHelper.IsCollectionGenericTypeInternal incorrectly handles non-generic types derived from generic collections (e.g., CarDtoList : List).
When calling:
the collection check passes, but later mapping fails with IndexOutOfRangeException because type.GetGenericArguments()[0] is accessed on a non-generic derived type.
This causes collection mapping to fail for valid custom collection types derived from List.
Reproduction Steps
1.Define DTO/entity types:
2.Call:
Expected behavior
If this scenario is not intended to be supported (custom non-generic derived collection types like CarDtoList : List), the framework should safely return null from collection-type detection (so mapping falls back to other strategies) instead of throwing an exception (IndexOutOfRangeException).
Actual behavior
Throws IndexOutOfRangeException in collection type detection/mapping path (around ObjectMappingHelper.cs line ~62 in my local source).
Regression?
No response
Known Workarounds
No response
Version
10.1-rc3
User Interface
Common (Default)
Database Provider
EF Core (Default)
Tiered or separate authentication server
None (Default)
Operation System
Windows (Default)
Other information
No response