Requesting features for AutoMapper

On the AutoMapper mailing list, I get a lot of what I consider wacky requests.  Not because the requests aren’t valid, but rarely do I get any context of what people are trying to do with AutoMapper.  As a reference, we are using AutoMapper in these situations:

  • Mapping from Domain/Presentation Model to ViewModel
  • Mapping from Domain/Presentation Model to EditModel (forms) <- yes, different concerns at play here
  • Mapping from Domain to a Reporting model (think printable view screens, not analytics)
  • Mapping from EditModel forms to Command objects

Some of the requests I’ve inferred include a lot of mapping from ViewModels back to Domain models.  Personally, this seems wacky to me, unless you’re in some sort of ActiveRecord/CRUD scenario.  In those cases, I’d rather expose my model directly to my views.

If AutoMapper doesn’t do what you want, a few things might be true:

  • There is a bug
  • You’re doing something valid, but in a scenario I haven’t encountered
  • You’re doing something you shouldn’t do, and trying to attach two boards with a screw and a hammer

Object-to-object mapping is a broad spectrum of distinct scenarios, and AutoMapper really only focuses on the scenarios where your destination type looks like your source type, plus some flattening.  So if you’d like a scenario to be supported by AutoMapper, two things would greatly help me:

  • Code showing a failing test
  • Description of the context for which you’re trying to use it

Context is very helpful for me in the overall design, as only failing tests show me contrived, Foo to FooDto scenarios.  It helps if I understand at what place in your architecture you’re trying to use it, as it may not line up to how it was originally designed.  But context tells me if there is a broader concept at play, and I can design (or not) for that category of usage.

Thanks again to everyone that has contributed, I’ve been consistently surprised by the number of feature requests that include a patch.  To date, I’ve received around 25 patches from the community, far exceeding any expectations I had.

Simplest versus first thing that could possibly work