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
PhilipWoulfe pushed a commit to PhilipWoulfe/F1Competition that referenced this pull request Mar 10, 2026
Updated [AutoMapper](https://github.com/LuckyPennySoftware/AutoMapper)
from 14.0.0 to 16.1.0.

<details>
<summary>Release notes</summary>

_Sourced from [AutoMapper's
releases](https://github.com/LuckyPennySoftware/AutoMapper/releases)._

## 16.1.0

## What's Changed
* Add Debug and Release build configurations to slnx by @​Copilot in
LuckyPennySoftware/AutoMapper#4590
* Migrating to slnx by @​jbogard in
LuckyPennySoftware/AutoMapper#4589
* Allow disabling of polymorphic LINQ mapping by @​jbogard in
LuckyPennySoftware/AutoMapper#4596
* Fix duplicate BOM in ServiceCollectionExtensions.cs by @​Copilot in
LuckyPennySoftware/AutoMapper#4600
* Fix review feedback: double semicolon, DI condition integration test,
docs example by @​Copilot in
LuckyPennySoftware/AutoMapper#4601
* Adding DI-enabled conditions and pre-conditions; updated docs accordi…
by @​jbogard in
LuckyPennySoftware/AutoMapper#4599
* Adding support for DI-enabled destination factories. by @​jbogard in
LuckyPennySoftware/AutoMapper#4603
* Correctly converting nullables for MapAtRuntime; fixes #​4597 by
@​jbogard in LuckyPennySoftware/AutoMapper#4604
* Correctly handling consecutive uppercase characters; fixes #​4593 by
@​jbogard in LuckyPennySoftware/AutoMapper#4605
* Wrapping the exception to provide better feedback to the user; fixes …
by @​jbogard in
LuckyPennySoftware/AutoMapper#4606
* Fixing bug around order of open generic registration by @​jbogard in
LuckyPennySoftware/AutoMapper#4607
* Adding perpetual licensing by @​jbogard in
LuckyPennySoftware/AutoMapper#4608

## New Contributors
* @​Copilot made their first contribution in
LuckyPennySoftware/AutoMapper#4590

**Full Changelog**:
LuckyPennySoftware/AutoMapper@v16.0.0...v16.1.0

## 16.0.0

## What's Changed
* Fix release pipelines by @​jbogard in
LuckyPennySoftware/AutoMapper#4583
* Adding support for .NET 10 by @​jbogard in
LuckyPennySoftware/AutoMapper#4586


**Full Changelog**:
LuckyPennySoftware/AutoMapper@v15.1.0...v16.0.0

## 16.0.0-beta-1

## What's Changed
* Fix release pipelines by @​jbogard in
LuckyPennySoftware/AutoMapper#4583
* Adding support for .NET 10 by @​jbogard in
LuckyPennySoftware/AutoMapper#4586

**Full Changelog**:
LuckyPennySoftware/AutoMapper@v15.1.0...v16.0.0-beta-1

This release is a beta release that introduces .NET 10 support and
package signing. Signed packages means going forward packages can be
validated against trusted authorities that the package has been
published by Lucky Penny Software and not tampered with.

## 15.1.0

## What's Changed
* remove Microsoft.SourceLink.GitHub by @​SimonCropp in
LuckyPennySoftware/AutoMapper#4555
* Direct .NET 4.x support by @​jbogard in
LuckyPennySoftware/AutoMapper#4569
* Bumping the JsonWebTokens because of GHSA-8g4q-xg66-9fp4; fixes #​4575
by @​jbogard in
LuckyPennySoftware/AutoMapper#4576
* Provide better exceptions for errors when building the mapping plan by
@​jbogard in LuckyPennySoftware/AutoMapper#4577
* Adding docs for license configuration by @​jbogard in
LuckyPennySoftware/AutoMapper#4581
* Updating refs to fix missing method issue by @​jbogard in
LuckyPennySoftware/AutoMapper#4582

## New Contributors
* @​SimonCropp made their first contribution in
LuckyPennySoftware/AutoMapper#4555

**Full Changelog**:
LuckyPennySoftware/AutoMapper@v15.0.1...v15.1.0

## 15.0.1

## What's Changed
* Removing public signing; fixes #​4545 by @​jbogard in
LuckyPennySoftware/AutoMapper#4552
* Adding back missing overloads and reverting registering behavior by
@​jbogard in LuckyPennySoftware/AutoMapper#4554


**Full Changelog**:
LuckyPennySoftware/AutoMapper@v15.0.0...v15.0.1

This release supersedes the 15.0.0 release, reverting behavior and
overloads so that the `AddAutoMapper` overloads separate the "scanning
for maps" from the "scanning for dependencies". Unfortunately it's not
really possible to combine these two together.

This also fixes a critical bug in #​4545 that does not work with .NET
4.x applications (as intended).

Because of this, the 15.0.0 will be delisted because of the breaking
changes there.

## 15.0.0

**Full Changelog**:
LuckyPennySoftware/AutoMapper@v14.0.0...v15.0.0

* Added support for .NET Standard 2.0
* Requiring license key
* Moving from MIT license to dual commercial/OSS license

To set your license key:

```csharp
services.AddAutoMapper(cfg => {
    cfg.LicenseKey = "<License key here>";
});
```

This also introduced a breaking change with `MapperConfiguration`
requiring an `ILoggerFactory` for logging purposes:

```csharp
public MapperConfiguration(MapperConfigurationExpression configurationExpression, ILoggerFactory loggerFactory)
```

Registering AutoMapper with `services.AddAutoMapper` will automatically
supply this parameter. Otherwise you'll need to supply the logger
factory.

You can obtain your license key at
[AutoMapper.io](https://automapper.io)

Commits viewable in [compare
view](LuckyPennySoftware/AutoMapper@v14.0.0...v16.1.0).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=AutoMapper&package-manager=nuget&previous-version=14.0.0&new-version=16.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Mar 14, 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