Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed bug where the interface matching got overwritten

  • Loading branch information...
commit 57e7c6bc8ee4940d6b4d844822b76e73524cbcca 1 parent 595ab90
@jbogard jbogard authored
View
2  src/AutoMapper/Configuration.cs
@@ -335,6 +335,8 @@ private TypeMap FindTypeMap(object source, Type sourceType, Type destinationType
{
typeMap = CreateTypeMap(sourceType, derivedTypeFor, profileName);
}
+
+ break;
}
if ((sourceType.BaseType != null) && (typeMap == null))
View
8 src/AutoMapper/MappingEngine.cs
@@ -118,11 +118,6 @@ object IMappingEngineRunner.Map(ResolutionContext context)
{
try
{
- //if (context.SourceValue == null && ShouldMapSourceValueAsNull(context))
- //{
- // return ObjectCreator.CreateDefaultValue(context.DestinationType);
- //}
-
var contextTypePair = new TypePair(context.SourceType, context.DestinationType);
IObjectMapper mapperToUse;
@@ -197,9 +192,6 @@ object IMappingEngineRunner.CreateObject(ResolutionContext context)
bool IMappingEngineRunner.ShouldMapSourceValueAsNull(ResolutionContext context)
{
- //if (context.DestinationType == typeof(string))
- // return false;
-
if (context.DestinationType.IsValueType)
return false;
View
58 src/UnitTests/Bug/MultipleInterfaceInheritance.cs
@@ -0,0 +1,58 @@
+using NBehave.Spec.NUnit;
+using NUnit.Framework;
+
+namespace AutoMapper.UnitTests.Bug
+{
+ [TestFixture]
+ public class MultipleInterfaceInheritance : AutoMapperSpecBase
+ {
+ private ThingDto _thingDto;
+
+ public class Thing
+ {
+ public IItem[] Items { get; set; }
+ }
+
+ public class ThingDto
+ {
+ public ItemDto[] Items { get; set; }
+ }
+
+ public class Item : IItem
+ {
+ }
+
+ public class ItemDto
+ {
+ }
+
+ public interface IItem : ISome // everything works well if IItem doesn't inherit ISome.
+ {
+ }
+
+ public interface ISome
+ {
+ }
+
+ protected override void Establish_context()
+ {
+ Mapper.Initialize(cfg =>
+ {
+ cfg.CreateMap<Thing, ThingDto>();
+ cfg.CreateMap<IItem, ItemDto>();
+ });
+ }
+
+ protected override void Because_of()
+ {
+ var thing = new Thing { Items = new[] { new Item() } };
+ _thingDto = Mapper.Map<Thing, ThingDto>(thing);
+ }
+
+ [Test]
+ public void Should_map_successfully()
+ {
+ _thingDto.Items.Length.ShouldEqual(1);
+ }
+ }
+}
View
1  src/UnitTests/UnitTests.csproj
@@ -90,6 +90,7 @@
<Compile Include="Bug\AddingConfigurationForNonMatchingDestinationMemberBug.cs" />
<Compile Include="Bug\EnumMatchingOnValue.cs" />
<Compile Include="Bug\IgnoreAll.cs" />
+ <Compile Include="Bug\MultipleInterfaceInheritance.cs" />
<Compile Include="Bug\NamingConventions.cs" />
<Compile Include="Bug\RepeatedMappingConfigurationTest.cs" />
<Compile Include="Bug\SequenceContainsNoElementsTest.cs">
Please sign in to comment.
Something went wrong with that request. Please try again.