Skip to content

Inheritance and scanning assembly for IRegister. #726

@vchc

Description

@vchc

If you use IRegister to define the inheritance mapping like this:

DerivedPocoProfile.cs

public class DerivedPocoProfile : IRegister
{
    public void Register(TypeAdapterConfig config)
    {
        .NewConfig<DerivedPoco, DerivedDto>()
        .Inherits<SimplePoco, SimpleDto>();
    }
}

SimplePocoProfile.cs

public class SimplePocoProfile : IRegister
{
    public void Register(TypeAdapterConfig config)
    {
        .NewConfig<SimplePoco, SimpleDto>();
    }
}

and then use scan assembly for types:

TypeAdapterConfig.GlobalSettings.Scan(typeof(DerivedPocoProfile).Assembly);

there is no guarantee that the base type will be registered first and

.Inherits<SimplePoco, SimpleDto>();

will fail silently, leaving your mapping inconsistent.

The current implementation of Inherits does nothing and simply returns when the type tuple has not yet been registered.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions