Given the following classes
public class FirstFoo {
public string Bar { get; }
public string Baz { get; }
public FirstFoo(string bar, string baz)
{
Bar = bar;
Baz = baz;
}
}
public class SecondFoo {
public string Bar { get; }
public string Baz { get; }
public SecondFoo(string bar, string baz)
{
Bar = bar;
Baz = baz;
}
}
and the following mapping definition
Mapper.CreateMap<FirstFoo, SecondFoo>();
I would have expected Mapper.Map<SecondFoo>(firstFooInstance)
to Just Work(TM), but it throws an ArgumentException
System.ArgumentException: Type 'SecondFoo' does not have a default constructor
Am I doing something wrong here?
Disclaimer: We're still using AutoMapper 2.2.1. I've perused the change log to figure out if this feature was introduced in a later release, but I've only found bugfixes or other improvement when searching for "constructor" in all entries, and 2.2.1 and earlier releases don't have any details in the change log, so I can't even confirm that it should work. (And yes, I'm aware this is a very old release. I'm looking at updating to the latest release across the large enterprise solution this is part of, but it's not a priority issue. It might become one, if it solves this issue, but I won't spend time on it just in case...)