title: Missing the end of the XML when serializing with DataContractSerializer
body: <p>I have the following method that I use to serialize various objects to XML. I then write the XML to a file. All the objects have the proper <code>[DataContract]</code> and <code>[DataMember]</code> attributes.</p>
  
  <pre><code>    public static string Serialize&lt;T&gt;(T item)
      {
          var builder = new StringBuilder();
          var serializer = new DataContractSerializer(typeof(T));
  
          using (var xmlWriter = XmlWriter.Create(builder))
          {
              serializer.WriteObject(xmlWriter, item);
              return builder.ToString();
          }
      }
  </code></pre>
  
  <p>The serialization works fine, however, I am missing the end of the content. I.e., the string does not contain the full XML document: the end gets truncated. Sometimes the string ends right in the middle of a tag.</p>
  
  <p>There does not seem to be a miximum length that would cause an issue: I have strings of 18k that are incomplete and I have strings of 80k that are incomplete as well.</p>
  
  <p>The XML structure is fairly simple and only about 6-8 nodes deep.</p>
  
  <p>Am I missing something?</p>