title: JSON .Net not respecting PreserveReferencesHandling on Deserialization
body: <p>I have doubly linked list that I am trying to deserialise.</p>
  
  <p>My scenario closely relates to this SO: <a href="https://stackoverflow.com/questions/24105749/doubly-linked-list-to-json">Doubly Linked List to JSON</a></p>
  
  <p>I have the following JSON settings:</p>
  
  <pre><code>_jsonSettings = new JsonSerializerSettings() 
  { 
      TypeNameHandling = TypeNameHandling.Auto, 
      ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
      PreserveReferencesHandling = PreserveReferencesHandling.Objects,
      ObjectCreationHandling = ObjectCreationHandling.Auto
  };
  </code></pre>
  
  <p>When I look at the serialised output, it appears correct, and the references between nodes are properly represented.</p>
  
  <p>When the data is deserialised, the Parent properties in the Child objects are null, even though they are populated with $ref correctly.</p>
  
  <p>Below is a sample of the JSON (trimmed for readability)</p>
  
  <p>In the process of typing this question - I may have seen the source of the trouble... </p>
  
  <p>The objects in the "Children" array property do not have $type attributes. </p>
  
  <p>This could be because the Children and Parent properties are of generic type T. </p>
  
  <p>Note that the actual type being serialised is a derived class of TemplateDataLinkedListBase </p>
  
  <pre><code>public class TemplateDataQueryElement : TemplateDataLinkedListBase&lt;TemplateDataQueryElement&gt;
  </code></pre>
  
  <p>Here is an excerpt of the base class:</p>
  
  <pre><code>public class TemplateDataLinkedListBase&lt;T&gt; where T : TemplateDataLinkedListBase&lt;T&gt;
  {
      [JsonProperty(TypeNameHandling = TypeNameHandling.Objects)]
      public T Parent { get; set; }
  
      [JsonProperty(TypeNameHandling=TypeNameHandling.Objects)]
      public List&lt;T&gt; Children { get; set; }
  }
  </code></pre>
  
  <p>How can I deserialise this JSON in such a way that the Parent property is not null and contains a reference to the parent object?</p>
  
  <pre><code>    {
      "$id": "9",
      "$type": "Contracts.Models.TemplateDataQueryElement, Contracts",
      "Query": null,
      "Parent": null,
      "Children": [
        {
          "$id": "11",
          "Query": null,
          "Parent": {
            "$ref": "9"
          },
          "Children": [
            {
              "$id": "13",
              "Query": null,
              "Parent": {
                "$ref": "11"
              },
              "Children": [],
              "EntityName": "Widgets",
              "Fields": [
                "Id"
              ],
              "Key": ""
            },
  </code></pre>
  
  <p>Here are PasteBin links to the relevant code:</p>
  
  <p><a href="http://pastebin.com/i1jxVGG3" rel="noreferrer">http://pastebin.com/i1jxVGG3</a>
  <a href="http://pastebin.com/T1xqEWW2" rel="noreferrer">http://pastebin.com/T1xqEWW2</a>
  <a href="http://pastebin.com/ha42SeF7" rel="noreferrer">http://pastebin.com/ha42SeF7</a>
  <a href="http://pastebin.com/cezwZqx6" rel="noreferrer">http://pastebin.com/cezwZqx6</a>
  <a href="http://pastebin.com/uFbTbUZe" rel="noreferrer">http://pastebin.com/uFbTbUZe</a>
  <a href="http://pastebin.com/sRhNQgzh" rel="noreferrer">http://pastebin.com/sRhNQgzh</a></p>