title: AutoMapper 5 Custom Value Resolver "Cannot convert expression type X to return type Y"
body: <p>I upgraded from an old version of AutoMapper and converted my custom resolvers, but I'm having a hard time.</p>
  
  <pre><code>public class ProductMappingProfile : Profile
  {
      public ProductMappingProfile()
      {
          CreateMap&lt;Product, ProductViewModel&gt;()
              .ForMember(
                  dest =&gt; dest.Model,
                  opt =&gt; opt.ResolveUsing&lt;ModelNameResolver&gt;(src =&gt; src.ModelId));
          // won't compile
      }
  }
  </code></pre>
  
  <p>Where Product has a <code>int? ModelId</code> property and ProductViewModel has a <code>string Name</code> property.</p>
  
  <h2>Custom Resolver</h2>
  
  <pre><code>public class ModelNameResolver : IValueResolver&lt;short?, string, string&gt;
  {
      private readonly InventoryService _inventoryService;
      public ModelNameResolver(InventoryService inventoryService)
      {
          _inventoryService = inventoryService;
      }
  
      public string Resolve(short? source, string destination, string destMember, ResolutionContext context)
      {
          if (!source.HasValue)
              return "n/a";
  
          return _inventoryService.GetModel(source.Value)
              .Name;
      }
  }
  </code></pre>
  
  <h2>Compilation Error:</h2>
  
  <pre><code>The type 'MyNamespace.Web.Resolvers.ModelCodeResolver' cannot be used as type parameter 'TValueResolver' in the generic type or method `'AutoMapper.IMemberConfigurationExpression&lt;TSource,TDestination,TMember&gt;.ResolveUsing&lt;TValueResolver&gt;()'`.
  
  There is no implicit reference conversion from `'MyNamespace.Web.Resolvers.ModelCodeResolver'` to `'AutoMapper.IValueResolver&lt;Data.Models.Product,Web.ViewModels.ProductViewModel,string&gt;'`.
  </code></pre>
  
  <p>What am I doing wrong? I suspect I am misunderstanding the new custom resolver interface.</p>