Skip to content

Fix: Open generics inheritance ignored based on registration order (AutoMapper #4567 backport)#8

Open
gthen95 wants to merge 1 commit intoNET-Sorcery:mainfrom
gthen95:fix/generic-open-type-order
Open

Fix: Open generics inheritance ignored based on registration order (AutoMapper #4567 backport)#8
gthen95 wants to merge 1 commit intoNET-Sorcery:mainfrom
gthen95:fix/generic-open-type-order

Conversation

@gthen95
Copy link
Contributor

@gthen95 gthen95 commented Mar 19, 2026

Description

This PR backports a fix from AutoMapper (#4567) to ensure open generic inheritance works consistently, regardless of the order in which the maps are registered.

The Issue:
When a derived concrete map (e.g., CreateMap<SourceDerived, DestinationDerived>()) is declared before its open generic base map, the inheritance configuration is ignored. It only works if declared in the reverse order. This happens because the configuration captures the initial instance of the TypeMap before the open generics are fully resolved.

The Fix:
Updated ProfileMap.cs to resolve the inherited TypeMap directly from the GlobalConfiguration rather than using the currently instanced TypeMapConfiguration. This guarantees that the fully materialized type map is used, making the registration order irrelevant.

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AutoMapper 14.0.0 breaks the order of created maps

1 participant