(Note: Code is using .NET Core and ASP.NET Core that is in VS 2015 Update 2)
When you want to return XML in ASP.NET Core the Microsoft.AspNet.Mvc.Formatters.XmlSerializerOutputFormatter is used. Internally XmlSerializerOutputFormatter uses System.Xml.Serialization.XmlSerializer to actually serialize the .NET Objects into XML. Unfortunaly XmlSerializer has some limitations, particularly around serializing collections. To solve this a concept of "wrappers" was introduced. Wrappers replace an object of type A with type AWrap and AWrap provides all the same data but is XmlSerializer safe. ASP.NET Core comes with a wrapper for collections built in. However, to use it you must write you own wrappers for your classes that consume it when they have collections.
Instead of creating wrappers for a complex and growing object model, I created a system that uses type generation at runtime to create wrappers for types as needed. Unfortunately some limitations in .NET Core made this more complex then somet