XmlSerializer.GenerateSerializer alternate in NetCore

We use XmlSerializer in our code to generate temporary assemblies containing serializers. These asesemblies are then cached, which ensure that resource consumption is low.

Our application is in .NET Framework, and the code we are using currently is –

 XmlSerializer.GenerateSerializer(
                        types.ToArray(),
                        xmlMapping.ToArray(),
                        parameters);

We are looking to move our code to .NET core, and I came across this answer, which listed the use of Microsoft.XmlSerializer.Generator package.

While trying to integrate it, I found that there is no constructor/method, which would take both type and xml mapping as argument.

Our net framework code also uses CompilerParameters class, present in System.CodeDom (which is the third argument to the call, named parameters).

Is there an equivalent way to achieve the net framework functionality using the net core package?

Leave a Comment