Closed valverij closed 2 years ago
I'm confused why you would see this error as we have that Distinct check already, do you have a repro?
@jbogard @lbargaoanu Here is a gist showing the error in action: https://gist.github.com/valverij/b32df6dcd47cf4934f5c09d8a6707244
@valverij Ok, that test should be part of the PR. And we only need one Distinct
, the one you added. You can reopen this PR, or simply don't pass duplicated assemblies anymore :)
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
If multiple types with the same assembly are sent in via on of the
AddAutoMapper
calls that useprofileAssemblyMarkerTypes
(or if duplicate assemblies are just passed in), then any Profiles in those assemblies end up being duplicated in the MapperConfiguration options, which can cause a lot of inconsistent behavior.Initially, this was discovered via the exception thrown in
TypeMap.CheckDifferent(TypePair types)
when using Profiles that contain maps withIncludeAllDerived()
set. If the assembly contains more than oneProfile
class, then the maps withIncludeAllDerived
set are duplicated, and thatCheckDifferent
validation throws at runtime.This change accounts for this accidental duplication of assemblies during configuration by explicitly setting
assembliesToScanArray
to distinct assemblies.