title: Inconsistencies after deserialization using protobuf-net
body: <p>I am facing a problem of inconsistency after deserialization using protobuf-net.</p>
  
  <p>The class I would like to serialize/deserialize looks like:</p>
  
  <pre><code>[ProtoContract]
  public class TSS
  {
      [ProtoMember(1, AsReference = true)]
      public EventManager eventManager { get; private set; }
  
      [ProtoMember(2)]
      public DateTime referenceDateTime { get; private set; }
  
      [ProtoMember(3)]
      public Mode mode;
  }
  </code></pre>
  
  <p>And inside EventManager class, it looks like:</p>
  
  <pre><code>[ProtoContract]
  public class EventManager
  {
      [ProtoMember(1)]
      public InputQueue inputQueue = new InputQueue();
      [ProtoMember(2)]
      public InputQueue InputQueue
      {
          get { return this.inputQueue; }
          set { this.inputQueue = value; }
      }
      [ProtoMember(7, AsReference = true)]
      public TSS tss;
  }
  </code></pre>
  
  <p>The tss in class EventManager is a reference of TSS object, and eventManager in class TSS is a reference of EventManager object. This is the reason I put <code>AsReference = true</code> there (is this the right way?)</p>
  
  <p>I do serialization like:</p>
  
  <pre><code>public void StateSaving(int time, TSS tss)
  {
      Stream memoryStream = new MemoryStream();
      Serializer.Serialize(memoryStream, tss);
      states.Add(time, memoryStream);
  }
  </code></pre>
  
  <p>and do deserialization like:</p>
  
  <pre><code>public void Deserialize(int time, ref TSS tss)
  {
      Stream memoryStream = states[time];
      memoryStream.Position = 0;
      tss = Serializer.Deserialize&lt;TSS&gt;(memoryStream);
  }
  </code></pre>
  
  <p>The problem is that whenever I do deserialization, the data structures like inputQueue in the EventManager is populated with NULL values instead of actual values at that point. I am a newbie to protobuf-net, so please point out any mistakes (I believe there are a lot).</p>
  
  <p>Thanks in advance!!</p>