0

I wanted to generate a test program to execute against our client tenants to verify we could handle all the data our new Microsoft graph app collects. My plan was to serialize the data using XmlSerializer serializer = new XmlSerializer(typeof(List<T>));

It failed on the first entity I tried, Microsoft.Graph.Domain ( in this case with the error Cannot serialize member Microsoft.Graph.Entity.AdditionalData of type ... because it is an interface.

A search on stack overflow found suggestions to decorate the problematic class property with XmlIgnore so XmlSerializer will ignore it, others recommended implementing a new IXmlSerializer. One post seemed to propose using serializing to XAML.

Open to a better way to collect real customer data which I can import into my unit tests? As a developer I do not have direct access to customer accounts.

Does anyone have other suggestions on how to serialize Microsoft Graph Entities.

tom.kanary
  • 89
  • 4

1 Answers1

0

I replaced my XmlSerializer with a Json one.

public void SerializeObjectsToJson<T>(List<T> serializableObjects)
{
        var jsonStr = JsonConvert.SerializeObject(serializableObjects);
} 

public List<T> DeSerializeObjectsFromXml<T>()
{
        TextReader textReader = new StreamReader(fqpathname, Encoding.UTF8);
        var jsonStr = textReader.ReadToEnd();
        data = JsonConvert.DeserializeObject<List<T>>(jsonStr);
}

This all seems to work with Domain, User, SubscribedSkus, Organization, etc.

tom.kanary
  • 89
  • 4