Skip to content

Fixing bug around order of open generic registration#4607

Merged
jbogard merged 1 commit intomainfrom
4567-automapper-1400-breaks-the-order-of-created-maps
Feb 21, 2026
Merged

Fixing bug around order of open generic registration#4607
jbogard merged 1 commit intomainfrom
4567-automapper-1400-breaks-the-order-of-created-maps

Conversation

@jbogard
Copy link
Contributor

@jbogard jbogard commented Feb 21, 2026

Fixes #4567

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical bug in AutoMapper 14.0.0 where the order of open generic type map registration could cause a NullReferenceException. The bug occurred when a derived map with an IncludeBase reference to a closed generic type (e.g., SourceBase<FooBar>) was registered before its open generic base map (e.g., SourceBase<>).

Changes:

  • Fixed ProfileMap.Configure to use FindTypeMapFor instead of TypeMapConfiguration.TypeMap property
  • Added comprehensive tests to verify both registration orderings work correctly

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/AutoMapper/ProfileMap.cs Fixed bug where TypeMapConfiguration.TypeMap could point to wrong TypeMap when closed generics are created from open generic definitions
src/UnitTests/Bug/OpenGenericInheritanceOrder.cs Added regression tests for both map registration orderings

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jbogard jbogard merged commit ef2bba6 into main Feb 21, 2026
10 checks passed
@jbogard jbogard deleted the 4567-automapper-1400-breaks-the-order-of-created-maps branch February 21, 2026 22:54
@jbogard jbogard added this to the 16.1.0 milestone Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AutoMapper 14.0.0 breaks the order of created maps

2 participants