Releases: odinsoft-lab/simple.automapper
Releases · odinsoft-lab/simple.automapper
v1.0.9
Simple.AutoMapper v1.0.9
Release date: 2026-01-11
Highlights
This release introduces powerful new mapping configuration options that bring Simple.AutoMapper closer to feature parity with full-featured mapping libraries, while maintaining simplicity and performance.
New Features
- Condition - Conditional property mapping based on source values
- NullSubstitute - Default value substitution when source is null
- BeforeMap / AfterMap - Pre and post mapping callbacks
- ConstructUsing - Custom object construction for immutable types
New Configuration APIs
Condition
Map properties only when a condition is met:
Mapper.CreateMap<User, UserDto>()
.ForMember(d => d.Email, opt => {
opt.MapFrom(s => s.Email);
opt.Condition(s => s.IsEmailVerified);
});NullSubstitute
Provide default values when source is null:
Mapper.CreateMap<User, UserDto>()
.ForMember(d => d.DisplayName, opt => {
opt.MapFrom(s => s.Nickname);
opt.NullSubstitute("Anonymous");
});BeforeMap / AfterMap
Execute custom logic before or after property mapping:
Mapper.CreateMap<User, UserDto>()
.BeforeMap((src, dest) => {
dest.CreatedAt = DateTime.UtcNow;
})
.AfterMap((src, dest) => {
dest.FullName = $"{dest.FirstName} {dest.LastName}";
});ConstructUsing
Use custom constructors or factory methods:
// For immutable objects
Mapper.CreateMap<User, ImmutableUserDto>()
.ConstructUsing(src => new ImmutableUserDto(src.Id, src.Name));
// For objects requiring initialization
Mapper.CreateMap<User, UserDto>()
.ConstructUsing(src => new UserDto {
CreatedBy = "System",
CreatedAt = DateTime.UtcNow
});Other Improvements
- Test Coverage: Increased from 63% to 87% line coverage
- Comprehensive Test Suites: Added tests for DI, Profile, MappingContext, TypePair, SyncResult
- net10.0 Support: Added .NET 10.0 target framework
- Bug Fix: Fixed PreserveReferences circular reference detection issue
- Bug Fix: Fixed net9.0 missing from DI support condition
- API Enhancement: Added
Mapper.Map<List<TDestination>>(entities)single type parameter support - Dependencies: Upgraded Microsoft.Extensions.* packages to 10.0.1
Test Results
- 174 tests passing
- 1 test skipped (known limitation)
Breaking Changes
None. All existing v1.0.8 features remain compatible.
Upgrade Guide
No migration required. Simply update the package:
dotnet add package Simple.AutoMapper --version 1.0.9Known Limitations
- Destination types must have parameterless constructors unless
ConstructUsingis configured - IQueryable projections are not supported; materialize queries before mapping
What's Next
See ROADMAP.md for planned features:
- ConvertUsing for full type conversion control
- TypeConverter for global type conversions
- IQueryable projection support