Skip to content

Add - Inherits Lazy #809

Draft
DocSvartz wants to merge 1 commit intoMapsterMapper:developmentfrom
DocSvartz:Lazy-Inherits
Draft

Add - Inherits Lazy #809
DocSvartz wants to merge 1 commit intoMapsterMapper:developmentfrom
DocSvartz:Lazy-Inherits

Conversation

@DocSvartz
Copy link
Contributor

@DocSvartz DocSvartz commented Jul 14, 2025

add Setting:
.InheritsLazy<,>()

Lazy loads settings for inherited types during the first call to Adapt<>

Example:

 TypeAdapterConfig<DerivedPoco, DerivedDto>.NewConfig()
                .InheritsLazy<SimplePoco, SimpleDto>()
                .Compile();

            TypeAdapterConfig<SimplePoco, SimpleDto>.NewConfig()
                .InheritsLazy<RootPoco, RootDto>()
                .Ignore(dest => dest.Name)
                .Compile();

            TypeAdapterConfig<RootPoco, RootDto>.NewConfig()
                .Map(dest => dest.NumberDto, src => 42)
                .Compile();

            dto = TypeAdapter.Adapt<DerivedDto>(source);

            dto.Id.ShouldBe(source.Id);
            dto.Name.ShouldBeNull();  // InheritsLazy Ignore is work
            dto.NumberDto.ShouldBe(42); // InheritsLazy is work

@DocSvartz DocSvartz linked an issue Jul 14, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inheritance and scanning assembly for IRegister.

1 participant