title: Adding AutoMapper Type Mapping Conventions For Generic Types in WCF Contract
body: <p>I have a WCF service that uses generics in its data contract, for example (simplified):</p>
  
  <pre><code>public GetDetails(StatusField&lt;string&gt; status);
  </code></pre>
  
  <p>Now WCF supports generics by creating a non-generic equivalent type for every possible value of T in the generic.  So, for the above example, the client consuming the WCF service will see the following signature for the above function:</p>
  
  <pre><code>public GetDetails(stringStatusField status);
  //...
  </code></pre>
  
  <p>Now the client has a copy of the generic version of the StatusField class.  We want to use AutoMapper in the client, to map between this generic StatusField and the types generated above by WCF (such as stringStatusField) so we can call the service.  We could do this by manually creating the maps at client startup, like so:</p>
  
  <pre><code>Mapper.CreateMap&lt;StatusField&lt;string&gt;, stringStatusField&gt;();
  </code></pre>
  
  <p>However this is laborious as there are 50+ possible values of  that WCF has converted.  Extending this idea, we could use reflection to automatically create maps for all the types and this is the solution we are currently using.</p>
  
  <p>Ideally what i would like to see is a solution that ties into the architecture of AutoMapper to avoid having to do the reflection manually.  conceptually, this would require some way of defining a <strong>convention</strong> that AutoMapper would use to allow it to tie the two types together, similar to how it allows custom conventions to be specified when matching properties.  As yet, i have not seen a way to do this and this is the question i would like answered here, if anyone knows how this can be done, specifically in relation to the above scenario.</p>
  
  <p>BTW i am aware that some may be thinking of Mapper.DynamicMap() as a solution to this problem.  Firstly, we dont want to use this as it means debugging could potentially be harder (as indicated by some in other posts similar to this) and also if the StatusField is deeply nested in an object graph being passed to the WCF method, im not sure this solution would work and could potentially lead to a type being incorrectly mapped and other such issues.  I would really like to concretely define the allowable mappings if possible.</p>