title: Xml-attributes in interfaces and abstract classes
body: <p>I found something that confused me today:</p>
  
  <p>
   1. If I have this:
  </p>
  
  <pre><code>public interface INamed
  {
      [XmlAttribute]
      string Name { get; set; }
  }
  
  public class Named : INamed
  {
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>It gives the following output (Name property serialized as element):</p>
  
  <pre><code>&lt;Named&gt;
    &lt;Name&gt;Johan&lt;/Name&gt;
  &lt;/Named&gt;
  </code></pre>
  
  <p>
   2. If I have this:
  </p>
  
  <pre><code>public abstract class NamedBase
  {
      [XmlAttribute]
      public abstract string Name { get; set; }
  }
  
  public class NamedDerived : NamedBase
  {
      public override string Name { get; set; }
  }
  </code></pre>
  
  <p>The XmlSerializer throws System.InvalidOperationException </p>
  
  <blockquote>
    <p>Member 'NamedDerived.Name' hides inherited member 'NamedBase.Name',
    but has different custom attributes.</p>
  </blockquote>
  
  <p>The code I used for serialization:</p>
  
  <pre><code>[TestFixture] 
  public class XmlAttributeTest
  {
      [Test]
      public void SerializeTest()
      {
          var named = new NamedDerived {Name = "Johan"};
          var xmlSerializer = new XmlSerializer(named.GetType());
          var stringBuilder = new StringBuilder();
          using (var stringWriter = new StringWriter(stringBuilder))
          {
              xmlSerializer.Serialize(stringWriter, named);
          }
          Console.WriteLine(stringBuilder.ToString());
      }
  }
  </code></pre>
  
  <p>My question is:</p>
  
  <p>Am I doing it wrong and if so what is the correct way to use xml attributes in interfaces and abstract classes?</p>