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
This call only returns public methods, omitting explicit interface realizations. Such a restriction leads to rather rather inefficient designs, when you need to implement a bunch of related mappings with the same source type, but IObjectMapper<TSource, TDestination>.Map(TSource) definitions will collide on the mapper type if you try to implement the interfaces in a regular way.
Also, .First method, when no map found throws an unspecific exception, which tells nothing essential about what is wrong.
Reproduction Steps
No response
Expected behavior
Change the line from .GetMethods() to .GetMethods(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public) to allow explicit interface implementations for mappers. Plus parameter matching logic.
Change .First(...) for more descriptive error explanation, like this .FirstOrDefault(...) ?? throw new InvaildOperationException($"No specific mapper method found on type {mapperType.FullName}") or better
Actual behavior
No response
Regression?
No response
Known Workarounds
No response
Version
8.2.2
User Interface
Common (Default)
Database Provider
EF Core (Default)
Tiered or separate authentication server
None (Default)
Operation System
Windows (Default)
Other information
No response
The text was updated successfully, but these errors were encountered:
class ADto {}
class AWithDetailsDto {}
class ABMapper:
// You can't have these both implemented via public methods, Map() methods collide.
// You've got to spawn the classes. It got the more complicated, the more complex logic is associated with the mappings
IObjectMapper<A, ADto>,
IObjectMapper<A, AWithDetaildDto>,
ITransientDependency
{
// you can compile this, but it won't work with the current DefaultObjectMapper.TryToMapCollections
ADto IObjectMapper<A, ADto>.Map(A source) => ...;
AWithDetailsDto IObjectMapper<A, AWithDetailsDto>.Map(A source) => ...;
}
Is there an existing issue for this?
Description
Currently,
DefaultObjectMapper.TryToMapCollection
searches only public methods of a specific object mapper viaGetMethods()
with no args:abp/framework/src/Volo.Abp.ObjectMapping/Volo/Abp/ObjectMapping/DefaultObjectMapper.cs
Line 147 in f96b918
This call only returns public methods, omitting explicit interface realizations. Such a restriction leads to rather rather inefficient designs, when you need to implement a bunch of related mappings with the same source type, but
IObjectMapper<TSource, TDestination>.Map(TSource)
definitions will collide on the mapper type if you try to implement the interfaces in a regular way.Also,
.First
method, when no map found throws an unspecific exception, which tells nothing essential about what is wrong.Reproduction Steps
No response
Expected behavior
.GetMethods()
to.GetMethods(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)
to allow explicit interface implementations for mappers. Plus parameter matching logic..First(...)
for more descriptive error explanation, like this.FirstOrDefault(...) ?? throw new InvaildOperationException($"No specific mapper method found on type {mapperType.FullName}")
or betterActual behavior
No response
Regression?
No response
Known Workarounds
No response
Version
8.2.2
User Interface
Common (Default)
Database Provider
EF Core (Default)
Tiered or separate authentication server
None (Default)
Operation System
Windows (Default)
Other information
No response
The text was updated successfully, but these errors were encountered: