8

We have two classes:

public class Foo
{
    public int A { get; set; }
    public int B { get; set; }
    public int C { get; set; }
}

public class Bar
{
    public int A { get; set; }
    public int B { get; set; }
} 

and mapping configuration

 Mapper.CreateMap<Foo, Bar>;

Is there some possibility for Automapper to check automatically that all source properties have corresponding destination properties, in my example throwing an exception which notifies us about Foo.C property not mapped to anything. Mapper.AssertConfigurationIsValid() checks only the other way round - that all destination properties have source properties so it doesn't help in my case.

jjjjj
  • 339
  • 4
  • 11
  • Maybe you can try to reach [@JimmyBogard](http://stackoverflow.com/users/58508/jimmy-bogard) as he is the creator of [tag:automapper] – Camilo Martinez May 10 '13 at 14:34

1 Answers1

2

Maybe you can use a hack and test the mapping in the other direction. Something like:

Mapper.CreateMap<Bar, Foo>; // Swap the direction of the mapping
Mapper.AssertConfigurationIsValid()

I know it isn't ideal but could be a quick solution.

Camilo Martinez
  • 1,723
  • 2
  • 21
  • 26
  • Nice point though I'd prefer not to have mappings that are used just for testing purposes and are in fact invalid. – jjjjj May 13 '13 at 05:05