title: Surrogate types for serialization in C# Portable Class Library
body: <p>I am currently porting code to a PCL (Key targets .NET 4.5 + mobile via Xamarin) and am running into a familiar issue, serialization of classes derived from non-serializable dependencies. I am using DataContract/Member attributes with DataContractJsonSerializer and therefore, in the non-portable version of this scenario I used IDataContractSurrogate to effectively swap out classes that couldn't be serailized for custom ones that could. IDataContractSurrogate doesn't exist in PCLs and DataContractJsonSerializer seems to be, logically, a reduced version.</p>
  
  <p>The real question here is:
  <strong>What is a portable equivalent of IDataContractSurrogate?</strong></p>
  
  <p>I have so far looked at:</p>
  
  <p><em>[On(De)Serializing] Attributes</em> that return a surrogate class but don't think this is actually how these attributes work and definitely aren't what they were designed for.</p>
  
  <p><em>SerializationBinder</em> but this doesn't seem to be accepted by the  PCL compatible DataContractJsonSerializer "This functionality is only available when using the BinaryFormatter or the NetDataContractSerializer".</p>
  
  <p><em>DataContractResolver</em> seems like the best option but it isn't included anywhere in the DataContractJsonSerializer settings.</p>
  
  <p><em>JsonCreationConverter/[JsonConverter]</em> from JSON.NET which seem like viable options but would prevent me from swapping serialization formats in future iterations (i.e. JSON is great for debugging but I might want to switch to Binary later, if possible).</p>
  
  <p>Having listed these options out it seems like the issue is that the different .NET serializers have different requirements and therefore their own ways of solving this problem meaning my desire to leave format options open maybe unreasonable. I'm going to look deeper into <em>DataContractSerializerOperationBehavior</em> but if there is a less complex alternative I would be more than amenable.</p>
  
  <p>Thanks in advance,</p>