So there’s the error. What I’m doing is serializing a list of classes (List). The BaseEnemy class also has a list in it of classes (List). When I run things, the list of BaseEnemy serializes properly. However, the list of BaseMoves does not. Is it a problem because BaseMoves is a list of classes inside of a class? If so, can anybody point me in the direction of the workaround?
EDIT - Forgot to mention. “Scratch” is a class that derives from BaseMove that is stored in the List.
Here’s the function that handles saving:
private void SaveEnemyRoster(string path, object obj){
using (TextWriter writer = new StreamWriter(path)){
Type[] extraTypes = {typeof(List<BaseMove>)};
XmlSerializer xml = new XmlSerializer(typeof(List<BaseEnemy>), extraTypes);
xml.Serialize(writer, obj);
}
}
The error is connected to line 5.