You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Same problem here. Our current fix is to do all that manually, so we can guarantee a specific order of registration, but that is still error prone, and would be so much better if Inherits<,> would evaluate lazily.
Edit: we do not use TypeAdapterConfig.GlobalSettings.Scan - but have our own interface & scanner, so it's not a problem with TypeAdapterConfig.GlobalSettings.Scan
Edit: we do not use TypeAdapterConfig.GlobalSettings.Scan - but have our own interface & scanner, so it's not a problem with TypeAdapterConfig.GlobalSettings.Scan
I came with the same solution for the problem - to reorder registrations manually.
And I think any assumptions on the library's part about the order or location of IRegister implementations may turn out to be wrong. So there is no simple way to handle this problem lazily.
There can be three ways to the universal solution:
To chain registrations. Like .Inherits<DTOEntity, Entity>().WithRegistration(IRegister)
which is somehow cumbersome.
To use a new typed IRegister interface and to rewrite the scanner and handle the order of registrations with taking into account the inheritance hierarchy of the registering types.
To handle registration in two steps. Collect all Configs for types. Execute them in reordered sequence based on the inheritance hierarchy. Something like this: DefaultConfig.Collect(First Assembly) DefaultConfig.Collect(Second Assembly)
... DefaultConfig.Register()
If you use IRegister to define the inheritance mapping like this:
DerivedPocoProfile.cs
SimplePocoProfile.cs
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.The text was updated successfully, but these errors were encountered: