title: Serialize string property as attribute, even if string is empty
body: <pre><code>public class Hat
  {
      [XmlTextAttribute]
      public string Name { get; set; }
      [XmlAttribute("Color")]
      public string Color { get; set; }
  }
  
  var hat1 = new Hat {Name="Cool Hat", Color="Red"};
  var hat2 = new Hat {Name="Funky Hat", Color=null};
  </code></pre>
  
  <p>This is what I get (notice missing color-attribute on Funky Hat):</p>
  
  <pre><code>&lt;Hats&gt;
   &lt;Hat Color="Red"&gt;Cool Hat&lt;/Hat&gt;
   &lt;Hat&gt;Funky Hat&lt;/Hat&gt;
  &lt;/Hats&gt;
  </code></pre>
  
  <p>This is what I want:</p>
  
  <pre><code>&lt;Hats&gt;
   &lt;Hat Color="Red"&gt;Cool Hat&lt;/Hat&gt;
   &lt;Hat Color=""&gt;Funky Hat&lt;/Hat&gt;
  &lt;/Hats&gt;
  </code></pre>
  
  <p>How can I force the serializer to create an empty attribute in stead of leaving it out? </p>
  
  <h1>EDIT:</h1>
  
  <p>Turns out I am an idiot and created an example that contained an error, because I wanted to simplify the code for the example. </p>
  
  <p>If the value of color is "" (or string.empty), it is actually serialized as an empty attribute. However, I really had a null value, not an empty string - hence it was left out.</p>
  
  <p>So the behavior I wanted was actually already the behavior of the example I created.</p>
  
  <p>Sorry, guys!</p>