title: How to deserialize a read only List with Json.Net
body: <p>I have a class with an internal list.  I don't want the user of this class to be able to interact with the list directly, since I want to both keep it sorted and to run a calculation (which depends on the order) before returning it.</p>
  
  <p>I expose</p>
  
  <pre><code>AddItem(Item x) 
  </code></pre>
  
  <p>and a </p>
  
  <pre><code>IEnumerable&lt;Item&gt; Items
  {
       get { // returns a projection of internal list }
  }
  </code></pre>
  
  <p>Serialization worked OK, but deserializing left the list empty.  I figured it was because I didn't have a setter.  So I added one that allowed you to set the list, but only if the internal list was empty. But this didn't solve the problem, turns out NewtonSoft does not call the setter, it only calls the getter to get the list, and then adds each item to it, which, since my getter returns a projected list, those items get added to an object that is immediately disposed once deserialization is done.</p>
  
  <p>How do I maintain a read-only access to my list, while at the same time allowing for somewhat straightforward deserialization?</p>