title: c# serialization - complex type containing simple content with attributes
body: <p>I have an existing solution that has used svcutil to create a set of classes based on an XSD schema.  I am now having to make edits to that schema and I have run into a bit of a stumbling block.  </p>
  
  <p>The schema is going to be extended with types like this:</p>
  
  <pre><code>&lt;xsd:complexType name="Awkward"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="awkward1" type="tt:AwkwardChild" nillable="true"&gt;      
      &lt;/xsd:element&gt;
      &lt;xsd:element name="awkward2" type="tt:AwkwardChild" nillable="true"&gt;
      &lt;/xsd:element&gt;
    &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;
  
  &lt;xsd:complexType name="AwkwardChild"&gt;
    &lt;xsd:simpleContent&gt;
      &lt;xsd:extension base="tt:AwkwardChildType"&gt;
        &lt;xsd:attribute name="id" type="xsd:ID"/&gt;
      &lt;/xsd:extension&gt;
    &lt;/xsd:simpleContent&gt;
  &lt;/xsd:complexType&gt;
  
  &lt;xsd:simpleType name="AwkwardChildType"&gt;
    &lt;xsd:restriction base="xsd:string"&gt;
      &lt;xsd:enumeration value="Dependent"/&gt;
      &lt;xsd:enumeration value="In between"/&gt;
      &lt;xsd:enumeration value="Independent"/&gt;
    &lt;/xsd:restriction&gt;
  &lt;/xsd:simpleType&gt;
  </code></pre>
  
  <p>Which would result in XML output something like this:</p>
  
  <pre><code>&lt;Awkward&gt;
    &lt;awkward1 id="z1"&gt;Dependent&lt;/awkward1&gt;
    &lt;awkward2 id="z2"&gt;Independent&lt;/awkward2&gt;
  &lt;/Awkward&gt;
  </code></pre>
  
  <p>SVCUtil is choking when trying to generate this complaining that</p>
  
  <p>"Type 'AwkwardChild' in namespace tt cannot be imported.  Complex types with simple content extension are not supported.  Either change the schema so that the types can map to data contract types or use ImporXmlType or use a different serializer."</p>
  
  <p>And I think that I understand this, as it is trying to output a string type, but include attributes with it.</p>
  
  <p>I am trying to figure out if there is a way I can hand code a class to achieve this kind of output, but I can't figure out a way to get the string to appear as 'simple content' in the xml node rather than as a child element, e.g. this class:</p>
  
  <pre><code>[DataContractAttribute(Name = "AwkwardChild", Namespace = "tt")]
      public class Awkward
      {
          [DataContractAttribute(Name="id")]
          public string id { get; set; }
  
          //What do I put here to get this to appear as the content of 
          //the awkward node, not in an element?
          public string nodecontent { get; set; }
      }
  </code></pre>
  
  <p>Could somebody point me in the right direction?</p>