title: XmlSerializer not copying nested class values
body: <p>I am using an XmlSerializer to DeepCopy an object, but somehow it's not copying the nested properties.</p>
  
  <pre><code>&lt;TestClass()&gt;
  Public Class ObjectClonerTest
      ReadOnly _target As IObjectCloner = New ObjectCloner()
  
      &lt;TestMethod()&gt;
      Public Sub DeepCopy_ComplexSourceObject_NestedObjectCopied()
          Dim source As New SerialisableComplexGenericParameterHelper()
          source.Data() = 1
          source.ComplexValue.Data() = 2
  
          Dim actual = _target.DeepCopy(source)
  
          Assert.AreEqual(1, actual.Data())
          Assert.AreEqual(2, actual.ComplexValue.Data())
      End Sub
  
      Public Class SerialisableComplexGenericParameterHelper
          Public Property Data() As Integer
          Public ReadOnly ComplexValue As New SerialisableGenericParameterHelper()
      End Class
  
      Public Class SerialisableGenericParameterHelper
          Public Property Data() As Integer
      End Class
  
  End Class
  </code></pre>
  
  <p>The copy function:</p>
  
  <pre><code>Public Function DeepCopy(Of T)(ByVal pSource As T) As T Implements IObjectCloner.DeepCopy
      Using memoryStream As New MemoryStream()
          Dim binaryFormatter As New XmlSerializer(GetType(T))
  
          binaryFormatter.Serialize(memoryStream, pSource)
  
          memoryStream.Position() = 0
  
          Return DirectCast(binaryFormatter.Deserialize(memoryStream), T)
      End Using
  End Function
  </code></pre>