Skip to content

Commit 99be09f

Browse files
committed
keep looking for matching maps, even when we cached a negative match
1 parent 340b298 commit 99be09f

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/AutoMapper/AutoMapper.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageProjectUrl>https://automapper.org</PackageProjectUrl>
1515
<PackageReadmeFile>README.md</PackageReadmeFile>
1616

17-
<MinVerDefaultPreReleasePhase>preview</MinVerDefaultPreReleasePhase>
17+
<MinVerDefaultPreReleaseIdentifiers>preview.0</MinVerDefaultPreReleaseIdentifiers>
1818
<MinVerTagPrefix>v</MinVerTagPrefix>
1919
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2020
<PublishRepositoryUrl>true</PublishRepositoryUrl>

src/AutoMapper/Configuration/MapperConfiguration.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ private TypeMap GetTypeMap(TypePair initialTypes)
343343
var types = new TypePair(sourceType, destinationType);
344344
if (_resolvedMaps.TryGetValue(types, out typeMap))
345345
{
346+
if(typeMap == null)
347+
{
348+
continue;
349+
}
346350
return typeMap;
347351
}
348352
typeMap = FindClosedGenericTypeMapFor(types);

src/UnitTests/InterfaceMapping.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
namespace AutoMapper.UnitTests.InterfaceMapping;
2-
2+
public class InterfaceWithObjectProperty : AutoMapperSpecBase
3+
{
4+
protected override MapperConfiguration CreateConfiguration() => new(cfg => cfg.CreateMap<ISourceModel, IDestModel>());
5+
public interface ISourceModel
6+
{
7+
object Id { get; set; }
8+
}
9+
public interface IDestModel
10+
{
11+
object Id { get; set; }
12+
}
13+
public class SourceModel : ISourceModel
14+
{
15+
public object Id { get; set; }
16+
}
17+
public class DestModel : IDestModel
18+
{
19+
public object Id { get; set; }
20+
}
21+
[Fact]
22+
public void Should_work() => Mapper.Map(new SourceModel { Id = 42 }, new DestModel()).Id.ShouldBe(42);
23+
}
324
public class InterfaceInheritance : AutoMapperSpecBase
425
{
526
protected override MapperConfiguration CreateConfiguration() => new(cfg =>

0 commit comments

Comments
 (0)